ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
40 {
41  var $lng;
42  var $ilias;
43  var $tpl;
44  var $tree;
47  var $cmd;
48  var $mode;
49  var $ctrl;
50 
56  {
57  global $lng, $ilias, $tpl, $tree, $rbacsystem, $objDefinition,
58  $_GET, $ilCtrl, $ilLog, $ilMainMenu;
59 
60  $this->lng =& $lng;
61  $this->lng->loadLanguageModule('administration');
62  $this->ilias =& $ilias;
63  $this->tpl =& $tpl;
64  $this->tree =& $tree;
65  $this->rbacsystem =& $rbacsystem;
66  $this->objDefinition =& $objDefinition;
67 
68  $this->ctrl =& $ilCtrl;
69  $ilMainMenu->setActive("administration");
70 
71  $this->creation_mode = false;
72 
73  $this->ctrl->saveParameter($this, array("ref_id", "admin_mode"));
74 
75  if ($_GET["admin_mode"] != "repository")
76  {
77  $_GET["admin_mode"] = "settings";
78  }
79 
80  if (!ilUtil::isAPICall())
81  $this->ctrl->setReturn($this,"");
82 
83  // determine current ref id and mode
84  if (!empty($_GET["ref_id"]) && $tree->isInTree($_GET["ref_id"]))
85  {
86  $this->cur_ref_id = $_GET["ref_id"];
87  }
88  else
89  {
90  //$this->cur_ref_id = $this->tree->getRootId();
91  $_POST = array();
92  if ($_GET["cmd"] != "getDropDown")
93  {
94  $_GET["cmd"] = "";
95  }
96  }
97  }
98 
99 
103  function &executeCommand()
104  {
105  global $tree, $rbacsystem, $ilias, $lng, $objDefinition, $ilHelp;
106 
107  // permission checks
108  include_once './Services/MainMenu/classes/class.ilMainMenuGUI.php';
110  {
111  $ilias->raiseError("You are not entitled to access this page!",$ilias->error_obj->WARNING);
112  }
113 
114  // check creation mode
115  // determined by "new_type" parameter
116  $new_type = $_POST["new_type"]
117  ? $_POST["new_type"]
118  : $_GET["new_type"];
119  if ($new_type != "" && $this->ctrl->getCmd() == "create")
120  {
121  $this->creation_mode = true;
122  }
123 
124  // determine next class
125  if ($this->creation_mode)
126  {
127  $obj_type = $new_type;
128  $class_name = $this->objDefinition->getClassName($obj_type);
129  $next_class = strtolower("ilObj".$class_name."GUI");
130  $this->ctrl->setCmdClass($next_class);
131  }
132  // set next_class directly for page translations
133  // (no cmdNode is given in translation link)
134  elseif ($this->ctrl->getCmdClass() == "ilobjlanguageextgui")
135  {
136  $next_class = "ilobjlanguageextgui";
137  }
138  else
139  {
140  $next_class = $this->ctrl->getNextClass($this);
141 
142  }
143 
144  if (($next_class == "iladministrationgui" || $next_class == ""
145  ) && ($this->ctrl->getCmd() == "return"))
146  {
147  // get GUI of current object
148  $obj_type = ilObject::_lookupType($this->cur_ref_id,true);
149  $class_name = $this->objDefinition->getClassName($obj_type);
150  $next_class = strtolower("ilObj".$class_name."GUI");
151  $this->ctrl->setCmdClass($next_class);
152  $this->ctrl->setCmd("view");
153  }
154 
155  $cmd = $this->ctrl->getCmd("frameset");
156 
157 //echo "<br>cmd:$cmd:nextclass:$next_class:-".$_GET["cmdClass"]."-".$_GET["cmd"]."-";
158  switch ($next_class)
159  {
160  /*
161  case "ilobjusergui":
162  include_once('./Services/User/classes/class.ilObjUserGUI.php');
163 
164  if(!$_GET['obj_id'])
165  {
166  $this->gui_obj = new ilObjUserGUI("",$_GET['ref_id'],true, false);
167  $this->gui_obj->setCreationMode($this->creation_mode);
168 
169  $this->prepareOutput(false);
170  $ret =& $this->ctrl->forwardCommand($this->gui_obj);
171  }
172  else
173  {
174  $this->gui_obj = new ilObjUserGUI("", $_GET['obj_id'],false, false);
175  $this->gui_obj->setCreationMode($this->creation_mode);
176 
177  $this->prepareOutput(false);
178  $ret =& $this->ctrl->forwardCommand($this->gui_obj);
179  }
180  $this->tpl->show();
181  break;
182  */
183 
184  /*
185  case "ilobjuserfoldergui":
186  include_once('./Services/User/classes/class.ilObjUserFolderGUI.php');
187 
188  $this->gui_obj = new ilObjUserFolderGUI("", $_GET['ref_id'],true, false);
189  $this->gui_obj->setCreationMode($this->creation_mode);
190 
191  $this->prepareOutput(false);
192  $ret =& $this->ctrl->forwardCommand($this->gui_obj);
193  $this->tpl->show();
194  break;*/
195 
196  default:
197 
198  // forward all other classes to gui commands
199  if ($next_class != "" && $next_class != "iladministrationgui")
200  {
201  // check db update
202  include_once ("./Services/Database/classes/class.ilDBUpdate.php");
203  $dbupdate = new ilDBUpdate($this->ilias->db,true);
204  if (!$dbupdate->getDBVersionStatus())
205  {
206  ilUtil::sendFailure($this->lng->txt("db_need_update"));
207  }
208  else if ($dbupdate->hotfixAvailable())
209  {
210  ilUtil::sendFailure($this->lng->txt("db_need_hotfix"));
211  }
212 
213  $class_path = $this->ctrl->lookupClassPath($next_class);
214  // get gui class instance
215  include_once($class_path);
216  $class_name = $this->ctrl->getClassForClasspath($class_path);
217  if (($next_class == "ilobjrolegui" || $next_class == "ilobjusergui"
218  || $next_class == "ilobjroletemplategui"
219  || $next_class == "ilobjstylesheetgui"))
220  {
221  if ($_GET["obj_id"] != "")
222  {
223  $this->gui_obj = new $class_name("", $_GET["obj_id"], false, false);
224  $this->gui_obj->setCreationMode(false);
225  }
226  else
227  {
228  $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
229  $this->gui_obj->setCreationMode(true);
230  }
231  }
232  else
233  {
234  if ($objDefinition->isPlugin(ilObject::_lookupType($this->cur_ref_id,true)))
235  {
236  $this->gui_obj = new $class_name($this->cur_ref_id);
237  }
238  else
239  {
240  if(is_subclass_of($class_name, "ilObject2GUI"))
241  {
242  $this->gui_obj = new $class_name($this->cur_ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
243  }
244  else
245  {
246  $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
247  }
248  }
249  $this->gui_obj->setCreationMode($this->creation_mode);
250  }
251  $tabs_out = ($new_type == "")
252  ? true
253  : false;
254 
255  // set standard screen id
256 // if (strtolower($next_class) == strtolower($this->ctrl->getCmdClass()) ||
257 // "ilpermissiongui" == strtolower($this->ctrl->getCmdClass()))
258 // {
259  $ilHelp->setScreenIdComponent(ilObject::_lookupType($this->cur_ref_id,true));
260 // }
261 
262  $this->ctrl->setReturn($this, "return");
263  $ret =& $this->ctrl->forwardCommand($this->gui_obj);
264  $html = $this->gui_obj->getHTML();
265 
266  if ($html != "")
267  {
268  $this->tpl->setVariable("OBJECTS", $html);
269  }
270  $this->tpl->show();
271  }
272  else //
273  {
274  $cmd = $this->ctrl->getCmd("frameset");
275  $this->$cmd();
276  }
277  break;
278  }
279  }
280 
284  function frameset()
285  {
286  global $tree;
287 
288  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
289  $fs_gui = new ilFramesetGUI();
290 
291  $fs_gui->setMainFrameName("content");
292  $fs_gui->setSideFrameName("tree");
293  $fs_gui->setFrameSetTitle($this->lng->txt("administration"));
294 
295  if ($_GET["admin_mode"] != "repository") // settings
296  {
297  if ($_GET["ref_id"] == USER_FOLDER_ID)
298  {
299  $this->ctrl->setParameter($this, "ref_id", USER_FOLDER_ID);
300  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
301  if (((int) $_GET["jmpToUser"]) > 0 && ilObject::_lookupType((int)$_GET["jmpToUser"]) == "usr")
302  {
303  $this->ctrl->setParameterByClass("ilobjuserfoldergui", "jmpToUser",
304  (int)$_GET["jmpToUser"]);
305  $fs_gui->setMainFrameSource(
306  $this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "jumpToUser"));
307  }
308  else
309  {
310  $fs_gui->setMainFrameSource(
311  $this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "view"));
312  }
313  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
314  }
315  else
316  {
317  $this->ctrl->setParameter($this, "ref_id", SYSTEM_FOLDER_ID);
318  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
319 
320  if($_GET['fr'])
321  {
322  // Security check: We do only allow relative urls
323  $url_parts = parse_url(base64_decode(rawurldecode($_GET['fr'])));
324  if($url_parts['http'] || $url_parts['host'])
325  {
326  global $ilias;
327 
328  $ilias->raiseError($this->lng->txt('permission_denied'), $ilias->error_obj->MESSAGE);
329  }
330 
331  $fs_gui->setMainFrameSource(
332  base64_decode(rawurldecode($_GET['fr'])));
333  ilUtil::redirect(ILIAS_HTTP_PATH.'/'.base64_decode(rawurldecode($_GET['fr'])));
334  }
335  else
336  {
337  $fs_gui->setMainFrameSource(
338  $this->ctrl->getLinkTargetByClass("ilobjsystemfoldergui", "view"));
339  $this->ctrl->redirectByClass("ilobjsystemfoldergui", "view");
340  }
341  }
342  $this->ctrl->setParameter($this, "expand", "1");
343  $fs_gui->setSideFrameSource(
344  $this->ctrl->getLinkTarget($this, "showTree"));
345  }
346  else
347  {
348  $this->ctrl->setParameter($this, "ref_id", ROOT_FOLDER_ID);
349  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
350  $fs_gui->setMainFrameSource(
351  $this->ctrl->getLinkTargetByClass("ilobjrootfoldergui", "view"));
352  $this->ctrl->setParameter($this, "expand", "1");
353  $fs_gui->setSideFrameSource(
354  $this->ctrl->getLinkTarget($this, "showTree"));
355  }
356 
357  $fs_gui->show();
358  exit;
359  }
360 
364  function showTree()
365  {
366  global $tpl, $tree, $lng;
367 
368  require_once "./Services/Administration/classes/class.ilAdministrationExplorer.php";
369 
370  $explorer = new ilAdministrationExplorer("ilias.php?baseClass=ilAdministrationGUI&cmd=view");
371  $explorer->setExpand($_GET["expand"]);
372  $explorer->setExpandTarget($this->ctrl->getLinkTarget($this, "showTree"));
373  $explorer->setUseStandardFrame(true);
374 
375  // hide RecoveryFolder if empty
376  if (!$tree->getChilds(RECOVERY_FOLDER_ID))
377  {
378  $explorer->addFilter("recf");
379  }
380  //$explorer->addFilter("rolf");
381 
382  if ($_GET["admin_mode"] == "settings")
383  {
384  $explorer->addFilter("cat");
385  $explorer->addFilter("catr");
386  }
387  else
388  {
389  $explorer->addFilter("adm");
390  }
391  /*
392  $explorer->addFilter("root");
393  $explorer->addFilter("cat");
394  $explorer->addFilter("grp");
395  $explorer->addFilter("crs");
396  $explorer->addFilter("le");
397  $explorer->addFilter("frm");
398  $explorer->addFilter("lo");
399  $explorer->addFilter("rolf");
400  $explorer->addFilter("adm");
401  $explorer->addFilter("lngf");
402  $explorer->addFilter("usrf");
403  $explorer->addFilter("objf");
404  */
405  //$explorer->setFiltered(false);
406  $explorer->setOutput(0);
407  $output = $explorer->getOutput();
408  $this->ctrl->setParameter($this, "expand", $_GET["expand"]);
409  echo $output;
410  }
411 
415  function jumpToPluginSlot()
416  {
417  global $ilCtrl;
418 
419  $ilCtrl->setParameterByClass("ilobjcomponentsettingsgui", "ctype", $_GET["ctype"]);
420  $ilCtrl->setParameterByClass("ilobjcomponentsettingsgui", "cname", $_GET["cname"]);
421  $ilCtrl->setParameterByClass("ilobjcomponentsettingsgui", "slot_id", $_GET["slot_id"]);
422  $ilCtrl->redirectByClass("ilobjcomponentsettingsgui", "showPluginSlot");
423 
424  }
425 
429  function getDropDown()
430  {
431  global $tree, $rbacsystem, $lng, $ilSetting, $objDefinition;
432 
433  $tpl = new ilTemplate("tpl.admin_drop_down.html", true, true, "Services/Administration");
434 
435  $objects = $tree->getChilds(SYSTEM_FOLDER_ID);
436 
437  foreach($objects as $object)
438  {
439  $new_objects[$object["title"].":".$object["child"]]
440  = $object;
441  }
442 
443  // add entry for switching to repository admin
444  // note: please see showChilds methods which prevents infinite look
445  $new_objects[$lng->txt("repository_admin").":".ROOT_FOLDER_ID] =
446  array(
447  "tree" => 1,
448  "child" => ROOT_FOLDER_ID,
449  "ref_id" => ROOT_FOLDER_ID,
450  "depth" => 3,
451  "type" => "root",
452  "title" => $lng->txt("repository_admin"),
453  "description" => $lng->txt("repository_admin_desc"),
454  "desc" => $lng->txt("repository_admin_desc"),
455  );
456 
457 //$nd = $tree->getNodeData(SYSTEM_FOLDER_ID);
458 //var_dump($nd);
459  $new_objects[$lng->txt("general_settings").":".SYSTEM_FOLDER_ID] =
460  array(
461  "tree" => 1,
462  "child" => SYSTEM_FOLDER_ID,
463  "ref_id" => SYSTEM_FOLDER_ID,
464  "depth" => 2,
465  "type" => "adm",
466  "title" => $lng->txt("general_settings"),
467  );
468  ksort($new_objects);
469 
470  // determine items to show
471  $items = array();
472  foreach ($new_objects as $c)
473  {
474  // check visibility
475  if ($tree->getParentId($c["ref_id"]) == ROOT_FOLDER_ID && $c["type"] != "adm" &&
476  $_GET["admin_mode"] != "repository")
477  {
478  continue;
479  }
480  // these objects may exist due to test cases that didnt clear
481  // data properly
482  if ($c["type"] == "" || $c["type"] == "objf" ||
483  $c["type"] == "xxx")
484  {
485  continue;
486  }
487  $accessible = $rbacsystem->checkAccess('visible,read', $c["ref_id"]);
488  if (!$accessible)
489  {
490  continue;
491  }
492  if ($c["ref_id"] == ROOT_FOLDER_ID &&
493  !$rbacsystem->checkAccess('write', $c["ref_id"]))
494  {
495  continue;
496  }
497  if ($c["type"] == "rolf" && $c["ref_id"] != ROLE_FOLDER_ID)
498  {
499  continue;
500  }
501  $items[] = $c;
502  }
503 
504  $cnt = 0;
505  $titems = array();
506  foreach ($items as $i)
507  {
508  $titems[$i["type"]] = $i;
509  }
510 
511  // admin menu layout
512  $layout = array(
513  1 => array(
514  "basic" =>
515  array("adm", "stys", "adve", "lngf", "cmps", "accs", "hlps", "trac"),
516  "users" =>
517  array("usrf", "rolf", "auth", "ps")
518  ),
519  2 => array(
520  "services" =>
521  array("pdts", "nwss", "tags", "prfa", "skmg", "cals", "mail", "---", "seas",
522  "mds","cert", 'ecss', "pays", "extt")
523  ),
524  3 => array(
525  "objects" =>
526  array("blga", "chta", "facs", "frma", "lrss", "mcts", "mobs", "svyf", "assf", "---",
527  'otpl', "root", "recf")
528  )
529  );
530 
531  // now get all items and groups that are accessible
532  $groups = array();
533  for ($i = 1; $i <= 3; $i++)
534  {
535  $groups[$i] = array();
536  foreach ($layout[$i] as $group => $entries)
537  {
538  $groups[$i][$group] = array();
539  $entries_since_last_sep = false;
540  foreach ($entries as $e)
541  {
542  if ($e == "---" || $titems[$e]["type"] != "")
543  {
544  if ($e == "---" && $entries_since_last_sep)
545  {
546  $groups[$i][$group][] = $e;
547  $entries_since_last_sep = false;
548  }
549  else if ($e != "---")
550  {
551  $groups[$i][$group][] = $e;
552  $entries_since_last_sep = true;
553  }
554  }
555  }
556  }
557  }
558 
559  include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
560  $gl = new ilGroupedListGUI();
561 
562  for ($i = 1; $i <= 3; $i++)
563  {
564  if ($i > 1)
565  {
566  $gl->nextColumn();
567  }
568  foreach ($groups[$i] as $group => $entries)
569  {
570  if (count($entries) > 0)
571  {
572  $gl->addGroupHeader($lng->txt("adm_".$group));
573 
574  foreach ($entries as $e)
575  {
576  if ($e == "---")
577  {
578  $gl->addSeparator();
579  }
580  else
581  {
582  $path = ilUtil::getImagePath("icon_".$titems[$e]["type"]."_s.png");
583  $icon = ($path != "")
584  ? ilUtil::img($path)." "
585  : "";
586 
587  if ($_GET["admin_mode"] == "settings" && $titems[$e]["ref_id"] == ROOT_FOLDER_ID)
588  {
589  $gl->addEntry($icon.$titems[$e]["title"],
590  "ilias.php?baseClass=ilAdministrationGUI&amp;ref_id=".
591  $titems[$e]["ref_id"]."&amp;admin_mode=repository",
592  "_top", "", "", "mm_adm_rep",
593  ilHelp::getMainMenuTooltip("mm_adm_rep"),
594  "bottom center", "top center", false);
595  }
596  else
597  {
598  $gl->addEntry($icon.$titems[$e]["title"],
599  "ilias.php?baseClass=ilAdministrationGUI&amp;ref_id=".
600  $titems[$e]["ref_id"]."&amp;cmd=jump",
601  "_top", "", "", "mm_adm_".$titems[$e]["type"],
602  ilHelp::getMainMenuTooltip("mm_adm_".$titems[$e]["type"]),
603  "bottom center", "top center", false);
604  }
605  }
606  }
607  }
608  }
609  }
610 
611  //$gl->addSeparator();
612 
613  echo $gl->getHTML();
614  exit;
615  }
616 
620  function jump()
621  {
622  global $ilCtrl, $objDefinition;
623 
624  $ref_id = (int) $_GET["ref_id"];
625  $obj_id = ilObject::_lookupObjId($ref_id);
626  $obj_type = ilObject::_lookupType($obj_id);
627  $class_name = $objDefinition->getClassName($obj_type);
628  $class = strtolower("ilObj".$class_name."GUI");
629  $ilCtrl->setParameterByClass($class, "ref_id", $ref_id);
630  $ilCtrl->redirectByClass($class, "view");
631  }
632 }
633 
634 ?>