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