ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilAdministrationGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
62 {
64  protected ilHelpGUI $help;
65  protected ilDBInterface $db;
66  public ilLanguage $lng;
68  public ilTree $tree;
70  public int $cur_ref_id;
71  public string $cmd;
72  public ilCtrl $ctrl;
73  protected string $admin_mode = "";
74  protected bool $creation_mode = false;
75  protected int $requested_obj_id = 0;
77  protected ilObjectGUI $gui_obj;
78  private readonly ilErrorHandling $error;
79 
80  public function __construct()
81  {
83  global $DIC;
84 
85  $this->help = $DIC["ilHelp"];
86  $this->db = $DIC->database();
87  $lng = $DIC->language();
88  $tpl = $DIC->ui()->mainTemplate();
89  $tree = $DIC->repositoryTree();
90  $rbacsystem = $DIC->rbac()->system();
91  $objDefinition = $DIC["objDefinition"];
92  $ilCtrl = $DIC->ctrl();
93  $this->error = $DIC['ilErr'];
94 
95  $this->lng = $lng;
96  $this->lng->loadLanguageModule('administration');
97  $this->tpl = $tpl;
98  $this->tree = $tree;
99  $this->rbacsystem = $rbacsystem;
100  $this->objDefinition = $objDefinition;
101  $this->ctrl = $ilCtrl;
102 
103  $context = $DIC->globalScreen()->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 ($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  $rbacsystem = $this->rbacsystem;
139  $objDefinition = $this->objDefinition;
140  $ilHelp = $this->help;
141  $ilDB = $this->db;
142 
143  // permission checks
144  if (!$rbacsystem->checkAccess("visible", SYSTEM_FOLDER_ID) &&
145  !$rbacsystem->checkAccess("read", SYSTEM_FOLDER_ID)) {
146  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
147  }
148 
149  // check creation mode
150  // determined by "new_type" parameter
151  $new_type = $this->request->getNewType();
152  if ($new_type) {
153  $this->creation_mode = true;
154  }
155  // determine next class
156  if ($this->creation_mode) {
157  $obj_type = $new_type;
158  $class_name = $this->objDefinition->getClassName($obj_type);
159  $next_class = strtolower("ilObj" . $class_name . "GUI");
160  $this->ctrl->setCmdClass($next_class);
161  }
162 
163  // set next_class directly for page translations
164  // (no cmdNode is given in translation link)
165  if ($this->ctrl->getCmdClass() === "ilobjlanguageextgui") {
166  $next_class = "ilobjlanguageextgui";
167  } else {
168  $next_class = $this->ctrl->getNextClass($this);
169  }
170 
171  if ((
172  $next_class === "iladministrationgui" || $next_class == ""
173  ) && ($this->ctrl->getCmd() === "return")) {
174  // get GUI of current object
175  $obj_type = ilObject::_lookupType($this->cur_ref_id, true);
176  $class_name = $this->objDefinition->getClassName($obj_type);
177  $next_class = strtolower("ilObj" . $class_name . "GUI");
178  $this->ctrl->setCmdClass($next_class);
179  $this->ctrl->setCmd("view");
180  }
181 
182  $cmd = $this->ctrl->getCmd("forward");
183 
184  //echo "<br>cmd:$cmd:nextclass:$next_class:-".$_GET["cmdClass"]."-".$_GET["cmd"]."-";
185  switch ($next_class) {
186  default:
187 
188  // forward all other classes to gui commands
189  if ($next_class != "" && $next_class !== "iladministrationgui") {
190  $class_path = $this->ctrl->lookupClassPath($next_class);
191  if (is_file($class_path)) {
192  require_once $class_path; // note: org unit plugins still need the require
193  }
194  // get gui class instance
195  $class_name = $this->ctrl->getClassForClasspath($class_path);
196  if (($next_class === "ilobjrolegui" || $next_class === "ilobjusergui"
197  || $next_class === "ilobjroletemplategui")) {
198  if ($this->requested_obj_id > 0) {
199  $this->gui_obj = new $class_name(null, $this->requested_obj_id, false, false);
200  $this->gui_obj->setCreationMode(false);
201  } else {
202  $this->gui_obj = new $class_name(null, $this->cur_ref_id, true, false);
203  $this->gui_obj->setCreationMode(true);
204  }
205  } else {
206  if ($objDefinition->isPlugin(ilObject::_lookupType($this->cur_ref_id, true))) {
207  $this->gui_obj = new $class_name($this->cur_ref_id);
208  } else {
209  if (!$this->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  }
223  $this->gui_obj->setCreationMode($this->creation_mode);
224  }
225  $this->gui_obj->setAdminMode($this->admin_mode);
226  $tabs_out = true;
227  $ilHelp->setScreenIdComponent(ilObject::_lookupType($this->cur_ref_id, true));
228  $this->showTree();
229 
230  $this->ctrl->setReturn($this, "return");
231  $ret = $this->ctrl->forwardCommand($this->gui_obj);
232  $html = $this->gui_obj->getHTML();
233 
234  if ($html != "") {
235  $this->tpl->setVariable("OBJECTS", $html);
236  }
237  $this->tpl->printToStdout();
238  } else { //
239  $cmd = $this->ctrl->getCmd("forward");
240  $this->$cmd();
241  }
242  break;
243  }
244  }
245 
251  public function forward(): void
252  {
253  if ($this->admin_mode !== "repository") { // settings
254  if ($this->request->getRefId() == USER_FOLDER_ID) {
255  $this->ctrl->setParameter($this, "ref_id", USER_FOLDER_ID);
256  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
257  if (ilObject::_lookupType($this->request->getJumpToUserId()) === "usr") {
258  $this->ctrl->setParameterByClass(
259  "ilobjuserfoldergui",
260  "jmpToUser",
261  $this->request->getJumpToUserId()
262  );
263  $this->ctrl->redirectByClass("ilobjuserfoldergui", "jumpToUser");
264  } else {
265  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
266  }
267  } else {
268  // this code should not be necessary anymore...
269  throw new ilPermissionException("Missing AdmiGUI parameter.");
270 
271  /*
272  $this->ctrl->setParameter($this, "ref_id", SYSTEM_FOLDER_ID);
273  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
274 
275 
276  if ($_GET['fr']) {
277  // Security check: We do only allow relative urls
278  $url_parts = parse_url(base64_decode(rawurldecode($_GET['fr'])));
279  if ($url_parts['http'] || $url_parts['host']) {
280  throw new ilPermissionException($this->lng->txt('permission_denied'));
281  }
282 
283  $fs_gui->setMainFrameSource(
284  base64_decode(rawurldecode($_GET['fr']))
285  );
286  ilUtil::redirect(ILIAS_HTTP_PATH . '/' . base64_decode(rawurldecode($_GET['fr'])));
287  } else {
288  $fs_gui->setMainFrameSource(
289  $this->ctrl->getLinkTargetByClass("ilobjsystemfoldergui", "view")
290  );
291  $this->ctrl->redirectByClass("ilobjsystemfoldergui", "view");
292  }*/
293  }
294  } else {
295  $this->ctrl->setParameter($this, "ref_id", ROOT_FOLDER_ID);
296  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
297  $this->ctrl->redirectByClass("ilobjrootfoldergui", "view");
298  }
299  }
300 
301  public function showTree(): void
302  {
303  global $DIC;
304 
305  if ($this->admin_mode !== "repository") {
306  return;
307  }
308 
309  $DIC->globalScreen()->tool()->context()->current()->addAdditionalData(ilAdminGSToolProvider::SHOW_ADMIN_TREE, true);
310 
311  $exp = new ilAdministrationExplorerGUI(self::class, "showTree");
312  $exp->handleCommand();
313  }
314 
315  // Special jump to plugin slot after ilCtrl has been reloaded
316  public function jumpToPluginSlot(): void
317  {
318  $ilCtrl = $this->ctrl;
319  $ilCtrl->redirectByClass("ilobjcomponentsettingsgui", "listPlugins");
320  }
321 
322  // Jump to node
323  public function jump(): void
324  {
325  $ilCtrl = $this->ctrl;
326  $objDefinition = $this->objDefinition;
327 
328  $ref_id = $this->request->getRefId();
329  $obj_id = ilObject::_lookupObjId($ref_id);
330  $obj_type = ilObject::_lookupType($obj_id);
331  $class_name = $objDefinition->getClassName($obj_type);
332  $class = strtolower("ilObj" . $class_name . "GUI");
333  $ilCtrl->setParameterByClass($class, "ref_id", $ref_id);
334  $ilCtrl->redirectByClass($class, "view");
335  }
336 }
Class ilAdministratioGUI.
readonly ilErrorHandling $error
const ADMIN_MODE_REPOSITORY
$context
Definition: webdav.php:31
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
const USER_FOLDER_ID
Definition: constants.php:33
const ROOT_FOLDER_ID
Definition: constants.php:32
Help GUI class.
isInTree(?int $a_node_id)
get all information of a node.
const SYSTEM_FOLDER_ID
Definition: constants.php:35
static _lookupObjId(int $ref_id)
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
global $DIC
Definition: feed.php:28
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
parses the objects.xml it handles the xml-description of all ilias objects
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
forward()
Forward to class/command.
$ref_id
Definition: ltiauth.php:67
__construct(VocabulariesInterface $vocabularies)
const ADMIN_MODE_SETTINGS
Class ilObjectGUI Basic methods of all Output classes.
getClassName(string $obj_name)
Administration explorer GUI class.
ilObjectDefinition $objDefinition
ilGlobalTemplateInterface $tpl
Error Handling & global info handling.
isPlugin(string $obj_name)
get RBAC status by type returns true if object type is an (activated) plugin type ...
static _lookupType(int $id, bool $reference=false)