ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjSystemCheckGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once 'Services/Object/classes/class.ilObjectGUI.php';
5 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
6 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
7 include_once './Services/SystemCheck/classes/class.ilSystemCheckTrash.php';
8 
9 
17 {
18  const SECTION_MAIN = 'main';
19  const SECTION_GROUP = 'group';
20 
21 
25  public $ctrl;
26 
33  public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
34  {
35 
36  $this->type = 'sysc';
37  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
38  $this->lng->loadLanguageModule('sysc');
39  $GLOBALS['ilLog']->write($this->lng->txt('sysc_overview'));
40  $GLOBALS['ilLog']->write($this->lng->txt('sysc_trash_restore'));
41 
42 
43 
44 
45  }
46 
51  public function getLang()
52  {
53  return $this->lng;
54  }
55 
59  public function executeCommand()
60  {
61  $next_class = $this->ctrl->getNextClass($this);
62  $cmd = $this->ctrl->getCmd();
63  $this->prepareOutput();
64 
65  switch($next_class)
66  {
67  case "ilobjectownershipmanagementgui":
68  $this->setSubTabs(self::SECTION_MAIN,'no_owner');
69  include_once 'Services/Object/classes/class.ilObjectOwnershipManagementGUI.php';
70  $gui = new ilObjectOwnershipManagementGUI(0);
71  $this->ctrl->forwardCommand($gui);
72  break;
73 
74  case 'ilobjsystemfoldergui':
75  include_once './Modules/SystemFolder/classes/class.ilObjSystemFolderGUI.php';
76  $sys_folder = new ilObjSystemFolderGUI('',SYSTEM_FOLDER_ID,TRUE);
77  $this->ctrl->forwardCommand($sys_folder);
78 
79  $GLOBALS['ilTabs']->clearTargets();
80 
81  $this->setSubTabs(self::SECTION_MAIN,'sc');
82  break;
83 
84  case 'ilpermissiongui':
85  $this->tabs_gui->setTabActive('perm_settings');
86  require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
87  $perm_gui = new ilPermissionGUI($this);
88  $this->ctrl->forwardCommand($perm_gui);
89  break;
90 
91  case '':
92  case 'ilobjsystemcheckgui':
93  if($cmd == '' || $cmd == 'view')
94  {
95  $cmd = 'overview';
96  }
97  $this->$cmd();
98  break;
99 
100  default:
101  // Forward to task handler
102  include_once './Services/SystemCheck/classes/class.ilSCComponentTaskFactory.php';
103  $this->ctrl->saveParameter($this,'grp_id');
104  $this->ctrl->saveParameter($this, 'task_id');
105  $this->ctrl->setReturn($this,'showGroup');
106  $GLOBALS['ilTabs']->clearTargets();
107  $GLOBALS['ilTabs']->setBackTarget($this->lng->txt('back'),$this->ctrl->getLinkTarget($this,'showGroup'));
108  $handler = ilSCComponentTaskFactory::getComponentTask((int) $_REQUEST['task_id']);
109  $this->ctrl->forwardCommand($handler);
110  break;
111 
112 
113  }
114  }
115 
120  public function getAdminTabs(ilTabsGUI $tabs_gui)
121  {
125  global $rbacsystem;
126 
127  if($rbacsystem->checkAccess('read', $this->object->getRefId()))
128  {
129  $tabs_gui->addTarget('overview', $this->ctrl->getLinkTarget($this, 'overview'));
130  }
131  if($rbacsystem->checkAccess('edit_permission', $this->object->getRefId()))
132  {
133  $tabs_gui->addTarget('perm_settings', $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), 'perm'), array('perm', 'info', 'owner'), 'ilpermissiongui');
134  }
135  }
136 
140  protected function overview()
141  {
142  $this->getLang()->loadLanguageModule('sysc');
143 
144 
145  $this->setSubTabs(self::SECTION_MAIN, 'overview');
146 
147 
148  include_once 'Services/SystemCheck/classes/class.ilSCGroupTableGUI.php';
149 
150  $table = new ilSCGroupTableGUI($this,'overview');
151  $table->init();
152  $table->parse();
153 
154  $GLOBALS['tpl']->setContent($table->getHTML());
155  return true;
156  }
157 
161  protected function showGroup()
162  {
163  $this->setSubTabs(self::SECTION_GROUP, '');
164 
165  $grp_id = (int) $_REQUEST['grp_id'];
166  $this->ctrl->saveParameter($this, 'grp_id');
167 
168  include_once 'Services/SystemCheck/classes/class.ilSCTaskTableGUI.php';
169  $table = new ilSCTaskTableGUI($grp_id,$this,'showGroup');
170  $table->init();
171  $table->parse();
172 
173  $GLOBALS['tpl']->setContent($table->getHTML());
174  return true;
175  }
176 
177 
178 
179 
184  protected function trash(ilPropertyFormGUI $form = null)
185  {
186  $this->setSubTabs(self::SECTION_MAIN,'trash');
187  if(!$form instanceof ilPropertyFormGUI)
188  {
189  $form = $this->initFormTrash();
190  }
191  $GLOBALS['tpl']->setContent($form->getHTML());
192  }
193 
198  protected function initFormTrash()
199  {
200  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
201  $form = new ilPropertyFormGUI();
202  $form->setFormAction($this->ctrl->getFormAction($this));
203 
204  $form->setTitle($this->lng->txt('sysc_administrate_deleted'));
205 
206  $action = new ilRadioGroupInputGUI($this->lng->txt('sysc_trash_action'), 'type');
207  $action->setRequired(TRUE);
208 
209  // Restore
210  $restore = new ilRadioOption($this->lng->txt('sysc_trash_restore'), ilSystemCheckTrash::MODE_TRASH_RESTORE);
211  $restore->setInfo($this->lng->txt('sysc_trash_restore_info'));
212  $action->addOption($restore);
213 
214  // Remove
215  $remove = new ilRadioOption($this->lng->txt('sysc_trash_remove'), ilSystemCheckTrash::MODE_TRASH_REMOVE);
216  $remove->setInfo($this->lng->txt('sysc_trash_remove_info'));
217  $action->addOption($remove);
218 
219  // limit number
220  $num = new ilNumberInputGUI($this->lng->txt('sysc_trash_limit_num'), 'number');
221  $num->setInfo($this->lng->txt('purge_count_limit_desc'));
222  $num->setSize(10);
223  $num->setMinValue(1);
224  $remove->addSubItem($num);
225 
226  $age = new ilDateTimeInputGUI($this->lng->txt('sysc_trash_limit_age'), 'age');
227  $age->setInfo($this->lng->txt('purge_age_limit_desc'));
228  $age->setMinuteStepSize(15);
229  $age->setMode(ilDateTimeInputGUI::MODE_INPUT);
230  #$earlier = new ilDateTime(time(),IL_CAL_UNIX);
231  #$earlier->increment(IL_CAL_MONTH,-6);
232  #$age->setDate($earlier);
233  $remove->addSubItem($age);
234 
235  // limit types
236  $types = new ilSelectInputGUI($this->lng->txt('sysc_trash_limit_type'), 'types');
237  /*
238  * @var ilObjDefinition
239  */
240  $sub_objects = $GLOBALS['tree']->lookupTrashedObjectTypes();
241 
242  $options = array();
243  $options[0] = '';
244  foreach($sub_objects as $obj_type)
245  {
246  if(!$GLOBALS['objDefinition']->isRBACObject($obj_type) or !$GLOBALS['objDefinition']->isAllowedInRepository($obj_type))
247  {
248  continue;
249  }
250  $options[$obj_type] = $this->lng->txt('obj_'.$obj_type);
251  }
252 
253  asort($options);
254 
255  $types->setOptions($options);
256  $remove->addSubItem($types);
257 
258  $form->addItem($action);
259 
260 
261  $form->addCommandButton('handleTrashAction', $this->lng->txt('start_scan'));
262  $form->addCommandButton('',$this->lng->txt('cancel'));
263 
264  return $form;
265  }
266 
270  protected function handleTrashAction()
271  {
272  $form = $this->initFormTrash();
273  if($form->checkInput())
274  {
275  $trash = new ilSystemCheckTrash();
276  $trash->setMode(ilSystemCheckTrash::MODE_TRASH_REMOVE);
277 
278  $dt_arr = $form->getInput('age');
279 
280  $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($dt_arr,TRUE));
281 
282 
283  if($dt_arr['date'])
284  {
285  $trash->setAgeLimit(new ilDate($dt_arr['date'],IL_CAL_DATE));
286  }
287  $trash->setNumberLimit($form->getInput('number'));
288 
289  if($form->getInput('types'))
290  {
291  $trash->setTypesLimit((array) $form->getInput('types'));
292  }
293  $trash->setMode($form->getInput('type'));
294  $trash->start();
295 
296  ilUtil::sendSuccess($this->lng->txt('settings_saved'),TRUE);
297  $form->setValuesByPost();
298  $this->trash($form);
299  return TRUE;
300  }
301 
302  ilUtil::sendFailure($this->lng->txt('err_check_input'));
303  $form->setValuesByPost();
304  $this->trash($form);
305  return FALSE;
306  }
307 
308 
313  protected function setSubTabs($a_section, $a_active)
314  {
315  switch($a_section)
316  {
317  case self::SECTION_MAIN:
318  $GLOBALS['ilTabs']->addSubTab(
319  '',
320  $this->getLang()->txt('sysc_groups'),
321  $this->ctrl->getLinkTarget($this,'overview')
322  );
323  $GLOBALS['ilTabs']->addSubTab(
324  'trash',
325  $this->getLang()->txt('sysc_tab_trash'),
326  $this->ctrl->getLinkTarget($this,'trash')
327  );
328  $GLOBALS['ilTabs']->addSubTab(
329  'no_owner',
330  $this->getLang()->txt('system_check_no_owner'),
331  $this->ctrl->getLinkTargetByClass('ilobjectownershipmanagementgui')
332  );
333  break;
334 
335  case self::SECTION_GROUP:
336  $GLOBALS['ilTabs']->clearTargets();
337  $GLOBALS['ilTabs']->setBackTarget(
338  $this->lng->txt('back'),
339  $this->ctrl->getLinkTarget($this,'overview')
340  );
341  }
342  $GLOBALS['ilTabs']->activateSubTab($a_active);
343  }
344 
345 }
346 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
Tabs GUI.
This class represents a property form user interface.
overview()
Show overview table.
$cmd
Definition: sahs_server.php:35
initFormTrash()
Show trash restore form.
addTarget($a_text, $a_link, $a_cmd="", $a_cmdClass="", $a_frame="", $a_activate=false, $a_dir_text=false)
DEPRECATED.
setInfo($a_info)
Set Info.
Class ilObjectOwnershipManagementGUI.
handleTrashAction()
Handle Trash action.
Class ilObjSystemFolderGUI.
setSubTabs($a_section, $a_active)
Set subtabs.
This class represents a date/time property in a property form.
trash(ilPropertyFormGUI $form=null)
Show trash form.
setInfo($a_info)
Set Information Text.
This class represents a property in a property form.
Class for single dates.
if(!is_array($argv)) $options
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
executeCommand()
ilCtrl execute command
This class represents a number property in a property form.
Class ilObjectGUI Basic methods of all Output classes.
getAdminTabs(&$tabs_gui)
administration tabs show only permissions and trash folder
prepareOutput()
prepare output
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const IL_CAL_DATE
Table GUI for system check groups overview.
Table GUI for system check task overview.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
setRequired($a_required)
Set Required.