ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
25 
26  $lng = $DIC['lng'];
27 
28  $GLOBALS['DIC']['lng']->loadLanguageModule('sysc');
29  return $lng->txt('sysc_cron_empty_trash');
30  }
31 
32  public function getDescription()
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  }
41 
42  public function getDefaultScheduleType()
43  {
44  return self::SCHEDULE_TYPE_WEEKLY;
45  }
46 
50  public function getValidScheduleTypes()
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  }
60 
61 
62  public function getDefaultScheduleValue()
63  {
64  return 1;
65  }
66 
67  public function hasAutoActivation()
68  {
69  return false;
70  }
71 
72  public function hasFlexibleSchedule()
73  {
74  return true;
75  }
76 
80  public function hasCustomSettings()
81  {
82  return true;
83  }
84 
85 
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  }
141 
148  public function saveCustomSettings(ilPropertyFormGUI $a_form)
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  }
159 
163  public function run()
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  }
189 }
This class represents a selection list property in a property form.
$result
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
Cron job application base class.
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
$lng
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.
Cron job result data container.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.