ILIAS  release_8 Revision v8.24
ilSCCronTrash Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilSCCronTrash:
+ Collaboration diagram for ilSCCronTrash:

Public Member Functions

 __construct ()
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 run ()
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?int $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?int $a_type, ?int $a_value)
 Update current schedule (if flexible) More...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Protected Attributes

ilLanguage $lng
 
ilTree $tree
 
ilObjectDefinition $objDefinition
 
- Protected Attributes inherited from ilCronJob
int $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_HOURS = 3
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_DAYS = 4
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_WEEKLY = 5
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_MONTHLY = 6
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_QUARTERLY = 7
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_YEARLY = 8
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Purge trash by cron

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 25 of file class.ilSCCronTrash.php.

Constructor & Destructor Documentation

◆ __construct()

ilSCCronTrash::__construct ( )

Definition at line 31 of file class.ilSCCronTrash.php.

32 {
33 global $DIC;
34
35 $this->lng = $DIC->language();
36 $this->tree = $DIC->repositoryTree();
37 $this->objDefinition = $DIC['objDefinition'];
38 $this->lng->loadLanguageModule('sysc');
39 }
global $DIC
Definition: feed.php:28

References $DIC, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomSettingsToForm()

ilSCCronTrash::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Reimplemented from ilCronJob.

Definition at line 92 of file class.ilSCCronTrash.php.

92 : void
93 {
94 $this->lng->loadLanguageModule('sysc');
95
96 $settings = new ilSetting('sysc');
97
98 // limit number
99 $num = new ilNumberInputGUI($this->lng->txt('sysc_trash_limit_num'), 'number');
100 $num->allowDecimals(false);
101 $num->setInfo($this->lng->txt('purge_count_limit_desc'));
102 $num->setSize(10);
103 $num->setMinValue(1);
104 $num->setValue($settings->get('num', ''));
105 $a_form->addItem($num);
106
107 $age = new ilNumberInputGUI($this->lng->txt('sysc_trash_limit_age'), 'age');
108 $age->allowDecimals(false);
109 $age->setInfo($this->lng->txt('purge_age_limit_desc'));
110 $age->setSize(4);
111 $age->setMinValue(1);
112 $age->setMaxLength(4);
113
114 if ($settings->get('age', '')) {
115 $age->setValue($settings->get('age', ''));
116 }
117
118 $a_form->addItem($age);
119
120 // limit types
121 $types = new ilSelectInputGUI($this->lng->txt('sysc_trash_limit_type'), 'types');
122 $sub_objects = $this->tree->lookupTrashedObjectTypes();
123
124 $options = [];
125 $options[0] = '';
126 foreach ($sub_objects as $obj_type) {
127 if (!$this->objDefinition->isRBACObject($obj_type) || !$this->objDefinition->isAllowedInRepository($obj_type)) {
128 continue;
129 }
130 $options[$obj_type] = $this->lng->txt('obj_' . $obj_type);
131 }
132 asort($options);
133 $types->setOptions($options);
134 $types->setValue($settings->get('types', ''));
135 $a_form->addItem($types);
136 }
This class represents a number property in a property form.
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200

References ILIAS\LTI\ToolProvider\$settings, ilPropertyFormGUI\addItem(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilSCCronTrash::getDefaultScheduleType ( )

Reimplemented from ilCronJob.

Definition at line 56 of file class.ilSCCronTrash.php.

56 : int
57 {
59 }
const SCHEDULE_TYPE_WEEKLY
@depracated This will be replaced with an ENUM in ILIAS 9

References ilCronJob\SCHEDULE_TYPE_WEEKLY.

◆ getDefaultScheduleValue()

ilSCCronTrash::getDefaultScheduleValue ( )

Reimplemented from ilCronJob.

Definition at line 72 of file class.ilSCCronTrash.php.

72 : ?int
73 {
74 return 1;
75 }

◆ getDescription()

ilSCCronTrash::getDescription ( )

Reimplemented from ilCronJob.

Definition at line 51 of file class.ilSCCronTrash.php.

51 : string
52 {
53 return $this->lng->txt('sysc_cron_empty_trash_desc');
54 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getId()

ilSCCronTrash::getId ( )

Reimplemented from ilCronJob.

Definition at line 41 of file class.ilSCCronTrash.php.

41 : string
42 {
43 return 'sysc_trash';
44 }

◆ getTitle()

ilSCCronTrash::getTitle ( )

Reimplemented from ilCronJob.

Definition at line 46 of file class.ilSCCronTrash.php.

46 : string
47 {
48 return $this->lng->txt('sysc_cron_empty_trash');
49 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getValidScheduleTypes()

ilSCCronTrash::getValidScheduleTypes ( )

Returns a collection of all valid schedule types for a specific job.

Returns
int[]

Reimplemented from ilCronJob.

Definition at line 61 of file class.ilSCCronTrash.php.

61 : array
62 {
63 return [
69 ];
70 }
const SCHEDULE_TYPE_YEARLY
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_QUARTERLY
@depracated This will be replaced with an ENUM in ILIAS 9
const SCHEDULE_TYPE_MONTHLY
@depracated This will be replaced with an ENUM in ILIAS 9

References ilCronJob\SCHEDULE_TYPE_DAILY, ilCronJob\SCHEDULE_TYPE_MONTHLY, ilCronJob\SCHEDULE_TYPE_QUARTERLY, ilCronJob\SCHEDULE_TYPE_WEEKLY, and ilCronJob\SCHEDULE_TYPE_YEARLY.

◆ hasAutoActivation()

ilSCCronTrash::hasAutoActivation ( )

Is to be activated on "installation", does only work for ILIAS core cron jobs.

Reimplemented from ilCronJob.

Definition at line 77 of file class.ilSCCronTrash.php.

77 : bool
78 {
79 return false;
80 }

◆ hasCustomSettings()

ilSCCronTrash::hasCustomSettings ( )

Reimplemented from ilCronJob.

Definition at line 87 of file class.ilSCCronTrash.php.

87 : bool
88 {
89 return true;
90 }

◆ hasFlexibleSchedule()

ilSCCronTrash::hasFlexibleSchedule ( )

Reimplemented from ilCronJob.

Definition at line 82 of file class.ilSCCronTrash.php.

82 : bool
83 {
84 return true;
85 }

◆ run()

ilSCCronTrash::run ( )

Reimplemented from ilCronJob.

Definition at line 163 of file class.ilSCCronTrash.php.

164 {
165 $trash = new ilSystemCheckTrash();
167
168 $settings = new ilSetting('sysc');
169
170 $trash->setNumberLimit((int) $settings->get('num', '0'));
171 $trash->setTypesLimit(array_filter([$settings->get('types', '')]));
172
173 $age = (int) $settings->get('age', '0');
174 if ($age) {
175 $date = new ilDateTime(time(), IL_CAL_UNIX);
176 $date->increment(IL_CAL_DAY, $age * -1);
177 $trash->setAgeLimit($date);
178 }
179 $trash->start();
180
181 $result = new ilCronJobResult();
182 $result->setStatus(ilCronJobResult::STATUS_OK);
183 return $result;
184 }
const IL_CAL_UNIX
const IL_CAL_DAY
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\LTI\ToolProvider\$settings, IL_CAL_DAY, IL_CAL_UNIX, ILIAS\Repository\int(), ilSystemCheckTrash\MODE_TRASH_REMOVE, and ilCronJobResult\STATUS_OK.

+ Here is the call graph for this function:

◆ saveCustomSettings()

ilSCCronTrash::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Reimplemented from ilCronJob.

Definition at line 138 of file class.ilSCCronTrash.php.

138 : bool
139 {
140 $settings = new ilSetting('sysc');
141
142 if ((string) $a_form->getInput('number') === '') {
143 $settings->delete('num');
144 } else {
145 $settings->set('num', (string) ((int) $a_form->getInput('number')));
146 }
147
148 if ((string) $a_form->getInput('age') === '') {
149 $settings->delete('age');
150 } else {
151 $settings->set('age', (string) ((int) $a_form->getInput('age')));
152 }
153
154 if ($a_form->getInput('types') === '') {
155 $settings->delete('types');
156 } else {
157 $settings->set('types', $a_form->getInput('types'));
158 }
159
160 return true; // #18579
161 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...

References ILIAS\LTI\ToolProvider\$settings, and ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilLanguage ilSCCronTrash::$lng
protected

Definition at line 27 of file class.ilSCCronTrash.php.

◆ $objDefinition

ilObjectDefinition ilSCCronTrash::$objDefinition
protected

Definition at line 29 of file class.ilSCCronTrash.php.

◆ $tree

ilTree ilSCCronTrash::$tree
protected

Definition at line 28 of file class.ilSCCronTrash.php.


The documentation for this class was generated from the following file: