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