/**
  * desc
  *
  * @param
  * @return
  */
 function renderMainMenuListEntries($a_tpl, $a_call_get = true)
 {
     global $rbacsystem, $lng, $ilias, $tree, $ilUser, $ilSetting, $ilAccess;
     // personal desktop
     if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID) {
         $this->renderEntry($a_tpl, "desktop", $lng->txt("personal_desktop"), "#");
     }
     // repository
     if ($ilAccess->checkAccess('visible', '', ROOT_FOLDER_ID)) {
         include_once './Services/Link/classes/class.ilLink.php';
         $nd = $tree->getNodeData(ROOT_FOLDER_ID);
         $title = $nd["title"];
         if ($title == "ILIAS") {
             $title = $lng->txt("repository");
         }
         if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID || IS_PAYMENT_ENABLED) {
             $this->renderEntry($a_tpl, "repository", $title, "#");
         }
     }
     // webshop
     if (IS_PAYMENT_ENABLED) {
         $title = $lng->txt("shop");
         $this->renderEntry($a_tpl, "shop", $title, "#");
     }
     // administration
     if (ilMainMenuGUI::_checkAdministrationPermission()) {
         $this->renderDropDown($a_tpl, "administration");
     }
     if ($a_call_get) {
         return $a_tpl->get();
     }
     return "";
 }
 /**
  * execute command
  */
 function &executeCommand()
 {
     global $tree, $rbacsystem, $ilias, $lng, $objDefinition, $ilHelp;
     // permission checks
     include_once './Services/MainMenu/classes/class.ilMainMenuGUI.php';
     if (!ilMainMenuGUI::_checkAdministrationPermission()) {
         $ilias->raiseError($this->lng->txt('permission_denied'), $ilias->error_obj->WARNING);
     }
     // check creation mode
     // determined by "new_type" parameter
     $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
     if ($new_type != "" && $this->ctrl->getCmd() == "create") {
         $this->creation_mode = true;
     }
     // determine next class
     if ($this->creation_mode) {
         $obj_type = $new_type;
         $class_name = $this->objDefinition->getClassName($obj_type);
         $next_class = strtolower("ilObj" . $class_name . "GUI");
         $this->ctrl->setCmdClass($next_class);
     } elseif ($this->ctrl->getCmdClass() == "ilobjlanguageextgui") {
         $next_class = "ilobjlanguageextgui";
     } else {
         $next_class = $this->ctrl->getNextClass($this);
     }
     if (($next_class == "iladministrationgui" || $next_class == "") && $this->ctrl->getCmd() == "return") {
         // get GUI of current object
         $obj_type = ilObject::_lookupType($this->cur_ref_id, true);
         $class_name = $this->objDefinition->getClassName($obj_type);
         $next_class = strtolower("ilObj" . $class_name . "GUI");
         $this->ctrl->setCmdClass($next_class);
         $this->ctrl->setCmd("view");
     }
     $cmd = $this->ctrl->getCmd("forward");
     //echo "<br>cmd:$cmd:nextclass:$next_class:-".$_GET["cmdClass"]."-".$_GET["cmd"]."-";
     switch ($next_class) {
         default:
             // forward all other classes to gui commands
             if ($next_class != "" && $next_class != "iladministrationgui") {
                 // check db update
                 include_once "./Services/Database/classes/class.ilDBUpdate.php";
                 $dbupdate = new ilDBUpdate($this->ilias->db, true);
                 if (!$dbupdate->getDBVersionStatus()) {
                     ilUtil::sendFailure($this->lng->txt("db_need_update"));
                 } else {
                     if ($dbupdate->hotfixAvailable()) {
                         ilUtil::sendFailure($this->lng->txt("db_need_hotfix"));
                     }
                 }
                 $class_path = $this->ctrl->lookupClassPath($next_class);
                 // get gui class instance
                 include_once $class_path;
                 $class_name = $this->ctrl->getClassForClasspath($class_path);
                 if ($next_class == "ilobjrolegui" || $next_class == "ilobjusergui" || $next_class == "ilobjroletemplategui" || $next_class == "ilobjstylesheetgui") {
                     if ($_GET["obj_id"] != "") {
                         $this->gui_obj = new $class_name("", $_GET["obj_id"], false, false);
                         $this->gui_obj->setCreationMode(false);
                     } else {
                         $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
                         $this->gui_obj->setCreationMode(true);
                     }
                 } else {
                     if ($objDefinition->isPlugin(ilObject::_lookupType($this->cur_ref_id, true))) {
                         $this->gui_obj = new $class_name($this->cur_ref_id);
                     } else {
                         if (is_subclass_of($class_name, "ilObject2GUI")) {
                             $this->gui_obj = new $class_name($this->cur_ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
                         } else {
                             $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
                         }
                     }
                     $this->gui_obj->setCreationMode($this->creation_mode);
                 }
                 $tabs_out = $new_type == "" ? true : false;
                 // set standard screen id
                 //					if (strtolower($next_class) == strtolower($this->ctrl->getCmdClass()) ||
                 //						"ilpermissiongui" == strtolower($this->ctrl->getCmdClass()))
                 //					{
                 $ilHelp->setScreenIdComponent(ilObject::_lookupType($this->cur_ref_id, true));
                 //					}
                 $this->showTree();
                 $this->ctrl->setReturn($this, "return");
                 $ret = $this->ctrl->forwardCommand($this->gui_obj);
                 $html = $this->gui_obj->getHTML();
                 if ($html != "") {
                     $this->tpl->setVariable("OBJECTS", $html);
                 }
                 $this->tpl->show();
             } else {
                 $cmd = $this->ctrl->getCmd("forward");
                 $this->{$cmd}();
             }
             break;
     }
 }
 /**
  * desc
  *
  * @param
  * @return
  */
 function renderMainMenuListEntries($a_tpl, $a_call_get = true)
 {
     global $rbacsystem, $lng, $ilias, $tree, $ilUser, $ilSetting, $ilAccess;
     // personal desktop
     if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID) {
         /*$this->renderEntry($a_tpl, "desktop",
         		$lng->txt("personal_desktop"),
         		$this->getScriptTarget("ilias.php?baseClass=ilPersonalDesktopGUI"),
         		$this->target);*/
         //			$this->renderDropDown($a_tpl, "desktop");
         $this->renderEntry($a_tpl, "desktop", $lng->txt("personal_desktop"), "#");
         include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
         $ov = new ilOverlayGUI("mm_desk_ov");
         $ov->setTrigger("mm_desk_tr");
         $ov->setAnchor("mm_desk_tr");
         $ov->setAutoHide(false);
         $ov->add();
     }
     // repository
     if ($ilAccess->checkAccess('visible', '', ROOT_FOLDER_ID)) {
         include_once './Services/Link/classes/class.ilLink.php';
         $nd = $tree->getNodeData(ROOT_FOLDER_ID);
         $title = $nd["title"];
         if ($title == "ILIAS") {
             $title = $lng->txt("repository");
         }
         //$this->renderEntry($a_tpl, "repository",
         //	$title,
         //	ilLink::_getStaticLink(1,'root',true),
         //	$this->target);
         if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID || IS_PAYMENT_ENABLED) {
             $this->renderEntry($a_tpl, "repository", $title, "#");
             include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
             $ov = new ilOverlayGUI("mm_rep_ov");
             $ov->setTrigger("mm_rep_tr");
             $ov->setAnchor("mm_rep_tr");
             $ov->setAutoHide(false);
             $ov->add();
         }
     }
     // search
     include_once 'Services/Search/classes/class.ilSearchSettings.php';
     if ($rbacsystem->checkAccess('search', ilSearchSettings::_getSearchSettingRefId())) {
         /*			$this->renderEntry($a_tpl, "search",
         				$lng->txt("search"),
         				$this->getScriptTarget('ilias.php?baseClass=ilSearchController'),
         				$this->target); */
     }
     // webshop
     if (IS_PAYMENT_ENABLED) {
         $title = $lng->txt("shop");
         $this->renderEntry($a_tpl, "shop", $title, "#");
         include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
         $ov = new ilOverlayGUI("mm_shop_ov");
         $ov->setTrigger("mm_shop_tr");
         $ov->setAnchor("mm_shop_tr");
         $ov->setAutoHide(false);
         $ov->add();
     }
     // administration
     if (ilMainMenuGUI::_checkAdministrationPermission()) {
         //$this->renderEntry($a_tpl, "administration",
         //	$lng->txt("administration"),
         //	$this->getScriptTarget("ilias.php?baseClass=ilAdministrationGUI"),
         //	$this->target);
         $this->renderDropDown($a_tpl, "administration");
     }
     // navigation history
     /*		require_once("Services/Navigation/classes/class.ilNavigationHistoryGUI.php");
     		$nav_hist = new ilNavigationHistoryGUI();
     		$nav_html = $nav_hist->getHTML();
     		if ($nav_html != "")
     		{
     
     			$a_tpl->setCurrentBlock("nav_history");
     			$a_tpl->setVariable("TXT_LAST_VISITED", $lng->txt("last_visited"));
     			$a_tpl->setVariable("NAVIGATION_HISTORY", $nav_html);
     			$a_tpl->parseCurrentBlock();
     		}*/
     if ($a_call_get) {
         return $a_tpl->get();
     }
     return "";
 }
 /**
  * Create media object from upload directory
  */
 function createMediaFromUploadDir()
 {
     $mset = new ilSetting("mobs");
     $upload_dir = trim($mset->get("upload_dir"));
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     if (is_array($_POST["file"]) && ilMainMenuGUI::_checkAdministrationPermission()) {
         foreach ($_POST["file"] as $f) {
             $f = str_replace("..", "", $f);
             $fullpath = $upload_dir . "/" . $f;
             $mob = new ilObjMediaObject();
             $mob->setTitle(basename($fullpath));
             $mob->setDescription("");
             $mob->create();
             // determine and create mob directory, move uploaded file to directory
             //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
             $mob->createDirectory();
             $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
             $media_item = new ilMediaItem();
             $mob->addMediaItem($media_item);
             $media_item->setPurpose("Standard");
             $file = $mob_dir . "/" . basename($fullpath);
             ilUtil::moveUploadedFile($fullpath, basename($fullpath), $file, false, $_POST["action"]);
             // get mime type
             $format = ilObjMediaObject::getMimeType($file);
             $location = basename($fullpath);
             // set real meta and object data
             $media_item->setFormat($format);
             $media_item->setLocation($location);
             $media_item->setLocationType("LocalFile");
             $mob->setDescription($format);
             // determine width and height of known image types
             $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format, "File", $mob_dir . "/" . $location, $media_item->getLocation(), true, true, "", "");
             $media_item->setWidth($wh["width"]);
             $media_item->setHeight($wh["height"]);
             if ($wh["info"] != "") {
                 //				ilUtil::sendInfo($wh["info"], true);
             }
             $media_item->setHAlign("Left");
             ilUtil::renameExecutables($mob_dir);
             $mob->update();
             // put it into current folder
             $mep_item = new ilMediaPoolItem();
             $mep_item->setTitle($mob->getTitle());
             $mep_item->setType("mob");
             $mep_item->setForeignId($mob->getId());
             $mep_item->create();
             $tree = $this->object->getTree();
             $parent = $_GET["mepitem_id"] == "" ? $tree->getRootId() : $_GET["mepitem_id"];
             $tree->insertNode($mep_item->getId(), $parent);
         }
     }
     ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" . $_GET["ref_id"] . "&mepitem_id=" . $_GET["mepitem_id"]);
 }