ILIAS  release_8 Revision v8.24
class.ilOrgUnitExplorerGUI.php
Go to the documentation of this file.
1<?php
18/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
19
21
28{
29 protected const ORGU = "orgu";
30 protected array $stay_with_command = array('', 'render', 'view', 'infoScreen', 'showStaff', 'performPaste', 'cut');
31 protected ?ilTree $tree = null;
37
45 public function __construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree, \ilAccessHandler $access = null)
46 {
47 global $DIC;
48 parent::__construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree);
49 $this->setAjax(true);
50 $this->setTypeWhiteList(array(self::ORGU));
51 $this->tree->initLangCode();
52 $this->access = $DIC->access();
53 $this->settings = $DIC->settings();
54 $this->http_post = $DIC->http()->wrapper()->post();
55 $this->http_query= $DIC->http()->wrapper()->query();
56 $this->refinery = $DIC["refinery"];
57 }
58
64 public function getNodeContent($a_node): string
65 {
66 $node = $this->getNodeArrayRepresentation($a_node);
67
68 if ($node['title'] === '__OrgUnitAdministration') {
69 $node['title'] = $this->lng->txt('objs_orgu');
70 }
71 if ((int) $node['child'] === (int) $_GET['ref_id']) {
72 return "<span class='ilExp2NodeContent ilHighlighted'>" . $node['title'] . '</span>';
73 }
74
75 return ilUtil::secureString($node['title']);
76 }
77
78 public function getRootNode(): array
79 {
80 return $this->getTree()->getNodeData(ilObjOrgUnit::getRootOrgRefId());
81 }
82
89 public function getNodeIcon($a_node): string
90 {
91 $node = $this->getNodeArrayRepresentation($a_node);
92
93 $obj_id = 0;
94 if ($this->settings->get('custom_icons')) {
95 $icons_cache = ilObjOrgUnit::getIconsCache();
96 $obj_id = ilObject::_lookupObjId($node["child"]);
97 if (isset($icons_cache[$obj_id])) {
98 return $icons_cache[$obj_id];
99 }
100 }
101
102 return ilObject::_getIcon($obj_id, "tiny", $node["type"]);
103 }
104
109 public function getNodeHref($a_node): string
110 {
111 $node = $this->getNodeArrayRepresentation($a_node);
112
113 if ($this->select_postvar) {
114 return '#';
115 }
116
117 if ($this->ctrl->getCmd() === 'performPaste') {
118 $this->ctrl->setParameterByClass(ilObjOrgUnitGUI::class, 'target_node', $node['child']);
119 }
120 $array = $this->ctrl->getParameterArrayByClass(ilObjOrgUnitGUI::class);
121 $temp = $array['ref_id'];
122
123 $this->ctrl->setParameterByClass(ilObjOrgUnitGUI::class, 'ref_id', $node['child']);
124 $this->ctrl->setParameterByClass(ilObjPluginDispatchGUI::class, 'ref_id', $node['child']);
125
126 $link_target = ($node['type'] === self::ORGU) ? $this->getLinkTarget() : $this->getPluginLinkTarget();
127 $this->ctrl->setParameterByClass(ilObjOrgUnitGUI::class, 'ref_id', $temp);
128 return $link_target;
129 }
130
131 protected function getLinkTarget(): string
132 {
133 if ($this->ctrl->getCmdClass() === strtolower(ilObjOrgUnitGUI::class) && in_array(
134 $this->ctrl->getCmd(),
135 $this->stay_with_command,
136 true
137 )) {
138 return $this->ctrl->getLinkTargetByClass(
139 array(ilAdministrationGUI::class, $this->ctrl->getCmdClass()),
140 $this->ctrl->getCmd()
141 );
142 }
143
144 return $this->ctrl->getLinkTargetByClass(array(ilAdministrationGUI::class, ilObjOrgUnitGUI::class), 'view');
145 }
146
150 protected function getPluginLinkTarget(): string
151 {
152 return $this->ctrl->getLinkTargetByClass(ilObjPluginDispatchGUI::class, 'forward');
153 }
154
159 public function isNodeClickable($a_node): bool
160 {
161 $node = $this->getNodeArrayRepresentation($a_node);
162
163 $node = $this->getNodeArrayRepresentation($a_node);
164
165 if ($this->access->checkAccess('read', '', $node['ref_id'])) {
166 return true;
167 }
168
169 return false;
170 }
171
172
177 public function isNodeSelectable($a_node): bool
178 {
179 $r = $this->refinery;
180 if ($this->http_post->has("id")) {
181 // Node selected via multiselect in "manage".
182 $selected_nodes = $this->http_post->retrieve(
183 "id",
184 $r->kindlyTo()->listOf($r->kindlyTo()->int()),
185 );
186 } elseif ($this->http_query->has("item_ref_id")) {
187 // Node selected via "move"-action.
188 $selected_nodes = $this->http_query->retrieve(
189 "item_ref_id",
190 $r->kindlyTo()->listOf($r->kindlyTo()->int()),
191 );
192 } else {
193 // No node selected.
194 return true;
195 }
196
197 $node = $this->getNodeArrayRepresentation($a_node);
198 foreach ($selected_nodes as $sn) {
199 // Can't insert into itself.
200 if ($node["child"] == $sn) {
201 return false;
202 }
203 // Can't insert below itself.
204 if ($this->tree->isGrandChild($sn, $node["child"])) {
205 return false;
206 }
207 }
208 return true;
209 }
210
215 private function getNodeArrayRepresentation($a_node): array
216 {
217 if (is_object($a_node)) {
218 return (array) $a_node;
219 }
220
221 return $a_node;
222 }
223
224 public function getChildsOfNode($a_parent_node_id): array
225 {
226 $children = parent::getChildsOfNode($a_parent_node_id);
227 return $this->filterChildrenByPermission($children);
228 }
229
230 protected function filterChildrenByPermission(array $children): array
231 {
232 return array_filter(
233 $children,
234 function ($child) {
235 return $this->access->checkAccess("visible", "", $child["ref_id"]);
236 }
237 );
238 }
239}
Builds data types.
Definition: Factory.php:21
static getIconsCache()
Returns an array that maps from OrgUnit object IDs to its icon defined by the assigned OrgUnit type.
static getRootOrgRefId()
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
Class ilOrgUnitExplorerGUI.
ILIAS HTTP Wrapper RequestWrapper $http_query
__construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree, \ilAccessHandler $access=null)
ILIAS Refinery Factory $refinery
getNodeIcon($a_node)
Get node icon.
ILIAS HTTP Wrapper RequestWrapper $http_post
getNodeContent($a_node)
Get content of a node.
filterChildrenByPermission(array $children)
getChildsOfNode($a_parent_node_id)
Get childs of node.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Explorer class that works on tree objects (Services/Tree)
setTypeWhiteList(array $a_val)
Set type white list.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static secureString(string $a_str, bool $a_strip_html=true, string $a_allow="")
global $DIC
Definition: feed.php:28
Interface RequestWrapper.
Interface for mapping data-structures to the Tree.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$_GET['client_id']
Definition: saml1-acs.php:21