ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
OrgUnitToolProvider.php
Go to the documentation of this file.
1<?php
2
20
26use ilObjOrgUnit;
30use ilTree;
31
37{
38 public const SHOW_ORGU_TREE = 'show_orgu_tree';
39
41 {
42 return $this->context_collection->main()->administration();
43 }
44
49 public function getToolsForContextStack(CalledContexts $called_contexts): array
50 {
51 $tools = [];
52
53 if ($called_contexts->current()->getAdditionalData()->is(self::SHOW_ORGU_TREE, true)) {
54 $iff = function (string $id) {
55 return $this->identification_provider->contextAwareIdentifier($id);
56 };
57
58 $t = function (string $key): string {
59 return $this->dic->language()->txt($key);
60 };
61
62 $tools[] = $this->factory->treeTool($iff('tree_new'))
63 ->withTitle($t('tree'))
64 ->withSymbol($this->dic->ui()->factory()->symbol()->icon()->standard(
65 'orgu',
66 'Orgu'
67 ))
68 ->withTree($this->getTree());
69 }
70
71 return $tools;
72 }
73
74 private function getTree(): Tree
75 {
76 global $DIC;
77 $lng = $DIC->language();
78 $tree = $this->getTreeRecursion();
79
80 $parent_node_id = $DIC->repositoryTree()->getParentId(ilObjOrgUnit::getRootOrgRefId());
81
82 return $this->dic->ui()->factory()->tree()->expandable($lng->txt("org_units"), $tree)
83 ->withData($tree->getChildsOfNode($parent_node_id));
84 }
85
86 private function getTreeRecursion(): TreeRecursion
87 {
88 $tree = new ilOrgUnitExplorerGUI(
89 "orgu_explorer",
90 ilObjOrgUnitGUI::class,
91 "showTree",
92 new ilTree(1),
93 $this->dic["ilAccess"]
94 );
95 $tree->setTypeWhiteList($this->getTreeWhiteList());
96 $tree->setRootId(ilObjOrgUnit::getRootOrgRefId());
97 $ref_id = (int) ($_GET['item_ref_id'] ?? $_GET['ref_id'] ?? 0);
98 if ($ref_id !== 0) {
99 $tree->setPathOpen((int) $ref_id);
100 }
101 $tree->setOrderField('title');
102
103 return $tree;
104 }
105
109 private function getTreeWhiteList(): array
110 {
111 $whiteList = array('orgu');
112 $pls = ilOrgUnitExtension::getActivePluginIdsForTree();
113
114 return array_merge($whiteList, $pls);
115 }
116}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
factory()
getToolsForContextStack(CalledContexts $called_contexts)
Class ilObjOrgUnit GUI class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getRootOrgRefId()
Class ilOrgUnitExplorerGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Interface for mapping data-structures to the Tree.
This describes a Tree Control.
Definition: Tree.php:29
$_GET['cmd']
Definition: lti.php:26
$ref_id
Definition: ltiauth.php:66
withSymbol(Symbol $symbol)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26