ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 Get all available schedule types. More...
 
 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...
 
 getValidScheduleTypes ()
 Get all available schedule types. 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 89 of file class.ilSCCronTrash.php.

References $GLOBALS, $lng, $options, ilPropertyFormGUI\addItem(), array, and ilFormPropertyGUI\setInfo().

90  {
91  global $lng;
92 
93  $lng->loadLanguageModule('sysc');
94 
95  include_once './Services/Administration/classes/class.ilSetting.php';
96  $settings = new ilSetting('sysc');
97 
98  // limit number
99  $num = new ilNumberInputGUI($lng->txt('sysc_trash_limit_num'), 'number');
100  $num->setInfo($lng->txt('purge_count_limit_desc'));
101  $num->setSize(10);
102  $num->setMinValue(1);
103  $num->setValue($settings->get('num',''));
104  $form->addItem($num);
105 
106  $age = new ilNumberInputGUI($lng->txt('sysc_trash_limit_age'), 'age');
107  $age->setInfo($lng->txt('purge_age_limit_desc'));
108  $age->setSize(4);
109  $age->setMinValue(1);
110  $age->setMaxLength(4);
111 
112  if($settings->get('age',''))
113  {
114  $age->setValue($settings->get('age',''));
115  }
116 
117  $form->addItem($age);
118 
119  // limit types
120  $types = new ilSelectInputGUI($lng->txt('sysc_trash_limit_type'), 'types');
121  $sub_objects = $GLOBALS['tree']->lookupTrashedObjectTypes();
122 
123  $options = array();
124  $options[0] = '';
125  foreach($sub_objects as $obj_type)
126  {
127  if(!$GLOBALS['objDefinition']->isRBACObject($obj_type) or !$GLOBALS['objDefinition']->isAllowedInRepository($obj_type))
128  {
129  continue;
130  }
131  $options[$obj_type] = $lng->txt('obj_'.$obj_type);
132  }
133  asort($options);
134  $types->setOptions($options);
135  $types->setValue($settings->get('types', ''));
136  $form->addItem($types);
137 
138  return $form;
139  }
ILIAS Setting Class.
This class represents a selection list property in a property form.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
addItem($a_item)
Add Item (Property, SectionHeader).
setInfo($a_info)
Set Information Text.
if(!is_array($argv)) $options
This class represents a number property in a property form.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ getDefaultScheduleType()

ilSCCronTrash::getDefaultScheduleType ( )

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

39  {
40  return self::SCHEDULE_TYPE_WEEKLY;
41  }

◆ getDefaultScheduleValue()

ilSCCronTrash::getDefaultScheduleValue ( )

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

61  {
62  return 1;
63  }

◆ getDescription()

ilSCCronTrash::getDescription ( )

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

References $GLOBALS, and $lng.

31  {
32  global $lng;
33 
34  $GLOBALS['lng']->loadLanguageModule('sysc');
35  return $lng->txt('sysc_cron_empty_trash_desc');
36  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $lng
Definition: privfeed.php:17

◆ 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 $GLOBALS, and $lng.

23  {
24  global $lng;
25 
26  $GLOBALS['lng']->loadLanguageModule('sysc');
27  return $lng->txt('sysc_cron_empty_trash');
28  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $lng
Definition: privfeed.php:17

◆ getValidScheduleTypes()

ilSCCronTrash::getValidScheduleTypes ( )

Get all available schedule types.

Returns
int

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

References array.

49  {
50  return array(
51  self::SCHEDULE_TYPE_DAILY,
52  self::SCHEDULE_TYPE_WEEKLY,
53  self::SCHEDULE_TYPE_MONTHLY,
54  self::SCHEDULE_TYPE_QUARTERLY,
55  self::SCHEDULE_TYPE_YEARLY
56  );
57  }
Create styles array
The data for the language used.

◆ hasAutoActivation()

ilSCCronTrash::hasAutoActivation ( )

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

66  {
67  return false;
68  }

◆ hasCustomSettings()

ilSCCronTrash::hasCustomSettings ( )
Returns
bool

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

79  {
80  return TRUE;
81  }

◆ hasFlexibleSchedule()

ilSCCronTrash::hasFlexibleSchedule ( )

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

71  {
72  return true;
73  }

◆ run()

ilSCCronTrash::run ( )

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

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

163  {
164  include_once './Services/SystemCheck/classes/class.ilSystemCheckTrash.php';
165  $trash = new ilSystemCheckTrash();
166  $trash->setMode(ilSystemCheckTrash::MODE_TRASH_REMOVE);
167 
168  include_once './Services/Administration/classes/class.ilSetting.php';
169  $settings = new ilSetting('sysc');
170 
171  $trash->setNumberLimit($settings->get('num',0));
172  $trash->setTypesLimit((array) $settings->get('types'));
173 
174  $age = $settings->get('age',0);
175  if($age)
176  {
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  $result = new ilCronJobResult();
186  return $result;
187  }
ILIAS Setting Class.
$result
const IL_CAL_UNIX
const IL_CAL_DAY
Date and time handling
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Cron job result data container.

◆ saveCustomSettings()

ilSCCronTrash::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Save custom settings.

Parameters
ilPropertyFormGUI$a_form
Returns
boolean

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

References ilPropertyFormGUI\getInput().

148  {
149  include_once './Services/Administration/classes/class.ilSetting.php';
150  $settings = new ilSetting('sysc');
151 
152  $settings->set('num', $a_form->getInput('number'));
153  $settings->set('age',$a_form->getInput('age'));
154  $settings->set('types',$a_form->getInput('types'));
155 
156  return true; // #18579
157  }
ILIAS Setting Class.
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: