ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  $age->setValue($settings->get('age', ''));
114  }
115 
116  $form->addItem($age);
117 
118  // limit types
119  $types = new ilSelectInputGUI($lng->txt('sysc_trash_limit_type'), 'types');
120  $sub_objects = $GLOBALS['tree']->lookupTrashedObjectTypes();
121 
122  $options = array();
123  $options[0] = '';
124  foreach ($sub_objects as $obj_type) {
125  if (!$GLOBALS['objDefinition']->isRBACObject($obj_type) or !$GLOBALS['objDefinition']->isAllowedInRepository($obj_type)) {
126  continue;
127  }
128  $options[$obj_type] = $lng->txt('obj_' . $obj_type);
129  }
130  asort($options);
131  $types->setOptions($options);
132  $types->setValue($settings->get('types', ''));
133  $form->addItem($types);
134 
135  return $form;
136  }
137 
144  public function saveCustomSettings(ilPropertyFormGUI $a_form)
145  {
146  include_once './Services/Administration/classes/class.ilSetting.php';
147  $settings = new ilSetting('sysc');
148 
149  $settings->set('num', $a_form->getInput('number'));
150  $settings->set('age', $a_form->getInput('age'));
151  $settings->set('types', $a_form->getInput('types'));
152 
153  return true; // #18579
154  }
155 
159  public function run()
160  {
161  include_once './Services/SystemCheck/classes/class.ilSystemCheckTrash.php';
162  $trash = new ilSystemCheckTrash();
163  $trash->setMode(ilSystemCheckTrash::MODE_TRASH_REMOVE);
164 
165  include_once './Services/Administration/classes/class.ilSetting.php';
166  $settings = new ilSetting('sysc');
167 
168  $trash->setNumberLimit($settings->get('num', 0));
169  $trash->setTypesLimit((array) $settings->get('types'));
170 
171  $age = $settings->get('age', 0);
172  if ($age) {
173  $date = new ilDateTime(time(), IL_CAL_UNIX);
174  $date->increment(IL_CAL_DAY, (int) $age * -1);
175  $trash->setAgeLimit($date);
176  }
177  $trash->start();
178 
179  include_once './Services/Cron/classes/class.ilCronJobResult.php';
180  ;
181  $result = new ilCronJobResult();
183  return $result;
184  }
185 }
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(isset($_POST['submit'])) $form
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.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20