ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilAdministrationGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use ILIAS\GlobalScreen\Services as GlobalScreen;
23
64{
65 private const array COMMANDS = ['forward', 'jump', 'jumpToPluginSlot', 'showTree'];
66
68 private readonly ilHelpGUI $help;
69 private readonly ilLanguage $lng;
71 private readonly ilTree $tree;
72 private readonly ilAccessHandler $access;
73 private readonly ilRbacReview $rbac_review;
74 private readonly ilObjUser $user;
75 private readonly ilCtrl $ctrl;
76 private readonly AdminGUIRequest $request;
77 private readonly GlobalScreen $global_screen;
78 private readonly ilLogger $logger;
79
80 private int $cur_ref_id;
81 private string $admin_mode = "";
82 private int $requested_obj_id = 0;
84
85 public function __construct()
86 {
87 global $DIC;
88
89 $this->help = $DIC["ilHelp"];
90 $this->logger = $DIC->logger()->root();
91 $this->lng = $DIC->language();
92 $this->tpl = $DIC->ui()->mainTemplate();
93 $this->tree = $DIC->repositoryTree();
94 $this->access = $DIC->access();
95 $this->user = $DIC->user();
96 $this->rbac_review = $DIC->rbac()->review();
97 $this->obj_definition = $DIC["objDefinition"];
98 $this->ctrl = $DIC->ctrl();
99 $this->global_screen = $DIC->globalScreen();
100
101 $this->lng->loadLanguageModule('administration');
102 $this->lng->loadLanguageModule('benchmark');
103
104 $context = $this->global_screen->tool()->context();
105 $context->claim()->administration();
106
107 $this->request = new AdminGUIRequest(
108 $DIC->http(),
109 $DIC->refinery()
110 );
111
112 $this->ctrl->saveParameter($this, array("ref_id", "admin_mode"));
113
114 $this->admin_mode = $this->request->getAdminMode();
115 if ($this->admin_mode !== ilObjectGUI::ADMIN_MODE_REPOSITORY) {
116 $this->admin_mode = ilObjectGUI::ADMIN_MODE_SETTINGS;
117 }
118
119 $this->ctrl->setReturn($this, "");
120
121 // determine current ref id and mode
122 $ref_id = $this->request->getRefId();
123 if ($this->tree->isInTree($ref_id)) {
124 $this->cur_ref_id = $ref_id;
125 } else {
126 throw new ilPermissionException("Invalid ref id.");
127 }
128
129 $this->requested_obj_id = $this->request->getObjId();
130 }
131
132
137 public function executeCommand(): void
138 {
139 // check the basic permission
140 // - admin nodes and their childs (e.g. org units) must have read permission to be called
141 // - admin mode for repository and trash is only available to the global admin role
142 $has_access = false;
143 if ($this->cur_ref_id === SYSTEM_FOLDER_ID || $this->tree->isGrandChild(SYSTEM_FOLDER_ID, $this->cur_ref_id)) {
144 $has_access = $this->access->checkAccess('read', '', $this->cur_ref_id);
145 } else {
146 $has_access = $this->rbac_review->isAssigned($this->user->getId(), SYSTEM_ROLE_ID);
147 }
148 if (!$has_access) {
149 $this->logger->log($this->lng->txt('permission_denied'), ilLogLevel::INFO);
150 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
151 $this->ctrl->redirectToURL(
153 );
154 }
155
156 // check creation mode
157 // determined by "new_type" parameter
158 // e.g. creation of a new role, user org unit, talk template
159 $new_type = $this->request->getNewType();
160 if ($new_type) {
161 $creation_mode = true;
162 $obj_type = $new_type;
163 $class_name = $this->obj_definition->getClassName($obj_type);
164 $next_class = strtolower("ilObj" . $class_name . "GUI");
165 } else {
166 $creation_mode = false;
167 }
168
169 // set next_class directly for page translations
170 // (no cmdNode is given in translation link)
171 if ($this->ctrl->getCmdClass() === "ilobjlanguageextgui") {
172 $next_class = "ilobjlanguageextgui";
173 } else {
174 $next_class = $this->ctrl->getNextClass($this);
175 }
176
177 if ((
178 $next_class === "iladministrationgui" || $next_class == ""
179 ) && ($this->ctrl->getCmd() === "return")) {
180 // get GUI of current object
181 $obj_type = ilObject::_lookupType($this->cur_ref_id, true);
182 $class_name = $this->obj_definition->getClassName($obj_type);
183 $next_class = strtolower("ilObj" . $class_name . "GUI");
184
185 // #47446: redirect to remove the "return" command which is not implemented by all GUIs
186 $this->ctrl->redirectByClass($next_class);
187 }
188
189 // forward all other classes to gui commands
190 if ($next_class != "" && $next_class !== "iladministrationgui") {
191 $class_path = $this->ctrl->lookupClassPath($next_class);
192 if (is_file($class_path)) {
193 require_once $class_path; // note: org unit plugins still need the require
194 }
195 // get gui class instance
196 $class_name = $this->ctrl->getClassForClasspath($class_path);
197 if (($next_class === "ilobjrolegui" || $next_class === "ilobjusergui"
198 || $next_class === "ilobjroletemplategui")) {
199 if ($this->requested_obj_id > 0) {
200 $this->gui_obj = new $class_name(null, $this->requested_obj_id, false, false);
201 $this->gui_obj->setCreationMode(false);
202 } else {
203 $this->gui_obj = new $class_name(null, $this->cur_ref_id, true, false);
204 $this->gui_obj->setCreationMode(true);
205 }
206 } else {
207 if ($this->obj_definition->isPlugin(ilObject::_lookupType($this->cur_ref_id, true))) {
208 $this->gui_obj = new $class_name($this->cur_ref_id);
209 } elseif (!$creation_mode) {
210 if (is_subclass_of($class_name, "ilObject2GUI")) {
211 $this->gui_obj = new $class_name($this->cur_ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
212 } else {
213 $this->gui_obj = new $class_name(null, $this->cur_ref_id, true, false);
214 }
215 } else {
216 if (is_subclass_of($class_name, "ilObject2GUI")) {
217 $this->gui_obj = new $class_name(null, ilObject2GUI::REPOSITORY_NODE_ID, $this->cur_ref_id);
218 } else {
219 $this->gui_obj = new $class_name("", 0, true, false);
220 }
221 }
222 $this->gui_obj->setCreationMode($creation_mode);
223 }
224 $this->gui_obj->setAdminMode($this->admin_mode);
225 $this->help->setScreenIdComponent(ilObject::_lookupType($this->cur_ref_id, true));
226 $this->showTree();
227
228 $this->ctrl->setReturn($this, "return");
229 $ret = $this->ctrl->forwardCommand($this->gui_obj);
230 $html = $this->gui_obj->getHTML();
231
232 if ($html != "") {
233 $this->tpl->setVariable("OBJECTS", $html);
234 }
235 $this->tpl->printToStdout();
236
237 } else {
238 // local command
239 $cmd = $this->ctrl->getCmd("forward");
240 if (in_array($cmd, self::COMMANDS)) {
241 $this->$cmd();
242 }
243 }
244 }
245
254 private function forward(): void
255 {
256 if ($this->admin_mode !== "repository") { // settings
257 if ($this->request->getRefId() == USER_FOLDER_ID) {
258 $this->ctrl->setParameter($this, "ref_id", USER_FOLDER_ID);
259 $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
260 if (ilObject::_lookupType($this->request->getJumpToUserId()) === "usr") {
261 $this->ctrl->setParameterByClass(
262 "ilobjuserfoldergui",
263 "jmpToUser",
264 $this->request->getJumpToUserId()
265 );
266 $this->ctrl->redirectByClass("ilobjuserfoldergui", "jumpToUser");
267 } else {
268 $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
269 }
270 } else {
271 // this code should not be necessary anymore...
272 throw new ilPermissionException("Missing AdmiGUI parameter.");
273 }
274 } else {
275 $this->ctrl->setParameter($this, "ref_id", ROOT_FOLDER_ID);
276 $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
277 $this->ctrl->redirectByClass("ilobjrootfoldergui", "view");
278 }
279 }
280
285 private function showTree(): void
286 {
287 if ($this->admin_mode !== "repository") {
288 return;
289 }
290
291 $this->global_screen->tool()->context()->current()->addAdditionalData(ilAdminGSToolProvider::SHOW_ADMIN_TREE, true);
292
293 $exp = new ilAdministrationExplorerGUI(self::class, "showTree");
294 $exp->handleCommand();
295 }
296
301 private function jumpToPluginSlot(): void
302 {
303 $this->ctrl->redirectByClass("ilobjcomponentsettingsgui", "listPlugins");
304 }
305
310 private function jump(): void
311 {
312 $ref_id = $this->request->getRefId();
314 $obj_type = ilObject::_lookupType($obj_id);
315 $class_name = $this->obj_definition->getClassName($obj_type);
316 $class = strtolower("ilObj" . $class_name . "GUI");
317 $this->ctrl->setParameterByClass($class, "ref_id", $ref_id);
318 $this->ctrl->redirectByClass($class, "view");
319 }
320}
Administration explorer GUI class.
Class ilAdministrationGUI.
readonly ilGlobalTemplateInterface $tpl
jumpToPluginSlot()
Special jump to plugin slot after ilCtrl has been reloaded Ths command is used by ilObjComponentSetti...
forward()
Redirect in special cases.
readonly ilAccessHandler $access
readonly ilRbacReview $rbac_review
readonly ilObjectDefinition $obj_definition
jump()
Jump to the GUI of an administration node This command is used by AdministrationMainBarProvider for t...
showTree()
Show the repository tree in the slate This command is used by ilAdministrationExplorerGUI the for adm...
readonly GlobalScreen $global_screen
readonly AdminGUIRequest $request
Class ilCtrl provides processing control methods.
Help GUI class.
language handling
Component logger with individual log levels by component id.
User class.
parses the objects.xml it handles the xml-description of all ilias objects
Class ilObjectGUI Basic methods of all Output classes.
const ADMIN_MODE_SETTINGS
const ADMIN_MODE_REPOSITORY
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
class ilRbacReview Contains Review functions of core Rbac.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static getStartingPointAsUrl()
const SYSTEM_ROLE_ID
Definition: constants.php:29
const USER_FOLDER_ID
Definition: constants.php:33
const SYSTEM_FOLDER_ID
Definition: constants.php:35
const ROOT_FOLDER_ID
Definition: constants.php:32
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26