ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSCCronTrash.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "Services/Cron/classes/class.ilCronJob.php";
5 
11 class ilSCCronTrash extends ilCronJob
12 {
17  public function getId()
18  {
19  return 'sysc_trash';
20  }
21 
22  public function getTitle()
23  {
24  global $lng;
25 
26  $GLOBALS['lng']->loadLanguageModule('sysc');
27  return $lng->txt('sysc_cron_empty_trash');
28  }
29 
30  public function getDescription()
31  {
32  global $lng;
33 
34  $GLOBALS['lng']->loadLanguageModule('sysc');
35  return $lng->txt('sysc_cron_empty_trash_desc');
36  }
37 
38  public function getDefaultScheduleType()
39  {
40  return self::SCHEDULE_TYPE_WEEKLY;
41  }
42 
48  public function getValidScheduleTypes()
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  }
58 
59 
60  public function getDefaultScheduleValue()
61  {
62  return 1;
63  }
64 
65  public function hasAutoActivation()
66  {
67  return false;
68  }
69 
70  public function hasFlexibleSchedule()
71  {
72  return true;
73  }
74 
78  public function hasCustomSettings()
79  {
80  return TRUE;
81  }
82 
83 
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  }
140 
147  public function saveCustomSettings(ilPropertyFormGUI $a_form)
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  }
158 
162  public function run()
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  }
188 }
189 ?>
ILIAS Setting Class.
This class represents a selection list property in a property form.
$result
This class represents a property form user interface.
Cron job application base class.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
addItem($a_item)
Add Item (Property, SectionHeader).
addCustomSettingsToForm(ilPropertyFormGUI $form)
Add custom settings to form.
const IL_CAL_UNIX
saveCustomSettings(ilPropertyFormGUI $a_form)
Save custom settings.
Purge trash by cron.
setInfo($a_info)
Set Information Text.
const IL_CAL_DAY
if(!is_array($argv)) $options
getValidScheduleTypes()
Get all available schedule types.
This class represents a number property in a property form.
Date and time handling
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Cron job result data container.