ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilOrgUnitExplorerGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
5
14{
15 protected const ORGU = "orgu";
19 protected $stay_with_command = array('', 'render', 'view', 'infoScreen', 'showStaff', 'performPaste', 'cut');
23 protected $tree;
24
28 protected $access;
29
30
38 public function __construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree, \ilAccessHandler $access = null)
39 {
40 parent::__construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree);
41 $this->setAjax(true);
42 $this->setTypeWhiteList(array(self::ORGU));
43 $this->tree->initLangCode();
44 $this->access = $access;
45 }
46
47
53 public function getNodeContent($node) : ?string
54 {
55 global $DIC;
56 if ($node['title'] === '__OrgUnitAdministration') {
57 $node['title'] = $DIC->language()->txt('objs_orgu');
58 }
59 if ((int) $node['child'] === (int) $_GET['ref_id']) {
60 return "<span class='ilExp2NodeContent ilHighlighted'>" . $node['title'] . '</span>';
61 }
62
63 return $node['title'];
64 }
65
66
70 public function getRootNode() : array
71 {
72 return $this->getTree()->getNodeData(ilObjOrgUnit::getRootOrgRefId());
73 }
74
75
84 public function getNodeIcon($a_node) : string
85 {
86 global $DIC;
87 $ilias = $DIC['ilias'];
88 if ($ilias->getSetting('custom_icons')) {
89 $icons_cache = ilObjOrgUnit::getIconsCache();
90 $obj_id = ilObject::_lookupObjId($a_node["child"]);
91 if (isset($icons_cache[$obj_id])) {
92 return $icons_cache[$obj_id];
93 }
94 }
95
96 return ilObject::_getIcon($obj_id, "tiny", $a_node["type"]);
97 }
98
99
105 public function getNodeHref($node) : string
106 {
107 global $DIC;
108
109 if ($this->select_postvar) {
110 return '#';
111 }
112
113 if ($DIC->ctrl()->getCmd() === 'performPaste') {
114 $DIC->ctrl()->setParameterByClass(ilObjOrgUnitGUI::class, 'target_node', $node['child']);
115 }
116 $array = $DIC->ctrl()->getParameterArrayByClass(ilObjOrgUnitGUI::class);
117 $temp = $array['ref_id'];
118
119 $DIC->ctrl()->setParameterByClass(ilObjOrgUnitGUI::class, 'ref_id', $node['child']);
120 $DIC->ctrl()->setParameterByClass(ilObjPluginDispatchGUI::class, 'ref_id', $node['child']);
121
122 $link_target = ($node['type'] === self::ORGU) ? $this->getLinkTarget() : $this->getPluginLinkTarget();
123 $DIC->ctrl()->setParameterByClass(ilObjOrgUnitGUI::class, 'ref_id', $temp);
124
125 return $link_target;
126 }
127
128
132 protected function getLinkTarget() : string
133 {
134 global $DIC;
135 if ($DIC->ctrl()->getCmdClass() === strtolower(ilObjOrgUnitGUI::class) && in_array($DIC->ctrl()->getCmd(), $this->stay_with_command, true)) {
136 return $DIC->ctrl()->getLinkTargetByClass(array(ilAdministrationGUI::class, $DIC->ctrl()->getCmdClass()), $DIC->ctrl()->getCmd());
137 }
138
139 return $DIC->ctrl()->getLinkTargetByClass(array(ilAdministrationGUI::class, ilObjOrgUnitGUI::class), 'view');
140 }
141
142
146 protected function getPluginLinkTarget() : string
147 {
148 global $DIC;
149
150 return $DIC->ctrl()->getLinkTargetByClass(ilObjPluginDispatchGUI::class, 'forward');
151 }
152
153
159 public function isNodeClickable($a_node) : bool
160 {
161 global $DIC;
162 $ilAccess = $DIC->access();
163
164 if ($ilAccess->checkAccess('read', '', $a_node['ref_id'])) {
165 return true;
166 }
167
168 return false;
169 }
170
171
177 public function isNodeSelectable($a_node) : bool
178 {
179 $current_node = filter_input(INPUT_GET, 'item_ref_id') ?? ilObjOrgUnit::getRootOrgRefId();
180
181 return !($a_node['child'] === $current_node || $this->tree->isGrandChild($current_node, $a_node['child']));
182 }
183
184 public function getChildsOfNode($a_parent_node_id)
185 {
186 $children = parent::getChildsOfNode($a_parent_node_id);
187
188 if (!is_null($this->access)) {
189 $children = $this->filterChildrenByPermission($children);
190 }
191
192 return $children;
193 }
194
195 protected function filterChildrenByPermission(array $children) : array
196 {
197 return array_filter(
198 $children,
199 function ($child) {
200 return $this->access->checkAccess("visible", "", $child["ref_id"]);
201 }
202 );
203 }
204}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static getRootOrgRefId()
static _lookupObjId($a_id)
Class ilOrgUnitExplorerGUI.
__construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree, \ilAccessHandler $access=null)
getNodeIcon($a_node)
Get node icon Return custom icon of OrgUnit type if existing.
filterChildrenByPermission(array $children)
getChildsOfNode($a_parent_node_id)
Get childs of node.
Explorer class that works on tree objects (Services/Tree)
setTypeWhiteList($a_val)
Set type white list.
Interface for mapping data-structures to the Tree.
Interface ilAccessHandler.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46