ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilObjCategoryGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
38 class ilObjCategoryGUI extends ilContainerGUI implements \ILIAS\Taxonomy\Settings\ModifierGUIInterface
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;
48  protected ilObjectGUI $gui_obj;
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);
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  {
422  $prefix = self::CONTAINER_SETTING_TAXBLOCK;
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  {
434  $prefix = self::CONTAINER_SETTING_TAXBLOCK;
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  {
488  $lng = $this->lng;
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;
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
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  {
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  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
914  // END ChangeEvent: Record update
915 
916  // services
918  $this->object->getId(),
919  $form,
920  [
927  ]
928  );
929 
930  // block limit
931  if ((int) $form->getInput("block_limit") > 0) {
933  $this->object->getId(),
934  "block_limit",
935  (string) ((int) $form->getInput("block_limit"))
936  );
937  } else {
938  ilContainer::_deleteContainerSettings($this->object->getId(), "block_limit");
939  }
940  // Update ecs export settings
941  $ecs = new ilECSCategorySettings($this->object);
942  if ($ecs->handleSettingsUpdate($form)) {
943  $this->afterUpdate();
944  return;
945  }
946  }
947 
948  // display form to correct errors
949  $this->setEditTabs();
951  $this->tpl->setContent($form->getHTML());
952  }
953  }
954 
955 
956  public static function _getImportDir(): string
957  {
958  return ilFileUtils::getDataDir() . "/cat_import";
959  }
960 
969  protected function resetFilterObject(): void
970  {
971  $utab = new ilUserTableGUI($this, "listUsers", ilUserTableGUI::MODE_LOCAL_USER);
972  $utab->resetOffset();
973  $utab->resetFilter();
974 
975  // from "old" implementation
976  $this->listUsersObject();
977  }
978 
983  protected function applyFilterObject(): void
984  {
985  $ilTabs = $this->tabs;
986 
987  $utab = new ilUserTableGUI($this, "listUsers", ilUserTableGUI::MODE_LOCAL_USER);
988  $utab->resetOffset();
989  $utab->writeFilterToSession();
990  $this->listUsersObject();
991  }
992 
993  // METHODS for local user administration
994  public function listUsersObject(bool $show_delete = false): void
995  {
996  $ilUser = $this->user;
998  $ilToolbar = $this->toolbar;
999 
1002 
1003  if (!$rbacsystem->checkAccess("cat_administrate_users", $this->object->getRefId())) {
1004  $ilErr->raiseError($this->lng->txt("msg_no_perm_admin_users"), $ilErr->MESSAGE);
1005  }
1006  $this->tabs_gui->setTabActive('administrate_users');
1007 
1008 
1009 
1010  $this->tpl->addBlockfile(
1011  'ADM_CONTENT',
1012  'adm_content',
1013  'tpl.cat_admin_users.html',
1014  "components/ILIAS/Category"
1015  );
1016 
1017  if (count($rbacreview->getGlobalAssignableRoles()) ||
1018  in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()), true)) {
1019  $ilToolbar->addButton(
1020  $this->lng->txt('add_user'),
1021  $this->ctrl->getLinkTargetByClass('ilobjusergui', 'create')
1022  );
1023 
1024  $ilToolbar->addButton(
1025  $this->lng->txt('import_users'),
1026  $this->ctrl->getLinkTargetByClass('ilobjuserfoldergui', 'importUserForm')
1027  );
1028  } else {
1029  $this->tpl->setOnScreenMessage('info', $this->lng->txt('no_roles_user_can_be_assigned_to'));
1030  }
1031 
1032  if ($show_delete) {
1033  $this->tpl->setCurrentBlock("confirm_delete");
1034  $this->tpl->setVariable("CONFIRM_FORMACTION", $this->ctrl->getFormAction($this));
1035  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt('cancel'));
1036  $this->tpl->setVariable("CONFIRM_CMD", 'performDeleteUsers');
1037  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt('delete'));
1038  $this->tpl->parseCurrentBlock();
1039  }
1040 
1041  $this->lng->loadLanguageModule('user');
1042 
1043  $utab = new ilUserTableGUI($this, 'listUsers', ilUserTableGUI::MODE_LOCAL_USER);
1044  $this->tpl->setVariable('USERS_TABLE', $utab->getHTML());
1045  }
1046 
1050  protected function addUserAutoCompleteObject(): void
1051  {
1052  $auto = new ilUserAutoComplete();
1053  $auto->setSearchFields(['login', 'firstname', 'lastname', 'email']);
1054  $auto->enableFieldSearchableCheck(true);
1055  //$auto->isMoreLinkAvailable(true);
1056 
1057  if (($this->cat_request->getFetchAll())) {
1058  $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
1059  }
1060 
1061  echo $auto->getList($this->cat_request->getTerm());
1062  exit();
1063  }
1064 
1065  public function performDeleteUsersObject(): void
1066  {
1067  $this->checkPermission("cat_administrate_users");
1068 
1069  foreach ($this->cat_request->getUserIds() as $user_id) {
1070  if (!in_array($user_id, ilLocalUser::_getAllUserIds($this->object->getRefId()), true)) {
1071  throw new ilException('user id not valid');
1072  }
1073  if (!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id, false)) {
1074  continue;
1075  }
1076  $tmp_obj->delete();
1077  }
1078  $this->tpl->setOnScreenMessage('success', $this->lng->txt('deleted_users'));
1079  $this->listUsersObject();
1080  }
1081 
1082  public function deleteUsersObject(): void
1083  {
1084  $this->checkPermission("cat_administrate_users");
1085  if ($this->cat_request->getIds() === []) {
1086  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_users_selected'));
1087  $this->listUsersObject();
1088  return;
1089  }
1090 
1091  $confirm = new ilConfirmationGUI();
1092  $confirm->setFormAction($this->ctrl->getFormAction($this));
1093  $confirm->setHeaderText($this->lng->txt('sure_delete_selected_users'));
1094  $confirm->setConfirm($this->lng->txt('delete'), 'performDeleteUsers');
1095  $confirm->setCancel($this->lng->txt('cancel'), 'listUsers');
1096 
1097  foreach ($this->cat_request->getIds() as $user) {
1098  $name = ilObjUser::_lookupName($user);
1099 
1100  $confirm->addItem(
1101  'user_ids[]',
1102  (string) $user,
1103  $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']'
1104  );
1105  }
1106  $this->tpl->setContent($confirm->getHTML());
1107  }
1108 
1109  public function assignRolesObject(): void
1110  {
1111  $this->ctrl->saveParameterByClass(self::class, "obj_id");
1112  $ilTabs = $this->tabs;
1113 
1114  $this->checkPermission("cat_administrate_users");
1115 
1116  if ($this->cat_request->getObjId() === 0) {
1117  $this->tpl->setOnScreenMessage('failure', 'no_user_selected');
1118  $this->listUsersObject();
1119  return;
1120  }
1121 
1122  $ilTabs->clearTargets();
1123  $ilTabs->setBackTarget($this->lng->txt('backto_lua'), $this->ctrl->getLinkTarget($this, 'listUsers'));
1124  $ilHelp = $this->help;
1125  $ilHelp->setScreenIdComponent("cat");
1126  $ilHelp->setScreenId("administrate_user");
1127  $ilHelp->setSubScreenId("assign_roles");
1128 
1129  $table = $this->cat_gui->assignedRoleTableBuilder(
1130  $this->ref_id,
1131  $this->cat_request->getObjId(),
1132  $this->user->getId(),
1133  $this,
1134  "assignRoles"
1135  )->getTable();
1136  if ($table->handleCommand()) {
1137  return;
1138  }
1139  $this->tpl->setContent($table->render());
1140  }
1141 
1142  public function assignSave(array $ids): void
1143  {
1144  $this->ctrl->saveParameterByClass(self::class, "obj_id");
1145  $this->checkPermission("cat_administrate_users");
1146  $lng = $this->domain->lng();
1147 
1148  // check hack
1149  if ($this->cat_request->getObjId() === 0 ||
1150  !in_array($this->cat_request->getObjId(), ilLocalUser::_getAllUserIds(), true)) {
1151  $this->tpl->setOnScreenMessage('failure', 'no_user_selected');
1152  $this->listUsersObject();
1153  return;
1154  }
1155  try {
1156  $this->cat_domain->assignedRolesManager(
1157  $this->ref_id,
1158  $this->cat_request->getObjId(),
1159  $this->user->getId()
1160  )->switchAssignment($ids);
1161  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1162  } catch (Exception $e) {
1163  $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
1164  }
1165  $this->ctrl->redirectByClass(self::class, "assignRoles");
1166  }
1167 
1168 
1169  public static function _goto(string $a_target): void
1170  {
1171  global $DIC;
1172  $main_tpl = $DIC->ui()->mainTemplate();
1173 
1174  $ilAccess = $DIC->access();
1175  $ilErr = $DIC["ilErr"];
1176  $lng = $DIC->language();
1177  if ($ilAccess->checkAccess("read", "", (int) $a_target)) {
1178  ilObjectGUI::_gotoRepositoryNode((int) $a_target);
1179  } elseif ($ilAccess->checkAccess("visible", "", (int) $a_target)) {
1180  ilObjectGUI::_gotoRepositoryNode((int) $a_target, "infoScreen");
1181  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1182  $main_tpl->setOnScreenMessage('failure', sprintf(
1183  $lng->txt("msg_no_perm_read_item"),
1185  ), true);
1187  }
1188 
1189  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1190  }
1191 
1192  //
1193  // taxonomy
1194  //
1195 
1196  protected function initTaxSubTabs($a_active = "tax_list"): void
1197  {
1198  $this->tabs_gui->setTabActive("obj_tool_setting_taxonomies");
1199  $this->tabs_gui->addSubTab(
1200  "tax_settings",
1201  $this->lng->txt("cntr_taxonomy_sideblock_settings"),
1202  $this->ctrl->getLinkTarget($this, "editTaxonomySettings")
1203  );
1204  $this->tabs_gui->addSubTab(
1205  "tax_list",
1206  $this->lng->txt("cntr_taxonomy_definitions"),
1207  $this->ctrl->getLinkTargetByClass("ilobjtaxonomygui", "")
1208  );
1209  $this->tabs_gui->activateSubTab($a_active);
1210  }
1211 
1212  protected function getTaxonomiesForRefId(): array
1213  {
1214  $tree = $this->tree;
1215 
1216  // see ilTaxMDGUI::getSelectableTaxonomies()
1217 
1218  $res = [];
1219  foreach ($tree->getPathFull($this->object->getRefId()) as $node) {
1220  //if ($node["ref_id"] != $this->object->getRefId())
1221  {
1222  // find all defined taxes for parent node, activation is not relevant
1223  $node_taxes = ilObjTaxonomy::getUsageOfObject((int) $node["obj_id"], true);
1224  if (count($node_taxes)) {
1225  foreach ($node_taxes as $node_tax) {
1226  $res[$node_tax["tax_id"]] = [
1227  "title" => $node_tax["title"]
1228  , "source" => $node["child"]
1229  ];
1230  }
1231  }
1232  }
1233  }
1234 
1235  asort($res);
1236  return $res;
1237  }
1238 
1239  protected function getActiveBlocks(): array
1240  {
1241  $res = [];
1242 
1243  $prefix = self::CONTAINER_SETTING_TAXBLOCK;
1244 
1245  foreach (ilContainer::_getContainerSettings($this->object->getId()) as $keyword => $value) {
1246  if ($value && strpos($keyword, $prefix) === 0) {
1247  $res[] = substr($keyword, strlen($prefix));
1248  }
1249  }
1250 
1251  return $res;
1252  }
1253 }
static _getAllUserIds(int $a_filter=0)
Class ilObjCategoryGUI.
ilRbacSystem $rbacsystem
StandardGUIRequest $cat_request
$res
Definition: ltiservices.php:66
Class ilObjectMetaDataGUI.
ilAdvancedMDRecordGUI $record_gui
setPropertyForm(ilPropertyFormGUI $form)
ilRbacReview $rbacreview
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
prepareOutput(bool $show_sub_objects=true)
const SYSTEM_ROLE_ID
Definition: constants.php:29
Help GUI class.
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...
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-...
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:33
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
setCreationMode(bool $mode=true)
If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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
TableGUI class for user administration.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Category InternalGUIService $cat_gui
static http()
Fetches the global http state from ILIAS.
ilNavigationHistory $nav_history
static _lookupTitle(int $obj_id)
setFormAction(string $a_formaction)
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)
global $DIC
Definition: shib_login.php:26
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)
static getDataDir()
get data directory (outside webspace)
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
Last visited history for repository items.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
ilErrorHandling $error
exit
static _goto(string $a_target)
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;)
form( $class_path, string $cmd, string $submit_caption="")
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
ILIAS Category InternalDomainService $cat_domain
setInfoObject(ilInfoScreenGUI $info)
get info sections
ILIAS Container InternalGUIService $gui
$info
Definition: entry_point.php:21
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
Class ilECSCategorySettings.
Class ilObjUserGUI.
static _catchupWriteEvents(int $obj_id, int $usr_id, ?string $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
ILIAS Taxonomy Service $taxonomy
addHeaderAction()
Add header action menu.
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)
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.