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