ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilObjCategoryGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
39{
40 public const CONTAINER_SETTING_TAXBLOCK = "tax_sblock_";
41 protected \ILIAS\Category\InternalDomainService $cat_domain;
42 protected \ILIAS\Category\InternalGUIService $cat_gui;
43 protected \ILIAS\Taxonomy\Service $taxonomy;
44
46 protected ilHelpGUI $help;
47 protected bool $info_screen_enabled = false;
49 protected bool $creation_mode;
52
53 public function __construct(
54 $a_data,
55 int $a_id,
56 bool $a_call_by_reference = true,
57 bool $a_prepare_output = true
58 ) {
59 global $DIC;
60
61 $this->rbacsystem = $DIC->rbac()->system();
62 $this->nav_history = $DIC["ilNavigationHistory"];
63 $this->access = $DIC->access();
64 $this->ctrl = $DIC->ctrl();
65 $this->tabs = $DIC->tabs();
66 $this->help = $DIC["ilHelp"];
67 $this->lng = $DIC->language();
68 $this->user = $DIC->user();
69 $this->tree = $DIC->repositoryTree();
70 $this->error = $DIC["ilErr"];
71 $this->settings = $DIC->settings();
72 $this->tpl = $DIC["tpl"];
73 $this->toolbar = $DIC->toolbar();
74 $this->rbacreview = $DIC->rbac()->review();
75 $this->rbacadmin = $DIC->rbac()->admin();
76
77 $this->lng->loadLanguageModule('cat');
78 $this->lng->loadLanguageModule('obj');
79
80 $this->type = "cat";
81 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
82
83 if (is_object($this->object)) {
84 $this->info_screen_enabled = (bool) ilContainer::_lookupContainerSetting(
85 $this->object->getId(),
87 '1'
88 );
89
90 }
91 $this->cat_request = $DIC
92 ->category()
93 ->internal()
94 ->gui()
95 ->standardRequest();
96 $this->taxonomy = $DIC->taxonomy();
97 $this->cat_gui = $DIC->category()->internal()->gui();
98 $this->cat_domain = $DIC->category()->internal()->domain();
99 }
100
101 public function executeCommand(): void
102 {
103 $ilNavigationHistory = $this->nav_history;
104 $ilAccess = $this->access;
105 $ilCtrl = $this->ctrl;
106 $ilTabs = $this->tabs;
107
108 $next_class = $this->ctrl->getNextClass($this);
109 $cmd = $this->ctrl->getCmd();
110
111 $header_action = true;
112 switch ($next_class) {
113 case strtolower(ilRepositoryTrashGUI::class):
114 $ru = new ilRepositoryTrashGUI($this);
115 $this->ctrl->setReturn($this, 'trash');
116 $this->ctrl->forwardCommand($ru);
117 break;
118
119 case "ilobjusergui":
120 $this->tabs_gui->setTabActive('administrate_users');
121 if ($this->cat_request->getObjId() === 0) {
122 $this->gui_obj = new ilObjUserGUI(
123 "",
124 $this->cat_request->getRefId(),
125 true,
126 false
127 );
128 } else {
129 $this->gui_obj = new ilObjUserGUI(
130 "",
131 $this->cat_request->getObjId(),
132 false,
133 false
134 );
135 }
136 $this->gui_obj->setCreationMode($this->creation_mode);
137 $this->ctrl->forwardCommand($this->gui_obj);
138
139 $ilTabs->clearTargets();
140 $ilTabs->setBackTarget($this->lng->txt('backto_lua'), $this->ctrl->getLinkTarget($this, 'listUsers'));
141 $ilHelp = $this->help;
142 $ilHelp->setScreenIdComponent("cat");
143 $ilHelp->setScreenId("administrate_user");
144 $ilHelp->setSubScreenId($ilCtrl->getCmd());
145 break;
146
147 case "ilobjuserfoldergui":
148 $this->gui_obj = new ilObjUserFolderGUI(
149 "",
150 $this->cat_request->getRefId(),
151 true
152 );
153 $this->gui_obj->setUserOwnerId($this->cat_request->getRefId());
154 $this->gui_obj->setCreationMode($this->creation_mode);
155 $this->ctrl->forwardCommand($this->gui_obj);
156
157 $ilTabs->clearTargets();
158 $ilTabs->setBackTarget($this->lng->txt('backto_lua'), $this->ctrl->getLinkTarget($this, 'listUsers'));
159 $ilHelp = $this->help;
160 $ilHelp->setScreenIdComponent("cat");
161 $ilHelp->setScreenId("administrate_user");
162 $ilHelp->setSubScreenId($ilCtrl->getCmd());
163 break;
164
165 case "ilcolumngui":
166 $this->checkPermission("read");
167 $this->prepareOutput();
168 $this->content_style_gui->addCss(
169 $this->tpl,
170 $this->object->getRefId()
171 );
172 $this->renderObject();
173 break;
174
175 case 'ilpermissiongui':
176 $this->prepareOutput();
177 $this->tabs_gui->setTabActive('perm_settings');
178 $perm_gui = new ilPermissionGUI($this);
179 $this->ctrl->forwardCommand($perm_gui);
180 break;
181
182 case 'ilinfoscreengui':
183 if ($this->info_screen_enabled) {
184 $this->prepareOutput();
185 $this->infoScreen();
186 }
187 break;
188
189 // container page editing
190 case "ilcontainerpagegui":
191 $this->prepareOutput(false);
192 $ret = $this->forwardToPageObject();
193 if ($ret !== "") {
194 $this->tpl->setContent($ret);
195 }
196 $header_action = false;
197 break;
198
199 case 'ilobjectcopygui':
200 $this->prepareOutput();
201
202 $cp = new ilObjectCopyGUI($this);
203 $cp->setType('cat');
204 $this->ctrl->forwardCommand($cp);
205 break;
206
207 case "ilobjectcontentstylesettingsgui":
208 $this->checkPermission("write");
209 $this->setTitleAndDescription();
210 $this->showContainerPageTabs();
211 $settings_gui = $this->content_style_gui
212 ->objectSettingsGUIForRefId(
213 null,
214 $this->object->getRefId()
215 );
216 $this->ctrl->forwardCommand($settings_gui);
217 break;
218
219 case 'ilusertablegui':
220 $u_table = new ilUserTableGUI($this, "listUsers");
221 $u_table->initFilter();
222 $this->ctrl->setReturn($this, 'listUsers');
223 $this->ctrl->forwardCommand($u_table);
224 break;
225
226 case "ilcommonactiondispatchergui":
227 $this->prepareOutput();
229 $this->ctrl->forwardCommand($gui);
230 break;
231
232 case 'ildidactictemplategui':
233 $this->ctrl->setReturn($this, 'edit');
234 $did = new ilDidacticTemplateGUI($this, $this->getDidacticTemplateIdFromQuery());
235 $this->ctrl->forwardCommand($did);
236 break;
237
238 case 'ilexportgui':
239 $this->prepareOutput();
240 $this->tabs_gui->setTabActive('export');
241 $exp = new ilExportGUI($this);
242 $exp->addFormat('xml');
243 $this->ctrl->forwardCommand($exp);
244 break;
245
246 case strtolower(TranslationGUI::class):
247 $this->checkPermissionBool("write");
248 $this->prepareOutput();
249 //$this->tabs_gui->setTabActive('export');
250 $this->setEditTabs("settings_trans");
251 $transgui = new TranslationGUI(
252 $this->getObject(),
253 $this->lng,
254 $this->access,
255 $this->user,
256 $this->ctrl,
257 $this->tpl,
258 $this->ui_factory,
259 $this->ui_renderer,
260 $this->http,
261 $this->refinery,
262 $this->toolbar
263 );
264 $this->ctrl->forwardCommand($transgui);
265 break;
266
267 case strtolower(ilTaxonomySettingsGUI::class):
268 $this->checkPermissionBool("write");
269 $this->prepareOutput();
270 $this->setEditTabs("taxonomy");
271 $tax_gui = $this->taxonomy->gui()->getSettingsGUI(
272 $this->object->getId(),
273 $this->lng->txt("cntr_tax_settings_info"),
274 true,
275 $this
276 );
277 $this->ctrl->forwardCommand($tax_gui);
278 break;
279
280 case 'ilobjectmetadatagui':
281 $this->checkPermissionBool("write");
282 $this->prepareOutput();
283 $this->tabs_gui->activateTab('meta_data');
284 $this->ctrl->forwardCommand($this->getObjectMetadataGUI());
285 break;
286
287 case "ilcontainernewssettingsgui":
288 $this->prepareOutput();
289 $this->tabs_gui->setTabActive('settings');
290 $this->setEditTabs();
291 $this->tabs_gui->activateSubTab('obj_news_settings');
292 $news_set_gui = new ilContainerNewsSettingsGUI($this);
293 $news_set_gui->setHideByDate(true);
294 $this->ctrl->forwardCommand($news_set_gui);
295 break;
296
297 case 'ilcontainerfilteradmingui':
298 $this->checkPermissionBool("write");
299 $this->prepareOutput();
300 $this->setEditTabs($active_tab = "settings_filter");
301 $this->tabs_gui->activateTab('settings');
302 $this->ctrl->forwardCommand(new ilContainerFilterAdminGUI($this));
303 break;
304
305 default:
306 if ($cmd === "infoScreen") {
307 $this->checkPermission("visible");
308 } else {
309 $this->checkPermission("read");
310 }
311
312 // add entry to navigation history
313 if (!$this->getCreationMode() &&
314 $ilAccess->checkAccess("read", "", $this->cat_request->getRefId())) {
315 $ilNavigationHistory->addItem(
316 $this->cat_request->getRefId(),
317 ilLink::_getLink($this->cat_request->getRefId(), "cat"),
318 "cat"
319 );
320 }
321
322 $this->prepareOutput();
323 if (is_object($this->object)) {
324 $this->content_style_gui->addCss(
325 $this->tpl,
326 $this->object->getRefId()
327 );
328 }
329
330 if (!$cmd) {
331 $cmd = "render";
332 }
333 $cmd .= "Object";
334 $this->tabs_gui->activateTab("view_content"); // see #19868
335 $this->$cmd();
336
337 break;
338 }
339
340 if ($header_action) {
341 $this->addHeaderAction();
342 }
343 }
344
345
347 {
348 $md_gui = new ilObjectMetaDataGUI($this->object);
349 /*
350 if (ilContainer::_lookupContainerSetting(
351 $this->object->getId(),
352 ilObjectServiceSettingsGUI::TAXONOMIES,
353 '0'
354 )) {
355 $md_gui->enableTaxonomyDefinition(true);
356 $tax = $md_gui->getTaxonomyObjGUI();
357 $tax->setMultiple(true);
358 $tax->setListInfo($this->lng->txt("cntr_tax_list_info"));
359 $taxonomies = $this->getTaxonomiesForRefId();
360 if (count($taxonomies)) {
361 $md_gui->setTaxonomySettings(function ($form) {
362 $tax = $this->getTaxonomiesForRefId();
363 $block = new ilCheckboxGroupInputGUI($this->lng->txt("cntr_taxonomy_show_sideblock"), "sblock");
364 $form->addItem($block);
365
366 $current = $this->getActiveBlocks();
367
368 $value = null;
369 foreach ($tax as $tax_id => $tax_item) {
370 $option = new ilCheckboxOption(
371 $tax_item["title"],
372 (string) $tax_id,
373 ilObject::_lookupDescription($tax_id)
374 );
375
376 if ((int) $tax_item["source"] !== $this->object->getRefId()) {
377 $loc = new ilLocatorGUI();
378 $loc->setTextOnly(true);
379 $loc->addRepositoryItems((int) $tax_item["source"]);
380 $option->setInfo($loc->getHTML());
381 }
382
383 $block->addOption($option);
384
385 if (in_array($tax_id, $current)) {
386 $value[] = $tax_id;
387 }
388 }
389
390 $block->setValue($value);
391 }, function ($form) {
392 $taxonomies = $this->getTaxonomiesForRefId();
393 if (count($taxonomies)) {
394 $sblock = $form->getInput("sblock");
395
396 $prefix = self::CONTAINER_SETTING_TAXBLOCK;
397
398 ilContainer::_deleteContainerSettings(
399 $this->object->getId(),
400 $prefix . "%",
401 true
402 );
403
404 if (is_array($sblock)) {
405 foreach ($sblock as $tax_id) {
406 ilContainer::_writeContainerSetting(
407 $this->object->getId(),
408 $prefix . $tax_id,
409 '1'
410 );
411 }
412 }
413 }
414 });
415 }
416 }*/
417 return $md_gui;
418 }
419
420 protected function showTaxAsSideBlockObject(): void
421 {
423 $tax_id = $this->cat_request->getTaxId();
425 $this->object->getId(),
426 $prefix . $tax_id,
427 '1'
428 );
429 $this->ctrl->redirectByClass(ilTaxonomySettingsGUI::class, "");
430 }
431
432 protected function hideTaxAsSideBlockObject(): void
433 {
435 $tax_id = $this->cat_request->getTaxId();
437 $this->object->getId(),
438 $prefix . $tax_id
439 );
440 $this->ctrl->redirectByClass(ilTaxonomySettingsGUI::class, "");
441 }
442
443 public function getProperties(
444 int $tax_id
445 ): array {
446 $active = in_array($tax_id, $this->getActiveBlocks());
447 $value = $active
448 ? $this->lng->txt("yes")
449 : $this->lng->txt("no");
450
451 return [
452 $this->lng->txt("cntr_taxonomy_show_sideblock") => $value
453 ];
454 }
455
456 public function getActions(
457 int $tax_id
458 ): array {
459 $actions = [];
460 $this->ctrl->setParameterByClass(self::class, "cat_tax_id", $tax_id);
461 $active = in_array($tax_id, $this->getActiveBlocks());
462 if (!$active) {
463 $actions[] = $this->ui->factory()->button()->shy(
464 $this->lng->txt("cat_show_tax_in_side_block"),
465 $this->ctrl->getLinkTargetByClass(
466 self::class,
467 "showTaxAsSideBlock"
468 )
469 );
470 } else {
471 $actions[] = $this->ui->factory()->button()->shy(
472 $this->lng->txt("cat_hide_tax_in_side_block"),
473 $this->ctrl->getLinkTargetByClass(
474 self::class,
475 "hideTaxAsSideBlock"
476 )
477 );
478 }
479 $this->ctrl->setParameterByClass(self::class, "cat_tax_id", null);
480
481 return $actions;
482 }
483
484
485 protected function getTabs(): void
486 {
487 $rbacsystem = $this->rbacsystem;
489 $ilHelp = $this->help;
490 $ilAccess = $this->access;
491
492 if ($this->ctrl->getCmd() === "editPageContent") {
493 return;
494 }
495
496 $ilHelp->setScreenIdComponent("cat");
497
498 if ($rbacsystem->checkAccess('read', $this->ref_id)) {
499 $this->tabs_gui->addTab(
500 "view_content",
501 $lng->txt("content"),
502 $this->ctrl->getLinkTarget($this, "")
503 );
504
505 //BEGIN ChangeEvent add info tab to category object
506 if ($this->info_screen_enabled) {
507 $force_active = $this->ctrl->getNextClass() === "ilinfoscreengui"
508 || strtolower($this->cat_request->getCmdClass()) === "ilnotegui";
509 $this->tabs_gui->addTarget(
510 "info_short",
511 $this->ctrl->getLinkTargetByClass(
512 ["ilobjcategorygui", "ilinfoscreengui"],
513 "showSummary"
514 ),
515 ["showSummary", "", "infoScreen"],
516 "",
517 "",
518 $force_active
519 );
520 }
521 //END ChangeEvent add info tab to category object
522 }
523
524 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
525 $force_active = ($this->ctrl->getCmd() === "edit");
526 $this->tabs_gui->addTarget(
527 "settings",
528 $this->ctrl->getLinkTarget($this, "edit"),
529 "edit",
530 get_class($this),
531 "",
532 $force_active
533 );
534
535
536
537 // metadata / taxonomies
538 $mdgui = new ilObjectMetaDataGUI($this->object);
539 /*if (ilContainer::_lookupContainerSetting(
540 $this->object->getId(),
541 ilObjectServiceSettingsGUI::TAXONOMIES,
542 '0'
543 )) {
544 $mdgui->enableTaxonomyDefinition(true);
545 }*/
546 $mdtab = $mdgui->getTab();
547 if ($mdtab) {
548 $this->tabs_gui->addTab(
549 "meta_data",
550 $this->lng->txt("meta_data"),
551 $mdtab
552 );
553 }
554 }
555
556 if (ilUserAccountSettings::getInstance()->isLocalUserAdministrationEnabled() &&
557 $rbacsystem->checkAccess('cat_administrate_users', $this->ref_id)) {
558 $this->tabs_gui->addTarget(
559 "administrate_users",
560 $this->ctrl->getLinkTarget($this, "listUsers"),
561 "listUsers",
562 get_class($this)
563 );
564 }
565
566 if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
567 $this->tabs_gui->addTarget(
568 'export',
569 $this->ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class, 'ilexportgui'], ''),
570 'export',
571 'ilexportgui'
572 );
573 }
574
575 // parent tabs (all container: edit_permission, clipboard, trash
576 parent::getTabs();
577 }
578
582 public function renderObject(): void
583 {
584 $ilTabs = $this->tabs;
585
586 $ilTabs->activateTab("view_content");
587 parent::renderObject();
588
590 $this->object->getType(),
591 $this->object->getRefId(),
592 $this->object->getId(),
593 $this->user->getId()
594 );
595 }
596
597 public function viewObject(): void
598 {
599 if (strtolower($this->cat_request->getBaseClass()) === "iladministrationgui") {
600 parent::viewObject();
601 return;
602 }
603 $this->renderObject();
604 }
605
606 protected function afterSave(ilObject $new_object): void
607 {
608 $tree = $this->tree;
609
610 // default: sort by title
611 $settings = new ilContainerSortingSettings($new_object->getId());
612 $settings->setSortMode(ilContainer::SORT_TITLE);
613 $settings->save();
614
615 // inherit parents content style, if not individual
616 $this->content_style_domain
617 ->styleForRefId($new_object->getRefId())
618 ->inheritFromParent();
619
620 // always send a message
621 $this->tpl->setOnScreenMessage('success', $this->lng->txt("cat_added"), true);
622 $this->ctrl->setParameter($this, "ref_id", $new_object->getRefId());
623 $this->redirectToRefId($new_object->getRefId(), "");
624 }
625
631 public function infoScreenObject(): void
632 {
633 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
634 }
635
639 public function infoScreen(): string
640 {
641 $ilAccess = $this->access;
642 $ilCtrl = $this->ctrl;
643 $ilErr = $this->error;
644
645 if (!$ilAccess->checkAccess("visible", "", $this->ref_id)) {
646 $ilErr->raiseError($this->lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
647 }
648
649 if (!$this->info_screen_enabled) {
650 return "";
651 }
652
653 // #10986
654 $this->tabs_gui->setTabActive('info_short');
655
656 $info = new ilInfoScreenGUI($this);
657
658 $info->enablePrivateNotes();
659
660 if ($ilAccess->checkAccess("read", "", $this->cat_request->getRefId())) {
661 $info->enableNews();
662 }
663
664 // no news editing for files, just notifications
665 $info->enableNewsEditing(false);
666 if ($ilAccess->checkAccess("write", "", $this->cat_request->getRefId())) {
667 $news_set = new ilSetting("news");
668 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
669
670 if ($enable_internal_rss) {
671 $info->setBlockProperty("news", "settings", '1');
672 $info->setBlockProperty("news", "public_notifications_option", '1');
673 }
674 }
675
676 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO, 'cat', $this->object->getId());
677 $record_gui->setInfoObject($info);
678 $record_gui->parse();
679
680
681 // standard meta data
682 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
683
684 // forward the command
685 if ($ilCtrl->getNextClass() === "ilinfoscreengui") {
686 $ilCtrl->forwardCommand($info);
687 } else {
688 return $ilCtrl->getHTML($info);
689 }
690 return "";
691 }
692
693 protected function editInfoObject(): void
694 {
695 $this->checkPermission("write");
696 $this->setEditTabs();
697 $this->tabs_gui->activateTab('settings');
698 $this->tabs_gui->setSubTabActive('edit_cat_settings');
699
700 $this->initExtendedSettings();
701 $this->tpl->setContent($this->form->getHTML());
702 }
703
704 // Update info (extended meta data)
705 protected function updateInfoObject(): void
706 {
707 $this->checkPermission("write");
708
709 // init form
710 $this->initExtendedSettings();
711
712 // still needed for date conversion and so on
713 $this->form->checkInput();
714
715 if ($this->record_gui->importEditFormPostValues()) {
716 $this->record_gui->writeEditForm();
717
718 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
719 $this->ctrl->redirect($this, "editInfo");
720 }
721
722 $this->editInfoObject();
723 }
724
725
726 // build property form for extended category settings
727 protected function initExtendedSettings(): bool
728 {
729 if (is_object($this->form)) {
730 return true;
731 }
732
733 $this->form = new ilPropertyFormGUI();
734 $this->form->setFormAction($this->ctrl->getFormAction($this));
735 $this->form->setTitle($this->lng->txt('ext_cat_settings'));
736 $this->form->addCommandButton('updateInfo', $this->lng->txt('save'));
737 $this->form->addCommandButton('editInfo', $this->lng->txt('cancel'));
738
739 $this->record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR, 'cat', $this->object->getId());
740 $this->record_gui->setPropertyForm($this->form);
741 $this->record_gui->parse();
742
743 return true;
744 }
745
746 protected function setEditTabs($active_tab = "settings_misc"): void
747 {
748 $this->tabs_gui->addSubTab(
749 "settings_misc",
750 $this->lng->txt("general"),
751 $this->ctrl->getLinkTarget($this, "edit")
752 );
753
754 $this->tabs_gui->addSubTab(
755 "settings_trans",
756 $this->lng->txt("obj_multilinguality"),
757 $this->ctrl->getLinkTargetByClass(TranslationGUI::class, "")
758 );
759
760 //news tab
762 $this->object->getId(),
764 '1'
765 );
766
767 if ($news_active) {
768 $this->tabs_gui->addSubTab(
769 'obj_news_settings',
770 $this->lng->txt("cont_news_settings"),
771 $this->ctrl->getLinkTargetByClass('ilcontainernewssettingsgui')
772 );
773 }
774
775 $this->tabs_gui->addSubTab(
776 "settings_filter",
777 $this->lng->txt("cont_filter"),
778 $this->ctrl->getLinkTargetByClass("ilcontainerfilteradmingui", "")
779 );
780
781 if ($obj = $this->getObject()) {
782 $this->taxonomy->gui()->addSettingsSubTab($obj->getId());
783 }
784
785 $this->tabs_gui->activateTab("settings");
786 $this->tabs_gui->activateSubTab($active_tab);
787 }
788
789 protected function initEditForm(): ilPropertyFormGUI
790 {
791 $obj_service = $this->getObjectService();
792
793 $this->lng->loadLanguageModule($this->object->getType());
794 $this->setEditTabs();
795
796 $form = new ilPropertyFormGUI();
797 $form->setFormAction($this->ctrl->getFormAction($this));
798 $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
799
800 // title/description
801 $this->initFormTitleDescription($form);
802
803 // Show didactic template type
804 $this->initDidacticTemplate($form);
805
806 // presentation
807 $pres = new ilFormSectionHeaderGUI();
808 $pres->setTitle($this->lng->txt('obj_presentation'));
809 $form->addItem($pres);
810
811 // title and icon visibility
812 $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTitleIconVisibility();
813
814 // top actions visibility
815 $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTopActionsVisibility();
816
817 // custom icon
818 $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addIcon();
819
820 // tile image
821 $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTileImage();
822
823 // list presentation
824 $form = $this->initListPresentationForm($form);
825
826 // sorting
827 $form = $this->initSortingForm(
828 $form,
829 [
833 ]
834 );
835
836 // block limit
837 $bl = new ilNumberInputGUI($this->lng->txt("cont_block_limit"), "block_limit");
838 $bl->setInfo($this->lng->txt("cont_block_limit_info"));
839 $bl->setValue(ilContainer::_lookupContainerSetting($this->object->getId(), "block_limit"));
840 $form->addItem($bl);
841
842 // icon settings
843
844 // Edit ecs export settings
845 $ecs = new ilECSCategorySettings($this->object);
846 $ecs->addSettingsToForm($form, 'cat');
847
848 // services
849 $sh = new ilFormSectionHeaderGUI();
850 $sh->setTitle($this->lng->txt('obj_features'));
851 $form->addItem($sh);
852
854 $this->object->getId(),
855 $form,
856 [
863 ]
864 );
865
866 $form->addCommandButton("update", $this->lng->txt("save"));
867
868 return $form;
869 }
870
871 protected function getEditFormValues(): array
872 {
873 return [];
874 }
875
876 public function updateObject(): void
877 {
878 $ilErr = $this->error;
879 $ilUser = $this->user;
880 $obj_service = $this->getObjectService();
881
882 if (!$this->checkPermissionBool("write")) {
883 $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
884 } else {
885 $form = $this->initEditForm();
886 if ($form->checkInput()) {
887 $title = $form->getInput("title");
888 $desc = $form->getInput("desc");
889
890 $this->object->setTitle($title);
891 $this->object->setDescription($desc);
892 $this->object->update();
893
894 $this->saveSortingSettings($form);
895
896 // title icon visibility
897 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTitleIconVisibility();
898
899 // top actions visibility
900 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTopActionsVisibility();
901
902 // custom icon
903 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveIcon();
904
905 // tile image
906 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
907
908 // list presentation
909 $this->saveListPresentation($form);
910
911 // BEGIN ChangeEvent: Record update
912 ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
913 // END ChangeEvent: Record update
914
915 // services
917 $this->object->getId(),
918 $form,
919 [
926 ]
927 );
928
929 // block limit
930 if ((int) $form->getInput("block_limit") > 0) {
932 $this->object->getId(),
933 "block_limit",
934 (string) ((int) $form->getInput("block_limit"))
935 );
936 } else {
937 ilContainer::_deleteContainerSettings($this->object->getId(), "block_limit");
938 }
939 // Update ecs export settings
940 $ecs = new ilECSCategorySettings($this->object);
941 if ($ecs->handleSettingsUpdate($form)) {
942 $this->afterUpdate();
943 return;
944 }
945 }
946
947 // display form to correct errors
948 $this->setEditTabs();
949 $form->setValuesByPost();
950 $this->tpl->setContent($form->getHTML());
951 }
952 }
953
954
955 public static function _getImportDir(): string
956 {
957 return ilFileUtils::getDataDir() . "/cat_import";
958 }
959
968 protected function resetFilterObject(): void
969 {
970 $utab = new ilUserTableGUI($this, "listUsers", ilUserTableGUI::MODE_LOCAL_USER);
971 $utab->resetOffset();
972 $utab->resetFilter();
973
974 // from "old" implementation
975 $this->listUsersObject();
976 }
977
982 protected function applyFilterObject(): void
983 {
984 $ilTabs = $this->tabs;
985
986 $utab = new ilUserTableGUI($this, "listUsers", ilUserTableGUI::MODE_LOCAL_USER);
987 $utab->resetOffset();
988 $utab->writeFilterToSession();
989 $this->listUsersObject();
990 }
991
992 // METHODS for local user administration
993 public function listUsersObject(bool $show_delete = false): void
994 {
995 $ilUser = $this->user;
996 $ilErr = $this->error;
997 $ilToolbar = $this->toolbar;
998
999 $rbacsystem = $this->rbacsystem;
1000 $rbacreview = $this->rbacreview;
1001
1002 if (!$rbacsystem->checkAccess("cat_administrate_users", $this->object->getRefId())) {
1003 $ilErr->raiseError($this->lng->txt("msg_no_perm_admin_users"), $ilErr->MESSAGE);
1004 }
1005 $this->tabs_gui->setTabActive('administrate_users');
1006
1007
1008
1009 $this->tpl->addBlockfile(
1010 'ADM_CONTENT',
1011 'adm_content',
1012 'tpl.cat_admin_users.html',
1013 "components/ILIAS/Category"
1014 );
1015
1016 if (count($rbacreview->getGlobalAssignableRoles()) ||
1017 in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()), true)) {
1018 $ilToolbar->addButton(
1019 $this->lng->txt('add_user'),
1020 $this->ctrl->getLinkTargetByClass('ilobjusergui', 'create')
1021 );
1022
1023 $ilToolbar->addButton(
1024 $this->lng->txt('import_users'),
1025 $this->ctrl->getLinkTargetByClass('ilobjuserfoldergui', 'importUserForm')
1026 );
1027 } else {
1028 $this->tpl->setOnScreenMessage('info', $this->lng->txt('no_roles_user_can_be_assigned_to'));
1029 }
1030
1031 if ($show_delete) {
1032 $this->tpl->setCurrentBlock("confirm_delete");
1033 $this->tpl->setVariable("CONFIRM_FORMACTION", $this->ctrl->getFormAction($this));
1034 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt('cancel'));
1035 $this->tpl->setVariable("CONFIRM_CMD", 'performDeleteUsers');
1036 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt('delete'));
1037 $this->tpl->parseCurrentBlock();
1038 }
1039
1040 $this->lng->loadLanguageModule('user');
1041
1042 $utab = new ilUserTableGUI($this, 'listUsers', ilUserTableGUI::MODE_LOCAL_USER);
1043 $this->tpl->setVariable('USERS_TABLE', $utab->getHTML());
1044 }
1045
1049 protected function addUserAutoCompleteObject(): void
1050 {
1051 $auto = new ilUserAutoComplete();
1052 $auto->setSearchFields(['login', 'firstname', 'lastname', 'email']);
1053 $auto->enableFieldSearchableCheck(true);
1054 //$auto->isMoreLinkAvailable(true);
1055
1056 if (($this->cat_request->getFetchAll())) {
1057 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
1058 }
1059
1060 echo $auto->getList($this->cat_request->getTerm());
1061 exit();
1062 }
1063
1064 public function performDeleteUsersObject(): void
1065 {
1066 $this->checkPermission("cat_administrate_users");
1067
1068 foreach ($this->cat_request->getUserIds() as $user_id) {
1069 if (!in_array($user_id, ilLocalUser::_getAllUserIds($this->object->getRefId()), true)) {
1070 throw new ilException('user id not valid');
1071 }
1072 if (!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id, false)) {
1073 continue;
1074 }
1075 $tmp_obj->delete();
1076 }
1077 $this->tpl->setOnScreenMessage('success', $this->lng->txt('deleted_users'));
1078 $this->listUsersObject();
1079 }
1080
1081 public function deleteUsersObject(): void
1082 {
1083 $this->checkPermission("cat_administrate_users");
1084 if ($this->cat_request->getIds() === []) {
1085 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_users_selected'));
1086 $this->listUsersObject();
1087 return;
1088 }
1089
1090 $confirm = new ilConfirmationGUI();
1091 $confirm->setFormAction($this->ctrl->getFormAction($this));
1092 $confirm->setHeaderText($this->lng->txt('sure_delete_selected_users'));
1093 $confirm->setConfirm($this->lng->txt('delete'), 'performDeleteUsers');
1094 $confirm->setCancel($this->lng->txt('cancel'), 'listUsers');
1095
1096 foreach ($this->cat_request->getIds() as $user) {
1097 $name = ilObjUser::_lookupName($user);
1098
1099 $confirm->addItem(
1100 'user_ids[]',
1101 (string) $user,
1102 $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']'
1103 );
1104 }
1105 $this->tpl->setContent($confirm->getHTML());
1106 }
1107
1108 public function assignRolesObject(): void
1109 {
1110 $this->ctrl->saveParameterByClass(self::class, "obj_id");
1111 $ilTabs = $this->tabs;
1112
1113 $this->checkPermission("cat_administrate_users");
1114
1115 if ($this->cat_request->getObjId() === 0) {
1116 $this->tpl->setOnScreenMessage('failure', 'no_user_selected');
1117 $this->listUsersObject();
1118 return;
1119 }
1120
1121 $ilTabs->clearTargets();
1122 $ilTabs->setBackTarget($this->lng->txt('backto_lua'), $this->ctrl->getLinkTarget($this, 'listUsers'));
1123 $ilHelp = $this->help;
1124 $ilHelp->setScreenIdComponent("cat");
1125 $ilHelp->setScreenId("administrate_user");
1126 $ilHelp->setSubScreenId("assign_roles");
1127
1128 $table = $this->cat_gui->assignedRoleTableBuilder(
1129 $this->ref_id,
1130 $this->cat_request->getObjId(),
1131 $this->user->getId(),
1132 $this,
1133 "assignRoles"
1134 )->getTable();
1135 if ($table->handleCommand()) {
1136 return;
1137 }
1138 $this->tpl->setContent($table->render());
1139 }
1140
1141 public function assignSave(array $ids): void
1142 {
1143 $this->ctrl->saveParameterByClass(self::class, "obj_id");
1144 $this->checkPermission("cat_administrate_users");
1145 $lng = $this->domain->lng();
1146
1147 // check hack
1148 if ($this->cat_request->getObjId() === 0 ||
1149 !in_array($this->cat_request->getObjId(), ilLocalUser::_getAllUserIds(), true)) {
1150 $this->tpl->setOnScreenMessage('failure', 'no_user_selected');
1151 $this->listUsersObject();
1152 return;
1153 }
1154 try {
1155 $this->cat_domain->assignedRolesManager(
1156 $this->ref_id,
1157 $this->cat_request->getObjId(),
1158 $this->user->getId()
1159 )->switchAssignment($ids);
1160 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1161 } catch (Exception $e) {
1162 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
1163 }
1164 $this->ctrl->redirectByClass(self::class, "assignRoles");
1165 }
1166
1167
1168 public static function _goto(string $a_target): void
1169 {
1170 global $DIC;
1171 $main_tpl = $DIC->ui()->mainTemplate();
1172
1173 $ilAccess = $DIC->access();
1174 $ilErr = $DIC["ilErr"];
1175 $lng = $DIC->language();
1176 if ($ilAccess->checkAccess("read", "", (int) $a_target)) {
1177 ilObjectGUI::_gotoRepositoryNode((int) $a_target);
1178 } elseif ($ilAccess->checkAccess("visible", "", (int) $a_target)) {
1179 ilObjectGUI::_gotoRepositoryNode((int) $a_target, "infoScreen");
1180 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1181 $main_tpl->setOnScreenMessage('failure', sprintf(
1182 $lng->txt("msg_no_perm_read_item"),
1184 ), true);
1186 }
1187
1188 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1189 }
1190
1191 //
1192 // taxonomy
1193 //
1194
1195 protected function initTaxSubTabs($a_active = "tax_list"): void
1196 {
1197 $this->tabs_gui->setTabActive("obj_tool_setting_taxonomies");
1198 $this->tabs_gui->addSubTab(
1199 "tax_settings",
1200 $this->lng->txt("cntr_taxonomy_sideblock_settings"),
1201 $this->ctrl->getLinkTarget($this, "editTaxonomySettings")
1202 );
1203 $this->tabs_gui->addSubTab(
1204 "tax_list",
1205 $this->lng->txt("cntr_taxonomy_definitions"),
1206 $this->ctrl->getLinkTargetByClass("ilobjtaxonomygui", "")
1207 );
1208 $this->tabs_gui->activateSubTab($a_active);
1209 }
1210
1211 protected function getTaxonomiesForRefId(): array
1212 {
1213 $tree = $this->tree;
1214
1215 // see ilTaxMDGUI::getSelectableTaxonomies()
1216
1217 $res = [];
1218 foreach ($tree->getPathFull($this->object->getRefId()) as $node) {
1219 //if ($node["ref_id"] != $this->object->getRefId())
1220 {
1221 // find all defined taxes for parent node, activation is not relevant
1222 $node_taxes = ilObjTaxonomy::getUsageOfObject((int) $node["obj_id"], true);
1223 if (count($node_taxes)) {
1224 foreach ($node_taxes as $node_tax) {
1225 $res[$node_tax["tax_id"]] = [
1226 "title" => $node_tax["title"]
1227 , "source" => $node["child"]
1228 ];
1229 }
1230 }
1231 }
1232 }
1233
1234 asort($res);
1235 return $res;
1236 }
1237
1238 protected function getActiveBlocks(): array
1239 {
1240 $res = [];
1241
1242 $prefix = self::CONTAINER_SETTING_TAXBLOCK;
1243
1244 foreach (ilContainer::_getContainerSettings($this->object->getId()) as $keyword => $value) {
1245 if ($value && strpos($keyword, $prefix) === 0) {
1246 $res[] = substr($keyword, strlen($prefix));
1247 }
1248 }
1249
1250 return $res;
1251 }
1252}
error(string $a_errmsg)
setInfoObject(ilInfoScreenGUI $info)
get info sections
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, $a_ext_rc=null, $a_ext_time=null)
static _recordWriteEvent(int $obj_id, int $usr_id, string $action, ?int $parent_obj_id=null)
Records a write event.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Filter administration for containers.
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder,...
ILIAS Container InternalGUIService $gui
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...
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
static _getContainerSettings(int $a_id)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
static _deleteContainerSettings(int $a_id, string $a_keyword="", bool $a_keyword_like=false)
GUI class for didactic template settings inside repository objects.
Class ilECSCategorySettings.
Base class for ILIAS Exception handling.
Export User Interface Class.
static getDataDir()
get data directory (outside webspace)
This class represents a section header in a property form.
Help GUI class.
setScreenIdComponent(string $a_comp)
Class ilInfoScreenGUI.
static _getAllUserIds(int $a_filter=0)
Last visited history for repository items.
This class represents a number property in a property form.
Class ilObjCategoryGUI.
ILIAS Category InternalDomainService $cat_domain
updateObject()
updates object entry in object_data
addUserAutoCompleteObject()
Show auto complete results.
initTaxSubTabs($a_active="tax_list")
listUsersObject(bool $show_delete=false)
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
infoScreen()
show information screen
ilAdvancedMDRecordGUI $record_gui
applyFilterObject()
Apply filter.
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
afterSave(ilObject $new_object)
Post (successful) object creation hook.
static _goto(string $a_target)
StandardGUIRequest $cat_request
getTabs()
@abstract overwrite in derived GUI class of your object type
setEditTabs($active_tab="settings_misc")
renderObject()
Render category.
ilNavigationHistory $nav_history
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
resetFilterObject()
import categories (static, also called by RootFolderGUI)
ILIAS Category InternalGUIService $cat_gui
ILIAS Taxonomy Service $taxonomy
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
Class ilObjUserGUI.
static _lookupName(int $a_user_id)
GUI class for the workflow of copying objects.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjectGUI Basic methods of all Output classes.
ilAccessHandler $access
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
addHeaderAction()
Add header action menu.
static _gotoRepositoryNode(int $ref_id, string $cmd="")
prepareOutput(bool $show_sub_objects=true)
Class ilObjectMetaDataGUI.
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
Class ilObject Basic functions for all objects.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This class represents a property form user interface.
Repository GUI Utilities.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
TableGUI class for user administration.
const SYSTEM_ROLE_ID
Definition: constants.php:29
const ROOT_FOLDER_ID
Definition: constants.php:32
exit
$info
Definition: entry_point.php:21
$res
Definition: ltiservices.php:69
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form(?array $class_path, string $cmd, string $submit_caption="")
global $lng
Definition: privfeed.php:31
$ilErr
Definition: raiseError.php:33
global $DIC
Definition: shib_login.php:26