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