ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMainMenuGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
32 {
38  var $ilias;
39  var $tpl;
40  var $target;
42 
43 
49  function ilMainMenuGUI($a_target = "_top", $a_use_start_template = false)
50  {
51  global $ilias;
52 
53 
54  $this->tpl = new ilTemplate("tpl.main_menu.html", true, true,
55  "Services/MainMenu");
56  $this->ilias =& $ilias;
57  $this->target = $a_target;
58  $this->start_template = $a_use_start_template;
59  $this->small = false;
60  }
61 
62  function setSmallMode($a_small)
63  {
64  $this->small = $a_small;
65  }
66 
70  function setActive($a_active)
71  {
72  $this->active = $a_active;
73  }
74 
78  function setTemplate(&$tpl)
79  {
80  echo "ilMainMenu->setTemplate is deprecated. Use getHTML instead.";
81  return;
82  $this->tpl =& $tpl;
83  }
84 
88  function getTemplate()
89  {
90  echo "ilMainMenu->getTemplate is deprecated. Use getHTML instead.";
91  return;
92  }
93 
97  function addMenuBlock($a_var = "CONTENT", $a_block = "navigation")
98  {
99  echo "ilMainMenu->addMenuBlick is deprecated. Use getHTML instead.";
100  return;
101  $this->tpl->addBlockFile($a_var, $a_block, "tpl.main_buttons.html");
102  }
103 
107  function setTemplateVars()
108  {
109  global $rbacsystem, $lng, $ilias, $tree, $ilUser, $ilSetting;
110 
111 
112  // navigation history
113  require_once("Services/Navigation/classes/class.ilNavigationHistoryGUI.php");
115  $nav_html = $nav_hist->getHTML();
116 
117  if ($nav_html != "")
118  {
119 
120  $this->tpl->setCurrentBlock("nav_history");
121  $this->tpl->setVariable("TXT_LAST_VISITED", $lng->txt("last_visited"));
122  $this->tpl->setVariable("NAVIGATION_HISTORY", $nav_html);
123  $this->tpl->parseCurrentBlock();
124  }
125 
126  // administration button
128  {
129  $this->tpl->setCurrentBlock("userisadmin");
130  $this->tpl->setVariable("IMG_ADMIN", ilUtil::getImagePath("navbar/admin.gif", false));
131  $this->tpl->setVariable("IMG_SPACE_ADMIN", ilUtil::getImagePath("spacer.gif", false));
132  $this->tpl->setVariable("TXT_ADMINISTRATION", $lng->txt("administration"));
133  $this->tpl->setVariable("SCRIPT_ADMIN", $this->getScriptTarget("ilias.php?baseClass=ilAdministrationGUI"));
134  $this->tpl->setVariable("TARGET_ADMIN", $this->target);
135  if ($this->active == "administration")
136  {
137  $this->tpl->setVariable("MM_CLASS", "MMActive");
138  $this->tpl->setVariable("SEL", '<span class="ilAccHidden">('.$lng->txt("stat_selected").')</span>');
139  }
140  else
141  {
142  $this->tpl->setVariable("MM_CLASS", "MMInactive");
143  }
144  $this->tpl->parseCurrentBlock();
145  }
146 
147  // search
148  include_once 'Services/Search/classes/class.ilSearchSettings.php';
149  if($rbacsystem->checkAccess('search',ilSearchSettings::_getSearchSettingRefId()))
150  {
151  $this->tpl->setCurrentBlock("searchbutton");
152  $this->tpl->setVariable("SCRIPT_SEARCH",$this->getScriptTarget('ilias.php?baseClass=ilSearchController'));
153  $this->tpl->setVariable("TARGET_SEARCH",$this->target);
154  $this->tpl->setVariable("TXT_SEARCH", $lng->txt("search"));
155  if ($this->active == "search")
156  {
157  $this->tpl->setVariable("MM_CLASS", "MMActive");
158  $this->tpl->setVariable("SEL", '<span class="ilAccHidden">('.$lng->txt("stat_selected").')</span>');
159  }
160  else
161  {
162  $this->tpl->setVariable("MM_CLASS", "MMInactive");
163  }
164  $this->tpl->parseCurrentBlock();
165 
166  include_once './Services/Search/classes/class.ilMainMenuSearchGUI.php';
167  $main_search = new ilMainMenuSearchGUI();
168  if(strlen($html = $main_search->getHTML()))
169  {
170  $this->tpl->setVariable('SEARCHBOX',$html);
171  }
172  }
173 
174 
175  // webshop
176  include_once 'payment/classes/class.ilGeneralSettings.php';
177  if((bool)ilGeneralSettings::_getInstance()->get('shop_enabled'))
178  {
179  $this->tpl->setCurrentBlock('shopbutton');
180  $this->tpl->setVariable('SCRIPT_SHOP', $this->getScriptTarget('ilias.php?baseClass=ilShopController&cmd=clearFilter'));
181  $this->tpl->setVariable('TARGET_SHOP', $this->target);
182 
183  include_once 'payment/classes/class.ilPaymentShoppingCart.php';
184  $objShoppingCart = new ilPaymentShoppingCart($ilUser);
185  $items = $objShoppingCart->getEntries();
186 
187  $this->tpl->setVariable('TXT_SHOP', $lng->txt('shop').(count($items) > 0 ? ' ('.count($items).')' : ''));
188 
189  if($this->active == 'shop')
190  {
191  $this->tpl->setVariable('MM_CLASS', 'MMActive');
192  $this->tpl->setVariable("SEL", '<span class="ilAccHidden">('.$lng->txt("stat_selected").')</span>');
193  }
194  else
195  {
196  $this->tpl->setVariable('MM_CLASS', 'MMInactive');
197  }
198  $this->tpl->parseCurrentBlock();
199  }
200 
201  // help button
202  //$this->tpl->setCurrentBlock("userhelp");
203  //$this->tpl->setVariable("TXT_HELP", $lng->txt("help"));
204  //$this->tpl->setVariable("SCRIPT_HELP", "ilias.php?baseClass=ilHelpGUI");
205  //$this->tpl->setVariable("TARGET_HELP", "ilias_help");
206  //$this->tpl->parseCurrentBlock();
207 
208  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
209 
210  // mail & desktop button
211  if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
212  {
213  $this->tpl->setCurrentBlock("desktopbutton");
214  $this->tpl->setVariable("IMG_DESK", ilUtil::getImagePath("navbar/desk.gif", false));
215  $this->tpl->setVariable("IMG_SPACE_DESK", ilUtil::getImagePath("spacer.gif", false));
216  $this->tpl->setVariable("TXT_PERSONAL_DESKTOP", $lng->txt("personal_desktop"));
217  #$this->tpl->setVariable("SCRIPT_DESK", $this->getScriptTarget("ilias.php?baseClass=ilPersonalDesktopGUI&PDHistory=1"));
218  $this->tpl->setVariable("SCRIPT_DESK", $this->getScriptTarget("ilias.php?baseClass=ilPersonalDesktopGUI"));
219  $this->tpl->setVariable("TARGET_DESK", $this->target);
220  if ($this->active == "desktop")
221  {
222  $this->tpl->setVariable("MM_CLASS", "MMActive");
223  $this->tpl->setVariable("SEL", '<span class="ilAccHidden">('.$lng->txt("stat_selected").')</span>');
224  }
225  else
226  {
227  $this->tpl->setVariable("MM_CLASS", "MMInactive");
228  }
229  $this->tpl->parseCurrentBlock();
230 
231  include_once "Services/Mail/classes/class.ilMail.php";
232 
233  $mail = new ilMail($_SESSION["AccountId"]);
234 
235  if( $rbacsystem->checkAccess('mail_visible', $mail->getMailObjectReferenceId()) )
236  {
237  $link = "ilias.php?baseClass=ilMailGUI";
238  $add = '';
239 
240  if( $new_mails = ilMailbox::_countNewMails($_SESSION["AccountId"]) )
241  {
242  $mail = new ilMail($_SESSION['AccountId']);
243  $add = " ".sprintf($lng->txt("cnt_new"), $new_mails);
244  }
245 
246  $this->tpl->setCurrentBlock("mailbutton");
247  $this->tpl->setVariable("IMG_MAIL", ilUtil::getImagePath("navbar/mail.gif", false));
248  $this->tpl->setVariable("IMG_SPACE_MAIL", ilUtil::getImagePath("spacer.gif", false));
249  $this->tpl->setVariable("TXT_MAIL", $lng->txt("mail").$add);
250  $this->tpl->setVariable("SCRIPT_MAIL", $this->getScriptTarget($link));
251  $this->tpl->setVariable("TARGET_MAIL", $this->target);
252  if ($this->active == "mail")
253  {
254  $this->tpl->setVariable("MM_CLASS", "MMActive");
255  $this->tpl->setVariable("SEL", '<span class="ilAccHidden">('.$lng->txt("stat_selected").')</span>');
256  }
257  else
258  {
259  $this->tpl->setVariable("MM_CLASS", "MMInactive");
260  }
261  $this->tpl->parseCurrentBlock();
262  }
263  }
264 
265  // chat messages
266  if ($ilSetting->get('chat_message_notify_status') == 1 && $_REQUEST['baseClass'] != 'ilChatPresentationGUI' && $ilUser->getPref('chat_message_notify_status') == 1) {
267  include_once 'Modules/Chat/classes/class.ilChatMessageNotifyGUI.php';
268  $msg_notify = new ilChatMessageNotifyGUI();
269  $html = $msg_notify->getHtml();
270  if ($html) {
271  $this->tpl->setCurrentBlock("chat_lastmsg");
272  $this->tpl->setVariable('CHAT_LAST_MESSAGE', $html);
273  $this->tpl->parseCurrentBlock();
274  }
275 
276  }
277 
278  // chat invitations
279  include_once 'Modules/Chat/classes/class.ilChatInvitationGUI.php';
280  $chat_invitation_gui = new ilChatInvitationGUI();
281  $chat_invitation_html = $chat_invitation_gui->getHTML();
282  if(trim($chat_invitation_html) != '')
283  {
284  $this->tpl->setCurrentBlock('chatbutton');
285  $this->tpl->setVariable('CHAT_INVITATIONS', $chat_invitation_html);
286  $this->tpl->parseCurrentBlock();
287  }
288 
289  // repository link
290  $this->tpl->setCurrentBlock("rep_button");
291 # $this->tpl->setVariable("SCRIPT_CATALOG",'goto__target__root_1__client__ilias38.html');
292 # #$this->getScriptTarget("repository.php?cmd=frameset&getlast=true"));
293 
294  include_once('classes/class.ilLink.php');
295  $this->tpl->setVariable('SCRIPT_CATALOG',ilLink::_getStaticLink(1,'root',true));
296  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
297  $title = $nd["title"];
298  if ($title == "ILIAS")
299  {
300  $title = $lng->txt("repository");
301  }
302  $this->tpl->setVariable("TXT_CATALOG", $title);
303  if ($this->active == "repository" || $this->active == "")
304  {
305  $this->tpl->setVariable("MM_CLASS", "MMActive");
306  $this->tpl->setVariable("SEL", '<span class="ilAccHidden">('.$lng->txt("stat_selected").')</span>');
307  }
308  else
309  {
310  $this->tpl->setVariable("MM_CLASS", "MMInactive");
311  }
312  // set target frame
313  $this->tpl->setVariable("TARGET", $this->target);
314  $this->tpl->parseCurrentBlock();
315 
316 
317  $link_dir = (defined("ILIAS_MODULE"))
318  ? "../"
319  : "";
320 
321  if (!$this->small)
322  {
323 
324  // login stuff
325  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
326  {
327  include_once 'Services/Registration/classes/class.ilRegistrationSettingsGUI.php';
329  {
330  $this->tpl->setCurrentBlock("registration_link");
331  $this->tpl->setVariable("TXT_REGISTER",$lng->txt("register"));
332  $this->tpl->setVariable("LINK_REGISTER", $link_dir."register.php?client_id=".rawurlencode(CLIENT_ID)."&lang=".$ilias->account->getCurrentLanguage());
333  $this->tpl->parseCurrentBlock();
334  }
335 
336  // language selection
337  include_once("./Services/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
338  $selection = new ilAdvancedSelectionListGUI();
339  $selection->setFormSelectMode("change_lang_to", "ilLanguageSelection", true,
340  "#", "ilNavHistory", "ilNavHistoryForm",
341  "_top", $lng->txt("ok"), "ilLogin");
342  //$selection->setListTitle($lng->txt("choose_language"));
343  $selection->setListTitle($lng->txt("language"));
344  $selection->setItemLinkClass("small");
345  $languages = $lng->getInstalledLanguages();
346  //var_dump($_SERVER);
347  foreach ($languages as $lang_key)
348  {
349  $base = substr($_SERVER["REQUEST_URI"], strrpos($_SERVER["REQUEST_URI"], "/") + 1);
350  $base = str_replace("lang=", "", $base);
351  $link = ilUtil::appendUrlParameterString($base,
352  "lang=".$lang_key);
353  $selection->addItem(ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key),
354  $lang_key, $link, "", "", "_top");
355  }
356  if (count($languages) > 0)
357  {
358  $this->tpl->setVariable("LANG_SELECT", $selection->getHTML());
359  }
360 
361  $this->tpl->setCurrentBlock("userisanonymous");
362  $this->tpl->setVariable("TXT_NOT_LOGGED_IN",$lng->txt("not_logged_in"));
363  $this->tpl->setVariable("TXT_LOGIN",$lng->txt("log_in"));
364 
365  $target_str = "";
366  if ($_GET["ref_id"] != "")
367  {
368  if ($tree->isInTree($_GET["ref_id"]) && $_GET["ref_id"] != $tree->getRootId())
369  {
370  $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
371  $type = ilObject::_lookupType($obj_id);
372  $target_str = $type."_".$_GET["ref_id"];
373  }
374  }
375  $this->tpl->setVariable("LINK_LOGIN",
376  $link_dir."login.php?target=".$target_str."&client_id=".rawurlencode(CLIENT_ID)."&cmd=force_login&lang=".$ilias->account->getCurrentLanguage());
377  $this->tpl->parseCurrentBlock();
378  }
379  else
380  {
381  $this->tpl->setCurrentBlock("userisloggedin");
382  $this->tpl->setVariable("TXT_LOGIN_AS",$lng->txt("login_as"));
383  $this->tpl->setVariable("TXT_LOGOUT2",$lng->txt("logout"));
384  $this->tpl->setVariable("LINK_LOGOUT2", $link_dir."logout.php?lang=".$ilias->account->getCurrentLanguage());
385  $this->tpl->setVariable("USERNAME",$ilias->account->getFullname());
386  $this->tpl->parseCurrentBlock();
387  }
388 
389 
390  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
391 
392  $this->tpl->setVariable("TXT_LOGOUT", $lng->txt("logout"));
393  $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.png"));
394  $this->tpl->setVariable("HEADER_BG_IMAGE", ilUtil::getImagePath("HeaderBackground.gif"));
395  include_once("./Modules/SystemFolder/classes/class.ilObjSystemFolder.php");
396  $this->tpl->setVariable("TXT_HEADER_TITLE", ilObjSystemFolder::_getHeaderTitle());
397 
398  // set link to return to desktop, not depending on a specific position in the hierarchy
399  //$this->tpl->setVariable("SCRIPT_START", $this->getScriptTarget("start.php"));
400  }
401  else
402  {
403  $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.png"));
404  }
405 
406  $this->tpl->setVariable("TXT_MAIN_MENU", $lng->txt("main_menu"));
407 
408  $this->tpl->parseCurrentBlock();
409  }
410 
414  function getScriptTarget($a_script)
415  {
416  global $ilias;
417 
418  $script = "./".$a_script;
419 
420  //if ($this->start_template == true)
421  //{
422  //if(is_file("./templates/".$ilias->account->skin."/tpl.start.html"))
423  //{
424  // $script = "./start.php?script=".rawurlencode($script);
425  //}
426  //}
427  if (defined("ILIAS_MODULE"))
428  {
429  $script = ".".$script;
430  }
431  return $script;
432  }
433  // STATIC
435  {
436  global $rbacsystem;
437 
438  if($rbacsystem->checkAccess("visible,read", SYSTEM_FOLDER_ID))
439  {
440  return true;
441  }
442  return false;
443  // Allow all local admins to use the administration
444  return count(ilUtil::_getObjectsByOperations('cat','cat_administrate_users')) ? true : false;
445  }
446 
447  function getHTML()
448  {
449  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
451 
452  if($set->isActive())
453  {
454  return $this->getMemberViewHTML();
455  }
456 
457 
458  $this->setTemplateVars();
459  return $this->tpl->get();
460  }
461 
462  protected function getMemberViewHTML()
463  {
464  global $lng;
465 
466  $this->tpl = new ilTemplate('tpl.member_view_main_menu.html',true,true,'Services/MainMenu');
467 
468  $this->tpl->setVariable('TXT_MM_HEADER',$lng->txt('mem_view_long'));
469  $this->tpl->setVariable('TXT_MM_CLOSE_PREVIEW',$lng->txt('mem_view_close'));
470  $this->tpl->setVariable('MM_CLOSE_IMG',ilUtil::getImagePath('cancel.gif'));
471 
472  include_once './classes/class.ilLink.php';
473 
474  $this->tpl->setVariable(
475  'HREF_CLOSE_MM',
477  (int) $_GET['ref_id'],
478  ilObject::_lookupType(ilObject::_lookupObjId((int) $_GET['ref_id'])),
479  array('mv' => 0)));
480 
481  return $this->tpl->get();
482  }
483 }
484 ?>