ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 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, ?CronJobScheduleType $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 (?CronJobScheduleType $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
CronJobScheduleType $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 27 of file class.ilSCCronTrash.php.

Constructor & Destructor Documentation

◆ __construct()

ilSCCronTrash::__construct ( )

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

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

34  {
35  global $DIC;
36 
37  $this->lng = $DIC->language();
38  $this->tree = $DIC->repositoryTree();
39  $this->objDefinition = $DIC['objDefinition'];
40  $this->lng->loadLanguageModule('sysc');
41  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomSettingsToForm()

ilSCCronTrash::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

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

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

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

◆ getDefaultScheduleType()

ilSCCronTrash::getDefaultScheduleType ( )

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

59  {
60  return CronJobScheduleType::SCHEDULE_TYPE_WEEKLY;
61  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getDefaultScheduleValue()

ilSCCronTrash::getDefaultScheduleValue ( )

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

74  : ?int
75  {
76  return 1;
77  }

◆ getDescription()

ilSCCronTrash::getDescription ( )

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

References ILIAS\Repository\lng().

53  : string
54  {
55  return $this->lng->txt('sysc_cron_empty_trash_desc');
56  }
+ Here is the call graph for this function:

◆ getId()

ilSCCronTrash::getId ( )

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

43  : string
44  {
45  return 'sysc_trash';
46  }

◆ getTitle()

ilSCCronTrash::getTitle ( )

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

References ILIAS\Repository\lng().

48  : string
49  {
50  return $this->lng->txt('sysc_cron_empty_trash');
51  }
+ Here is the call graph for this function:

◆ getValidScheduleTypes()

ilSCCronTrash::getValidScheduleTypes ( )

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

References ILIAS\Cron\Schedule\SCHEDULE_TYPE_YEARLY.

63  : array
64  {
65  return [
66  CronJobScheduleType::SCHEDULE_TYPE_DAILY,
67  CronJobScheduleType::SCHEDULE_TYPE_WEEKLY,
68  CronJobScheduleType::SCHEDULE_TYPE_MONTHLY,
69  CronJobScheduleType::SCHEDULE_TYPE_QUARTERLY,
71  ];
72  }

◆ hasAutoActivation()

ilSCCronTrash::hasAutoActivation ( )

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

79  : bool
80  {
81  return false;
82  }

◆ hasCustomSettings()

ilSCCronTrash::hasCustomSettings ( )

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

89  : bool
90  {
91  return true;
92  }

◆ hasFlexibleSchedule()

ilSCCronTrash::hasFlexibleSchedule ( )

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

84  : bool
85  {
86  return true;
87  }

◆ run()

ilSCCronTrash::run ( )

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

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

166  {
167  $trash = new ilSystemCheckTrash();
168  $trash->setMode(ilSystemCheckTrash::MODE_TRASH_REMOVE);
169 
170  $settings = new ilSetting('sysc');
171 
172  $trash->setNumberLimit((int) $settings->get('num', '0'));
173  $trash->setTypesLimit(array_filter([$settings->get('types', '')]));
174 
175  $age = (int) $settings->get('age', '0');
176  if ($age) {
177  $date = new ilDateTime(time(), IL_CAL_UNIX);
178  $date->increment(IL_CAL_DAY, $age * -1);
179  $trash->setAgeLimit($date);
180  }
181  $trash->start();
182 
183  $result = new ilCronJobResult();
184  $result->setStatus(ilCronJobResult::STATUS_OK);
185  return $result;
186  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_UNIX
const IL_CAL_DAY
+ Here is the call graph for this function:

◆ saveCustomSettings()

ilSCCronTrash::saveCustomSettings ( ilPropertyFormGUI  $a_form)

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

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

140  : bool
141  {
142  $settings = new ilSetting('sysc');
143 
144  if ((string) $a_form->getInput('number') === '') {
145  $settings->delete('num');
146  } else {
147  $settings->set('num', (string) ((int) $a_form->getInput('number')));
148  }
149 
150  if ((string) $a_form->getInput('age') === '') {
151  $settings->delete('age');
152  } else {
153  $settings->set('age', (string) ((int) $a_form->getInput('age')));
154  }
155 
156  if ($a_form->getInput('types') === '') {
157  $settings->delete('types');
158  } else {
159  $settings->set('types', $a_form->getInput('types'));
160  }
161 
162  return true; // #18579
163  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
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-...
+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilLanguage ilSCCronTrash::$lng
protected

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

◆ $objDefinition

ilObjectDefinition ilSCCronTrash::$objDefinition
protected

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

◆ $tree

ilTree ilSCCronTrash::$tree
protected

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


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