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