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