ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSCCronTrash Class Reference

Purge trash by cron. More...

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

Public Member Functions

 getId ()
 Get id. More...
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getValidScheduleTypes ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 run ()
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $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...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

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

Member Function Documentation

◆ addCustomSettingsToForm()

ilSCCronTrash::addCustomSettingsToForm ( ilPropertyFormGUI  $form)

Add custom settings to form.

Parameters
ilPropertyFormGUI$a_form

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

References $DIC, $form, $GLOBALS, $lng, PHPMailer\PHPMailer\$options, ilPropertyFormGUI\addItem(), and ilFormPropertyGUI\setInfo().

92  {
93  global $DIC;
94 
95  $lng = $DIC['lng'];
96 
97  $lng->loadLanguageModule('sysc');
98 
99  include_once './Services/Administration/classes/class.ilSetting.php';
100  $settings = new ilSetting('sysc');
101 
102  // limit number
103  $num = new ilNumberInputGUI($lng->txt('sysc_trash_limit_num'), 'number');
104  $num->setInfo($lng->txt('purge_count_limit_desc'));
105  $num->setSize(10);
106  $num->setMinValue(1);
107  $num->setValue($settings->get('num', ''));
108  $form->addItem($num);
109 
110  $age = new ilNumberInputGUI($lng->txt('sysc_trash_limit_age'), 'age');
111  $age->setInfo($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  $form->addItem($age);
121 
122  // limit types
123  $types = new ilSelectInputGUI($lng->txt('sysc_trash_limit_type'), 'types');
124  $sub_objects = $GLOBALS['DIC']['tree']->lookupTrashedObjectTypes();
125 
126  $options = array();
127  $options[0] = '';
128  foreach ($sub_objects as $obj_type) {
129  if (!$GLOBALS['DIC']['objDefinition']->isRBACObject($obj_type) or !$GLOBALS['DIC']['objDefinition']->isAllowedInRepository($obj_type)) {
130  continue;
131  }
132  $options[$obj_type] = $lng->txt('obj_' . $obj_type);
133  }
134  asort($options);
135  $types->setOptions($options);
136  $types->setValue($settings->get('types', ''));
137  $form->addItem($types);
138 
139  return $form;
140  }
This class represents a selection list property in a property form.
global $DIC
Definition: saml.php:7
addItem($a_item)
Add Item (Property, SectionHeader).
setInfo($a_info)
Set Information Text.
if(isset($_POST['submit'])) $form
$lng
This class represents a number property in a property form.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilSCCronTrash::getDefaultScheduleType ( )

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

43  {
44  return self::SCHEDULE_TYPE_WEEKLY;
45  }

◆ getDefaultScheduleValue()

ilSCCronTrash::getDefaultScheduleValue ( )

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

63  {
64  return 1;
65  }

◆ getDescription()

ilSCCronTrash::getDescription ( )

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

References $DIC, $GLOBALS, and $lng.

33  {
34  global $DIC;
35 
36  $lng = $DIC['lng'];
37 
38  $GLOBALS['DIC']['lng']->loadLanguageModule('sysc');
39  return $lng->txt('sysc_cron_empty_trash_desc');
40  }
global $DIC
Definition: saml.php:7
$lng
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

◆ getId()

ilSCCronTrash::getId ( )

Get id.

Returns
string

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

18  {
19  return 'sysc_trash';
20  }

◆ getTitle()

ilSCCronTrash::getTitle ( )

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

References $DIC, $GLOBALS, and $lng.

23  {
24  global $DIC;
25 
26  $lng = $DIC['lng'];
27 
28  $GLOBALS['DIC']['lng']->loadLanguageModule('sysc');
29  return $lng->txt('sysc_cron_empty_trash');
30  }
global $DIC
Definition: saml.php:7
$lng
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

◆ getValidScheduleTypes()

ilSCCronTrash::getValidScheduleTypes ( )

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

51  {
52  return array(
53  self::SCHEDULE_TYPE_DAILY,
54  self::SCHEDULE_TYPE_WEEKLY,
55  self::SCHEDULE_TYPE_MONTHLY,
56  self::SCHEDULE_TYPE_QUARTERLY,
57  self::SCHEDULE_TYPE_YEARLY
58  );
59  }

◆ hasAutoActivation()

ilSCCronTrash::hasAutoActivation ( )

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

68  {
69  return false;
70  }

◆ hasCustomSettings()

ilSCCronTrash::hasCustomSettings ( )
Returns
bool

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

81  {
82  return true;
83  }

◆ hasFlexibleSchedule()

ilSCCronTrash::hasFlexibleSchedule ( )

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

73  {
74  return true;
75  }

◆ run()

ilSCCronTrash::run ( )

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

References $result, IL_CAL_DAY, IL_CAL_UNIX, ilSystemCheckTrash\MODE_TRASH_REMOVE, and ilCronJobResult\STATUS_OK.

164  {
165  include_once './Services/SystemCheck/classes/class.ilSystemCheckTrash.php';
166  $trash = new ilSystemCheckTrash();
167  $trash->setMode(ilSystemCheckTrash::MODE_TRASH_REMOVE);
168 
169  include_once './Services/Administration/classes/class.ilSetting.php';
170  $settings = new ilSetting('sysc');
171 
172  $trash->setNumberLimit($settings->get('num', 0));
173  $trash->setTypesLimit((array) $settings->get('types'));
174 
175  $age = $settings->get('age', 0);
176  if ($age) {
177  $date = new ilDateTime(time(), IL_CAL_UNIX);
178  $date->increment(IL_CAL_DAY, (int) $age * -1);
179  $trash->setAgeLimit($date);
180  }
181  $trash->start();
182 
183  include_once './Services/Cron/classes/class.ilCronJobResult.php';
184  ;
185  $result = new ilCronJobResult();
187  return $result;
188  }
$result
const IL_CAL_UNIX
const IL_CAL_DAY
Date and time handling
Cron job result data container.

◆ saveCustomSettings()

ilSCCronTrash::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Save custom settings.

Parameters
ilPropertyFormGUI$a_form
Returns
boolean

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

References ilPropertyFormGUI\getInput().

149  {
150  include_once './Services/Administration/classes/class.ilSetting.php';
151  $settings = new ilSetting('sysc');
152 
153  $settings->set('num', $a_form->getInput('number'));
154  $settings->set('age', $a_form->getInput('age'));
155  $settings->set('types', $a_form->getInput('types'));
156 
157  return true; // #18579
158  }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ Here is the call graph for this function:

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