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