ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAdministrationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Table/classes/class.ilTableGUI.php");
6 
44 {
48  protected $objDefinition;
49 
53  protected $main_menu;
54 
58  protected $help;
59 
63  protected $error;
64 
68  protected $db;
69 
70  public $lng;
71  public $tpl;
72  public $tree;
73  public $rbacsystem;
74  public $cur_ref_id;
75  public $cmd;
76  public $mode;
77  public $ctrl;
78 
83  public function __construct()
84  {
85  global $DIC;
86 
87  $this->main_menu = $DIC["ilMainMenu"];
88  $this->help = $DIC["ilHelp"];
89  $this->error = $DIC["ilErr"];
90  $this->db = $DIC->database();
91  $lng = $DIC->language();
92  $tpl = $DIC["tpl"];
93  $tree = $DIC->repositoryTree();
94  $rbacsystem = $DIC->rbac()->system();
95  $objDefinition = $DIC["objDefinition"];
96  $ilCtrl = $DIC->ctrl();
97  $ilMainMenu = $DIC["ilMainMenu"];
98 
99  $this->lng = $lng;
100  $this->lng->loadLanguageModule('administration');
101  $this->tpl = $tpl;
102  $this->tree = $tree;
103  $this->rbacsystem = $rbacsystem;
104  $this->objDefinition = $objDefinition;
105  $this->ctrl = $ilCtrl;
106 
107  $ilMainMenu->setActive("administration");
108 
109  $this->creation_mode = false;
110 
111  $this->ctrl->saveParameter($this, array("ref_id", "admin_mode"));
112 
113  if ($_GET["admin_mode"] != "repository") {
114  $_GET["admin_mode"] = "settings";
115  }
116 
117  if (!ilUtil::isAPICall()) {
118  $this->ctrl->setReturn($this, "");
119  }
120 
121  // determine current ref id and mode
122  if (!empty($_GET["ref_id"]) && $tree->isInTree($_GET["ref_id"])) {
123  $this->cur_ref_id = $_GET["ref_id"];
124  } else {
125  //$this->cur_ref_id = $this->tree->getRootId();
126  $_POST = array();
127  if ($_GET["cmd"] != "getDropDown") {
128  $_GET["cmd"] = "";
129  }
130  }
131  }
132 
133 
137  public function executeCommand()
138  {
141  $ilHelp = $this->help;
143  $ilDB = $this->db;
144 
145  // permission checks
146  include_once './Services/MainMenu/classes/class.ilMainMenuGUI.php';
147  if (!$rbacsystem->checkAccess("visible", SYSTEM_FOLDER_ID) &&
148  !$rbacsystem->checkAccess("read", SYSTEM_FOLDER_ID)) {
149  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
150  }
151 
152  // check creation mode
153  // determined by "new_type" parameter
154  $new_type = $_POST["new_type"]
155  ? $_POST["new_type"]
156  : $_GET["new_type"];
157  if ($new_type != "") {
158  $this->creation_mode = true;
159  }
160 
161  // determine next class
162  if ($this->creation_mode) {
163  $obj_type = $new_type;
164  $class_name = $this->objDefinition->getClassName($obj_type);
165  $next_class = strtolower("ilObj" . $class_name . "GUI");
166  $this->ctrl->setCmdClass($next_class);
167  }
168  // set next_class directly for page translations
169  // (no cmdNode is given in translation link)
170  elseif ($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->objDefinition->getClassName($obj_type);
182  $next_class = strtolower("ilObj" . $class_name . "GUI");
183  $this->ctrl->setCmdClass($next_class);
184  $this->ctrl->setCmd("view");
185  }
186 
187  $cmd = $this->ctrl->getCmd("forward");
188 
189  //echo "<br>cmd:$cmd:nextclass:$next_class:-".$_GET["cmdClass"]."-".$_GET["cmd"]."-";
190  switch ($next_class) {
191  default:
192 
193  // forward all other classes to gui commands
194  if ($next_class != "" && $next_class != "iladministrationgui") {
195  // check db update
196  include_once("./Services/Database/classes/class.ilDBUpdate.php");
197  $dbupdate = new ilDBUpdate($ilDB, true);
198  if (!$dbupdate->getDBVersionStatus()) {
199  ilUtil::sendFailure($this->lng->txt("db_need_update"));
200  } elseif ($dbupdate->hotfixAvailable()) {
201  ilUtil::sendFailure($this->lng->txt("db_need_hotfix"));
202  }
203 
204  $class_path = $this->ctrl->lookupClassPath($next_class);
205  // get gui class instance
206  include_once($class_path);
207  $class_name = $this->ctrl->getClassForClasspath($class_path);
208  if (($next_class == "ilobjrolegui" || $next_class == "ilobjusergui"
209  || $next_class == "ilobjroletemplategui")) {
210  if ($_GET["obj_id"] != "") {
211  $this->gui_obj = new $class_name("", $_GET["obj_id"], false, false);
212  $this->gui_obj->setCreationMode(false);
213  } else {
214  $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
215  $this->gui_obj->setCreationMode(true);
216  }
217  } else {
218  if ($objDefinition->isPlugin(ilObject::_lookupType($this->cur_ref_id, true))) {
219  $this->gui_obj = new $class_name($this->cur_ref_id);
220  } else {
221  if (!$this->creation_mode) {
222  if (is_subclass_of($class_name, "ilObject2GUI")) {
223  $this->gui_obj = new $class_name($this->cur_ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
224  } else {
225  $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
226  }
227  } else {
228  if (is_subclass_of($class_name, "ilObject2GUI")) {
229  $this->gui_obj = new $class_name(null, ilObject2GUI::REPOSITORY_NODE_ID, $this->cur_ref_id);
230  } else {
231  $this->gui_obj = new $class_name("", 0, true, false);
232  }
233  }
234  }
235  $this->gui_obj->setCreationMode($this->creation_mode);
236  }
237  $tabs_out = ($new_type == "")
238  ? true
239  : false;
240 
241  // set standard screen id
242  // if (strtolower($next_class) == strtolower($this->ctrl->getCmdClass()) ||
243  // "ilpermissiongui" == strtolower($this->ctrl->getCmdClass()))
244  // {
245  $ilHelp->setScreenIdComponent(ilObject::_lookupType($this->cur_ref_id, true));
246  // }
247  $this->showTree();
248 
249  $this->ctrl->setReturn($this, "return");
250  $ret = $this->ctrl->forwardCommand($this->gui_obj);
251  $html = $this->gui_obj->getHTML();
252 
253  if ($html != "") {
254  $this->tpl->setVariable("OBJECTS", $html);
255  }
256  $this->tpl->show();
257  } else { //
258  $cmd = $this->ctrl->getCmd("forward");
259  $this->$cmd();
260  }
261  break;
262  }
263  }
264 
268  public function forward()
269  {
271 
272  if ($_GET["admin_mode"] != "repository") { // settings
273  if ($_GET["ref_id"] == USER_FOLDER_ID) {
274  $this->ctrl->setParameter($this, "ref_id", USER_FOLDER_ID);
275  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
276  if (((int) $_GET["jmpToUser"]) > 0 && ilObject::_lookupType((int) $_GET["jmpToUser"]) == "usr") {
277  $this->ctrl->setParameterByClass(
278  "ilobjuserfoldergui",
279  "jmpToUser",
280  (int) $_GET["jmpToUser"]
281  );
282  $this->ctrl->redirectByClass("ilobjuserfoldergui", "jumpToUser");
283  } else {
284  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
285  }
286  } else {
287  $this->ctrl->setParameter($this, "ref_id", SYSTEM_FOLDER_ID);
288  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
289 
290  if ($_GET['fr']) {
291  // Security check: We do only allow relative urls
292  $url_parts = parse_url(base64_decode(rawurldecode($_GET['fr'])));
293  if ($url_parts['http'] || $url_parts['host']) {
294  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
295  }
296 
297  $fs_gui->setMainFrameSource(
298  base64_decode(rawurldecode($_GET['fr']))
299  );
300  ilUtil::redirect(ILIAS_HTTP_PATH . '/' . base64_decode(rawurldecode($_GET['fr'])));
301  } else {
302  $fs_gui->setMainFrameSource(
303  $this->ctrl->getLinkTargetByClass("ilobjsystemfoldergui", "view")
304  );
305  $this->ctrl->redirectByClass("ilobjsystemfoldergui", "view");
306  }
307  }
308  } else {
309  $this->ctrl->setParameter($this, "ref_id", ROOT_FOLDER_ID);
310  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
311  $this->ctrl->redirectByClass("ilobjrootfoldergui", "view");
312  }
313  }
314 
318  public function showTree()
319  {
320  $tpl = $this->tpl;
321  $tree = $this->tree;
322  $lng = $this->lng;
323 
324  if ($_GET["admin_mode"] != "repository") {
325  return;
326  }
327 
328  include_once("./Services/Administration/classes/class.ilAdministrationExplorerGUI.php");
329  $exp = new ilAdministrationExplorerGUI($this, "showTree");
330  if (!$exp->handleCommand()) {
331  $tpl->setLeftNavContent($exp->getHTML());
332  }
333  }
334 
338  public function jumpToPluginSlot()
339  {
341 
342  $ilCtrl->setParameterByClass("ilobjcomponentsettingsgui", "ctype", $_GET["ctype"]);
343  $ilCtrl->setParameterByClass("ilobjcomponentsettingsgui", "cname", $_GET["cname"]);
344  $ilCtrl->setParameterByClass("ilobjcomponentsettingsgui", "slot_id", $_GET["slot_id"]);
345 
346  if ($_GET["plugin_id"]) {
347  $ilCtrl->setParameter($this, "plugin_id", $_GET["plugin_id"]);
348  $ilCtrl->redirectByClass("ilobjcomponentsettingsgui", "showPlugin");
349  } else {
350  $ilCtrl->redirectByClass("ilobjcomponentsettingsgui", "listPlugins");
351  }
352  }
353 
357  public function getDropDown()
358  {
359  $tree = $this->tree;
361  $lng = $this->lng;
362 
363  $objects = $tree->getChilds(SYSTEM_FOLDER_ID);
364 
365  foreach ($objects as $object) {
366  $new_objects[$object["title"] . ":" . $object["child"]]
367  = $object;
368  // have to set it manually as translation type of main node cannot be "sys" as this type is a orgu itself.
369  if ($object["type"] == "orgu") {
370  $new_objects[$object["title"] . ":" . $object["child"]]["title"] = $lng->txt("objs_orgu");
371  }
372  }
373 
374  // add entry for switching to repository admin
375  // note: please see showChilds methods which prevents infinite look
376  $new_objects[$lng->txt("repository_admin") . ":" . ROOT_FOLDER_ID] =
377  array(
378  "tree" => 1,
379  "child" => ROOT_FOLDER_ID,
380  "ref_id" => ROOT_FOLDER_ID,
381  "depth" => 3,
382  "type" => "root",
383  "title" => $lng->txt("repository_admin"),
384  "description" => $lng->txt("repository_admin_desc"),
385  "desc" => $lng->txt("repository_admin_desc"),
386  );
387 
388  $new_objects[$lng->txt("general_settings") . ":" . SYSTEM_FOLDER_ID] =
389  array(
390  "tree" => 1,
391  "child" => SYSTEM_FOLDER_ID,
392  "ref_id" => SYSTEM_FOLDER_ID,
393  "depth" => 2,
394  "type" => "adm",
395  "title" => $lng->txt("general_settings"),
396  );
397  ksort($new_objects);
398 
399  // determine items to show
400  $items = array();
401  foreach ($new_objects as $c) {
402  // check visibility
403  if ($tree->getParentId($c["ref_id"]) == ROOT_FOLDER_ID && $c["type"] != "adm" &&
404  $_GET["admin_mode"] != "repository") {
405  continue;
406  }
407  // these objects may exist due to test cases that didnt clear
408  // data properly
409  if ($c["type"] == "" || $c["type"] == "objf" ||
410  $c["type"] == "xxx") {
411  continue;
412  }
413  $accessible = $rbacsystem->checkAccess('visible,read', $c["ref_id"]);
414  if (!$accessible) {
415  continue;
416  }
417  if ($c["ref_id"] == ROOT_FOLDER_ID &&
418  !$rbacsystem->checkAccess('write', $c["ref_id"])) {
419  continue;
420  }
421  if ($c["type"] == "rolf" && $c["ref_id"] != ROLE_FOLDER_ID) {
422  continue;
423  }
424  $items[] = $c;
425  }
426 
427  $titems = array();
428  foreach ($items as $i) {
429  $titems[$i["type"]] = $i;
430  }
431 
432  // admin menu layout
433  $layout = array(
434  1 => array(
435  "basic" =>
436  array("adm", "stys", "adve", "lngf", "hlps", "accs", "cmps", "extt", "wfe"),
437  "user_administration" =>
438  array("usrf", 'tos', "rolf", "orgu", "auth", "ps"),
439  "learning_outcomes" =>
440  array("skmg", "bdga", "cert", "trac")
441  ),
442  2 => array(
443  "user_services" =>
444  array("pdts", "prfa", "nwss", "awra", "cadm", "cals", "mail"),
445  "content_services" =>
446  array("seas", "mds", "tags", "taxs", 'ecss', "ltis", "otpl", "pdfg"),
447  "maintenance" =>
448  array('logs', 'sysc', "recf", "root")
449  ),
450  3 => array(
451  "container" =>
452  array("reps", "crss", "grps", "prgs"),
453  "content_objects" =>
454  array("bibs", "blga", "chta", "excs", "facs", "frma",
455  "lrss", "mcts", "mobs", "svyf", "assf", "wbrs", "wiks")
456  )
457  );
458 
459  // now get all items and groups that are accessible
460  $groups = array();
461  for ($i = 1; $i <= 3; $i++) {
462  $groups[$i] = array();
463  foreach ($layout[$i] as $group => $entries) {
464  $groups[$i][$group] = array();
465  $entries_since_last_sep = false;
466  foreach ($entries as $e) {
467  if ($e == "---" || $titems[$e]["type"] != "") {
468  if ($e == "---" && $entries_since_last_sep) {
469  $groups[$i][$group][] = $e;
470  $entries_since_last_sep = false;
471  } elseif ($e != "---") {
472  $groups[$i][$group][] = $e;
473  $entries_since_last_sep = true;
474  }
475  }
476  }
477  }
478  }
479 
480  include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
481  $gl = new ilGroupedListGUI();
482  $gl->setAsDropDown(true);
483 
484  for ($i = 1; $i <= 3; $i++) {
485  if ($i > 1) {
486  $gl->nextColumn();
487  }
488  foreach ($groups[$i] as $group => $entries) {
489  if (count($entries) > 0) {
490  $gl->addGroupHeader($lng->txt("adm_" . $group));
491 
492  foreach ($entries as $e) {
493  if ($e == "---") {
494  $gl->addSeparator();
495  } else {
496  $path = ilObject::_getIcon("", "tiny", $titems[$e]["type"]);
497  $icon = ($path != "")
498  ? ilUtil::img($path) . " "
499  : "";
500 
501  if ($_GET["admin_mode"] == "settings" && $titems[$e]["ref_id"] == ROOT_FOLDER_ID) {
502  $gl->addEntry(
503  $icon . $titems[$e]["title"],
504  "ilias.php?baseClass=ilAdministrationGUI&ref_id=" .
505  $titems[$e]["ref_id"] . "&admin_mode=repository",
506  "_top",
507  "",
508  "",
509  "mm_adm_rep",
510  ilHelp::getMainMenuTooltip("mm_adm_rep"),
511  "bottom center",
512  "top center",
513  false
514  );
515  } else {
516  $gl->addEntry(
517  $icon . $titems[$e]["title"],
518  "ilias.php?baseClass=ilAdministrationGUI&ref_id=" .
519  $titems[$e]["ref_id"] . "&cmd=jump",
520  "_top",
521  "",
522  "",
523  "mm_adm_" . $titems[$e]["type"],
524  ilHelp::getMainMenuTooltip("mm_adm_" . $titems[$e]["type"]),
525  "bottom center",
526  "top center",
527  false
528  );
529  }
530  }
531  }
532  }
533  }
534  }
535 
536  echo $gl->getHTML();
537  exit;
538  }
539 
543  public function jump()
544  {
547 
548  $ref_id = (int) $_GET["ref_id"];
549  $obj_id = ilObject::_lookupObjId($ref_id);
550  $obj_type = ilObject::_lookupType($obj_id);
551  $class_name = $objDefinition->getClassName($obj_type);
552  $class = strtolower("ilObj" . $class_name . "GUI");
553  $ilCtrl->setParameterByClass($class, "ref_id", $ref_id);
554  $ilCtrl->redirectByClass($class, "view");
555  }
556 }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
Class ilAdministratioGUI.
global $ilErr
Definition: raiseError.php:16
global $DIC
Definition: saml.php:7
jumpToPluginSlot()
Special jump to plugin slot after ilCtrl has been reloaded.
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
forward()
Forward to class/command.
Grouped list GUI class.
static _lookupObjId($a_id)
Database Update class.
Administration explorer GUI class.
static getMainMenuTooltip($a_item_id)
Get main menu tooltip.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
__construct()
Constructor public.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
global $ilDB
$ret
Definition: parser.php:6
$i
Definition: disco.tpl.php:19
const USER_FOLDER_ID
Class ilObjUserFolder.
static redirect($a_script)
$_POST["username"]
$html
Definition: example_001.php:87
static isAPICall()