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

Generated on Fri Dec 13 2013 10:18:27 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1