• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilMainMenuGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00032 class ilMainMenuGUI
00033 {
00039         var $ilias;
00040         var $tpl;
00041         var $target;
00042         var $start_template;
00043 
00044 
00050         function ilMainMenuGUI($a_target = "_top", $a_use_start_template = false)
00051         {
00052                 global $ilias;
00053                 
00054                 
00055                 $this->tpl = new ilTemplate("tpl.main_buttons.html", true, true);
00056                 $this->ilias =& $ilias;
00057                 $this->target = $a_target;
00058                 $this->start_template = $a_use_start_template;
00059                 $this->small = false;
00060         }
00061         
00062         function setSmallMode($a_small)
00063         {
00064                 $this->small = $a_small;
00065         }
00066         
00070         function setActive($a_active)
00071         {
00072                 $this->active = $a_active;
00073         }
00074 
00078         function setTemplate(&$tpl)
00079         {
00080                 echo "ilMainMenu->setTemplate is deprecated. Use getHTML instead.";
00081                 return;
00082                 $this->tpl =& $tpl;
00083         }
00084 
00088         function getTemplate()
00089         {
00090                 echo "ilMainMenu->getTemplate is deprecated. Use getHTML instead.";
00091                 return;
00092                 return $this->tpl;
00093         }
00094 
00098         function addMenuBlock($a_var = "CONTENT", $a_block = "navigation")
00099         {
00100                 echo "ilMainMenu->addMenuBlick is deprecated. Use getHTML instead.";
00101                 return;
00102                 $this->tpl->addBlockFile($a_var, $a_block, "tpl.main_buttons.html");
00103         }
00104 
00108         function setTemplateVars()
00109         {
00110                 global $rbacsystem, $lng, $ilias, $tree;
00111 
00112                 // administration button
00113 
00114                 #if ($rbacsystem->checkAccess("visible,read", SYSTEM_FOLDER_ID))
00115                 if(ilMainMenuGUI::_checkAdministrationPermission())
00116                 {
00117                         $this->tpl->setCurrentBlock("userisadmin");
00118                         $this->tpl->setVariable("IMG_ADMIN", ilUtil::getImagePath("navbar/admin.gif", false));
00119                         $this->tpl->setVariable("IMG_SPACE_ADMIN", ilUtil::getImagePath("spacer.gif", false));
00120                         $this->tpl->setVariable("TXT_ADMINISTRATION", $lng->txt("administration"));
00121                         $this->tpl->setVariable("SCRIPT_ADMIN", $this->getScriptTarget("ilias.php?baseClass=ilAdministrationGUI"));
00122                         $this->tpl->setVariable("TARGET_ADMIN", $this->target);
00123                         if ($this->active == "administration")
00124                         {
00125                                 $this->tpl->setVariable("MM_CLASS", "MMActive");
00126                         }
00127                         else
00128                         {
00129                                 $this->tpl->setVariable("MM_CLASS", "MMInactive");
00130                         }
00131                         $this->tpl->parseCurrentBlock();
00132                 }
00133 
00134                 include_once 'Services/Search/classes/class.ilSearchSettings.php';
00135                 if($rbacsystem->checkAccess('search',ilSearchSettings::_getSearchSettingRefId()))
00136                 {
00137                         $this->tpl->setCurrentBlock("searchbutton");
00138                         $this->tpl->setVariable("SCRIPT_SEARCH",$this->getScriptTarget('search.php'));
00139                         #$this->tpl->setVariable("SCRIPT_SEARCH",$this->getScriptTarget('search_new.php'));
00140                         $this->tpl->setVariable("TARGET_SEARCH",$this->target);
00141                         $this->tpl->setVariable("TXT_SEARCH", $lng->txt("search"));
00142                         if ($this->active == "search")
00143                         {
00144                                 $this->tpl->setVariable("MM_CLASS", "MMActive");
00145                         }
00146                         else
00147                         {
00148                                 $this->tpl->setVariable("MM_CLASS", "MMInactive");
00149                         }
00150                         $this->tpl->parseCurrentBlock();
00151                 }
00152 
00153                 // help button
00154                 //$this->tpl->setCurrentBlock("userhelp");
00155                 //$this->tpl->setVariable("TXT_HELP", $lng->txt("help"));
00156                 //$this->tpl->setVariable("SCRIPT_HELP", "ilias.php?baseClass=ilHelpGUI");
00157                 //$this->tpl->setVariable("TARGET_HELP", "ilias_help");
00158                 //$this->tpl->parseCurrentBlock();
00159 
00160                 $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
00161                 
00162                 // mail & desktop button
00163                 if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
00164                 {
00165                         $this->tpl->setCurrentBlock("desktopbutton");
00166                         $this->tpl->setVariable("IMG_DESK", ilUtil::getImagePath("navbar/desk.gif", false));
00167                         $this->tpl->setVariable("IMG_SPACE_DESK", ilUtil::getImagePath("spacer.gif", false));
00168                         $this->tpl->setVariable("TXT_PERSONAL_DESKTOP", $lng->txt("personal_desktop"));
00169                         $this->tpl->setVariable("SCRIPT_DESK", $this->getScriptTarget("ilias.php?baseClass=ilPersonalDesktopGUI&PDHistory=1"));
00170                         $this->tpl->setVariable("TARGET_DESK", $this->target);
00171                         if ($this->active == "desktop")
00172                         {
00173                                 $this->tpl->setVariable("MM_CLASS", "MMActive");
00174                         }
00175                         else
00176                         {
00177                                 $this->tpl->setVariable("MM_CLASS", "MMInactive");
00178                         }
00179                         $this->tpl->parseCurrentBlock();
00180 
00181                         include_once "./classes/class.ilMail.php";
00182                         
00183                         $mail =& new ilMail($_SESSION["AccountId"]);
00184 
00185                         if($rbacsystem->checkAccess('mail_visible',$mail->getMailObjectReferenceId()))
00186                         {
00187                                 $link = "mail_frameset.php";
00188                                 if ($mail_id = ilMailbox::hasNewMail($_SESSION["AccountId"]))
00189                                 {
00190                                         $mbox = new ilMailbox($_SESSION["AccountId"]);
00191                                         $mail =& new ilMail($_SESSION['AccountId']);
00192                                         $folder_id = $mbox->getInboxFolder();
00193                                 
00194                                         //$link = "mail_frameset.php?target=".
00195                                         //      htmlentities(urlencode("mail_read.php?mobj_id=".
00196                                         //      $folder_id."&mail_id=".$mail_id));
00197                                         $add = " ".sprintf($lng->txt("cnt_new"),
00198                                                 ilMailbox::_countNewMails($_SESSION["AccountId"]));
00199                                 }
00200                                 
00201                                 $this->tpl->setCurrentBlock("mailbutton");
00202                                 $this->tpl->setVariable("IMG_MAIL", ilUtil::getImagePath("navbar/mail.gif", false));
00203                                 $this->tpl->setVariable("IMG_SPACE_MAIL", ilUtil::getImagePath("spacer.gif", false));
00204                                 $this->tpl->setVariable("TXT_MAIL", $lng->txt("mail").$add);
00205                                 $this->tpl->setVariable("SCRIPT_MAIL", $this->getScriptTarget($link));
00206                                 $this->tpl->setVariable("TARGET_MAIL", $this->target);
00207                                 if ($this->active == "mail")
00208                                 {
00209                                         $this->tpl->setVariable("MM_CLASS", "MMActive");
00210                                 }
00211                                 else
00212                                 {
00213                                         $this->tpl->setVariable("MM_CLASS", "MMInactive");
00214                                 }
00215                                 $this->tpl->parseCurrentBlock();
00216                         }
00217                 }
00218 
00219                 // repository link
00220                 $this->tpl->setCurrentBlock("rep_button");
00221                 $this->tpl->setVariable("SCRIPT_CATALOG",
00222                         $this->getScriptTarget("repository.php?cmd=frameset&getlast=true"));
00223                 $this->tpl->setVariable("TXT_CATALOG", $lng->txt("repository"));
00224                 if ($this->active == "repository" || $this->active == "")
00225                 {
00226                         $this->tpl->setVariable("MM_CLASS", "MMActive");
00227                 }
00228                 else
00229                 {
00230                         $this->tpl->setVariable("MM_CLASS", "MMInactive");
00231                 }
00232                 // set target frame
00233                 $this->tpl->setVariable("TARGET", $this->target);
00234                 $this->tpl->parseCurrentBlock();
00235                 
00236 
00237                 $link_dir = (defined("ILIAS_MODULE"))
00238                         ? "../"
00239                         : "";
00240 
00241                 if (!$this->small)
00242                 {
00243         
00244                         // login stuff
00245                         if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00246                         {
00247                                 include_once 'Services/Registration/classes/class.ilRegistrationSettingsGUI.php';
00248                                 if (ilRegistrationSettings::_lookupRegistrationType() != IL_REG_DISABLED)
00249                                 {
00250                                         $this->tpl->setCurrentBlock("registration_link");
00251                                         $this->tpl->setVariable("TXT_REGISTER",$lng->txt("register"));
00252                                         $this->tpl->setVariable("LINK_REGISTER", $link_dir."register.php?client_id=".rawurlencode(CLIENT_ID)."&lang=".$ilias->account->getCurrentLanguage());
00253                                         $this->tpl->parseCurrentBlock();
00254                                 }
00255         
00256                                 $languages = $lng->getInstalledLanguages();
00257                                 
00258                                 foreach ($languages as $lang_key)
00259                                 {
00260                                         $this->tpl->setCurrentBlock("languages");
00261                                         $this->tpl->setVariable("LANG_KEY", $lang_key);
00262                                         $this->tpl->setVariable("LANG_NAME",
00263                                                 ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key));
00264                                         $this->tpl->parseCurrentBlock();
00265                                 }
00266         
00267                                 $this->tpl->setVariable("TXT_OK", $lng->txt("ok"));
00268                                 $this->tpl->setVariable("LANG_FORM_ACTION", "repository.php?ref_id=".$_GET["ref_id"]);
00269                                 $this->tpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
00270         
00271                                 $this->tpl->setCurrentBlock("userisanonymous");
00272                                 $this->tpl->setVariable("TXT_NOT_LOGGED_IN",$lng->txt("not_logged_in"));
00273                                 $this->tpl->setVariable("TXT_LOGIN",$lng->txt("log_in"));
00274                                 
00275                                 $target_str = "";
00276                                 if ($_GET["ref_id"] != "")
00277                                 {
00278                                         if ($tree->isInTree($_GET["ref_id"]) && $_GET["ref_id"] != $tree->getRootId())
00279                                         {
00280                                                 $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
00281                                                 $type = ilObject::_lookupType($obj_id);
00282                                                 $target_str = $type."_".$_GET["ref_id"];
00283                                         }
00284                                 }
00285                                 $this->tpl->setVariable("LINK_LOGIN",
00286                                         $link_dir."login.php?target=".$target_str."&client_id=".rawurlencode(CLIENT_ID)."&cmd=force_login&lang=".$ilias->account->getCurrentLanguage());
00287                                 $this->tpl->parseCurrentBlock();
00288                         }
00289                         else
00290                         {
00291                                 $this->tpl->setCurrentBlock("userisloggedin");
00292                                 $this->tpl->setVariable("TXT_LOGIN_AS",$lng->txt("login_as"));
00293                                 $this->tpl->setVariable("TXT_LOGOUT2",$lng->txt("logout"));
00294                                 $this->tpl->setVariable("LINK_LOGOUT2", $link_dir."logout.php?lang=".$ilias->account->getCurrentLanguage());
00295                                 $this->tpl->setVariable("USERNAME",$ilias->account->getFullname());
00296                                 $this->tpl->parseCurrentBlock();
00297                         }
00298         
00299         
00300                         $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00301                         //$this->tpl->setVariable("JS_BUTTONS", ilUtil::getJSPath("buttons.js"));
00302         
00303                         $this->tpl->setVariable("TXT_LOGOUT", $lng->txt("logout"));
00304         
00305                         $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.png"));
00306                         $this->tpl->setVariable("HEADER_BG_IMAGE", ilUtil::getImagePath("HeaderBackground.gif"));
00307                         include_once("classes/class.ilObjSystemFolder.php");
00308                         $this->tpl->setVariable("TXT_HEADER_TITLE", ilObjSystemFolder::_getHeaderTitle());
00309         
00310                         // set link to return to desktop, not depending on a specific position in the hierarchy
00311                         //$this->tpl->setVariable("SCRIPT_START", $this->getScriptTarget("start.php"));
00312                 }
00313 
00314                 $this->tpl->parseCurrentBlock();
00315         }
00316 
00320         function getScriptTarget($a_script)
00321         {
00322                 global $ilias;
00323 
00324                 $script = "./".$a_script;
00325 
00326                 //if ($this->start_template == true)
00327                 //{
00328                         //if(is_file("./templates/".$ilias->account->skin."/tpl.start.html"))
00329                         //{
00330         //                      $script = "./start.php?script=".rawurlencode($script);
00331                         //}
00332                 //}
00333                 if (defined("ILIAS_MODULE"))
00334                 {
00335                         $script = ".".$script;
00336                 }
00337                 return $script;
00338         }
00339         // STATIC
00340         function _checkAdministrationPermission()
00341         {
00342                 global $rbacsystem;
00343 
00344                 if($rbacsystem->checkAccess("visible,read", SYSTEM_FOLDER_ID))
00345                 {
00346                         return true;
00347                 }
00348                 return false;
00349                 // Allow all local admins to use the administration
00350                 return count(ilUtil::_getObjectsByOperations('cat','cat_administrate_users')) ? true : false;
00351         }
00352         
00353         function getHTML()
00354         {
00355                 $this->setTemplateVars();
00356                 return $this->tpl->get();
00357         }
00358 }
00359 ?>

Generated on Fri Dec 13 2013 13:52:07 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1