• Main Page
  • Related Pages
  • 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-2001 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 
00033 class ilMainMenuGUI
00034 {
00040         var $ilias;
00041         var $tpl;
00042         var $target;
00043         var $start_template;
00044 
00045 
00051         function ilMainMenuGUI($a_target = "_top", $a_use_start_template = false)
00052         {
00053                 global $ilias;
00054 
00055                 $this->ilias =& $ilias;
00056                 $this->target = $a_target;
00057                 $this->start_template = $a_use_start_template;
00058 
00059         }
00060 
00064         function setTemplate(&$tpl)
00065         {
00066                 $this->tpl =& $tpl;
00067         }
00068 
00072         function getTemplate()
00073         {
00074                 return $this->tpl;
00075         }
00076 
00080         function addMenuBlock($a_var = "CONTENT", $a_block = "navigation")
00081         {
00082                 $this->tpl->addBlockFile($a_var, $a_block, "tpl.main_buttons.html");
00083         }
00084 
00088         function setTemplateVars()
00089         {
00090                 global $rbacsystem, $lng, $ilias;
00091 
00092                 // administration button
00093 
00094                 #if ($rbacsystem->checkAccess("visible,read", SYSTEM_FOLDER_ID))
00095                 if(ilMainMenuGUI::_checkAdministrationPermission())
00096                 {
00097                         $this->tpl->setCurrentBlock("userisadmin");
00098                         $this->tpl->setVariable("IMG_ADMIN", ilUtil::getImagePath("navbar/admin.gif", false));
00099                         $this->tpl->setVariable("IMG_SPACE_ADMIN", ilUtil::getImagePath("spacer.gif", false));
00100                         $this->tpl->setVariable("TXT_ADMINISTRATION", $lng->txt("administration"));
00101                         $this->tpl->setVariable("SCRIPT_ADMIN", $this->getScriptTarget("adm_index.php"));
00102                         $this->tpl->setVariable("TARGET_ADMIN", $this->target);
00103                         $this->tpl->parseCurrentBlock();
00104                 }
00105 
00106                 // mail & desktop button
00107                 if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
00108                 {
00109                         $this->tpl->setCurrentBlock("desktopbutton");
00110                         $this->tpl->setVariable("IMG_DESK", ilUtil::getImagePath("navbar/desk.gif", false));
00111                         $this->tpl->setVariable("IMG_SPACE_DESK", ilUtil::getImagePath("spacer.gif", false));
00112                         $this->tpl->setVariable("TXT_PERSONAL_DESKTOP", $lng->txt("personal_desktop"));
00113                         $this->tpl->setVariable("SCRIPT_DESK", $this->getScriptTarget("usr_personaldesktop.php"));
00114                         $this->tpl->setVariable("TARGET_DESK", $this->target);
00115                         $this->tpl->parseCurrentBlock();
00116 
00117                         include_once "./classes/class.ilMail.php";
00118                         
00119                         $mail =& new ilMail($_SESSION["AccountId"]);
00120 
00121                         if($rbacsystem->checkAccess('mail_visible',$mail->getMailObjectReferenceId()))
00122                         {
00123                                 $this->tpl->setCurrentBlock("mailbutton");
00124                                 $this->tpl->setVariable("IMG_MAIL", ilUtil::getImagePath("navbar/mail.gif", false));
00125                                 $this->tpl->setVariable("IMG_SPACE_MAIL", ilUtil::getImagePath("spacer.gif", false));
00126                                 $this->tpl->setVariable("TXT_MAIL", $lng->txt("mail"));
00127                                 $this->tpl->setVariable("SCRIPT_MAIL", $this->getScriptTarget("mail_frameset.php"));
00128                                 $this->tpl->setVariable("TARGET_MAIL", $this->target);
00129                                 $this->tpl->parseCurrentBlock();
00130                         }
00131                 }
00132 
00133                 $link_dir = (defined("ILIAS_MODULE"))
00134                         ? "../"
00135                         : "";
00136 
00137                 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00138                 {
00139                         if ($this->ilias->getSetting("enable_registration") and AUTH_CURRENT == AUTH_LOCAL)
00140                         {
00141                                 $this->tpl->setCurrentBlock("registration_link");
00142                                 $this->tpl->setVariable("TXT_REGISTER",$lng->txt("register"));
00143                                 $this->tpl->setVariable("LINK_REGISTER", $link_dir."register.php?lang=".$ilias->account->getCurrentLanguage());
00144                                 $this->tpl->parseCurrentBlock();
00145                         }
00146 
00147                         $this->tpl->setCurrentBlock("userisanonymous");
00148                         $this->tpl->setVariable("TXT_NOT_LOGGED_IN",$lng->txt("not_logged_in"));
00149                         $this->tpl->setVariable("TXT_LOGIN",$lng->txt("login"));
00150                         $this->tpl->setVariable("LINK_LOGIN", $link_dir."index.php?cmd=login&lang=".$ilias->account->getCurrentLanguage());
00151                         $this->tpl->parseCurrentBlock();
00152                 }
00153                 else
00154                 {
00155                         $this->tpl->setCurrentBlock("userisloggedin");
00156                         $this->tpl->setVariable("TXT_LOGIN_AS",$lng->txt("login_as"));
00157                         $this->tpl->setVariable("TXT_LOGOUT2",$lng->txt("logout"));
00158                         $this->tpl->setVariable("LINK_LOGOUT2", $link_dir."logout.php?lang=".$ilias->account->getCurrentLanguage());
00159                         $this->tpl->setVariable("USERNAME",$ilias->account->getFullname());
00160                         $this->tpl->parseCurrentBlock();
00161                 }
00162 
00163                 $var2image = array( "IMG_DESK" => "navbar/desk.gif",
00164                                                         "IMG_DESK_O" => "navbar/desk_o.gif",
00165                                                         "IMG_SPACE" => "spacer.gif",
00166                                                         "IMG_CATALOG" => "navbar/course.gif",
00167                                                         "IMG_CATALOG_O" => "navbar/course_o.gif",
00168                                                         "IMG_MAIL" => "navbar/mail.gif",
00169                                                         "IMG_MAIL_O" => "navbar/mail_o.gif",
00170                                                         "IMG_FORUMS" => "navbar/newsgr.gif",
00171                                                         "IMG_FORUMS_O" => "navbar/newsgr_o.gif",
00172                                                         "IMG_SEARCH" => "navbar/search.gif",
00173                                                         "IMG_SEARCH_O" => "navbar/search_o.gif",
00174                                                         "IMG_LITERAT" => "navbar/literat.gif",
00175                                                         "IMG_LITERAT_O" => "navbar/literat_o.gif",
00176                                                         "IMG_GROUPS" => "navbar/groups.gif",
00177                                                         "IMG_GROUPS_O" => "navbar/groups_o.gif",
00178                                                         "IMG_HELP" => "navbar/help.gif",
00179                                                         "IMG_HELP_O" => "navbar/help_o.gif",
00180                                                         "IMG_FEEDB" => "navbar/feedb.gif",
00181                                                         "IMG_FEEDB_O" => "navbar/feedb_o.gif",
00182                                                         "IMG_ADMIN" => "navbar/admin.gif",
00183                                                         "IMG_ADMIN_O" => "navbar/admin_o.gif",
00184                                                         "IMG_DP" => "navbar/termin.gif",
00185                                                         "IMG_DP_O" => "navbar/termin_o.gif",
00186                                                         "IMG_LOGOUT" => "navbar/logout.gif",
00187                                                         "IMG_LOGOUT_O" => "navbar/logout_o.gif",
00188                                                         "IMG_ILIAS" => "navbar/ilias.gif");
00189 
00190                 // temporary disable calendar
00191                 unset($var2image["IMG_DP"]);
00192                 unset($var2image["IMG_DP_O"]);
00193 
00194                 foreach ($var2image as $var => $im)
00195                 {
00196                         $this->tpl->setVariable($var, ilUtil::getImagePath($im, false));
00197                 }
00198 
00199                 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00200                 $this->tpl->setVariable("JS_BUTTONS", ilUtil::getJSPath("buttons.js"));
00201 
00202                 // set target scripts
00203                 $scripts = array (      "SCRIPT_COURSE" => "lo_list.php",
00204                                                         "SCRIPT_CATALOG" => "repository.php?cmd=frameset&getlast=true",
00205                                                         "SCRIPT_SEARCH" => "search.php",
00206                                                         //"SCRIPT_LITERAT"=> "literature.php",
00207                                                         "SCRIPT_FORUMS" => "forums.php",
00208                                                         "SCRIPT_GROUPS" => "grp_list.php",
00209                                                         "SCRIPT_FEEDB"  => "feedback.php",
00210                                                         "SCRIPT_LOGOUT" => "logout.php" );
00211 
00212                 foreach ($scripts as $var => $script)
00213                 {
00214                         $this->tpl->setVariable($var, $this->getScriptTarget($script));
00215                 }
00216 
00217                 // set tooltip texts
00218                 $this->tpl->setVariable("TXT_CATALOG", $lng->txt("repository"));
00219                 $this->tpl->setVariable("TXT_LO_OVERVIEW", $lng->txt("lo_overview"));
00220                 $this->tpl->setVariable("TXT_BOOKMARKS", $lng->txt("bookmarks"));
00221                 $this->tpl->setVariable("TXT_SEARCH", $lng->txt("search"));
00222                 //$this->tpl->setVariable("TXT_LITERATURE", $lng->txt("literature"));
00223                 $this->tpl->setVariable("TXT_FORUMS", $lng->txt("forums"));
00224                 $this->tpl->setVariable("TXT_GROUPS", $lng->txt("groups"));
00225                 $this->tpl->setVariable("TXT_HELP", $lng->txt("help"));
00226                 $this->tpl->setVariable("TXT_FEEDBACK", $lng->txt("feedback"));
00227                 $this->tpl->setVariable("TXT_LOGOUT", $lng->txt("logout"));
00228 
00229                 // temporary disable dateplaner
00230                 //$this->tpl->setVariable("TXT_DP",  $lng->txt("dateplaner"));
00231 
00232                 // set target frame
00233                 $this->tpl->setVariable("TARGET", $this->target);
00234 
00235                 $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.png"));
00236                 $this->tpl->setVariable("HEADER_BG_IMAGE", ilUtil::getImagePath("HeaderBackground.gif"));
00237                 include_once("classes/class.ilObjSystemFolder.php");
00238                 $this->tpl->setVariable("TXT_HEADER_TITLE", ilObjSystemFolder::_getHeaderTitle());
00239 
00240                 // set link to return to desktop, not depending on a specific position in the hierarchy
00241                 $this->tpl->setVariable("SCRIPT_START", $this->getScriptTarget("start.php"));
00242 
00243                 $this->tpl->parseCurrentBlock();
00244         }
00245 
00249         function getScriptTarget($a_script)
00250         {
00251                 global $ilias;
00252 
00253                 $script = "./".$a_script;
00254 
00255                 if ($this->start_template == true)
00256                 {
00257                         if(is_file("./templates/".$ilias->account->skin."/tpl.start.html"))
00258                         {
00259                                 $script = "./start.php?script=".rawurlencode($script);
00260                         }
00261                 }
00262                 if (defined("ILIAS_MODULE"))
00263                 {
00264                         $script = ".".$script;
00265                 }
00266                 return $script;
00267         }
00268         // STATIC
00269         function _checkAdministrationPermission()
00270         {
00271                 global $rbacsystem;
00272 
00273                 if($rbacsystem->checkAccess("visible,read", SYSTEM_FOLDER_ID))
00274                 {
00275                         return true;
00276                 }
00277                 // Allow all local admins to use the administration
00278                 return count(ilUtil::getObjectsByOperations('cat','cat_administrate_users')) ? true : false;
00279         }
00280 }
00281 ?>

Generated on Fri Dec 13 2013 09:06:34 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1