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