ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilOrgUnitExplorerGUI.php
Go to the documentation of this file.
1<?php
2
20
27{
28 protected const ORGU = "orgu";
29 protected array $stay_with_command = array('', 'render', 'view', 'infoScreen', 'showStaff', 'performPaste', 'cut');
30 protected ?ilTree $tree = null;
36
44 public function __construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree, ?\ilAccessHandler $access = null)
45 {
46 global $DIC;
47 parent::__construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree);
48 $this->setAjax(true);
49 $this->setTypeWhiteList(array(self::ORGU));
50 $this->tree->initLangCode();
51 $this->access = $DIC->access();
52 $this->settings = $DIC->settings();
53 $this->http_post = $DIC->http()->wrapper()->post();
54 $this->http_query = $DIC->http()->wrapper()->query();
55 $this->refinery = $DIC["refinery"];
56 }
57
63 public function getNodeContent($a_node): string
64 {
65 $node = $this->getNodeArrayRepresentation($a_node);
66
67 if ($node['title'] === '__OrgUnitAdministration') {
68 $node['title'] = $this->lng->txt('objs_orgu');
69 }
70 if ((int) $node['child'] === (int) $_GET['ref_id']) {
71 return "<span class='ilExp2NodeContent ilHighlighted'>" . $node['title'] . '</span>';
72 }
73
74 return ilUtil::secureString($node['title']);
75 }
76
77 public function getRootNode(): array
78 {
79 return $this->getTree()->getNodeData(ilObjOrgUnit::getRootOrgRefId());
80 }
81
88 public function getNodeIcon($a_node): string
89 {
90 $node = $this->getNodeArrayRepresentation($a_node);
91
92 $obj_id = 0;
93 if ($this->settings->get('custom_icons')) {
94 $icons_cache = ilObjOrgUnit::getIconsCache();
95 $obj_id = ilObject::_lookupObjId($node["child"]);
96 if (isset($icons_cache[$obj_id])) {
97 return $icons_cache[$obj_id];
98 }
99 }
100
101 return ilObject::_getIcon($obj_id, "tiny", $node["type"]);
102 }
103
108 public function getNodeHref($a_node): string
109 {
110 $node = $this->getNodeArrayRepresentation($a_node);
111
112 if ($this->select_postvar) {
113 return '#';
114 }
115
116 if ($this->ctrl->getCmd() === 'performPaste') {
117 $this->ctrl->setParameterByClass(ilObjOrgUnitGUI::class, 'target_node', $node['child']);
118 }
119 $array = $this->ctrl->getParameterArrayByClass(ilObjOrgUnitGUI::class);
120 $temp = $array['ref_id'];
121
122 $this->ctrl->setParameterByClass(ilObjOrgUnitGUI::class, 'ref_id', $node['child']);
123 $this->ctrl->setParameterByClass(ilObjPluginDispatchGUI::class, 'ref_id', $node['child']);
124
125 $link_target = ($node['type'] === self::ORGU) ? $this->getLinkTarget() : $this->getPluginLinkTarget();
126 $this->ctrl->setParameterByClass(ilObjOrgUnitGUI::class, 'ref_id', $temp);
127 return $link_target;
128 }
129
130 protected function getLinkTarget(): string
131 {
132 if ($this->ctrl->getCmdClass() === strtolower(ilObjOrgUnitGUI::class) && in_array(
133 $this->ctrl->getCmd(),
134 $this->stay_with_command,
135 true
136 )) {
137 return $this->ctrl->getLinkTargetByClass(
138 array(ilAdministrationGUI::class, $this->ctrl->getCmdClass()),
139 $this->ctrl->getCmd()
140 );
141 }
142
143 return $this->ctrl->getLinkTargetByClass(array(ilAdministrationGUI::class, ilObjOrgUnitGUI::class), 'view');
144 }
145
149 protected function getPluginLinkTarget(): string
150 {
151 return $this->ctrl->getLinkTargetByClass(ilObjPluginDispatchGUI::class, 'forward');
152 }
153
158 public function isNodeClickable($a_node): bool
159 {
160 $node = $this->getNodeArrayRepresentation($a_node);
161
162 $node = $this->getNodeArrayRepresentation($a_node);
163
164 if ($this->access->checkAccess('read', '', $node['ref_id'])) {
165 return true;
166 }
167
168 return false;
169 }
170
171
176 public function isNodeSelectable($a_node): bool
177 {
178 $r = $this->refinery;
179 if ($this->http_post->has("id")) {
180 // Node selected via multiselect in "manage".
181 $selected_nodes = $this->http_post->retrieve(
182 "id",
183 $r->kindlyTo()->listOf($r->kindlyTo()->int()),
184 );
185 } elseif ($this->http_query->has("item_ref_id")) {
186 // Node selected via "move"-action.
187 $selected_nodes = $this->http_query->retrieve(
188 "item_ref_id",
189 $r->kindlyTo()->listOf($r->kindlyTo()->int()),
190 );
191 } else {
192 // No node selected.
193 return true;
194 }
195
196 $node = $this->getNodeArrayRepresentation($a_node);
197 foreach ($selected_nodes as $sn) {
198 // Can't insert into itself.
199 if ($node["child"] == $sn) {
200 return false;
201 }
202 // Can't insert below itself.
203 if ($this->tree->isGrandChild($sn, $node["child"])) {
204 return false;
205 }
206 }
207 return true;
208 }
209
214 private function getNodeArrayRepresentation($a_node): array
215 {
216 if (is_object($a_node)) {
217 return (array) $a_node;
218 }
219
220 return $a_node;
221 }
222
223 public function getChildsOfNode($a_parent_node_id): array
224 {
225 $children = parent::getChildsOfNode($a_parent_node_id);
226 return $this->filterChildrenByPermission($children);
227 }
228
229 protected function filterChildrenByPermission(array $children): array
230 {
231 return array_filter(
232 $children,
233 function ($child) {
234 return $this->access->checkAccess("visible", "", $child["ref_id"]);
235 }
236 );
237 }
238}
Builds data types.
Definition: Factory.php:36
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
ILIAS Refinery Factory $refinery
__construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree, ?\ilAccessHandler $access=null)
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.
ILIAS Setting Class.
Explorer class that works on tree objects (Services/Tree)
setTypeWhiteList(array $a_val)
Set type white list.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static secureString(string $a_str, bool $a_strip_html=true, string $a_allow="")
Interface RequestWrapper.
Interface for mapping data-structures to the Tree.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$_GET['cmd']
Definition: lti.php:26
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26