ILIAS  release_8 Revision v8.24
class.ilObjFolderGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
19
33{
34 protected ilHelpGUI $help;
37
38 public function __construct(
39 $a_data,
40 int $a_id = 0,
41 bool $a_call_by_reference = true,
42 bool $a_prepare_output = false
43 ) {
44 global $DIC;
45
46 $this->tree = $DIC->repositoryTree();
47 $this->tabs = $DIC->tabs();
48 $this->user = $DIC->user();
49 $this->ctrl = $DIC->ctrl();
50 $this->lng = $DIC->language();
51 $this->access = $DIC->access();
52 $this->rbacsystem = $DIC->rbac()->system();
53 $this->help = $DIC["ilHelp"];
54 $this->error = $DIC["ilErr"];
55 $this->tpl = $DIC["tpl"];
56 $this->settings = $DIC->settings();
57 $this->type = "fold";
58 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
59 $this->lng->loadLanguageModule("obj");
60 $this->folder_request = $DIC
61 ->folder()
62 ->internal()
63 ->gui()
64 ->standardRequest();
65 }
66
67
68 public function viewObject(): void
69 {
70 $this->checkPermission('read');
71 if (strtolower($this->folder_request->getBaseClass()) === "iladministrationgui") {
72 parent::viewObject();
73 return;
74 }
75
76 // Trac access - see ilObjCourseGUI
78 $GLOBALS["ilUser"]->getId(),
79 $this->object->getId(),
80 $this->object->getRefId(),
81 'fold'
82 );
83
84 $this->renderObject();
85 $this->tabs_gui->setTabActive('view_content');
86 }
87
88 public function renderObject(): void
89 {
90 $ilTabs = $this->tabs;
91
92 $this->checkPermission('read');
93
94 $ilTabs->activateTab("view_content");
95 parent::renderObject();
96 }
97
98 public function executeCommand(): void
99 {
101 $next_class = $this->ctrl->getNextClass($this);
102 $cmd = $this->ctrl->getCmd();
103
104 $header_action = true;
105 switch ($next_class) {
106 case strtolower(ilRepositoryTrashGUI::class):
107 $ru = new ilRepositoryTrashGUI($this);
108 $this->ctrl->setReturn($this, 'trash');
109 $this->ctrl->forwardCommand($ru);
110 break;
111
112 case 'ilpermissiongui':
113 $this->prepareOutput();
114 $this->tabs_gui->activateTab('perm_settings');
115 $perm_gui = new ilPermissionGUI($this);
116 $ret = $this->ctrl->forwardCommand($perm_gui);
117 break;
118
119
120 case 'ilcoursecontentgui':
121 $this->prepareOutput();
122 $course_content_obj = new ilCourseContentGUI($this);
123 $this->ctrl->forwardCommand($course_content_obj);
124 break;
125
126 case "illearningprogressgui":
127 $this->prepareOutput();
128
129 $new_gui = new ilLearningProgressGUI(
131 $this->object->getRefId(),
132 $this->folder_request->getUserId() ?: $ilUser->getId()
133 );
134 $this->ctrl->forwardCommand($new_gui);
135 $this->tabs_gui->setTabActive('learning_progress');
136 break;
137
138 // container page editing
139 case "ilcontainerpagegui":
140 $this->prepareOutput(false);
141 $ret = $this->forwardToPageObject();
142 if ($ret !== "") {
143 $this->tpl->setContent($ret);
144 }
145 $header_action = false;
146 break;
147
148 case 'ilinfoscreengui':
149 $this->prepareOutput();
150 $this->infoScreen();
151 break;
152
153 case 'ilobjectcopygui':
154 $this->prepareOutput();
155
156 $cp = new ilObjectCopyGUI($this);
157 $cp->setType('fold');
158 $this->ctrl->forwardCommand($cp);
159 break;
160
161 case "ilobjectcontentstylesettingsgui":
162 $this->checkPermission("write");
163 $this->setTitleAndDescription();
164 $this->showContainerPageTabs();
165 $settings_gui = $this->content_style_gui
166 ->objectSettingsGUIForRefId(
167 null,
168 $this->object->getRefId()
169 );
170 $this->ctrl->forwardCommand($settings_gui);
171 break;
172
173 case 'ilexportgui':
174 $this->prepareOutput();
175
176 $this->tabs_gui->setTabActive('export');
177 $exp = new ilExportGUI($this);
178 $exp->addFormat('xml');
179 $this->ctrl->forwardCommand($exp);
180 break;
181
182 case "ilcommonactiondispatchergui":
183 $this->prepareOutput();
185 $this->ctrl->forwardCommand($gui);
186 break;
187
188 case 'ildidactictemplategui':
189 $this->ctrl->setReturn($this, 'edit');
190 $did = new ilDidacticTemplateGUI($this);
191 $this->ctrl->forwardCommand($did);
192 break;
193 case 'ilcolumngui':
194 $this->tabs_gui->setTabActive('none');
195 $this->checkPermission("read");
196 $this->viewObject();
197 break;
198
199 case 'ilobjecttranslationgui':
200 $this->checkPermissionBool("write");
201 $this->prepareOutput();
202 $this->setSubTabs("settings_trans");
203 $transgui = new ilObjectTranslationGUI($this);
204 $this->ctrl->forwardCommand($transgui);
205 break;
206
207 default:
208
209 $this->prepareOutput();
210 // cognos-blu-patch: begin
211 // removed timings forward
212 // cognos-blu-patch: end
213
214 if (empty($cmd)) {
215 $cmd = "view";
216 }
217 $cmd .= "Object";
218 $this->$cmd();
219 break;
220 }
221
222 if ($header_action) {
223 $this->addHeaderAction();
224 }
225 }
226
227 public function setFolderTree(ilTree $a_tree): void
228 {
229 $this->folder_tree = $a_tree;
230 }
231
232 protected function importFileObject(?int $parent_id = null): void
233 {
235
236 parent::importFileObject($parent_id);
237
238 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
239 $this->ctrl->returnToParent($this);
240 }
241
242 protected function initEditForm(): ilPropertyFormGUI
243 {
245 $obj_service = $this->getObjectService();
246
247 $lng->loadLanguageModule($this->object->getType());
248
249 $form = new ilPropertyFormGUI();
250 $form->setFormAction($this->ctrl->getFormAction($this, "update"));
251 $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
252
253 // title
254 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
255 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
256 $ti->setMaxLength(ilObject::TITLE_LENGTH);
257 $ti->setRequired(true);
258 $form->addItem($ti);
259
260 // description
261 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
262 $ta->setCols(40);
263 $ta->setRows(2);
264 $form->addItem($ta);
265
266 // Show didactic template type
268
269 $pres = new ilFormSectionHeaderGUI();
270 $pres->setTitle($this->lng->txt('fold_presentation'));
271 $form->addItem($pres);
272
273 // title and icon visibility
274 $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTitleIconVisibility();
275
276 // top actions visibility
277 $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTopActionsVisibility();
278
279 // custom icon
280 $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addIcon();
281
282 // tile image
283 $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTileImage();
284
285 // list presentation
287
288 $this->initSortingForm(
289 $form,
290 [
295 ]
296 );
297
298 $form->addCommandButton("update", $this->lng->txt("save"));
299 //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
300
301 return $form;
302 }
303
304 protected function getEditFormCustomValues(array &$a_values): void
305 {
306 // we cannot use $this->object->getOrderType()
307 // if set to inherit it will be translated to parent setting
308 $sort = new ilContainerSortingSettings($this->object->getId());
309 $a_values["sor"] = $sort->getSortMode();
310 }
311
312 protected function updateCustom(ilPropertyFormGUI $form): void
313 {
314 $obj_service = $this->getObjectService();
315
316 // title icon visibility
317 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTitleIconVisibility();
318
319 // top actions visibility
320 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTopActionsVisibility();
321
322 // custom icon
323 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveIcon();
324
325 // tile image
326 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
327
328 // list presentation
329 $this->saveListPresentation($form);
330
331 $this->saveSortingSettings($form);
332 }
333
339 public function showSummaryObject(): void
340 {
341 $this->ctrl->setCmd("showSummary");
342 $this->ctrl->setCmdClass("ilinfoscreengui");
343 $this->infoScreen();
344 }
345
346 protected function afterSave(ilObject $new_object): void
347 {
348 $sort = new ilContainerSortingSettings($new_object->getId());
349 $sort->setSortMode(ilContainer::SORT_INHERIT);
350 $sort->update();
351
352 // always send a message
353 $this->tpl->setOnScreenMessage('success', $this->lng->txt("fold_added"), true);
354 $this->ctrl->setParameter($this, "ref_id", $new_object->getRefId());
355 $this->redirectToRefId($new_object->getRefId(), "");
356 }
357
363 public function infoScreenObject(): void
364 {
365 $this->ctrl->setCmd("showSummary");
366 $this->ctrl->setCmdClass("ilinfoscreengui");
367 $this->infoScreen();
368 }
369
373 public function infoScreen(): void
374 {
375 $ilAccess = $this->access;
376
377 if (!$ilAccess->checkAccess("visible", "", $this->ref_id)) {
378 throw new ilPermissionException($this->lng->txt("msg_no_perm_read"));
379 }
380
381 $info = new ilInfoScreenGUI($this);
382
383 $GLOBALS['ilTabs']->activateTab('info_short');
384
385 $info->enablePrivateNotes();
386
387 if ($ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
388 $info->enableNews();
389 }
390
391 // no news editing for files, just notifications
392 $info->enableNewsEditing(false);
393 if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
394 $news_set = new ilSetting("news");
395 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
396
397 if ($enable_internal_rss) {
398 $info->setBlockProperty("news", "settings", '1');
399 $info->setBlockProperty("news", "public_notifications_option", '1');
400 }
401 }
402
403
404 // standard meta data
405 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
406
407 // forward the command
408 $this->ctrl->forwardCommand($info);
409 }
410
411 protected function getTabs(): void
412 {
415 $ilCtrl = $this->ctrl;
416 $ilAccess = $this->access;
417 $ilHelp = $this->help;
418
419 $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
420
421 $ilHelp->setScreenIdComponent("fold");
422
423 $this->tabs_gui->setTabActive("");
424 if ($ilAccess->checkAccess('read', '', $this->ref_id)) {
425 $this->tabs_gui->addTab(
426 "view_content",
427 $lng->txt("content"),
428 $this->ctrl->getLinkTarget($this, "")
429 );
430
431 //BEGIN ChangeEvent add info tab to category object
432 $force_active = $this->ctrl->getNextClass() === "ilinfoscreengui"
433 || strtolower($this->ctrl->getCmdClass()) === "ilnotegui";
434 $this->tabs_gui->addTarget(
435 "info_short",
436 $this->ctrl->getLinkTargetByClass(
437 ["ilobjfoldergui", "ilinfoscreengui"],
438 "showSummary"
439 ),
440 ["showSummary", "", "infoScreen"],
441 "",
442 "",
443 $force_active
444 );
445 //END ChangeEvent add info tab to category object
446 }
447
448 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
449 $this->tabs_gui->addTarget(
450 "settings",
451 $this->ctrl->getLinkTarget($this, "edit"),
452 "edit",
453 "",
454 "",
455 ($ilCtrl->getCmd() === "edit")
456 );
457 }
458
459 // learning progress
460 if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
461 $this->tabs_gui->addTarget(
462 'learning_progress',
463 $this->ctrl->getLinkTargetByClass(['ilobjfoldergui', 'illearningprogressgui'], ''),
464 '',
465 ['illplistofobjectsgui', 'illplistofsettingsgui', 'illearningprogressgui', 'illplistofprogressgui']
466 );
467 }
468
469 if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
470 $this->tabs_gui->addTarget(
471 'export',
472 $this->ctrl->getLinkTargetByClass('ilexportgui', ''),
473 'export',
474 'ilexportgui'
475 );
476 }
477
478
479 if ($rbacsystem->checkAccess('edit_permission', $this->ref_id)) {
480 $this->tabs_gui->addTarget(
481 "perm_settings",
482 $this->ctrl->getLinkTargetByClass([get_class($this), 'ilpermissiongui'], "perm"),
483 ["perm", "info", "owner"],
484 'ilpermissiongui'
485 );
486 }
487 }
488
492 public static function _goto($a_target): void
493 {
494 global $DIC;
495
496 $ilAccess = $DIC->access();
497 $ilErr = $DIC["ilErr"];
498 $lng = $DIC->language();
499
500 $a_target = (int) $a_target;
501
502 if ($ilAccess->checkAccess("read", "", $a_target)) {
504 }
505 if ($ilAccess->checkAccess("visible", "", $a_target)) {
506 ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
507 }
508 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
509 }
510
511 public function modifyItemGUI(ilObjectListGUI $a_item_list_gui, array $a_item_data): void
512 {
514
515 // if folder is in a course, modify item list gui according to course requirements
516 if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs')) {
517 $course_obj_id = ilObject::_lookupObjId($course_ref_id);
519 $a_item_list_gui,
520 'ilcoursecontentgui',
521 $a_item_data,
522 ilObjCourse::_lookupAboStatus($course_obj_id),
523 $course_ref_id,
524 $course_obj_id,
525 $this->object->getRefId()
526 );
527 }
528 }
529
533 protected function showPossibleSubObjects(): void
534 {
535 $gui = new ilObjectAddNewItemGUI($this->object->getRefId());
536 $gui->render();
537 }
538
539
540 protected function forwardToTimingsView(): void
541 {
543
544 if (!$crs_ref = $tree->checkForParentType($this->ref_id, 'crs')) {
545 return;
546 }
548 if (!ilSession::has('crs_timings')) {
549 ilSession::set('crs_timings', true);
550 }
551
552 if (ilSession::get('crs_timings')) {
553 $course_content_obj = new ilCourseContentGUI($this);
554 $this->ctrl->setCmdClass(get_class($course_content_obj));
555 $this->ctrl->setCmd('editUserTimings');
556 $this->ctrl->forwardCommand($course_content_obj);
557 return;
558 }
559 }
560 ilSession::set('crs_timings', false);
561 }
562
563 public function editObject(): void
564 {
565 $ilTabs = $this->tabs;
567
568 $this->setSubTabs("settings");
569 $ilTabs->activateTab("settings");
570
571 if (!$this->checkPermissionBool("write")) {
572 $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
573 }
574
575 $form = $this->initEditForm();
576 $values = $this->getEditFormValues();
577 if ($values) {
578 $form->setValuesByArray($values, true);
579 }
580 $GLOBALS['tpl']->setContent($form->getHTML());
581 }
582
583 public function setSubTabs(string $a_tab): void
584 {
585 $ilTabs = $this->tabs;
587
588 $ilTabs->addSubTab(
589 "settings",
590 $lng->txt("fold_settings"),
591 $this->ctrl->getLinkTarget($this, 'edit')
592 );
593
594 $this->tabs_gui->addSubTab(
595 "settings_trans",
596 $this->lng->txt("obj_multilinguality"),
597 $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "")
598 );
599
600 $ilTabs->activateSubTab($a_tab);
601 $ilTabs->activateTab("settings");
602 }
603
604 public function deleteObject(bool $error = false): void
605 {
606 $this->tabs_gui->activateTab('view_content');
607 parent::deleteObject($error);
608 }
609}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
error(string $a_errmsg)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder,...
ilRbacSystem $rbacsystem
initSortingForm(ilPropertyFormGUI $form, array $a_sorting_settings)
Append sorting settings to property form.
prepareOutput(bool $show_subobjects=true)
ilPropertyFormGUI $form
ilErrorHandling $error
saveListPresentation(ilPropertyFormGUI $form)
initListPresentationForm(ilPropertyFormGUI $form)
Add list presentation settings to form.
saveSortingSettings(ilPropertyFormGUI $form)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCourseContentGUI.
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...
setFormAction(string $a_formaction)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Help GUI class.
Class ilInfoScreenGUI.
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _tracProgress(int $a_user_id, int $a_obj_id, int $a_ref_id, string $a_obj_type='')
static _modifyItemGUI(ilObjectListGUI $a_item_list_gui, string $a_cmd_class, array $a_item_data, bool $a_abo_status, int $a_course_ref_id, int $a_course_obj_id, int $a_parent_ref_id=0)
static _lookupAboStatus(int $a_id)
static _lookupViewMode(int $a_id)
Class ilObjFolderGUI.
deleteObject(bool $error=false)
Display deletion confirmation screen.
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
StandardGUIRequest $folder_request
showPossibleSubObjects()
show possible sub objects selection list
setSubTabs(string $a_tab)
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
updateCustom(ilPropertyFormGUI $form)
Insert custom update form values into object.
afterSave(ilObject $new_object)
Post (successful) object creation hook.
modifyItemGUI(ilObjectListGUI $a_item_list_gui, array $a_item_data)
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
getTabs()
@abstract overwrite in derived GUI class of your object type
setFolderTree(ilTree $a_tree)
static _goto($a_target)
goto target group
__construct( $a_data, int $a_id=0, bool $a_call_by_reference=true, bool $a_prepare_output=false)
showSummaryObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
importFileObject(?int $parent_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
GUI class for the workflow of copying objects.
ilAccessHandler $access
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
initDidacticTemplate(ilPropertyFormGUI $form)
addHeaderAction()
Add header action menu.
static _gotoRepositoryNode(int $ref_id, string $cmd="")
redirectToRefId(int $ref_id, string $cmd="")
redirects to (repository) view per ref id usually to a container and usually used at the end of a sav...
ilLanguage $lng
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...
const TITLE_LENGTH
static _lookupObjId(int $ref_id)
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.
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
Repository GUI Utilities.
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
static has($a_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ilErr
Definition: raiseError.php:17