ILIAS  release_8 Revision v8.24
class.ilObjSystemCheckGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
22
29{
30 protected const SECTION_MAIN = 'main';
31 protected const SECTION_GROUP = 'group';
32
34 protected Factory $refinery;
35
36 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
37 {
38 global $DIC;
39 $this->http = $DIC->http();
40 $this->refinery = $DIC->refinery();
41 $this->type = 'sysc';
42 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
43 $this->lng->loadLanguageModule('sysc');
44 }
45
46 protected function getGrpIdFromRequest(): int
47 {
48 if ($this->http->wrapper()->query()->has('grp_id')) {
49 return $this->http->wrapper()->query()->retrieve(
50 'grp_id',
51 $this->refinery->kindlyTo()->int()
52 );
53 }
54 return 0;
55 }
56
57 protected function getTaskIdFromRequest(): int
58 {
59 if ($this->http->wrapper()->query()->has('task_id')) {
60 return $this->http->wrapper()->query()->retrieve(
61 'task_id',
62 $this->refinery->kindlyTo()->int()
63 );
64 }
65 return 0;
66 }
67
68 public function getLang(): ilLanguage
69 {
70 return $this->lng;
71 }
72
73 public function executeCommand(): void
74 {
75 $this->checkPermission('read');
76
77 $next_class = $this->ctrl->getNextClass($this);
78 $cmd = $this->ctrl->getCmd();
79 $this->prepareOutput();
80
81 switch ($next_class) {
82 case 'ilobjectownershipmanagementgui':
83 $this->setSubTabs(self::SECTION_MAIN, 'no_owner');
84 $this->tabs_gui->activateTab('overview');
85
86 $read_only = !$this->checkPermissionBool('write');
87
88 $gui = new ilObjectOwnershipManagementGUI(0, $read_only);
89 $this->ctrl->forwardCommand($gui);
90 break;
91
92 case 'ilobjsystemfoldergui':
93
94 $sys_folder = new ilObjSystemFolderGUI('', SYSTEM_FOLDER_ID, true);
95 $this->ctrl->forwardCommand($sys_folder);
96
97 $this->tabs_gui->clearTargets();
98
99 $this->setSubTabs(self::SECTION_MAIN, 'sc');
100 break;
101
102 case 'ilpermissiongui':
103 $this->tabs_gui->activateTab('perm_settings');
104
105 $perm_gui = new ilPermissionGUI($this);
106 $this->ctrl->forwardCommand($perm_gui);
107 break;
108
109 case '':
110 case 'ilobjsystemcheckgui':
111 if ($cmd === null || $cmd === '' || $cmd === 'view') {
112 $cmd = 'overview';
113 }
114 $this->$cmd();
115 break;
116
117 default:
118 // Forward to task handler
119
120 $this->ctrl->saveParameter($this, 'grp_id');
121 $this->ctrl->saveParameter($this, 'task_id');
122 $this->ctrl->setReturn($this, 'showGroup');
123 $this->tabs_gui->clearTargets();
124 $this->tabs_gui->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'showGroup'));
126 $this->ctrl->forwardCommand($handler);
127 break;
128
129 }
130 }
131
132 public function getAdminTabs(): void
133 {
134 if ($this->checkPermissionBool('read')) {
135 $this->tabs_gui->addTab(
136 'overview',
137 $this->lng->txt('overview'),
138 $this->ctrl->getLinkTarget($this, 'overview')
139 );
140 }
141 if ($this->checkPermissionBool('edit_permission')) {
142 $this->tabs_gui->addTab(
143 'perm_settings',
144 $this->lng->txt('perm_settings'),
145 $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), 'perm')
146 );
147 }
148 }
149
150 protected function overview(): bool
151 {
152 $this->getLang()->loadLanguageModule('sysc');
153
154 $this->setSubTabs(self::SECTION_MAIN, 'overview');
155 $this->tabs_gui->activateTab('overview');
156
157 $table = new ilSCGroupTableGUI($this, 'overview');
158 $table->init();
159 $table->parse();
160
161 $this->tpl->setContent($table->getHTML());
162 return true;
163 }
164
165 protected function showGroup(): bool
166 {
167 $this->setSubTabs(self::SECTION_GROUP, '');
168
169 $this->ctrl->saveParameter($this, 'grp_id');
170
171 $table = new ilSCTaskTableGUI($this->getGrpIdFromRequest(), $this, 'showGroup');
172 $table->init();
173 $table->parse();
174
175 $this->tpl->setContent($table->getHTML());
176 return true;
177 }
178
179 protected function trash(ilPropertyFormGUI $form = null): void
180 {
181 $this->checkPermission('write');
182
183 $this->setSubTabs(self::SECTION_MAIN, 'trash');
184 $this->tabs_gui->activateTab('overview');
185 if (!$form instanceof ilPropertyFormGUI) {
186 $form = $this->initFormTrash();
187 }
188 $this->tpl->setContent($form->getHTML());
189 }
190
191 protected function initFormTrash(): ilPropertyFormGUI
192 {
193 $form = new ilPropertyFormGUI();
194 $form->setFormAction($this->ctrl->getFormAction($this));
195
196 $form->setTitle($this->lng->txt('sysc_administrate_deleted'));
197
198 $action = new ilRadioGroupInputGUI($this->lng->txt('sysc_trash_action'), 'type');
199 $action->setRequired(true);
200
201 // Restore
202 $restore = new ilRadioOption($this->lng->txt('sysc_trash_restore'), (string) ilSystemCheckTrash::MODE_TRASH_RESTORE);
203 $restore->setInfo($this->lng->txt('sysc_trash_restore_info'));
204 $action->addOption($restore);
205
206 // Remove
207 $remove = new ilRadioOption($this->lng->txt('sysc_trash_remove'), (string) ilSystemCheckTrash::MODE_TRASH_REMOVE);
208 $remove->setInfo($this->lng->txt('sysc_trash_remove_info'));
209 $action->addOption($remove);
210
211 // limit number
212 $num = new ilNumberInputGUI($this->lng->txt('sysc_trash_limit_num'), 'number');
213 $num->setInfo($this->lng->txt('purge_count_limit_desc'));
214 $num->setSize(10);
215 $num->setMinValue(1);
216 $remove->addSubItem($num);
217
218 $age = new ilDateTimeInputGUI($this->lng->txt('sysc_trash_limit_age'), 'age');
219 $age->setInfo($this->lng->txt('purge_age_limit_desc'));
220 $age->setMinuteStepSize(15);
221 $remove->addSubItem($age);
222
223 // limit types
224 $types = new ilSelectInputGUI($this->lng->txt('sysc_trash_limit_type'), 'types');
225
226 $sub_objects = $this->tree->lookupTrashedObjectTypes();
227
228 $options = array();
229 $options[0] = '';
230 foreach ($sub_objects as $obj_type) {
231 if (!$this->obj_definition->isRBACObject($obj_type) || !$this->obj_definition->isAllowedInRepository($obj_type)) {
232 continue;
233 }
234 $options[$obj_type] = $this->lng->txt('obj_' . $obj_type);
235 }
236
237 asort($options);
238
239 $types->setOptions($options);
240 $remove->addSubItem($types);
241
242 $form->addItem($action);
243
244 $form->addCommandButton('handleTrashAction', $this->lng->txt('start_scan'));
245 $form->addCommandButton('', $this->lng->txt('cancel'));
246
247 return $form;
248 }
249
250 protected function handleTrashAction(): bool
251 {
252 $form = $this->initFormTrash();
253 if ($form->checkInput()) {
254 $trash = new ilSystemCheckTrash();
256 $dt = $form->getItemByPostVar('age')->getDate();
257 if ($dt) {
258 $trash->setAgeLimit($dt);
259 }
260 $trash->setNumberLimit((int) $form->getInput('number'));
261
262 if ($form->getInput('types')) {
263 $trash->setTypesLimit((array) $form->getInput('types'));
264 }
265 $trash->setMode((int) $form->getInput('type'));
266 $trash->start();
267
268 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
269 $form->setValuesByPost();
270 $this->trash($form);
271 return true;
272 }
273
274 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
275 $form->setValuesByPost();
276 $this->trash($form);
277 return false;
278 }
279
280 protected function setSubTabs(string $a_section, string $a_active): void
281 {
282 switch ($a_section) {
284 $this->setMainSubTabs();
285 break;
286
288 $this->setGroupSubTabs();
289 }
290 $this->tabs_gui->activateSubTab($a_active);
291 }
292
293 protected function setMainSubTabs(): void
294 {
295 $this->tabs_gui->addSubTab(
296 'overview',
297 $this->getLang()->txt('sysc_groups'),
298 $this->ctrl->getLinkTarget($this, 'overview')
299 );
300
301 if ($this->checkPermissionBool('write')) {
302 $this->tabs_gui->addSubTab(
303 'trash',
304 $this->getLang()->txt('sysc_tab_trash'),
305 $this->ctrl->getLinkTarget($this, 'trash')
306 );
307 }
308
309 $this->tabs_gui->addSubTab(
310 'no_owner',
311 $this->getLang()->txt('system_check_no_owner'),
312 $this->ctrl->getLinkTargetByClass('ilobjectownershipmanagementgui')
313 );
314 }
315
316 protected function setGroupSubTabs(): void
317 {
318 $this->tabs_gui->clearTargets();
319 $this->tabs_gui->setBackTarget(
320 $this->lng->txt('back'),
321 $this->ctrl->getLinkTarget($this, 'overview')
322 );
323 }
324}
Builds data types.
Definition: Factory.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
This class represents a number property in a property form.
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
getAdminTabs()
administration tabs show only permissions and trash folder
trash(ilPropertyFormGUI $form=null)
setSubTabs(string $a_section, string $a_active)
Class ilObjSystemFolderGUI.
Class ilObjectGUI Basic methods of all Output classes.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: feed.php:28
Interface GlobalHttpState.
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc