1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once "./Services/Container/classes/class.ilContainerGUI.php";
6
7/**
8* Class ilObjCategoryGUI
9*
10* @author Stefan Meyer <meyer@leifos.com>
11* @author Sascha Hofmann <saschahofmann@gmx.de>
12* @version $Id$
13*
14* @ilCtrl_Calls ilObjCategoryGUI: ilPermissionGUI, ilContainerPageGUI, ilContainerLinkListGUI, ilObjUserGUI, ilObjUserFolderGUI
15* @ilCtrl_Calls ilObjCategoryGUI: ilInfoScreenGUI, ilObjStyleSheetGUI, ilCommonActionDispatcherGUI, ilObjectTranslationGUI
16* @ilCtrl_Calls ilObjCategoryGUI: ilColumnGUI, ilObjectCopyGUI, ilUserTableGUI, ilDidacticTemplateGUI, ilExportGUI
17* @ilCtrl_Calls ilObjCategoryGUI: ilObjTaxonomyGUI, ilObjectMetaDataGUI, ilContainerNewsSettingsGUI
18*
19* @ingroup ModulesCategory
20*/
21class ilObjCategoryGUI extends ilContainerGUI
22{
23    /**
24     * @var ilNavigationHistory
25     */
26    protected $nav_history;
27
28    /**
29     * @var ilHelpGUI
30     */
31    protected $help;
32
33    public $ctrl;
34
35    const CONTAINER_SETTING_TAXBLOCK = "tax_sblock_";
36
37    /**
38    * Constructor
39    * @access public
40    */
41    public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
42    {
43        global $DIC;
44
45        $this->rbacsystem = $DIC->rbac()->system();
46        $this->nav_history = $DIC["ilNavigationHistory"];
47        $this->access = $DIC->access();
48        $this->ctrl = $DIC->ctrl();
49        $this->tabs = $DIC->tabs();
50        $this->help = $DIC["ilHelp"];
51        $this->lng = $DIC->language();
52        $this->user = $DIC->user();
53        $this->tree = $DIC->repositoryTree();
54        $this->error = $DIC["ilErr"];
55        $this->settings = $DIC->settings();
56        $this->tpl = $DIC["tpl"];
57        $this->toolbar = $DIC->toolbar();
58        $this->rbacreview = $DIC->rbac()->review();
59        $this->rbacadmin = $DIC->rbac()->admin();
60        //global $ilCtrl;
61
62        // CONTROL OPTIONS
63        //$this->ctrl =& $ilCtrl;
64        //$this->ctrl->saveParameter($this,array("ref_id","cmdClass"));
65        $GLOBALS['lng']->loadLanguageModule('cat');
66        $GLOBALS['lng']->loadLanguageModule('obj');
67
68        $this->type = "cat";
69        parent::__construct($a_data, (int) $a_id, $a_call_by_reference, false);
70
71        if (is_object($this->object)) {
72            include_once("./Services/Container/classes/class.ilContainer.php");
73            include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
74            $this->info_screen_enabled = ilContainer::_lookupContainerSetting(
75                $this->object->getId(),
76                ilObjectServiceSettingsGUI::INFO_TAB_VISIBILITY,
77                true
78            );
79        }
80    }
81
82    public function executeCommand()
83    {
84        $rbacsystem = $this->rbacsystem;
85        $ilNavigationHistory = $this->nav_history;
86        $ilAccess = $this->access;
87        $ilCtrl = $this->ctrl;
88        $ilTabs = $this->tabs;
89
90        $next_class = $this->ctrl->getNextClass($this);
91        $cmd = $this->ctrl->getCmd();
92
93        // show repository tree
94        $this->showRepTree();
95
96        switch ($next_class) {
97            case "ilobjusergui":
98                include_once('./Services/User/classes/class.ilObjUserGUI.php');
99
100                $this->tabs_gui->setTabActive('administrate_users');
101                if (!$_GET['obj_id']) {
102                    $this->gui_obj = new ilObjUserGUI("", $_GET['ref_id'], true, false);
103                    $this->gui_obj->setCreationMode($this->creation_mode);
104                    $ret = &$this->ctrl->forwardCommand($this->gui_obj);
105                } else {
106                    $this->gui_obj = new ilObjUserGUI("", $_GET['obj_id'], false, false);
107                    $this->gui_obj->setCreationMode($this->creation_mode);
108                    $ret = &$this->ctrl->forwardCommand($this->gui_obj);
109                }
110
111                $ilTabs->clearTargets();
112                $ilTabs->setBackTarget($this->lng->txt('backto_lua'), $this->ctrl->getLinkTarget($this, 'listUsers'));
113        $ilHelp = $this->help;
114                $ilHelp->setScreenIdComponent("cat");
115                $ilHelp->setScreenId("administrate_user");
116                $ilHelp->setSubScreenId($ilCtrl->getCmd());
117                break;
118
119            case "ilobjuserfoldergui":
120                include_once('./Services/User/classes/class.ilObjUserFolderGUI.php');
121
122                $this->gui_obj = new ilObjUserFolderGUI("", (int) $_GET['ref_id'], true, false);
123                $this->gui_obj->setUserOwnerId((int) $_GET['ref_id']);
124                $this->gui_obj->setCreationMode($this->creation_mode);
125                $ret = &$this->ctrl->forwardCommand($this->gui_obj);
126
127                $ilTabs->clearTargets();
128                $ilTabs->setBackTarget($this->lng->txt('backto_lua'), $this->ctrl->getLinkTarget($this, 'listUsers'));
129        $ilHelp = $this->help;
130                $ilHelp->setScreenIdComponent("cat");
131                $ilHelp->setScreenId("administrate_user");
132                $ilHelp->setSubScreenId($ilCtrl->getCmd());
133                break;
134
135            case "ilcolumngui":
136                $this->checkPermission("read");
137                $this->prepareOutput();
138                include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
139                $this->tpl->setVariable(
140                    "LOCATION_CONTENT_STYLESHEET",
141                    ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
142                );
143                $this->renderObject();
144                break;
145
146            case 'ilpermissiongui':
147                $this->prepareOutput();
148                $this->tabs_gui->setTabActive('perm_settings');
149                include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
150                $perm_gui = new ilPermissionGUI($this);
151                $ret = &$this->ctrl->forwardCommand($perm_gui);
152                break;
153
154            case 'ilinfoscreengui':
155                if ($this->info_screen_enabled) {
156                    $this->prepareOutput();
157                    $this->infoScreen();
158                }
159                break;
160
161            case 'ilcontainerlinklistgui':
162                include_once("Services/Container/classes/class.ilContainerLinkListGUI.php");
163                $link_list_gui = new ilContainerLinkListGUI();
164                $ret = &$this->ctrl->forwardCommand($link_list_gui);
165                break;
166
167            // container page editing
168            case "ilcontainerpagegui":
169                $this->prepareOutput(false);
170                $ret = $this->forwardToPageObject();
171                if ($ret != "") {
172                    $this->tpl->setContent($ret);
173                }
174                break;
175
176            case 'ilobjectcopygui':
177                $this->prepareOutput();
178
179                include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
180                $cp = new ilObjectCopyGUI($this);
181                $cp->setType('cat');
182                $this->ctrl->forwardCommand($cp);
183                break;
184
185            case "ilobjstylesheetgui":
186                $this->forwardToStyleSheet();
187                break;
188
189            case 'ilusertablegui':
190                include_once './Services/User/classes/class.ilUserTableGUI.php';
191                $u_table = new ilUserTableGUI($this, "listUsers");
192                $u_table->initFilter();
193                $this->ctrl->setReturn($this, 'listUsers');
194                $this->ctrl->forwardCommand($u_table);
195                break;
196
197            case "ilcommonactiondispatchergui":
198                $this->prepareOutput();
199                include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
200                $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall();
201                $this->ctrl->forwardCommand($gui);
202                break;
203
204            case 'ildidactictemplategui':
205                $this->ctrl->setReturn($this, 'edit');
206                include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateGUI.php';
207                $did = new ilDidacticTemplateGUI($this);
208                $this->ctrl->forwardCommand($did);
209                break;
210
211            case 'ilexportgui':
212                $this->prepareOutput();
213                $this->tabs_gui->setTabActive('export');
214                include_once './Services/Export/classes/class.ilExportGUI.php';
215                $exp = new ilExportGUI($this);
216                $exp->addFormat('xml');
217                $this->ctrl->forwardCommand($exp);
218                break;
219
220            case 'ilobjecttranslationgui':
221                $this->checkPermissionBool("write");
222                $this->prepareOutput();
223                //$this->tabs_gui->setTabActive('export');
224                $this->setEditTabs("settings_trans");
225                include_once("./Services/Object/classes/class.ilObjectTranslationGUI.php");
226                $transgui = new ilObjectTranslationGUI($this);
227                $this->ctrl->forwardCommand($transgui);
228                break;
229
230            case 'ilobjtaxonomygui':
231                $this->checkPermissionBool("write");
232                $this->prepareOutput();
233                $this->initTaxSubTabs();
234                include_once("./Services/Taxonomy/classes/class.ilObjTaxonomyGUI.php");
235                $tax = new ilObjTaxonomyGUI();
236                $tax->setAssignedObject($this->object->getId());
237                $tax->setMultiple(true);
238                $tax->setListInfo($this->lng->txt("cntr_tax_list_info"));
239                $this->ctrl->forwardCommand($tax);
240                break;
241
242            case 'ilobjectmetadatagui':
243                $this->checkPermissionBool("write");
244                $this->prepareOutput();
245                $this->tabs_gui->activateTab('meta_data');
246                $this->ctrl->forwardCommand($this->getObjectMetadataGUI());
247                break;
248
249            case "ilcontainernewssettingsgui":
250                $this->prepareOutput();
251                $this->tabs_gui->setTabActive('settings');
252                $this->setEditTabs();
253                $this->tabs_gui->activateSubTab('obj_news_settings');
254                $news_set_gui = new ilContainerNewsSettingsGUI($this);
255                $news_set_gui->setHideByDate(true);
256                $this->ctrl->forwardCommand($news_set_gui);
257                break;
258
259            default:
260                if ($cmd == "infoScreen") {
261                    $this->checkPermission("visible");
262                } else {
263                    $this->checkPermission("read");
264                }
265
266                // add entry to navigation history
267                if (!$this->getCreationMode() &&
268                    $ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
269                    include_once("./Services/Link/classes/class.ilLink.php");
270                    $ilNavigationHistory->addItem(
271                        $_GET["ref_id"],
272                        ilLink::_getLink($_GET["ref_id"], "cat"),
273                        "cat"
274                    );
275                }
276
277                $this->prepareOutput();
278                include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
279                if (is_object($this->object)) {
280                    $this->tpl->setVariable(
281                        "LOCATION_CONTENT_STYLESHEET",
282                        ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
283                    );
284                }
285
286                if (!$cmd) {
287                    $cmd = "render";
288                }
289                $cmd .= "Object";
290                $this->tabs_gui->activateTab("view_content");	// see #19868
291                $this->$cmd();
292
293                break;
294        }
295
296        $this->addHeaderAction();
297
298        return true;
299    }
300
301
302    /**
303     * @inheritDoc
304     */
305    protected function addHeaderAction()
306    {
307        ilPreviewGUI::initPreview();
308        parent::addHeaderAction();
309    }
310
311
312    /**
313     * Get object metadata gui
314     *
315     * @param
316     * @return
317     */
318    public function getObjectMetadataGUI()
319    {
320        include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
321        $md_gui = new ilObjectMetaDataGUI($this->object);
322        include_once "Services/Object/classes/class.ilObjectServiceSettingsGUI.php";
323        if (ilContainer::_lookupContainerSetting(
324            $this->object->getId(),
325            ilObjectServiceSettingsGUI::TAXONOMIES,
326            false
327        )) {
328            $md_gui->enableTaxonomyDefinition(true);
329            $tax = $md_gui->getTaxonomyObjGUI();
330            $tax->setMultiple(true);
331            $tax->setListInfo($this->lng->txt("cntr_tax_list_info"));
332            $taxonomies = $this->getTaxonomiesForRefId();
333            if (sizeof($taxonomies)) {
334                $md_gui->setTaxonomySettings(function ($form) {
335                    $tax = $this->getTaxonomiesForRefId();
336                    $block = new ilCheckboxGroupInputGUI($this->lng->txt("cntr_taxonomy_show_sideblock"), "sblock");
337                    $form->addItem($block);
338
339                    $current = $this->getActiveBlocks();
340
341                    foreach ($tax as $tax_id => $tax_item) {
342                        $option = new ilCheckboxOption(
343                            $tax_item["title"],
344                            $tax_id,
345                            ilObject::_lookupDescription($tax_id)
346                        );
347
348                        if ($tax_item["source"] != $this->object->getRefId()) {
349                            $loc = new ilLocatorGUI();
350                            $loc->setTextOnly(true);
351                            $loc->addRepositoryItems($tax_item["source"]);
352                            $option->setInfo($loc->getHTML());
353                        }
354
355                        $block->addOption($option);
356
357                        if (in_array($tax_id, $current)) {
358                            $value[] = $tax_id;
359                        }
360                    }
361
362                    $block->setValue($value);
363                }, function ($form) {
364                    $taxonomies = $this->getTaxonomiesForRefId();
365                    if (sizeof($taxonomies)) {
366                        $sblock = $form->getInput("sblock");
367
368                        $prefix = self::CONTAINER_SETTING_TAXBLOCK;
369
370                        ilContainer::_deleteContainerSettings(
371                            $this->object->getId(),
372                            $prefix . "%",
373                            true
374                        );
375
376                        if (is_array($sblock)) {
377                            foreach ($sblock as $tax_id) {
378                                ilContainer::_writeContainerSetting(
379                                    $this->object->getId(),
380                                    $prefix . $tax_id,
381                                    1
382                                );
383                            }
384                        }
385                    }
386                });
387            }
388        }
389        return $md_gui;
390    }
391
392
393    /**
394    * Get tabs
395    */
396    public function getTabs()
397    {
398        $rbacsystem = $this->rbacsystem;
399        $lng = $this->lng;
400        $ilHelp = $this->help;
401        $ilAccess = $this->access;
402
403        if ($this->ctrl->getCmd() == "editPageContent") {
404            return;
405        }
406        #$this->ctrl->setParameter($this,"ref_id",$this->ref_id);
407
408        $ilHelp->setScreenIdComponent("cat");
409
410        if ($rbacsystem->checkAccess('read', $this->ref_id)) {
411            $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "render")
412                ? true
413                : false;
414            $this->tabs_gui->addTab(
415                "view_content",
416                $lng->txt("content"),
417                $this->ctrl->getLinkTarget($this, "")
418            );
419
420            //BEGIN ChangeEvent add info tab to category object
421            if ($this->info_screen_enabled) {
422                $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
423                    || strtolower($_GET["cmdClass"]) == "ilnotegui")
424                    ? true
425                    : false;
426                $this->tabs_gui->addTarget(
427                    "info_short",
428                    $this->ctrl->getLinkTargetByClass(
429                        array("ilobjcategorygui", "ilinfoscreengui"),
430                        "showSummary"
431                    ),
432                    array("showSummary","", "infoScreen"),
433                    "",
434                    "",
435                    $force_active
436                );
437            }
438            //END ChangeEvent add info tab to category object
439        }
440
441        if ($rbacsystem->checkAccess('write', $this->ref_id)) {
442            $force_active = ($_GET["cmd"] == "edit")
443                ? true
444                : false;
445            $this->tabs_gui->addTarget(
446                "settings",
447                $this->ctrl->getLinkTarget($this, "edit"),
448                "edit",
449                get_class($this),
450                "",
451                $force_active
452            );
453
454
455
456            // metadata / taxonomies
457            include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
458            $mdgui = new ilObjectMetaDataGUI($this->object);
459            if (ilContainer::_lookupContainerSetting(
460                $this->object->getId(),
461                ilObjectServiceSettingsGUI::TAXONOMIES,
462                false
463            )) {
464                $mdgui->enableTaxonomyDefinition(true);
465            }
466            $mdtab = $mdgui->getTab();
467            if ($mdtab) {
468                $this->tabs_gui->addTab(
469                    "meta_data",
470                    $this->lng->txt("meta_data"),
471                    $mdtab
472                );
473            }
474        }
475
476        include_once './Services/User/classes/class.ilUserAccountSettings.php';
477        if (
478            ilUserAccountSettings::getInstance()->isLocalUserAdministrationEnabled() and
479            $rbacsystem->checkAccess('cat_administrate_users', $this->ref_id)) {
480            $this->tabs_gui->addTarget(
481                "administrate_users",
482                $this->ctrl->getLinkTarget($this, "listUsers"),
483                "listUsers",
484                get_class($this)
485            );
486        }
487
488        if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
489            $this->tabs_gui->addTarget(
490                'export',
491                $this->ctrl->getLinkTargetByClass('ilexportgui', ''),
492                'export',
493                'ilexportgui'
494            );
495        }
496
497        // parent tabs (all container: edit_permission, clipboard, trash
498        parent::getTabs();
499    }
500
501    /**
502    * Render category
503    */
504    public function renderObject()
505    {
506        $ilTabs = $this->tabs;
507
508        $ilTabs->activateTab("view_content");
509        $ret = parent::renderObject();
510        return $ret;
511    }
512
513    public function viewObject()
514    {
515        if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
516            parent::viewObject();
517            return true;
518        }
519        return $this->renderObject();
520    }
521
522    protected function initCreationForms($a_new_type)
523    {
524        $forms = parent::initCreationForms($a_new_type);
525        //unset($forms[self::CFORM_IMPORT]);
526        return $forms;
527    }
528
529    protected function afterSave(ilObject $a_new_object)
530    {
531        $tree = $this->tree;
532
533        // default: sort by title
534        include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
535        $settings = new ilContainerSortingSettings($a_new_object->getId());
536        $settings->setSortMode(ilContainer::SORT_TITLE);
537        $settings->save();
538
539        // inherit parents content style, if not individual
540        $parent_ref_id = $tree->getParentId($a_new_object->getRefId());
541        $parent_id = ilObject::_lookupObjId($parent_ref_id);
542        include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
543        $style_id = ilObjStyleSheet::lookupObjectStyle($parent_id);
544        if ($style_id > 0) {
545            if (ilObjStyleSheet::_lookupStandard($style_id)) {
546                ilObjStyleSheet::writeStyleUsage($a_new_object->getId(), $style_id);
547            }
548        }
549
550        // always send a message
551        ilUtil::sendSuccess($this->lng->txt("cat_added"), true);
552        $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
553        $this->redirectToRefId($a_new_object->getRefId(), "");
554    }
555
556    /**
557    * this one is called from the info button in the repository
558    * not very nice to set cmdClass/Cmd manually, if everything
559    * works through ilCtrl in the future this may be changed
560    */
561    public function infoScreenObject()
562    {
563        $this->ctrl->setCmd("showSummary");
564        $this->ctrl->setCmdClass("ilinfoscreengui");
565        $this->infoScreen();
566    }
567
568    /**
569    * show information screen
570    */
571    public function infoScreen()
572    {
573        $ilAccess = $this->access;
574        $ilCtrl = $this->ctrl;
575        $ilErr = $this->error;
576
577        if (!$ilAccess->checkAccess("visible", "", $this->ref_id)) {
578            $ilErr->raiseError($this->lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
579        }
580
581        if (!$this->info_screen_enabled) {
582            return;
583        }
584
585        // #10986
586        $this->tabs_gui->setTabActive('info_short');
587
588        include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
589        $info = new ilInfoScreenGUI($this);
590
591        $info->enablePrivateNotes();
592
593        if ($ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
594            $info->enableNews();
595        }
596
597        // no news editing for files, just notifications
598        $info->enableNewsEditing(false);
599        if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
600            $news_set = new ilSetting("news");
601            $enable_internal_rss = $news_set->get("enable_rss_for_internal");
602
603            if ($enable_internal_rss) {
604                $info->setBlockProperty("news", "settings", true);
605                $info->setBlockProperty("news", "public_notifications_option", true);
606            }
607        }
608
609        include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
610        $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO, 'cat', $this->object->getId());
611        $record_gui->setInfoObject($info);
612        $record_gui->parse();
613
614
615        // standard meta data
616        $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
617
618        // forward the command
619        if ($ilCtrl->getNextClass() == "ilinfoscreengui") {
620            $ilCtrl->forwardCommand($info);
621        } else {
622            return $ilCtrl->getHTML($info);
623        }
624    }
625
626    /**
627     * Edit extended category settings
628     *
629     * @access protected
630     */
631    protected function editInfoObject()
632    {
633        $this->checkPermission("write");
634        $this->setEditTabs();
635        $this->tabs_gui->activateTab('settings');
636        $this->tabs_gui->setSubTabActive('edit_cat_settings');
637
638        $this->initExtendedSettings();
639        $this->tpl->setContent($this->form->getHTML());
640    }
641
642    /**
643     * Update info (extended meta data)
644     *
645     * @access protected
646     */
647    protected function updateInfoObject()
648    {
649        $this->checkPermission("write");
650
651        // init form
652        $this->initExtendedSettings();
653
654        // still needed for date conversion and so on
655        $this->form->checkInput();
656
657        if ($this->record_gui->importEditFormPostValues()) {
658            $this->record_gui->writeEditForm();
659
660            ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
661            $this->ctrl->redirect($this, "editInfo");
662        }
663
664        $this->editInfoObject();
665    }
666
667
668    /**
669     * build property form for extended category settings
670     *
671     * @access protected
672     */
673    protected function initExtendedSettings()
674    {
675        if (is_object($this->form)) {
676            return true;
677        }
678
679        include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
680        $this->form = new ilPropertyFormGUI();
681        $this->form->setFormAction($this->ctrl->getFormAction($this));
682        $this->form->setTitle($this->lng->txt('ext_cat_settings'));
683        $this->form->addCommandButton('updateInfo', $this->lng->txt('save'));
684        $this->form->addCommandButton('editInfo', $this->lng->txt('cancel'));
685
686        include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
687        $this->record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR, 'cat', $this->object->getId());
688        $this->record_gui->setPropertyForm($this->form);
689        $this->record_gui->parse();
690
691        return true;
692    }
693
694    protected function setEditTabs($active_tab = "settings_misc")
695    {
696        $ilSetting = $this->settings;
697        $ilTabs = $this->tabs;
698
699        $this->tabs_gui->addSubTab(
700            "settings_misc",
701            $this->lng->txt("settings"),
702            $this->ctrl->getLinkTarget($this, "edit")
703        );
704
705        $this->tabs_gui->addSubTab(
706            "settings_trans",
707            $this->lng->txt("obj_multilinguality"),
708            $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "")
709        );
710
711        //news tab
712        $news_active = ilContainer::_lookupContainerSetting(
713            $this->object->getId(),
714            ilObjectServiceSettingsGUI::NEWS_VISIBILITY,
715            true
716        );
717
718        if ($news_active) {
719            $this->tabs_gui->addSubTab(
720                'obj_news_settings',
721                $this->lng->txt("cont_news_settings"),
722                $this->ctrl->getLinkTargetByClass('ilcontainernewssettingsgui')
723            );
724        }
725
726        $this->tabs_gui->activateTab("settings");
727        $this->tabs_gui->activateSubTab($active_tab);
728    }
729
730    public function initEditForm()
731    {
732        $obj_service = $this->getObjectService();
733
734        $this->lng->loadLanguageModule($this->object->getType());
735        $this->setEditTabs();
736
737        include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
738        $form = new ilPropertyFormGUI();
739        $form->setFormAction($this->ctrl->getFormAction($this));
740        $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
741
742        // title/description
743        $this->initFormTitleDescription($form);
744
745        // Show didactic template type
746        $this->initDidacticTemplate($form);
747
748        // presentation
749        $pres = new ilFormSectionHeaderGUI();
750        $pres->setTitle($this->lng->txt('obj_presentation'));
751        $form->addItem($pres);
752
753        // title and icon visibility
754        $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTitleIconVisibility();
755
756        // top actions visibility
757        $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTopActionsVisibility();
758
759        // custom icon
760        $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addIcon();
761
762        // tile image
763        $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTileImage();
764
765        // list presentation
766        $form = $this->initListPresentationForm($form);
767
768        // sorting
769        $form = $this->initSortingForm(
770            $form,
771            array(
772                    ilContainer::SORT_TITLE,
773                    ilContainer::SORT_CREATION,
774                    ilContainer::SORT_MANUAL
775                )
776        );
777
778        // block limit
779        $bl = new ilNumberInputGUI($this->lng->txt("cont_block_limit"), "block_limit");
780        $bl->setInfo($this->lng->txt("cont_block_limit_info"));
781        $bl->setValue(ilContainer::_lookupContainerSetting($this->object->getId(), "block_limit"));
782        $form->addItem($bl);
783
784        // icon settings
785
786        // Edit ecs export settings
787        include_once 'Modules/Category/classes/class.ilECSCategorySettings.php';
788        $ecs = new ilECSCategorySettings($this->object);
789        $ecs->addSettingsToForm($form, 'cat');
790
791        // services
792        $sh = new ilFormSectionHeaderGUI();
793        $sh->setTitle($this->lng->txt('obj_features'));
794        $form->addItem($sh);
795
796        include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
797        ilObjectServiceSettingsGUI::initServiceSettingsForm(
798            $this->object->getId(),
799            $form,
800            array(
801                    ilObjectServiceSettingsGUI::INFO_TAB_VISIBILITY,
802                    ilObjectServiceSettingsGUI::NEWS_VISIBILITY,
803                    ilObjectServiceSettingsGUI::TAXONOMIES,
804                    ilObjectServiceSettingsGUI::CUSTOM_METADATA
805                )
806        );
807
808        $form->addCommandButton("update", $this->lng->txt("save"));
809
810        return $form;
811    }
812
813    public function getEditFormValues()
814    {
815        // values are set in initEditForm()
816    }
817
818    /**
819    * updates object entry in object_data
820    *
821    * @access	public
822    */
823    public function updateObject()
824    {
825        $ilErr = $this->error;
826        $ilUser = $this->user;
827        $obj_service = $this->getObjectService();
828
829        if (!$this->checkPermissionBool("write")) {
830            $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
831        } else {
832            $form = $this->initEditForm();
833            if ($form->checkInput()) {
834                $title = $form->getInput("title");
835                $desc = $form->getInput("desc");
836
837                $this->object->setTitle($title);
838                $this->object->setDescription($desc);
839                $this->object->update();
840
841                $this->saveSortingSettings($form);
842
843                // title icon visibility
844                $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTitleIconVisibility();
845
846                // top actions visibility
847                $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTopActionsVisibility();
848
849                // custom icon
850                $obj_service->commonSettings()->legacyForm($form, $this->object)->saveIcon();
851
852                // tile image
853                $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
854
855                // list presentation
856                $this->saveListPresentation($form);
857
858                // BEGIN ChangeEvent: Record update
859                require_once('Services/Tracking/classes/class.ilChangeEvent.php');
860                ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
861                ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
862                // END ChangeEvent: Record update
863
864                // services
865                include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
866                ilObjectServiceSettingsGUI::updateServiceSettingsForm(
867                    $this->object->getId(),
868                    $form,
869                    array(
870                        ilObjectServiceSettingsGUI::INFO_TAB_VISIBILITY,
871                        ilObjectServiceSettingsGUI::NEWS_VISIBILITY,
872                        ilObjectServiceSettingsGUI::TAXONOMIES,
873                        ilObjectServiceSettingsGUI::CUSTOM_METADATA
874                    )
875                );
876
877                // block limit
878                if ((int) $form->getInput("block_limit") > 0) {
879                    ilContainer::_writeContainerSetting($this->object->getId(), "block_limit", (int) $form->getInput("block_limit"));
880                } else {
881                    ilContainer::_deleteContainerSettings($this->object->getId(), "block_limit");
882                }
883                // Update ecs export settings
884                include_once 'Modules/Category/classes/class.ilECSCategorySettings.php';
885                $ecs = new ilECSCategorySettings($this->object);
886                if ($ecs->handleSettingsUpdate()) {
887                    return $this->afterUpdate();
888                }
889            }
890
891            // display form to correct errors
892            $this->setEditTabs();
893            $form->setValuesByPost();
894            $this->tpl->setContent($form->getHTML());
895        }
896    }
897
898    /**
899    * display form for category import
900    */
901    public function importCategoriesFormObject()
902    {
903        ilObjCategoryGUI::_importCategoriesForm($this->ref_id, $this->tpl);
904    }
905
906    /**
907    * display form for category import (static, also called by RootFolderGUI)
908    */
909    public static function _importCategoriesForm($a_ref_id, &$a_tpl)
910    {
911        global $DIC;
912
913        $lng = $DIC->language();
914        $rbacreview = $DIC->rbac()->review();
915        $ilCtrl = $DIC->ctrl();
916
917        $a_tpl->addBlockfile(
918            "ADM_CONTENT",
919            "adm_content",
920            "tpl.cat_import_form.html",
921            "Modules/Category"
922        );
923
924        $a_tpl->setVariable("FORMACTION", $ilCtrl->getFormActionByClass('ilObjCategoryGUI'));
925
926        $a_tpl->setVariable("TXT_IMPORT_CATEGORIES", $lng->txt("import_categories"));
927        $a_tpl->setVariable("TXT_HIERARCHY_OPTION", $lng->txt("import_cat_localrol"));
928        $a_tpl->setVariable("TXT_IMPORT_FILE", $lng->txt("import_file"));
929        $a_tpl->setVariable("TXT_IMPORT_TABLE", $lng->txt("import_cat_table"));
930
931        $a_tpl->setVariable("BTN_IMPORT", $lng->txt("import"));
932        $a_tpl->setVariable("BTN_CANCEL", $lng->txt("cancel"));
933
934        // NEED TO FILL ADOPT_PERMISSIONS HTML FORM....
935        $parent_role_ids = $rbacreview->getParentRoleIds($a_ref_id, true);
936
937        // sort output for correct color changing
938        ksort($parent_role_ids);
939
940        foreach ($parent_role_ids as $key => $par) {
941            if ($par["obj_id"] != SYSTEM_ROLE_ID) {
942                $check = ilUtil::formCheckbox(0, "adopt[]", $par["obj_id"], 1);
943                $output["adopt"][$key]["css_row_adopt"] = ilUtil::switchColor($key, "tblrow1", "tblrow2");
944                $output["adopt"][$key]["check_adopt"] = $check;
945                $output["adopt"][$key]["role_id"] = $par["obj_id"];
946                $output["adopt"][$key]["type"] = ($par["type"] == 'role' ? 'Role' : 'Template');
947                $output["adopt"][$key]["role_name"] = $par["title"];
948            }
949        }
950
951        //var_dump($output);
952
953        // BEGIN ADOPT PERMISSIONS
954        foreach ($output["adopt"] as $key => $value) {
955            $a_tpl->setCurrentBlock("ADOPT_PERM_ROW");
956            $a_tpl->setVariable("CSS_ROW_ADOPT", $value["css_row_adopt"]);
957            $a_tpl->setVariable("CHECK_ADOPT", $value["check_adopt"]);
958            $a_tpl->setVariable("LABEL_ID", $value["role_id"]);
959            $a_tpl->setVariable("TYPE", $value["type"]);
960            $a_tpl->setVariable("ROLE_NAME", $value["role_name"]);
961            $a_tpl->parseCurrentBlock();
962        }
963    }
964
965
966    /**
967    * import cancelled
968    *
969    * @access private
970    */
971    public function importCancelledObject()
972    {
973        $this->ctrl->redirect($this);
974    }
975
976    /**
977    * get user import directory name
978    */
979    public static function _getImportDir()
980    {
981        return ilUtil::getDataDir() . "/cat_import";
982    }
983
984    /**
985    * import categories
986    */
987    public function importCategoriesObject()
988    {
989        ilObjCategoryGUI::_importCategories($_GET["ref_id"]);
990        // call to importCategories with $withrol = 0
991        ilObjCategoryGUI::_importCategories($_GET["ref_id"], 0);
992    }
993
994    /**
995     * import categories with local rol
996     */
997    public function importCategoriesWithRolObject()
998    {
999
1000      //echo "entra aqui";
1001        // call to importCategories with $withrol = 1
1002        ilObjCategoryGUI::_importCategories($_GET["ref_id"], 1);
1003    }
1004
1005    /**
1006    * import categories (static, also called by RootFolderGUI)
1007    */
1008
1009    public static function _importCategories($a_ref_id, $withrol_tmp)
1010    {
1011        global $DIC;
1012
1013        $lng = $DIC->language();
1014        $ilCtrl = $DIC->ctrl();
1015
1016        require_once("./Modules/Category/classes/class.ilCategoryImportParser.php");
1017
1018        $import_dir = ilObjCategoryGUI::_getImportDir();
1019
1020        // create user import directory if necessary
1021        if (!@is_dir($import_dir)) {
1022            ilUtil::createDirectory($import_dir);
1023        }
1024
1025        // move uploaded file to user import directory
1026
1027        $file_name = $_FILES["importFile"]["name"];
1028
1029        // added to prevent empty file names
1030        if (!strcmp($file_name, "")) {
1031            ilUtil::sendFailure($lng->txt("no_import_file_found"), true);
1032            $ilCtrl->redirectByClass('ilObjCategoryGUI');
1033        }
1034
1035        $parts = pathinfo($file_name);
1036        $full_path = $import_dir . "/" . $file_name;
1037        ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"], $file_name, $full_path);
1038
1039        // unzip file
1040        ilUtil::unzip($full_path);
1041
1042        $subdir = basename($parts["basename"], "." . $parts["extension"]);
1043        $xml_file = $import_dir . "/" . $subdir . "/" . $subdir . ".xml";
1044        // CategoryImportParser
1045        //var_dump($_POST);
1046        $importParser = new ilCategoryImportParser($xml_file, $a_ref_id, $withrol_tmp);
1047        $importParser->startParsing();
1048
1049        ilUtil::sendSuccess($lng->txt("categories_imported"), true);
1050        $ilCtrl->redirectByClass('ilObjCategoryGUI');
1051    }
1052
1053    /**
1054    * Reset filter
1055    * (note: this function existed before data table filter has been introduced
1056    */
1057    protected function resetFilterObject()
1058    {
1059        include_once("./Services/User/classes/class.ilUserTableGUI.php");
1060        $utab = new ilUserTableGUI($this, "listUsers", ilUserTableGUI::MODE_LOCAL_USER);
1061        $utab->resetOffset();
1062        $utab->resetFilter();
1063
1064        // from "old" implementation
1065        $this->listUsersObject();
1066    }
1067
1068    /**
1069     * Apply filter
1070     * @return
1071     */
1072    protected function applyFilterObject()
1073    {
1074        $ilTabs = $this->tabs;
1075
1076        include_once("./Services/User/classes/class.ilUserTableGUI.php");
1077        $utab = new ilUserTableGUI($this, "listUsers", ilUserTableGUI::MODE_LOCAL_USER);
1078        $utab->resetOffset();
1079        $utab->writeFilterToSession();
1080        $this->listUsersObject();
1081    }
1082
1083    // METHODS for local user administration
1084    public function listUsersObject($show_delete = false)
1085    {
1086        $ilUser = $this->user;
1087        $ilErr = $this->error;
1088        $ilToolbar = $this->toolbar;
1089
1090        include_once './Services/User/classes/class.ilLocalUser.php';
1091        include_once './Services/User/classes/class.ilObjUserGUI.php';
1092
1093        $rbacsystem = $this->rbacsystem;
1094        $rbacreview = $this->rbacreview;
1095
1096        if (!$rbacsystem->checkAccess("cat_administrate_users", $this->object->getRefId())) {
1097            $ilErr->raiseError($this->lng->txt("msg_no_perm_admin_users"), $ilErr->MESSAGE);
1098        }
1099        $this->tabs_gui->setTabActive('administrate_users');
1100
1101
1102
1103        $this->tpl->addBlockfile(
1104            'ADM_CONTENT',
1105            'adm_content',
1106            'tpl.cat_admin_users.html',
1107            "Modules/Category"
1108        );
1109
1110        if (count($rbacreview->getGlobalAssignableRoles()) or in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
1111            $ilToolbar->addButton(
1112                $this->lng->txt('add_user'),
1113                $this->ctrl->getLinkTargetByClass('ilobjusergui', 'create')
1114            );
1115
1116            $ilToolbar->addButton(
1117                $this->lng->txt('import_users'),
1118                $this->ctrl->getLinkTargetByClass('ilobjuserfoldergui', 'importUserForm')
1119            );
1120        } else {
1121            ilUtil::sendInfo($this->lng->txt('no_roles_user_can_be_assigned_to'));
1122        }
1123
1124        if ($show_delete) {
1125            $this->tpl->setCurrentBlock("confirm_delete");
1126            $this->tpl->setVariable("CONFIRM_FORMACTION", $this->ctrl->getFormAction($this));
1127            $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt('cancel'));
1128            $this->tpl->setVariable("CONFIRM_CMD", 'performDeleteUsers');
1129            $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt('delete'));
1130            $this->tpl->parseCurrentBlock();
1131        }
1132
1133        $this->lng->loadLanguageModule('user');
1134
1135        include_once("./Services/User/classes/class.ilUserTableGUI.php");
1136        $utab = new ilUserTableGUI($this, 'listUsers', ilUserTableGUI::MODE_LOCAL_USER);
1137        $this->tpl->setVariable('USERS_TABLE', $utab->getHTML());
1138
1139        return true;
1140    }
1141
1142    /**
1143     * Show auto complete results
1144     */
1145    protected function addUserAutoCompleteObject()
1146    {
1147        include_once './Services/User/classes/class.ilUserAutoComplete.php';
1148        $auto = new ilUserAutoComplete();
1149        $auto->setSearchFields(array('login','firstname','lastname','email'));
1150        $auto->enableFieldSearchableCheck(true);
1151        $auto->isMoreLinkAvailable(true);
1152
1153        if (($_REQUEST['fetchall'])) {
1154            $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
1155        }
1156
1157        echo $auto->getList($_REQUEST['term']);
1158        exit();
1159    }
1160
1161
1162    public function performDeleteUsersObject()
1163    {
1164        include_once './Services/User/classes/class.ilLocalUser.php';
1165        $this->checkPermission("cat_administrate_users");
1166
1167        foreach ($_POST['user_ids'] as $user_id) {
1168            if (!in_array($user_id, ilLocalUser::_getAllUserIds($this->object->getRefId()))) {
1169                die('user id not valid');
1170            }
1171            if (!$tmp_obj = &ilObjectFactory::getInstanceByObjId($user_id, false)) {
1172                continue;
1173            }
1174            $tmp_obj->delete();
1175        }
1176        ilUtil::sendSuccess($this->lng->txt('deleted_users'));
1177        $this->listUsersObject();
1178
1179        return true;
1180    }
1181
1182    public function deleteUsersObject()
1183    {
1184        $this->checkPermission("cat_administrate_users");
1185        if (!count($_POST['id'])) {
1186            ilUtil::sendFailure($this->lng->txt('no_users_selected'));
1187            $this->listUsersObject();
1188
1189            return true;
1190        }
1191
1192        include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
1193        $confirm = new ilConfirmationGUI();
1194        $confirm->setFormAction($this->ctrl->getFormAction($this));
1195        $confirm->setHeaderText($this->lng->txt('sure_delete_selected_users'));
1196        $confirm->setConfirm($this->lng->txt('delete'), 'performDeleteUsers');
1197        $confirm->setCancel($this->lng->txt('cancel'), 'listUsers');
1198
1199        foreach ($_POST['id'] as $user) {
1200            $name = ilObjUser::_lookupName($user);
1201
1202            $confirm->addItem(
1203                'user_ids[]',
1204                $user,
1205                $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']'
1206            );
1207        }
1208        $this->tpl->setContent($confirm->getHTML());
1209    }
1210
1211    public function assignRolesObject()
1212    {
1213        $rbacreview = $this->rbacreview;
1214        $ilTabs = $this->tabs;
1215
1216        $this->checkPermission("cat_administrate_users");
1217
1218        include_once './Services/User/classes/class.ilLocalUser.php';
1219
1220        if (!isset($_GET['obj_id'])) {
1221            ilUtil::sendFailure('no_user_selected');
1222            $this->listUsersObject();
1223
1224            return true;
1225        }
1226
1227        $ilTabs->clearTargets();
1228        $ilTabs->setBackTarget($this->lng->txt('backto_lua'), $this->ctrl->getLinkTarget($this, 'listUsers'));
1229        $ilHelp = $this->help;
1230        $ilHelp->setScreenIdComponent("cat");
1231        $ilHelp->setScreenId("administrate_user");
1232        $ilHelp->setSubScreenId("assign_roles");
1233
1234
1235        $roles = $this->__getAssignableRoles();
1236
1237        if (!count($roles)) {
1238            #ilUtil::sendInfo($this->lng->txt('no_roles_user_can_be_assigned_to'));
1239            #$this->listUsersObject();
1240
1241            #return true;
1242        }
1243
1244        $ass_roles = $rbacreview->assignedRoles($_GET['obj_id']);
1245
1246        $counter = 0;
1247        $f_result = array();
1248
1249        foreach ($roles as $role) {
1250            $role_obj = &ilObjectFactory::getInstanceByObjId($role['obj_id']);
1251
1252            $disabled = false;
1253            $f_result[$counter]['checkbox'] = ilUtil::formCheckbox(
1254                in_array($role['obj_id'], $ass_roles) ? 1 : 0,
1255                'role_ids[]',
1256                $role['obj_id'],
1257                $disabled
1258            );
1259            $f_result[$counter]['title'] = $role_obj->getTitle() ? $role_obj->getTitle() : "";
1260            $f_result[$counter]['desc'] = $role_obj->getDescription() ? $role_obj->getDescription() : "";
1261            $f_result[$counter]['type'] = $role['role_type'] == 'global' ?
1262                $this->lng->txt('global') :
1263                $this->lng->txt('local');
1264
1265            unset($role_obj);
1266            ++$counter;
1267        }
1268
1269        include_once('./Modules/Category/classes/class.ilCategoryAssignRoleTableGUI.php');
1270        $table = new ilCategoryAssignRoleTableGUI($this, "assignRoles");
1271        $tmp_obj = &ilObjectFactory::getInstanceByObjId($_GET['obj_id']);
1272        $title = $this->lng->txt('role_assignment') . ' (' . $tmp_obj->getFullname() . ')';
1273        $table->setTitle($title, "icon_role.svg", $this->lng->txt("role_assignment"));
1274        $table->setData($f_result);
1275        $this->tpl->setContent($table->getHTML());
1276    }
1277
1278    public function assignSaveObject()
1279    {
1280        $rbacreview = $this->rbacreview;
1281        $rbacadmin = $this->rbacadmin;
1282        $this->checkPermission("cat_administrate_users");
1283
1284        include_once './Services/User/classes/class.ilLocalUser.php';
1285        // check hack
1286        if (!isset($_GET['obj_id']) or !in_array($_REQUEST['obj_id'], ilLocalUser::_getAllUserIds())) {
1287            ilUtil::sendFailure('no_user_selected');
1288            $this->listUsersObject();
1289
1290            return true;
1291        }
1292        $roles = $this->__getAssignableRoles();
1293
1294        // check minimum one global role
1295        if (!$this->__checkGlobalRoles($_POST['role_ids'])) {
1296            ilUtil::sendFailure($this->lng->txt('no_global_role_left'));
1297            $this->assignRolesObject();
1298
1299            return false;
1300        }
1301
1302        $new_role_ids = $_POST['role_ids'] ? $_POST['role_ids'] : array();
1303        $assigned_roles = $rbacreview->assignedRoles((int) $_REQUEST['obj_id']);
1304        foreach ($roles as $role) {
1305            if (in_array($role['obj_id'], $new_role_ids) and !in_array($role['obj_id'], $assigned_roles)) {
1306                $rbacadmin->assignUser($role['obj_id'], (int) $_REQUEST['obj_id']);
1307            }
1308            if (in_array($role['obj_id'], $assigned_roles) and !in_array($role['obj_id'], $new_role_ids)) {
1309                $rbacadmin->deassignUser($role['obj_id'], (int) $_REQUEST['obj_id']);
1310            }
1311        }
1312        ilUtil::sendSuccess($this->lng->txt('role_assignment_updated'));
1313        $this->assignRolesObject();
1314
1315        return true;
1316    }
1317
1318    // PRIVATE
1319    public function __getAssignableRoles()
1320    {
1321        $rbacreview = $this->rbacreview;
1322        $ilUser = $this->user;
1323
1324        // check local user
1325        $tmp_obj = &ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
1326        // Admin => all roles
1327        if (in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
1328            $global_roles = $rbacreview->getGlobalRolesArray();
1329        } elseif ($tmp_obj->getTimeLimitOwner() == $this->object->getRefId()) {
1330            $global_roles = $rbacreview->getGlobalAssignableRoles();
1331        } else {
1332            $global_roles = array();
1333        }
1334        return $roles = array_merge(
1335            $global_roles,
1336            $rbacreview->getAssignableChildRoles($this->object->getRefId())
1337        );
1338    }
1339
1340    public function __checkGlobalRoles($new_assigned)
1341    {
1342        $rbacreview = $this->rbacreview;
1343        $ilUser = $this->user;
1344
1345        $this->checkPermission("cat_administrate_users");
1346
1347        // return true if it's not a local user
1348        $tmp_obj = &ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
1349        if ($tmp_obj->getTimeLimitOwner() != $this->object->getRefId() and
1350           !in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
1351            return true;
1352        }
1353
1354        // new assignment by form
1355        $new_assigned = $new_assigned ? $new_assigned : array();
1356        $assigned = $rbacreview->assignedRoles((int) $_GET['obj_id']);
1357
1358        // all assignable globals
1359        if (!in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
1360            $ga = $rbacreview->getGlobalAssignableRoles();
1361        } else {
1362            $ga = $rbacreview->getGlobalRolesArray();
1363        }
1364        $global_assignable = array();
1365        foreach ($ga as $role) {
1366            $global_assignable[] = $role['obj_id'];
1367        }
1368
1369        $new_visible_assigned_roles = array_intersect($new_assigned, $global_assignable);
1370        $all_assigned_roles = array_intersect($assigned, $rbacreview->getGlobalRoles());
1371        $main_assigned_roles = array_diff($all_assigned_roles, $global_assignable);
1372
1373        if (!count($new_visible_assigned_roles) and !count($main_assigned_roles)) {
1374            return false;
1375        }
1376        return true;
1377    }
1378
1379    public static function _goto($a_target)
1380    {
1381        global $DIC;
1382
1383        $ilAccess = $DIC->access();
1384        $ilErr = $DIC["ilErr"];
1385        $lng = $DIC->language();
1386
1387        if ($ilAccess->checkAccess("read", "", $a_target)) {
1388            ilObjectGUI::_gotoRepositoryNode($a_target);
1389        } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1390            ilUtil::sendFailure(sprintf(
1391                $lng->txt("msg_no_perm_read_item"),
1392                ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))
1393            ), true);
1394            ilObjectGUI::_gotoRepositoryRoot();
1395        }
1396
1397        $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1398    }
1399
1400    //
1401    // taxonomy
1402    //
1403
1404    protected function initTaxSubTabs($a_active = "tax_list")
1405    {
1406        $this->tabs_gui->setTabActive("obj_tool_setting_taxonomies");
1407        $this->tabs_gui->addSubTab(
1408            "tax_settings",
1409            $this->lng->txt("cntr_taxonomy_sideblock_settings"),
1410            $this->ctrl->getLinkTarget($this, "editTaxonomySettings")
1411        );
1412        $this->tabs_gui->addSubTab(
1413            "tax_list",
1414            $this->lng->txt("cntr_taxonomy_definitions"),
1415            $this->ctrl->getLinkTargetByClass("ilobjtaxonomygui", "")
1416        );
1417        $this->tabs_gui->activateSubTab($a_active);
1418    }
1419
1420    protected function getTaxonomiesForRefId()
1421    {
1422        $tree = $this->tree;
1423
1424        include_once "Services/Object/classes/class.ilObjectServiceSettingsGUI.php";
1425        include_once "Services/Taxonomy/classes/class.ilObjTaxonomy.php";
1426
1427        // see ilTaxMDGUI::getSelectableTaxonomies()
1428
1429        $res = array();
1430        foreach ($tree->getPathFull($this->object->getRefId()) as $node) {
1431            //if ($node["ref_id"] != $this->object->getRefId())
1432            {
1433                // find all defined taxes for parent node, activation is not relevant
1434                $node_taxes = ilObjTaxonomy::getUsageOfObject($node["obj_id"], true);
1435                if (sizeof($node_taxes)) {
1436                    foreach ($node_taxes as $node_tax) {
1437                        $res[$node_tax["tax_id"]] = array(
1438                            "title" => $node_tax["title"]
1439                        , "source" => $node["child"]
1440                        );
1441                    }
1442                }
1443            }
1444        }
1445
1446        asort($res);
1447        return $res;
1448    }
1449
1450
1451    protected function getActiveBlocks()
1452    {
1453        $res = array();
1454
1455        $prefix = self::CONTAINER_SETTING_TAXBLOCK;
1456
1457        foreach (ilContainer::_getContainerSettings($this->object->getId()) as $keyword => $value) {
1458            if (substr($keyword, 0, strlen($prefix)) == $prefix && (bool) $value) {
1459                $res[] = substr($keyword, strlen($prefix));
1460            }
1461        }
1462
1463        return $res;
1464    }
1465} // END class.ilObjCategoryGUI
1466