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