00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031 class ilMainMenuGUI
00032 {
00038 var $ilias;
00039 var $tpl;
00040 var $target;
00041 var $start_template;
00042
00043
00049 function ilMainMenuGUI($a_target = "_top", $a_use_start_template = false)
00050 {
00051 global $ilias;
00052
00053
00054 $this->tpl = new ilTemplate("tpl.main_buttons.html", true, true);
00055 $this->ilias =& $ilias;
00056 $this->target = $a_target;
00057 $this->start_template = $a_use_start_template;
00058 $this->small = false;
00059 }
00060
00061 function setSmallMode($a_small)
00062 {
00063 $this->small = $a_small;
00064 }
00065
00069 function setActive($a_active)
00070 {
00071 $this->active = $a_active;
00072 }
00073
00077 function setTemplate(&$tpl)
00078 {
00079 echo "ilMainMenu->setTemplate is deprecated. Use getHTML instead.";
00080 return;
00081 $this->tpl =& $tpl;
00082 }
00083
00087 function getTemplate()
00088 {
00089 echo "ilMainMenu->getTemplate is deprecated. Use getHTML instead.";
00090 return;
00091 }
00092
00096 function addMenuBlock($a_var = "CONTENT", $a_block = "navigation")
00097 {
00098 echo "ilMainMenu->addMenuBlick is deprecated. Use getHTML instead.";
00099 return;
00100 $this->tpl->addBlockFile($a_var, $a_block, "tpl.main_buttons.html");
00101 }
00102
00106 function setTemplateVars()
00107 {
00108 global $rbacsystem, $lng, $ilias, $tree, $ilUser;
00109
00110
00111
00112 require_once("Services/Navigation/classes/class.ilNavigationHistoryGUI.php");
00113 $nav_hist = new ilNavigationHistoryGUI();
00114 $nav_html = $nav_hist->getHTML();
00115 if ($nav_html != "")
00116 {
00117 $this->tpl->setCurrentBlock("nav_history");
00118 $this->tpl->setVariable("NAVIGATION_HISTORY", $nav_html);
00119 $this->tpl->parseCurrentBlock();
00120 }
00121
00122
00123 if(ilMainMenuGUI::_checkAdministrationPermission())
00124 {
00125 $this->tpl->setCurrentBlock("userisadmin");
00126 $this->tpl->setVariable("IMG_ADMIN", ilUtil::getImagePath("navbar/admin.gif", false));
00127 $this->tpl->setVariable("IMG_SPACE_ADMIN", ilUtil::getImagePath("spacer.gif", false));
00128 $this->tpl->setVariable("TXT_ADMINISTRATION", $lng->txt("administration"));
00129 $this->tpl->setVariable("SCRIPT_ADMIN", $this->getScriptTarget("ilias.php?baseClass=ilAdministrationGUI"));
00130 $this->tpl->setVariable("TARGET_ADMIN", $this->target);
00131 if ($this->active == "administration")
00132 {
00133 $this->tpl->setVariable("MM_CLASS", "MMActive");
00134 }
00135 else
00136 {
00137 $this->tpl->setVariable("MM_CLASS", "MMInactive");
00138 }
00139 $this->tpl->parseCurrentBlock();
00140 }
00141
00142
00143 include_once 'Services/Search/classes/class.ilSearchSettings.php';
00144 if($rbacsystem->checkAccess('search',ilSearchSettings::_getSearchSettingRefId()))
00145 {
00146 $this->tpl->setCurrentBlock("searchbutton");
00147 $this->tpl->setVariable("SCRIPT_SEARCH",$this->getScriptTarget('ilias.php?baseClass=ilSearchController'));
00148 $this->tpl->setVariable("TARGET_SEARCH",$this->target);
00149 $this->tpl->setVariable("TXT_SEARCH", $lng->txt("search"));
00150 if ($this->active == "search")
00151 {
00152 $this->tpl->setVariable("MM_CLASS", "MMActive");
00153 }
00154 else
00155 {
00156 $this->tpl->setVariable("MM_CLASS", "MMInactive");
00157 }
00158 $this->tpl->parseCurrentBlock();
00159 }
00160
00161
00162
00163
00164
00165
00166
00167
00168 $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
00169
00170
00171 if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
00172 {
00173 $this->tpl->setCurrentBlock("desktopbutton");
00174 $this->tpl->setVariable("IMG_DESK", ilUtil::getImagePath("navbar/desk.gif", false));
00175 $this->tpl->setVariable("IMG_SPACE_DESK", ilUtil::getImagePath("spacer.gif", false));
00176 $this->tpl->setVariable("TXT_PERSONAL_DESKTOP", $lng->txt("personal_desktop"));
00177 $this->tpl->setVariable("SCRIPT_DESK", $this->getScriptTarget("ilias.php?baseClass=ilPersonalDesktopGUI&PDHistory=1"));
00178 $this->tpl->setVariable("TARGET_DESK", $this->target);
00179 if ($this->active == "desktop")
00180 {
00181 $this->tpl->setVariable("MM_CLASS", "MMActive");
00182 }
00183 else
00184 {
00185 $this->tpl->setVariable("MM_CLASS", "MMInactive");
00186 }
00187 $this->tpl->parseCurrentBlock();
00188
00189 include_once "Services/Mail/classes/class.ilMail.php";
00190
00191 $mail =& new ilMail($_SESSION["AccountId"]);
00192
00193 if($rbacsystem->checkAccess('mail_visible',$mail->getMailObjectReferenceId()))
00194 {
00195 #$link = "mail_frameset.php";
00196 $link = "ilias.php?baseClass=ilMailGUI";
00197
00198 if ($mail_id = ilMailbox::hasNewMail($_SESSION["AccountId"]))
00199 {
00200 $mbox = new ilMailbox($_SESSION["AccountId"]);
00201 $mail =& new ilMail($_SESSION['AccountId']);
00202 $folder_id = $mbox->getInboxFolder();
00203
00204
00205
00206
00207 $add = " ".sprintf($lng->txt("cnt_new"),
00208 ilMailbox::_countNewMails($_SESSION["AccountId"]));
00209 }
00210
00211 $this->tpl->setCurrentBlock("mailbutton");
00212 $this->tpl->setVariable("IMG_MAIL", ilUtil::getImagePath("navbar/mail.gif", false));
00213 $this->tpl->setVariable("IMG_SPACE_MAIL", ilUtil::getImagePath("spacer.gif", false));
00214 $this->tpl->setVariable("TXT_MAIL", $lng->txt("mail").$add);
00215 $this->tpl->setVariable("SCRIPT_MAIL", $this->getScriptTarget($link));
00216 $this->tpl->setVariable("TARGET_MAIL", $this->target);
00217 if ($this->active == "mail")
00218 {
00219 $this->tpl->setVariable("MM_CLASS", "MMActive");
00220 }
00221 else
00222 {
00223 $this->tpl->setVariable("MM_CLASS", "MMInactive");
00224 }
00225 $this->tpl->parseCurrentBlock();
00226
00227
00228
00229 include_once "./Modules/Chat/classes/class.ilChatInvitations.php";
00230
00231
00232 $link = "ilias.php?baseClass=ilMailGUI";
00233 if ($invitation_count = ilChatInvitations::_countNewInvitations($_SESSION["AccountId"]))
00234 {
00235 $add = " ".sprintf($lng->txt("cnt_new"),$invitation_count);
00236
00237
00238 $lng_chat =& new ilLanguage($ilUser->getLanguage());
00239 $lng_chat->loadLanguageModule("chat");
00240
00241 $this->tpl->setCurrentBlock("chatbutton");
00242 $this->tpl->setVariable("TXT_CHAT", $lng_chat->txt("chat_invitation_subject").$add);
00243 $this->tpl->setVariable("SCRIPT_CHAT", $this->getScriptTarget($link));
00244 $this->tpl->setVariable("TARGET_CHAT", $this->target);
00245 # $this->tpl->setVariable("CHAT_INVITATION", ilUtil::getSoundPath("chat_invitation.wav"));
00246
00247 if ($this->active == "chat_invitation")
00248 {
00249 $this->tpl->setVariable("MM_CLASS", "MMActive");
00250 }
00251 else
00252 {
00253 $this->tpl->setVariable("MM_CLASS", "MMInactive");
00254 }
00255
00256 $this->tpl->parseCurrentBlock();
00257 }
00258 }
00259 }
00260
00261
00262
00263 $this->tpl->setCurrentBlock("rep_button");
00264 # $this->tpl->setVariable("SCRIPT_CATALOG",'goto__target__root_1__client__ilias38.html');
00265 # #$this->getScriptTarget("repository.php?cmd=frameset&getlast=true"));
00266
00267 include_once('classes/class.ilLink.php');
00268 $this->tpl->setVariable('SCRIPT_CATALOG',ilLink::_getStaticLink(1,'root',true));
00269 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
00270 $title = $nd["title"];
00271 if ($title == "ILIAS")
00272 {
00273 $title = $lng->txt("repository");
00274 }
00275 $this->tpl->setVariable("TXT_CATALOG", $title);
00276 if ($this->active == "repository" || $this->active == "")
00277 {
00278 $this->tpl->setVariable("MM_CLASS", "MMActive");
00279 }
00280 else
00281 {
00282 $this->tpl->setVariable("MM_CLASS", "MMInactive");
00283 }
00284
00285 $this->tpl->setVariable("TARGET", $this->target);
00286 $this->tpl->parseCurrentBlock();
00287
00288
00289 $link_dir = (defined("ILIAS_MODULE"))
00290 ? "../"
00291 : "";
00292
00293 if (!$this->small)
00294 {
00295
00296
00297 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00298 {
00299 include_once 'Services/Registration/classes/class.ilRegistrationSettingsGUI.php';
00300 if (ilRegistrationSettings::_lookupRegistrationType() != IL_REG_DISABLED)
00301 {
00302 $this->tpl->setCurrentBlock("registration_link");
00303 $this->tpl->setVariable("TXT_REGISTER",$lng->txt("register"));
00304 $this->tpl->setVariable("LINK_REGISTER", $link_dir."register.php?client_id=".rawurlencode(CLIENT_ID)."&lang=".$ilias->account->getCurrentLanguage());
00305 $this->tpl->parseCurrentBlock();
00306 }
00307
00308 $languages = $lng->getInstalledLanguages();
00309
00310 foreach ($languages as $lang_key)
00311 {
00312 $this->tpl->setCurrentBlock("languages");
00313 $this->tpl->setVariable("LANG_KEY", $lang_key);
00314 $this->tpl->setVariable("LANG_NAME",
00315 ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key));
00316 $this->tpl->parseCurrentBlock();
00317 }
00318
00319 $this->tpl->setVariable("TXT_OK", $lng->txt("ok"));
00320
00321 $this->tpl->setVariable("LANG_FORM_ACTION", "#");
00322 $this->tpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
00323
00324 $this->tpl->setCurrentBlock("userisanonymous");
00325 $this->tpl->setVariable("TXT_NOT_LOGGED_IN",$lng->txt("not_logged_in"));
00326 $this->tpl->setVariable("TXT_LOGIN",$lng->txt("log_in"));
00327
00328 $target_str = "";
00329 if ($_GET["ref_id"] != "")
00330 {
00331 if ($tree->isInTree($_GET["ref_id"]) && $_GET["ref_id"] != $tree->getRootId())
00332 {
00333 $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
00334 $type = ilObject::_lookupType($obj_id);
00335 $target_str = $type."_".$_GET["ref_id"];
00336 }
00337 }
00338 $this->tpl->setVariable("LINK_LOGIN",
00339 $link_dir."login.php?target=".$target_str."&client_id=".rawurlencode(CLIENT_ID)."&cmd=force_login&lang=".$ilias->account->getCurrentLanguage());
00340 $this->tpl->parseCurrentBlock();
00341 }
00342 else
00343 {
00344 $this->tpl->setCurrentBlock("userisloggedin");
00345 $this->tpl->setVariable("TXT_LOGIN_AS",$lng->txt("login_as"));
00346 $this->tpl->setVariable("TXT_LOGOUT2",$lng->txt("logout"));
00347 $this->tpl->setVariable("LINK_LOGOUT2", $link_dir."logout.php?lang=".$ilias->account->getCurrentLanguage());
00348 $this->tpl->setVariable("USERNAME",$ilias->account->getFullname());
00349 $this->tpl->parseCurrentBlock();
00350 }
00351
00352
00353 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00354
00355 $this->tpl->setVariable("TXT_LOGOUT", $lng->txt("logout"));
00356
00357 $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.png"));
00358 $this->tpl->setVariable("HEADER_BG_IMAGE", ilUtil::getImagePath("HeaderBackground.gif"));
00359 include_once("classes/class.ilObjSystemFolder.php");
00360 $this->tpl->setVariable("TXT_HEADER_TITLE", ilObjSystemFolder::_getHeaderTitle());
00361
00362
00363
00364 }
00365
00366 $this->tpl->parseCurrentBlock();
00367 }
00368
00372 function getScriptTarget($a_script)
00373 {
00374 global $ilias;
00375
00376 $script = "./".$a_script;
00377
00378
00379
00380
00381
00382
00383
00384
00385 if (defined("ILIAS_MODULE"))
00386 {
00387 $script = ".".$script;
00388 }
00389 return $script;
00390 }
00391
00392 function _checkAdministrationPermission()
00393 {
00394 global $rbacsystem;
00395
00396 if($rbacsystem->checkAccess("visible,read", SYSTEM_FOLDER_ID))
00397 {
00398 return true;
00399 }
00400 return false;
00401
00402 return count(ilUtil::_getObjectsByOperations('cat','cat_administrate_users')) ? true : false;
00403 }
00404
00405 function getHTML()
00406 {
00407 $this->setTemplateVars();
00408 return $this->tpl->get();
00409 }
00410 }
00411 ?>