ILIAS  release_7 Revision v7.30-3-g800a261c036
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  $this->type = 'sysc';
36  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
37  $this->lng->loadLanguageModule('sysc');
38  }
39 
44  public function getLang()
45  {
46  return $this->lng;
47  }
48 
52  public function executeCommand()
53  {
54  $next_class = $this->ctrl->getNextClass($this);
55  $cmd = $this->ctrl->getCmd();
56  $this->prepareOutput();
57 
58  switch ($next_class) {
59  case "ilobjectownershipmanagementgui":
60  $this->setSubTabs(self::SECTION_MAIN, 'no_owner');
61  include_once 'Services/Object/classes/class.ilObjectOwnershipManagementGUI.php';
62  $gui = new ilObjectOwnershipManagementGUI(0);
63  $this->ctrl->forwardCommand($gui);
64  break;
65 
66  case 'ilobjsystemfoldergui':
67  include_once './Modules/SystemFolder/classes/class.ilObjSystemFolderGUI.php';
68  $sys_folder = new ilObjSystemFolderGUI('', SYSTEM_FOLDER_ID, true);
69  $this->ctrl->forwardCommand($sys_folder);
70 
71  $GLOBALS['DIC']['ilTabs']->clearTargets();
72 
73  $this->setSubTabs(self::SECTION_MAIN, 'sc');
74  break;
75 
76  case 'ilpermissiongui':
77  $this->tabs_gui->setTabActive('perm_settings');
78  require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
79  $perm_gui = new ilPermissionGUI($this);
80  $this->ctrl->forwardCommand($perm_gui);
81  break;
82 
83  case '':
84  case 'ilobjsystemcheckgui':
85  if ($cmd == '' || $cmd == 'view') {
86  $cmd = 'overview';
87  }
88  $this->$cmd();
89  break;
90 
91  default:
92  // Forward to task handler
93  include_once './Services/SystemCheck/classes/class.ilSCComponentTaskFactory.php';
94  $this->ctrl->saveParameter($this, 'grp_id');
95  $this->ctrl->saveParameter($this, 'task_id');
96  $this->ctrl->setReturn($this, 'showGroup');
97  $GLOBALS['DIC']['ilTabs']->clearTargets();
98  $GLOBALS['DIC']['ilTabs']->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'showGroup'));
99  $handler = ilSCComponentTaskFactory::getComponentTask((int) $_REQUEST['task_id']);
100  $this->ctrl->forwardCommand($handler);
101  break;
102 
103 
104  }
105  }
106 
111  public function getAdminTabs()
112  {
116  global $DIC;
117 
118  $rbacsystem = $DIC['rbacsystem'];
119 
120  if ($rbacsystem->checkAccess('read', $this->object->getRefId())) {
121  $this->tabs_gui->addTarget('overview', $this->ctrl->getLinkTarget($this, 'overview'));
122  }
123  if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
124  $this->tabs_gui->addTarget('perm_settings', $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), 'perm'), array('perm', 'info', 'owner'), 'ilpermissiongui');
125  }
126  }
127 
131  protected function overview()
132  {
133  $this->getLang()->loadLanguageModule('sysc');
134 
135 
136  $this->setSubTabs(self::SECTION_MAIN, 'overview');
137 
138 
139  include_once 'Services/SystemCheck/classes/class.ilSCGroupTableGUI.php';
140 
141  $table = new ilSCGroupTableGUI($this, 'overview');
142  $table->init();
143  $table->parse();
144 
145  $GLOBALS['DIC']['tpl']->setContent($table->getHTML());
146  return true;
147  }
148 
152  protected function showGroup()
153  {
154  $this->setSubTabs(self::SECTION_GROUP, '');
155 
156  $grp_id = (int) $_REQUEST['grp_id'];
157  $this->ctrl->saveParameter($this, 'grp_id');
158 
159  include_once 'Services/SystemCheck/classes/class.ilSCTaskTableGUI.php';
160  $table = new ilSCTaskTableGUI($grp_id, $this, 'showGroup');
161  $table->init();
162  $table->parse();
163 
164  $GLOBALS['DIC']['tpl']->setContent($table->getHTML());
165  return true;
166  }
167 
168 
169 
170 
175  protected function trash(ilPropertyFormGUI $form = null)
176  {
177  $this->setSubTabs(self::SECTION_MAIN, 'trash');
178  if (!$form instanceof ilPropertyFormGUI) {
179  $form = $this->initFormTrash();
180  }
181  $GLOBALS['DIC']['tpl']->setContent($form->getHTML());
182  }
183 
188  protected function initFormTrash()
189  {
190  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
191  $form = new ilPropertyFormGUI();
192  $form->setFormAction($this->ctrl->getFormAction($this));
193 
194  $form->setTitle($this->lng->txt('sysc_administrate_deleted'));
195 
196  $action = new ilRadioGroupInputGUI($this->lng->txt('sysc_trash_action'), 'type');
197  $action->setRequired(true);
198 
199  // Restore
200  $restore = new ilRadioOption($this->lng->txt('sysc_trash_restore'), ilSystemCheckTrash::MODE_TRASH_RESTORE);
201  $restore->setInfo($this->lng->txt('sysc_trash_restore_info'));
202  $action->addOption($restore);
203 
204  // Remove
205  $remove = new ilRadioOption($this->lng->txt('sysc_trash_remove'), ilSystemCheckTrash::MODE_TRASH_REMOVE);
206  $remove->setInfo($this->lng->txt('sysc_trash_remove_info'));
207  $action->addOption($remove);
208 
209  // limit number
210  $num = new ilNumberInputGUI($this->lng->txt('sysc_trash_limit_num'), 'number');
211  $num->setInfo($this->lng->txt('purge_count_limit_desc'));
212  $num->setSize(10);
213  $num->setMinValue(1);
214  $remove->addSubItem($num);
215 
216  $age = new ilDateTimeInputGUI($this->lng->txt('sysc_trash_limit_age'), 'age');
217  $age->setInfo($this->lng->txt('purge_age_limit_desc'));
218  $age->setMinuteStepSize(15);
219  #$earlier = new ilDateTime(time(),IL_CAL_UNIX);
220  #$earlier->increment(IL_CAL_MONTH,-6);
221  #$age->setDate($earlier);
222  $remove->addSubItem($age);
223 
224  // limit types
225  $types = new ilSelectInputGUI($this->lng->txt('sysc_trash_limit_type'), 'types');
226  /*
227  * @var ilObjDefinition
228  */
229  $sub_objects = $GLOBALS['DIC']['tree']->lookupTrashedObjectTypes();
230 
231  $options = array();
232  $options[0] = '';
233  foreach ($sub_objects as $obj_type) {
234  if (!$GLOBALS['DIC']['objDefinition']->isRBACObject($obj_type) or !$GLOBALS['DIC']['objDefinition']->isAllowedInRepository($obj_type)) {
235  continue;
236  }
237  $options[$obj_type] = $this->lng->txt('obj_' . $obj_type);
238  }
239 
240  asort($options);
241 
242  $types->setOptions($options);
243  $remove->addSubItem($types);
244 
245  $form->addItem($action);
246 
247 
248  $form->addCommandButton('handleTrashAction', $this->lng->txt('start_scan'));
249  $form->addCommandButton('', $this->lng->txt('cancel'));
250 
251  return $form;
252  }
253 
257  protected function handleTrashAction()
258  {
259  $form = $this->initFormTrash();
260  if ($form->checkInput()) {
261  $trash = new ilSystemCheckTrash();
262  $trash->setMode(ilSystemCheckTrash::MODE_TRASH_REMOVE);
263  $dt = $form->getItemByPostVar('age')->getDate();
264  if ($dt) {
265  $trash->setAgeLimit($dt);
266  }
267  $trash->setNumberLimit($form->getInput('number'));
268 
269  if ($form->getInput('types')) {
270  $trash->setTypesLimit((array) $form->getInput('types'));
271  }
272  $trash->setMode($form->getInput('type'));
273  $trash->start();
274 
275  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
276  $form->setValuesByPost();
277  $this->trash($form);
278  return true;
279  }
280 
281  ilUtil::sendFailure($this->lng->txt('err_check_input'));
282  $form->setValuesByPost();
283  $this->trash($form);
284  return false;
285  }
286 
287 
292  protected function setSubTabs($a_section, $a_active)
293  {
294  switch ($a_section) {
295  case self::SECTION_MAIN:
296  $GLOBALS['DIC']['ilTabs']->addSubTab(
297  '',
298  $this->getLang()->txt('sysc_groups'),
299  $this->ctrl->getLinkTarget($this, 'overview')
300  );
301  $GLOBALS['DIC']['ilTabs']->addSubTab(
302  'trash',
303  $this->getLang()->txt('sysc_tab_trash'),
304  $this->ctrl->getLinkTarget($this, 'trash')
305  );
306  $GLOBALS['DIC']['ilTabs']->addSubTab(
307  'no_owner',
308  $this->getLang()->txt('system_check_no_owner'),
309  $this->ctrl->getLinkTargetByClass('ilobjectownershipmanagementgui')
310  );
311  break;
312 
313  case self::SECTION_GROUP:
314  $GLOBALS['DIC']['ilTabs']->clearTargets();
315  $GLOBALS['DIC']['ilTabs']->setBackTarget(
316  $this->lng->txt('back'),
317  $this->ctrl->getLinkTarget($this, 'overview')
318  );
319  }
320  $GLOBALS['DIC']['ilTabs']->activateSubTab($a_active);
321  }
322 }
This class represents an option in a radio group.
This class represents a property form user interface.
overview()
Show overview table.
initFormTrash()
Show trash restore form.
setInfo($a_info)
Set Info.
Class ilObjectOwnershipManagementGUI.
handleTrashAction()
Handle Trash action.
const SYSTEM_FOLDER_ID
Definition: constants.php:33
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.
prepareOutput($a_show_subobjects=true)
prepare output
This class represents a property in a property form.
__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.
global $DIC
Definition: goto.php:24
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
__construct(Container $dic, ilPlugin $plugin)
Table GUI for system check groups overview.
Table GUI for system check task overview.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
getAdminTabs()
administration tabs show only permissions and trash folder
setRequired($a_required)
Set Required.