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

Generated on Fri Dec 13 2013 11:57:54 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1