ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
AdministrationMainBarProvider.php
Go to the documentation of this file.
2
7
14{
15
19 public function getStaticTopItems() : array
20 {
21 return [];
22 }
23
24
28 public function getStaticSubItems() : array
29 {
31 $top = StandardTopItemsProvider::getInstance()->getAdministrationIdentification();
32
33 if (!$access_helper->isUserLoggedIn()() || !$access_helper->hasAdministrationAccess()()) {
34 return [];
35 }
36
37 $entries = [];
38 $this->dic->language()->loadLanguageModule('administration');
39
40 list($groups, $titems) = $this->getGroups();
41 $position = 1;
42 foreach ($groups as $group => $group_items) {
43 // Is Group
44 if (is_array($group_items) && count($group_items) > 0) {
45 // Entries
46 $links = [];
47 foreach ($group_items as $group_item) {
48 if ($group_item == "---") {
49 continue;
50 }
51
52 $icon = $this->dic->ui()->factory()->symbol()->icon()->standard($titems[$group_item]["type"], $titems[$group_item]["title"])
53 ->withIsOutlined(true);
54
55 $ref_id = $titems[$group_item]["ref_id"];
56 if ($_GET["admin_mode"] != 'repository' && $ref_id == ROOT_FOLDER_ID) {
57 $identification = $this->if->identifier('mm_adm_rep');
58 $action = "ilias.php?baseClass=ilAdministrationGUI&ref_id=" . $ref_id . "&admin_mode=repository";
59 } else {
60 $identification = $this->if->identifier("mm_adm_" . $titems[$group_item]["type"]);
61 $action = "ilias.php?baseClass=ilAdministrationGUI&ref_id=" . $ref_id . "&cmd=jump";
62 }
63
64 $links[] = $this->globalScreen()
65 ->mainBar()
66 ->link($identification)
67 ->withTitle($titems[$group_item]["title"])
68 ->withAction($action)
69 ->withSymbol($icon)
70 ->withVisibilityCallable(function() use($ref_id){
71 return $this->dic->rbac()->system()->checkAccess('visible,read', $ref_id);
72 });
73 }
74
75 // Main entry
76 $title = $this->dic->language()->txt("adm_" . $group);
77 $entries[] = $this->globalScreen()
78 ->mainBar()
79 ->linkList($this->if->identifier('adm_content_' . $group))
80 ->withSupportsAsynchronousLoading(true)
81 ->withLinks($links)
82 ->withTitle($title)
83 ->withSymbol($this->getIconForGroup($group, $title))
84 ->withParent($top)
85 ->withPosition($position * 10)
86 ->withAlwaysAvailable(true)
87 ->withNonAvailableReason($this->dic->ui()->factory()->legacy("{$this->dic->language()->txt('item_must_be_always_active')}"))
88 ->withVisibilityCallable(
89 $access_helper->hasAdministrationAccess()
90 )->withAvailableCallable(
91 $access_helper->isUserLoggedIn()
92 );
93 $position++;
94 }
95 }
96
97 return $entries;
98 }
99
100 protected function getIconForGroup(string $group, string $title) : Icon
101 {
102 $icon_map = array(
103 "maintenance" => "icon_sysa",
104 "layout_and_navigation" => "icon_laya",
105 "user_administration" => "icon_usra",
106 "personal_workspace" => "icon_pwsa",
107 "achievements" => "icon_achva",
108 "communication" => "icon_coma",
109 "search_and_find" => "icon_safa",
110 "extending_ilias" => "icon_exta",
111 "repository_and_objects" => "icon_repa"
112 );
113 $icon_path = \ilUtil::getImagePath("outlined/" . $icon_map[$group] . ".svg");
114 return $this->dic->ui()->factory()->symbol()->icon()->custom($icon_path, $title);
115 }
116
117
121 private function getGroups() : array
122 {
123 if (!$this->dic->offsetExists('tree')) { // isDependencyAvailable does not work, Fatal error: Uncaught Error: Call to undefined method ILIAS\DI\Container::tree() in /var/www/html/src/DI/Container.php on line 294
124 return [[], []];
125 }
126 $tree = $this->dic->repositoryTree();
127 $rbacsystem = $this->dic->rbac()->system();
128 $lng = $this->dic->language();
129
130 $objects = $tree->getChilds(SYSTEM_FOLDER_ID);
131
132 foreach ($objects as $object) {
133 $new_objects[$object["title"] . ":" . $object["child"]]
134 = $object;
135 // have to set it manually as translation type of main node cannot be "sys" as this type is a orgu itself.
136 if ($object["type"] == "orgu") {
137 $new_objects[$object["title"] . ":" . $object["child"]]["title"] = $lng->txt("objs_orgu");
138 }
139 }
140
141 // add entry for switching to repository admin
142 // note: please see showChilds methods which prevents infinite look
143 $new_objects[$lng->txt("repository_admin") . ":" . ROOT_FOLDER_ID]
144 = array(
145 "tree" => 1,
146 "child" => ROOT_FOLDER_ID,
147 "ref_id" => ROOT_FOLDER_ID,
148 "depth" => 3,
149 "type" => "root",
150 "title" => $lng->txt("repository_admin"),
151 "description" => $lng->txt("repository_admin_desc"),
152 "desc" => $lng->txt("repository_admin_desc"),
153 );
154
155 $new_objects[$lng->txt("general_settings") . ":" . SYSTEM_FOLDER_ID]
156 = array(
157 "tree" => 1,
158 "child" => SYSTEM_FOLDER_ID,
159 "ref_id" => SYSTEM_FOLDER_ID,
160 "depth" => 2,
161 "type" => "adm",
162 "title" => $lng->txt("general_settings"),
163 );
164 ksort($new_objects);
165
166 // determine items to show
167 $items = array();
168 foreach ($new_objects as $c) {
169 // check visibility
170 if ($tree->getParentId($c["ref_id"]) == ROOT_FOLDER_ID && $c["type"] != "adm"
171 && $_GET["admin_mode"] != "repository"
172 ) {
173 continue;
174 }
175 // these objects may exist due to test cases that didnt clear
176 // data properly
177 if ($c["type"] == "" || $c["type"] == "objf"
178 || $c["type"] == "xxx"
179 ) {
180 continue;
181 }
182 $items[] = $c;
183 }
184
185 $titems = array();
186 foreach ($items as $i) {
187 $titems[$i["type"]] = $i;
188 }
189
190 // admin menu layout
191 $layout = array(
192 "maintenance" =>
193 array("adm", "lngf", "hlps", "wfe", "pdfg", 'logs', 'sysc', "recf", "root"),
194 "layout_and_navigation" =>
195 array("mme", "stys", "adve", "accs"),
196 "user_administration" =>
197 array("usrf", 'tos', "rolf", "otpl", "auth", "ps"),
198 "personal_workspace" =>
199 array("dshs", "tags", "cals", "prfa", "prss", "nots"),
200 "achievements" =>
201 array("lhts", "skmg", "trac", "bdga", "cert"),
202 "communication" =>
203 array("mail", "cadm", "nwss", "coms", "awra"),
204 "search_and_find" =>
205 array("seas", "mds", "taxs"),
206 "extending_ilias" =>
207 array('ecss', "ltis", "cmis", "cmps", "extt"),
208 "repository_and_objects" =>
209 array("reps", "crss", "grps", "prgs", "bibs", "blga", "chta", "facs", "frma", "lrss",
210 "mcts", "mobs", "svyf", "assf", "wbrs", "wiks", 'lsos'),
211 );
212 $groups = [];
213 // now get all items and groups that are accessible
214 foreach ($layout as $group => $entries) {
215 $groups[$group] = array();
216 $entries_since_last_sep = false;
217 foreach ($entries as $e) {
218 if ($e == "---" || $titems[$e]["type"] != "") {
219 if ($e == "---" && $entries_since_last_sep) {
220 $groups[$group][] = $e;
221 $entries_since_last_sep = false;
222 } else {
223 if ($e != "---") {
224 $groups[$group][] = $e;
225 $entries_since_last_sep = true;
226 }
227 }
228 }
229 }
230 }
231
232 return [$groups, $titems];
233 }
234}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
This describes how a icon could be modified during construction of UI.
Definition: Icon.php:10
$i
Definition: metadata.php:24
$lng