ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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('benchmark');
102
103 $context = $this->global_screen->tool()->context();
104 $context->claim()->administration();
105
106 $this->request = new AdminGUIRequest(
107 $DIC->http(),
108 $DIC->refinery()
109 );
110
111 $this->ctrl->saveParameter($this, array("ref_id", "admin_mode"));
112
113 $this->admin_mode = $this->request->getAdminMode();
114 if ($this->admin_mode !== ilObjectGUI::ADMIN_MODE_REPOSITORY) {
115 $this->admin_mode = ilObjectGUI::ADMIN_MODE_SETTINGS;
116 }
117
118 $this->ctrl->setReturn($this, "");
119
120 // determine current ref id and mode
121 $ref_id = $this->request->getRefId();
122 if ($this->tree->isInTree($ref_id)) {
123 $this->cur_ref_id = $ref_id;
124 } else {
125 throw new ilPermissionException("Invalid ref id.");
126 }
127
128 $this->requested_obj_id = $this->request->getObjId();
129 }
130
131
136 public function executeCommand(): void
137 {
138 // check the basic permission
139 // - admin nodes and their childs (e.g. org units) must have read permission to be called
140 // - admin mode for repository and trash is only available to the global admin role
141 $has_access = false;
142 if ($this->cur_ref_id === SYSTEM_FOLDER_ID || $this->tree->isGrandChild(SYSTEM_FOLDER_ID, $this->cur_ref_id)) {
143 $has_access = $this->access->checkAccess('read', '', $this->cur_ref_id);
144 } else {
145 $has_access = $this->rbac_review->isAssigned($this->user->getId(), SYSTEM_ROLE_ID);
146 }
147 if (!$has_access) {
148 $this->logger->log($this->lng->txt('permission_denied'), ilLogLevel::INFO);
149 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
150 $this->ctrl->redirectToURL(
152 );
153 }
154
155 // check creation mode
156 // determined by "new_type" parameter
157 // e.g. creation of a new role, user org unit, talk template
158 $new_type = $this->request->getNewType();
159 if ($new_type) {
160 $creation_mode = true;
161 $obj_type = $new_type;
162 $class_name = $this->obj_definition->getClassName($obj_type);
163 $next_class = strtolower("ilObj" . $class_name . "GUI");
164 } else {
165 $creation_mode = false;
166 }
167
168 // set next_class directly for page translations
169 // (no cmdNode is given in translation link)
170 if ($this->ctrl->getCmdClass() === "ilobjlanguageextgui") {
171 $next_class = "ilobjlanguageextgui";
172 } else {
173 $next_class = $this->ctrl->getNextClass($this);
174 }
175
176 if ((
177 $next_class === "iladministrationgui" || $next_class == ""
178 ) && ($this->ctrl->getCmd() === "return")) {
179 // get GUI of current object
180 $obj_type = ilObject::_lookupType($this->cur_ref_id, true);
181 $class_name = $this->obj_definition->getClassName($obj_type);
182 $next_class = strtolower("ilObj" . $class_name . "GUI");
183 }
184
185 // forward all other classes to gui commands
186 if ($next_class != "" && $next_class !== "iladministrationgui") {
187 $class_path = $this->ctrl->lookupClassPath($next_class);
188 if (is_file($class_path)) {
189 require_once $class_path; // note: org unit plugins still need the require
190 }
191 // get gui class instance
192 $class_name = $this->ctrl->getClassForClasspath($class_path);
193 if (($next_class === "ilobjrolegui" || $next_class === "ilobjusergui"
194 || $next_class === "ilobjroletemplategui")) {
195 if ($this->requested_obj_id > 0) {
196 $this->gui_obj = new $class_name(null, $this->requested_obj_id, false, false);
197 $this->gui_obj->setCreationMode(false);
198 } else {
199 $this->gui_obj = new $class_name(null, $this->cur_ref_id, true, false);
200 $this->gui_obj->setCreationMode(true);
201 }
202 } else {
203 if ($this->obj_definition->isPlugin(ilObject::_lookupType($this->cur_ref_id, true))) {
204 $this->gui_obj = new $class_name($this->cur_ref_id);
205 } elseif (!$creation_mode) {
206 if (is_subclass_of($class_name, "ilObject2GUI")) {
207 $this->gui_obj = new $class_name($this->cur_ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
208 } else {
209 $this->gui_obj = new $class_name(null, $this->cur_ref_id, true, false);
210 }
211 } else {
212 if (is_subclass_of($class_name, "ilObject2GUI")) {
213 $this->gui_obj = new $class_name(null, ilObject2GUI::REPOSITORY_NODE_ID, $this->cur_ref_id);
214 } else {
215 $this->gui_obj = new $class_name("", 0, true, false);
216 }
217 }
218 $this->gui_obj->setCreationMode($creation_mode);
219 }
220 $this->gui_obj->setAdminMode($this->admin_mode);
221 $this->help->setScreenIdComponent(ilObject::_lookupType($this->cur_ref_id, true));
222 $this->showTree();
223
224 $this->ctrl->setReturn($this, "return");
225 $ret = $this->ctrl->forwardCommand($this->gui_obj);
226 $html = $this->gui_obj->getHTML();
227
228 if ($html != "") {
229 $this->tpl->setVariable("OBJECTS", $html);
230 }
231 $this->tpl->printToStdout();
232
233 } else {
234 // local command
235 $cmd = $this->ctrl->getCmd("forward");
236 if (in_array($cmd, self::COMMANDS)) {
237 $this->$cmd();
238 }
239 }
240 }
241
250 private function forward(): void
251 {
252 if ($this->admin_mode !== "repository") { // settings
253 if ($this->request->getRefId() == USER_FOLDER_ID) {
254 $this->ctrl->setParameter($this, "ref_id", USER_FOLDER_ID);
255 $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
256 if (ilObject::_lookupType($this->request->getJumpToUserId()) === "usr") {
257 $this->ctrl->setParameterByClass(
258 "ilobjuserfoldergui",
259 "jmpToUser",
260 $this->request->getJumpToUserId()
261 );
262 $this->ctrl->redirectByClass("ilobjuserfoldergui", "jumpToUser");
263 } else {
264 $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
265 }
266 } else {
267 // this code should not be necessary anymore...
268 throw new ilPermissionException("Missing AdmiGUI parameter.");
269 }
270 } else {
271 $this->ctrl->setParameter($this, "ref_id", ROOT_FOLDER_ID);
272 $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
273 $this->ctrl->redirectByClass("ilobjrootfoldergui", "view");
274 }
275 }
276
281 private function showTree(): void
282 {
283 if ($this->admin_mode !== "repository") {
284 return;
285 }
286
287 $this->global_screen->tool()->context()->current()->addAdditionalData(ilAdminGSToolProvider::SHOW_ADMIN_TREE, true);
288
289 $exp = new ilAdministrationExplorerGUI(self::class, "showTree");
290 $exp->handleCommand();
291 }
292
297 private function jumpToPluginSlot(): void
298 {
299 $this->ctrl->redirectByClass("ilobjcomponentsettingsgui", "listPlugins");
300 }
301
306 private function jump(): void
307 {
308 $ref_id = $this->request->getRefId();
310 $obj_type = ilObject::_lookupType($obj_id);
311 $class_name = $this->obj_definition->getClassName($obj_type);
312 $class = strtolower("ilObj" . $class_name . "GUI");
313 $this->ctrl->setParameterByClass($class, "ref_id", $ref_id);
314 $this->ctrl->redirectByClass($class, "view");
315 }
316}
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
$context
Definition: webdav.php:31