ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSCCronTrash Class Reference

Purge trash by cron. 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 ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $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 (?JobScheduleType $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 ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 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 ILIAS\Cron\CronJob
JobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Detailed Description

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 29 of file class.ilSCCronTrash.php.

Constructor & Destructor Documentation

◆ __construct()

ilSCCronTrash::__construct ( )

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

36 {
37 global $DIC;
38
39 $this->lng = $DIC->language();
40 $this->tree = $DIC->repositoryTree();
41 $this->objDefinition = $DIC['objDefinition'];
42 $this->lng->loadLanguageModule('sysc');
43 }
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomSettingsToForm()

ilSCCronTrash::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

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

96 : void
97 {
98 $this->lng->loadLanguageModule('sysc');
99
100 $settings = new ilSetting('sysc');
101
102 // limit number
103 $num = new ilNumberInputGUI($this->lng->txt('sysc_trash_limit_num'), 'number');
104 $num->allowDecimals(false);
105 $num->setInfo($this->lng->txt('purge_count_limit_desc'));
106 $num->setSize(10);
107 $num->setMinValue(1);
108 $num->setValue($settings->get('num', ''));
109 $a_form->addItem($num);
110
111 $age = new ilNumberInputGUI($this->lng->txt('sysc_trash_limit_age'), 'age');
112 $age->allowDecimals(false);
113 $age->setInfo($this->lng->txt('purge_age_limit_desc'));
114 $age->setSize(4);
115 $age->setMinValue(1);
116 $age->setMaxLength(4);
117
118 if ($settings->get('age', '')) {
119 $age->setValue($settings->get('age', ''));
120 }
121
122 $a_form->addItem($age);
123
124 // limit types
125 $types = new ilSelectInputGUI($this->lng->txt('sysc_trash_limit_type'), 'types');
126 $sub_objects = $this->tree->lookupTrashedObjectTypes();
127
128 $options = [];
129 $options[0] = '';
130 foreach ($sub_objects as $obj_type) {
131 if (!$this->objDefinition->isRBACObject($obj_type) || !$this->objDefinition->isAllowedInRepository($obj_type)) {
132 continue;
133 }
134 $options[$obj_type] = $this->lng->txt('obj_' . $obj_type);
135 }
136 asort($options);
137 $types->setOptions($options);
138 $types->setValue($settings->get('types', ''));
139 $a_form->addItem($types);
140 }
This class represents a number property in a property form.
This class represents a selection list property in a property form.
ILIAS Setting Class.

References ilPropertyFormGUI\addItem(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilSCCronTrash::getDefaultScheduleType ( )

Reimplemented from ILIAS\Cron\CronJob.

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

61 {
62 return JobScheduleType::WEEKLY;
63 }

◆ getDefaultScheduleValue()

ilSCCronTrash::getDefaultScheduleValue ( )

Reimplemented from ILIAS\Cron\CronJob.

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

76 : ?int
77 {
78 return 1;
79 }

◆ getDescription()

ilSCCronTrash::getDescription ( )

Reimplemented from ILIAS\Cron\CronJob.

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

55 : string
56 {
57 return $this->lng->txt('sysc_cron_empty_trash_desc');
58 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getId()

ilSCCronTrash::getId ( )

Reimplemented from ILIAS\Cron\CronJob.

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

45 : string
46 {
47 return 'sysc_trash';
48 }

◆ getTitle()

ilSCCronTrash::getTitle ( )

Reimplemented from ILIAS\Cron\CronJob.

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

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

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
list<JobScheduleType>

Reimplemented from ILIAS\Cron\CronJob.

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

65 : array
66 {
67 return [
68 JobScheduleType::DAILY,
69 JobScheduleType::WEEKLY,
70 JobScheduleType::MONTHLY,
71 JobScheduleType::QUARTERLY,
73 ];
74 }

References ILIAS\Cron\Job\Schedule\YEARLY.

◆ hasAutoActivation()

ilSCCronTrash::hasAutoActivation ( )

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

Reimplemented from ILIAS\Cron\CronJob.

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

81 : bool
82 {
83 return false;
84 }

◆ hasCustomSettings()

ilSCCronTrash::hasCustomSettings ( )

Reimplemented from ILIAS\Cron\CronJob.

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

91 : bool
92 {
93 return true;
94 }

◆ hasFlexibleSchedule()

ilSCCronTrash::hasFlexibleSchedule ( )

Reimplemented from ILIAS\Cron\CronJob.

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

86 : bool
87 {
88 return true;
89 }

◆ run()

ilSCCronTrash::run ( )

Reimplemented from ILIAS\Cron\CronJob.

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

167 : JobResult
168 {
169 $trash = new ilSystemCheckTrash();
171
172 $settings = new ilSetting('sysc');
173
174 $trash->setNumberLimit((int) $settings->get('num', '0'));
175 $trash->setTypesLimit(array_filter([$settings->get('types', '')]));
176
177 $age = (int) $settings->get('age', '0');
178 if ($age) {
179 $date = new ilDateTime(time(), IL_CAL_UNIX);
180 $date->increment(IL_CAL_DAY, $age * -1);
181 $trash->setAgeLimit($date);
182 }
183 $trash->start();
184
185 $result = new JobResult();
186 $result->setStatus(JobResult::STATUS_OK);
187 return $result;
188 }
const IL_CAL_UNIX
const IL_CAL_DAY
@classDescription Date and time handling

References IL_CAL_DAY, IL_CAL_UNIX, ILIAS\Repository\int(), and ilSystemCheckTrash\MODE_TRASH_REMOVE.

+ Here is the call graph for this function:

◆ saveCustomSettings()

ilSCCronTrash::saveCustomSettings ( ilPropertyFormGUI  $a_form)

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

142 : bool
143 {
144 $settings = new ilSetting('sysc');
145
146 if ((string) $a_form->getInput('number') === '') {
147 $settings->delete('num');
148 } else {
149 $settings->set('num', (string) ((int) $a_form->getInput('number')));
150 }
151
152 if ((string) $a_form->getInput('age') === '') {
153 $settings->delete('age');
154 } else {
155 $settings->set('age', (string) ((int) $a_form->getInput('age')));
156 }
157
158 if ($a_form->getInput('types') === '') {
159 $settings->delete('types');
160 } else {
161 $settings->set('types', $a_form->getInput('types'));
162 }
163
164 return true; // #18579
165 }
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 ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilLanguage ilSCCronTrash::$lng
protected

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

◆ $objDefinition

ilObjectDefinition ilSCCronTrash::$objDefinition
protected

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

◆ $tree

ilTree ilSCCronTrash::$tree
protected

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


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