ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAdministrationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
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 
79  public function __construct()
80  {
82  global $DIC;
83 
84  $this->help = $DIC["ilHelp"];
85  $this->db = $DIC->database();
86  $lng = $DIC->language();
87  $tpl = $DIC->ui()->mainTemplate();
88  $tree = $DIC->repositoryTree();
89  $rbacsystem = $DIC->rbac()->system();
90  $objDefinition = $DIC["objDefinition"];
91  $ilCtrl = $DIC->ctrl();
92 
93  $this->lng = $lng;
94  $this->lng->loadLanguageModule('administration');
95  $this->tpl = $tpl;
96  $this->tree = $tree;
97  $this->rbacsystem = $rbacsystem;
98  $this->objDefinition = $objDefinition;
99  $this->ctrl = $ilCtrl;
100 
101  $context = $DIC->globalScreen()->tool()->context();
102  $context->claim()->administration();
103 
104  $this->request = new AdminGUIRequest(
105  $DIC->http(),
106  $DIC->refinery()
107  );
108 
109  $this->ctrl->saveParameter($this, array("ref_id", "admin_mode"));
110 
111  $this->admin_mode = $this->request->getAdminMode();
112  if ($this->admin_mode !== ilObjectGUI::ADMIN_MODE_REPOSITORY) {
113  $this->admin_mode = ilObjectGUI::ADMIN_MODE_SETTINGS;
114  }
115 
116  $this->ctrl->setReturn($this, "");
117 
118  // determine current ref id and mode
119  $ref_id = $this->request->getRefId();
120  if ($tree->isInTree($ref_id)) {
121  $this->cur_ref_id = $ref_id;
122  } else {
123  throw new ilPermissionException("Invalid ref id.");
124  }
125 
126  $this->requested_obj_id = $this->request->getObjId();
127  }
128 
129 
134  public function executeCommand(): void
135  {
136  $rbacsystem = $this->rbacsystem;
137  $objDefinition = $this->objDefinition;
138  $ilHelp = $this->help;
139  $ilDB = $this->db;
140 
141  // permission checks
142  if (!$rbacsystem->checkAccess("visible", SYSTEM_FOLDER_ID) &&
143  !$rbacsystem->checkAccess("read", SYSTEM_FOLDER_ID)) {
144  throw new ilPermissionException($this->lng->txt('permission_denied'));
145  }
146 
147  // check creation mode
148  // determined by "new_type" parameter
149  $new_type = $this->request->getNewType();
150  if ($new_type) {
151  $this->creation_mode = true;
152  }
153  // determine next class
154  if ($this->creation_mode) {
155  $obj_type = $new_type;
156  $class_name = $this->objDefinition->getClassName($obj_type);
157  $next_class = strtolower("ilObj" . $class_name . "GUI");
158  $this->ctrl->setCmdClass($next_class);
159  }
160 
161  // set next_class directly for page translations
162  // (no cmdNode is given in translation link)
163  if ($this->ctrl->getCmdClass() === "ilobjlanguageextgui") {
164  $next_class = "ilobjlanguageextgui";
165  } else {
166  $next_class = $this->ctrl->getNextClass($this);
167  }
168 
169  if ((
170  $next_class === "iladministrationgui" || $next_class == ""
171  ) && ($this->ctrl->getCmd() === "return")) {
172  // get GUI of current object
173  $obj_type = ilObject::_lookupType($this->cur_ref_id, true);
174  $class_name = $this->objDefinition->getClassName($obj_type);
175  $next_class = strtolower("ilObj" . $class_name . "GUI");
176  $this->ctrl->setCmdClass($next_class);
177  $this->ctrl->setCmd("view");
178  }
179 
180  $cmd = $this->ctrl->getCmd("forward");
181 
182  //echo "<br>cmd:$cmd:nextclass:$next_class:-".$_GET["cmdClass"]."-".$_GET["cmd"]."-";
183  switch ($next_class) {
184  default:
185 
186  // forward all other classes to gui commands
187  if ($next_class != "" && $next_class !== "iladministrationgui") {
188  // check db update
189  $dbupdate = new ilDBUpdate($ilDB);
190  if (!$dbupdate->getDBVersionStatus()) {
191  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("db_need_update"));
192  } elseif ($dbupdate->hotfixAvailable()) {
193  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("db_need_hotfix"));
194  }
195 
196  $class_path = $this->ctrl->lookupClassPath($next_class);
197  if (is_file($class_path)) {
198  require_once $class_path; // note: org unit plugins still need the require
199  }
200  // get gui class instance
201  $class_name = $this->ctrl->getClassForClasspath($class_path);
202  if (($next_class === "ilobjrolegui" || $next_class === "ilobjusergui"
203  || $next_class === "ilobjroletemplategui")) {
204  if ($this->requested_obj_id > 0) {
205  $this->gui_obj = new $class_name(null, $this->requested_obj_id, false, false);
206  $this->gui_obj->setCreationMode(false);
207  } else {
208  $this->gui_obj = new $class_name(null, $this->cur_ref_id, true, false);
209  $this->gui_obj->setCreationMode(true);
210  }
211  } else {
212  if ($objDefinition->isPlugin(ilObject::_lookupType($this->cur_ref_id, true))) {
213  $this->gui_obj = new $class_name($this->cur_ref_id);
214  } else {
215  if (!$this->creation_mode) {
216  if (is_subclass_of($class_name, "ilObject2GUI")) {
217  $this->gui_obj = new $class_name($this->cur_ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
218  } else {
219  $this->gui_obj = new $class_name(null, $this->cur_ref_id, true, false);
220  }
221  } else {
222  if (is_subclass_of($class_name, "ilObject2GUI")) {
223  $this->gui_obj = new $class_name(null, ilObject2GUI::REPOSITORY_NODE_ID, $this->cur_ref_id);
224  } else {
225  $this->gui_obj = new $class_name("", 0, true, false);
226  }
227  }
228  }
229  $this->gui_obj->setCreationMode($this->creation_mode);
230  }
231  $this->gui_obj->setAdminMode($this->admin_mode);
232  $tabs_out = true;
233  $ilHelp->setScreenIdComponent(ilObject::_lookupType($this->cur_ref_id, true));
234  $this->showTree();
235 
236  $this->ctrl->setReturn($this, "return");
237  $ret = $this->ctrl->forwardCommand($this->gui_obj);
238  $html = $this->gui_obj->getHTML();
239 
240  if ($html != "") {
241  $this->tpl->setVariable("OBJECTS", $html);
242  }
243  $this->tpl->printToStdout();
244  } else { //
245  $cmd = $this->ctrl->getCmd("forward");
246  $this->$cmd();
247  }
248  break;
249  }
250  }
251 
257  public function forward(): void
258  {
259  if ($this->admin_mode !== "repository") { // settings
260  if ($this->request->getRefId() == USER_FOLDER_ID) {
261  $this->ctrl->setParameter($this, "ref_id", USER_FOLDER_ID);
262  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
263  if (ilObject::_lookupType($this->request->getJumpToUserId()) === "usr") {
264  $this->ctrl->setParameterByClass(
265  "ilobjuserfoldergui",
266  "jmpToUser",
267  $this->request->getJumpToUserId()
268  );
269  $this->ctrl->redirectByClass("ilobjuserfoldergui", "jumpToUser");
270  } else {
271  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
272  }
273  } else {
274 
275  // this code should not be necessary anymore...
276  throw new ilPermissionException("Missing AdmiGUI parameter.");
277 
278  /*
279  $this->ctrl->setParameter($this, "ref_id", SYSTEM_FOLDER_ID);
280  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
281 
282 
283  if ($_GET['fr']) {
284  // Security check: We do only allow relative urls
285  $url_parts = parse_url(base64_decode(rawurldecode($_GET['fr'])));
286  if ($url_parts['http'] || $url_parts['host']) {
287  throw new ilPermissionException($this->lng->txt('permission_denied'));
288  }
289 
290  $fs_gui->setMainFrameSource(
291  base64_decode(rawurldecode($_GET['fr']))
292  );
293  ilUtil::redirect(ILIAS_HTTP_PATH . '/' . base64_decode(rawurldecode($_GET['fr'])));
294  } else {
295  $fs_gui->setMainFrameSource(
296  $this->ctrl->getLinkTargetByClass("ilobjsystemfoldergui", "view")
297  );
298  $this->ctrl->redirectByClass("ilobjsystemfoldergui", "view");
299  }*/
300  }
301  } else {
302  $this->ctrl->setParameter($this, "ref_id", ROOT_FOLDER_ID);
303  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
304  $this->ctrl->redirectByClass("ilobjrootfoldergui", "view");
305  }
306  }
307 
308  public function showTree(): void
309  {
310  global $DIC;
311 
312  if ($this->admin_mode !== "repository") {
313  return;
314  }
315 
316  $DIC->globalScreen()->tool()->context()->current()->addAdditionalData(ilAdminGSToolProvider::SHOW_ADMIN_TREE, true);
317 
318  $exp = new ilAdministrationExplorerGUI(self::class, "showTree");
319  $exp->handleCommand();
320  }
321 
322  // Special jump to plugin slot after ilCtrl has been reloaded
323  public function jumpToPluginSlot(): void
324  {
325  $ilCtrl = $this->ctrl;
326  $ilCtrl->redirectByClass("ilobjcomponentsettingsgui", "listPlugins");
327  }
328 
329  // Jump to node
330  public function jump(): void
331  {
332  $ilCtrl = $this->ctrl;
333  $objDefinition = $this->objDefinition;
334 
335  $ref_id = $this->request->getRefId();
336  $obj_id = ilObject::_lookupObjId($ref_id);
337  $obj_type = ilObject::_lookupType($obj_id);
338  $class_name = $objDefinition->getClassName($obj_type);
339  $class = strtolower("ilObj" . $class_name . "GUI");
340  $ilCtrl->setParameterByClass($class, "ref_id", $ref_id);
341  $ilCtrl->redirectByClass($class, "view");
342  }
343 }
Class ilAdministratioGUI.
const ADMIN_MODE_REPOSITORY
$context
Definition: webdav.php:29
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
const ADMIN_MODE_SETTINGS
Class ilObjectGUI Basic methods of all Output classes.
getClassName(string $obj_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Administration explorer GUI class.
ilObjectDefinition $objDefinition
ilGlobalTemplateInterface $tpl
__construct(Container $dic, ilPlugin $plugin)
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)