PageRenderTime 56ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/community/www/new_sidebar.php

https://github.com/svn2github/efront-lms
PHP | 462 lines | 351 code | 5 blank | 106 comment | 159 complexity | 6c71ff582cb6f263599079f994314981 MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0
  1. <?php
  2. /**
  3. * Sidebar frame
  4. *
  5. * This page is used as the leftmost frame, which is the menu bar
  6. * @package eFront
  7. * @version 1.0
  8. */
  9. //---------------------------------------------Initialization-------------------------------------------------
  10. error_reporting(E_ERROR);
  11. if (!$horizontal_inframe_version) {
  12. session_cache_limiter('none');
  13. session_start();
  14. }
  15. $path = "../libraries/";
  16. /** Configuration file.*/
  17. require_once $path."configuration.php";
  18. $benchmark = new EfrontBenchmark($debug_TimeStart);
  19. $benchmark -> set('init');
  20. //Set headers in order to eliminate browser cache (especially IE's)'
  21. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  22. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  23. require_once $path."menu.class.php";
  24. /*Check the user type. If the user is not valid, he cannot access this page, so exit*/
  25. try {
  26. if (!isset($currentUser)) {
  27. $currentUser = EfrontUser :: checkUserAccess();
  28. }
  29. $smarty -> assign("T_CURRENT_USER", $currentUser);
  30. if ($_SESSION['s_lessons_ID'] && ($currentUser instanceof EfrontLessonUser)) {
  31. $userLessons = $currentUser -> getLessons();
  32. $currentUser -> applyRoleOptions($userLessons[$_SESSION['s_lessons_ID']]); //Initialize user's role options for this lesson
  33. $currentLesson = new EfrontLesson($_SESSION['s_lessons_ID']);
  34. } else {
  35. $currentUser -> applyRoleOptions(); //Initialize user's role options for this lesson
  36. }
  37. } catch (Exception $e) {
  38. eF_redirect("index.php?ctg=expired");
  39. exit;
  40. }
  41. if (!isset($horizontal_inframe_version) || !$horizontal_inframe_version) {
  42. if (!isset($_GET['ajax']) && !isset($_GET['postAjaxRequest'])) {
  43. $_SESSION['previousSideUrl'] = $_SERVER['REQUEST_URI'];
  44. }
  45. }
  46. //---------------------------------------------End of Initialization-------------------------------------------------
  47. ///MODULE1
  48. $modules = $currentUser -> getModules();
  49. // Include module languages
  50. foreach ($modules as $module) {
  51. // The $setLanguage variable is defined in globals.php
  52. $mod_lang_file = $module -> getLanguageFile($setLanguage);
  53. if (is_file ($mod_lang_file)) {
  54. require_once $mod_lang_file;
  55. }
  56. }
  57. /***Check if the chat configuration exists - if not create it***/
  58. if (!isset($horizontal_inframe_version) || !$horizontal_inframe_version) {
  59. /***** TOP MENU WITH AVATAR AND NAME *****/
  60. try {
  61. if (isset($_SESSION['facebook_details']['pic'])) {
  62. $avatar['path'] = $_SESSION['facebook_details']['pic'];
  63. $smarty -> assign("T_ABSOLUTE_AVATAR_PATH", 1);
  64. $smarty -> assign ("T_AVATAR", $_SESSION['facebook_details']['pic']);
  65. } else {
  66. $avatar = new EfrontFile($currentUser -> user['avatar']);
  67. $smarty -> assign ("T_AVATAR", $currentUser -> user['avatar']);
  68. }
  69. // Get current dimensions
  70. list($width, $height) = getimagesize($avatar['path']);
  71. if ($width > 200 || $height > 100) {
  72. // Get normalized dimensions
  73. list($newwidth, $newheight) = eF_getNormalizedDims($avatar['path'], 200, 100);
  74. // The template will check if they are defined and normalize the picture only if needed
  75. $width = $newwidth;
  76. $height = $newheight;
  77. }
  78. } catch (Exception $e) {
  79. $width = 64;
  80. $height = 64;
  81. }
  82. $smarty -> assign("T_NEWWIDTH", $width);
  83. $smarty -> assign("T_NEWHEIGHT", $height);
  84. }
  85. //pr($_SESSION);
  86. if (isset($_SESSION['facebook_user'])) {
  87. //pr($_SESSION);
  88. //$facebook = new EfrontFacebook();
  89. //$fb_details = $facebook->api_client->fql_query("SELECT first_name, last_name, pic FROM user WHERE uid = " . $_SESSION['facebook_user']);
  90. // //unset($_SESSION['facebook_details']);
  91. //$realname = substr($_SESSION['facebook_details']['first_name'],0,1).".&nbsp;" . $_SESSION['facebook_details']['last_name']. "<br>"; //get the initial letter
  92. $smarty -> assign("T_FB_STATUS", $_SESSION['facebook_details']['status']['message']);
  93. } else {
  94. if ($currentUser -> user['name'] != '') {
  95. //$realname = substr($currentUser -> user['name'],0,1) .".&nbsp;" . $currentUser -> user['surname']; //get the initial letter
  96. $smarty -> assign("T_RESULT", $currentUser -> user);
  97. }
  98. }
  99. $efront_type = "<b><i>" . $_SESSION['s_login'] . "</i></b><br>";
  100. $roleNames = EfrontUser :: getRoles(true);
  101. if ($_SESSION['s_type'] == 'administrator') {
  102. $efront_type .= "<b>" . _TYPEOFUSER . "</b>:<br>";
  103. } else if ($_SESSION['s_type'] == 'student') {
  104. $efront_type .= "<b>" . _EDUCATIONALROLE . "</b>:<br>";
  105. } else {
  106. $efront_type .= "<b>" . _EDUCATIONALROLE . "</b>:<br>";
  107. }
  108. if ($currentUser -> user['user_types_ID']) {
  109. $_SESSION['s_lessons_ID'] ? $efront_type .= $roleNames[$userLessons[$_SESSION['s_lessons_ID']]] : $efront_type .= $roleNames[$currentUser -> user['user_types_ID']];
  110. } else {
  111. $efront_type .= EfrontUser :: $basicUserTypesTranslations[$_SESSION['s_type']];
  112. }
  113. $efront_type .= "<br>";
  114. /***** FOR SEARCHING *****/
  115. /**Search module is used to display the search field and perform the searches*/
  116. include "module_search.php";
  117. /***** MENU - only for interfaces 0:vertical and 1: horizontal *****/
  118. if (isset($GLOBALS['currentTheme'] -> options['sidebar_interface']) && $GLOBALS['currentTheme'] -> options['sidebar_interface'] < 2) {
  119. $newMenu = new EfrontMenu();
  120. $active_menu = 1; // initialized here, might change later
  121. // SYSTEM MENU - ADMINISTRATOR ONLY
  122. if ($_SESSION['s_type'] == 'administrator') {
  123. $systemMenu = array();
  124. $systemMenu[0] = array("id" => "control_panel_a", "image" => "home", "link" => "administrator.php?ctg=control_panel", "title" => _CONTROLCENTER);
  125. if (!$GLOBALS['configuration']['disable_forum'] && (!isset($GLOBALS['currentUser'] -> coreAccess['forum']) || $GLOBALS['currentUser'] -> coreAccess['forum'] != 'hidden')) {
  126. $systemMenu[1] = array("id" => "forum_a", "image" => "message", "link" => "administrator.php?ctg=forum", "title" => _FORUM);
  127. }
  128. /*
  129. if (!isset($GLOBALS['currentUser'] -> coreAccess['configuration']) || $GLOBALS['currentUser'] -> coreAccess['configuration'] != 'hidden') {
  130. $systemMenu[2] = array("id" => "cms_a", "image" => "unit", "link" => "administrator.php?ctg=themes&tab=external", "title" => _CMS);
  131. }
  132. */
  133. if (!isset($currentUser -> coreAccess['statistics']) || $currentUser -> coreAccess['statistics'] != 'hidden') {
  134. $systemMenu[4] = array("id" => "statistics_system_a", "image" => "reports", "link" => "administrator.php?ctg=statistics&option=system", "title" => _SYSTEMSTATISTICS);
  135. }
  136. // Get system menu modules
  137. $moduleMenus = eF_getModuleMenu($modules, "system");
  138. foreach ($moduleMenus as $moduleMenu) {
  139. $systemMenu[] = $moduleMenu;
  140. }
  141. $newMenu -> insertMenuOption($systemMenu, false, _SYSTEM);
  142. }
  143. //pr($_GET);
  144. // LESSON MENU
  145. if (isset($_GET['new_lesson_id']) && $_GET['new_lesson_id']) {
  146. // This is a lesson specific menu
  147. $_SESSION['s_lessons_ID'] = $_GET['new_lesson_id'];
  148. if (!isset($currentLesson)) {
  149. $currentLesson = new EfrontLesson($_GET['new_lesson_id']);
  150. }
  151. $lessonMenu = eF_getMenu();
  152. $lessons = eF_getTableData("users_to_lessons ul, lessons l", "l.name","ul.archive =0 and ul.users_LOGIN='".$_SESSION['s_login']."' AND ul.active=1 AND l.id=ul.lessons_ID AND l.active=1 AND l.id = '".$_GET['new_lesson_id']."'");
  153. $lessonMenuId = $newMenu -> createMenu( array("title" => $lessons[0][name], "image" => "go_back.png", "link" => "new_sidebar.php?sbctg=lessons")); //onclick="top.mainframe.location='{$smarty.session.s_type}.php?ctg=lessons';"
  154. // Get current lesson menu modules
  155. $moduleMenus = eF_getModuleMenu($modules, "current_lesson");
  156. foreach ($moduleMenus as $moduleMenu) {
  157. $lessonMenu['lesson'][] = $moduleMenu;
  158. }
  159. $newMenu -> insertMenuOption($lessonMenu['lesson'], $lessonMenuId);
  160. // Insert blank option
  161. $newMenu -> insertMenuOptionAsRawHtml("<table height='8px'></table>", $lessonMenuId);
  162. $userType = eF_getTableData("users", "user_type", "login='".$_SESSION['s_login']."'");
  163. if (!isset($_SESSION['s_type'])) {
  164. $_SESSION['s_type'] = $userType[0]['user_type'];
  165. }
  166. if (!(isset($GLOBALS['configuration']['hide_sidebar_images']) && $GLOBALS['configuration']['hide_sidebar_images'] == 1)) {
  167. $newMenu -> insertMenuOptionAsRawHtml("<a href=\"javascript:void(0);\" onclick=\"top.mainframe.location='".$userType[0]['user_type'].".php?ctg=lessons';hideAllLessonSpecific();\"><img style=\"border:0; float: left;\" src=\"images/16x16/go_back.png\" />"._CHANGELESSON."</a>", $lessonMenuId);
  168. } else {
  169. $newMenu -> insertMenuOptionAsRawHtml("<a href=\"javascript:void(0);\" onclick=\"top.mainframe.location='".$userType[0]['user_type'].".php?ctg=lessons';hideAllLessonSpecific();\">"._CHANGELESSON."</a>", $lessonMenuId);
  170. }
  171. //$newMenu -> insertMenuOption(array("id" => "change_lesson_a", "image" => "back_lessons", "link" => "professor.php?ctg=lessons", "title" => _CHANGELESSON, "target" => "mainframe"), $lessonMenuId);
  172. $smarty -> assign("T_ACTIVE_ID","lesson_main");
  173. $smarty -> assign("T_SPECIFIC_LESSON",1);
  174. // For the second hidden div
  175. // baltas: why was this commented out? is needed to be hidden behind lesson specific options so that change lesson does not trigger sidebar reloading
  176. $newMenu -> insertMenuOption(array("id" => "lessons_a", "image" => "lessons", "link" => $_SESSION['s_type'].".php?ctg=lessons", "title" => _MYCOURSES), $lessonMenuId);
  177. // Get lessons menu modules
  178. $moduleMenus = eF_getModuleMenu($modules, "lessons");
  179. foreach ($moduleMenus as $moduleMenu) {
  180. $newMenu -> insertMenuOption($moduleMenu, $lessonMenuId);
  181. }
  182. //pr($newMenu);
  183. } else {
  184. $_SESSION['s_lessons_ID'] = "";
  185. $lessonMenuId = $newMenu -> createMenu( array("title" => _LESSONS));
  186. if ($_SESSION['s_type'] == "administrator") {
  187. if (!isset($GLOBALS['currentUser'] -> coreAccess['lessons']) || $GLOBALS['currentUser'] -> coreAccess['lessons'] != 'hidden') {
  188. $newMenu -> insertMenuOption(array("id" => "lessons_a", "image" => "lessons", "link" => "administrator.php?ctg=lessons", "title" => _LESSONS), $lessonMenuId);
  189. $newMenu -> insertMenuOption(array("id" => "directions_a", "image" => "categories", "link" => "administrator.php?ctg=directions", "title" => _DIRECTIONS) , $lessonMenuId);
  190. $newMenu -> insertMenuOption(array("id" => "courses_a", "image" => "courses", "link" => "administrator.php?ctg=courses", "title" => _COURSES), $lessonMenuId);
  191. }
  192. // $newMenu -> insertMenuOption(array("id" => "search_courses_a", "image" => "book_open2", "link" => "administrator.php?ctg=search_courses", "title" => _SEARCHCOURSEUSERS), $lessonMenuId);
  193. if (!isset($currentUser -> coreAccess['statistics']) || $currentUser -> coreAccess['statistics'] != 'hidden') {
  194. $newMenu -> insertMenuOption(array("id" => "statistics_lesson_a", "image" => "reports", "link" => "administrator.php?ctg=statistics&option=lesson", "title" => _LESSONSTATISTICS), $lessonMenuId);
  195. $newMenu -> insertMenuOption(array("id" => "statistics_course_a", "image" => "reports", "link" => "administrator.php?ctg=statistics&option=course", "title" => _COURSESTATISTICS), $lessonMenuId);
  196. }
  197. // Get lessons menu modules
  198. $moduleMenus = eF_getModuleMenu($modules, "lessons");
  199. foreach ($moduleMenus as $moduleMenu) {
  200. $newMenu -> insertMenuOption($moduleMenu, $lessonMenuId);
  201. }
  202. $smarty -> assign("T_ACTIVE_ID","control_panel");
  203. } else {
  204. $newMenu -> insertMenuOption(array("id" => "lessons_a", "image" => "lessons", "link" => $_SESSION['s_type'].".php?ctg=lessons", "title" => _MYCOURSES), $lessonMenuId);
  205. // Get lessons menu modules
  206. $moduleMenus = eF_getModuleMenu($modules, "lessons");
  207. foreach ($moduleMenus as $moduleMenu) {
  208. $newMenu -> insertMenuOption($moduleMenu, $lessonMenuId);
  209. }
  210. $userLessons = $currentUser -> getLessons();
  211. if (empty($userLessons)) {
  212. $active_menu = 1;
  213. }
  214. $smarty -> assign("T_ACTIVE_ID","lessons");
  215. }
  216. }
  217. // USERS MENU - ADMINISTRATOR ONLY
  218. if ($_SESSION['s_type'] == 'administrator') {
  219. $usersMenu = array();
  220. if (!isset($currentUser -> coreAccess['users']) || $currentUser -> coreAccess['users'] != 'hidden') {
  221. $usersMenu[0] = array("id" => "users_a", "image" => "user", "link" => "administrator.php?ctg=users", "title" => _USERS);
  222. }
  223. if (!isset($currentUser -> coreAccess['configuration']) || $currentUser -> coreAccess['configuration'] != 'hidden') {
  224. $usersMenu[1] = array("id" => "user_types_a", "image" => "user_types", "link" => "administrator.php?ctg=user_types", "title" => _ROLES);
  225. }
  226. if (!isset($currentUser -> coreAccess['users']) || $currentUser -> coreAccess['users'] != 'hidden') {
  227. $usersMenu[2] = array("id" => "user_groups_a", "image" => "users", "link" => "administrator.php?ctg=user_groups", "title" => _GROUPS);
  228. if (G_VERSIONTYPE == 'educational') {
  229. $usersMenu[3] = array("id" => "search_employee_a", "image" => "search", "link" => "administrator.php?ctg=search_courses", "title" => _SEARCHUSER);
  230. }
  231. }
  232. if (!isset($currentUser -> coreAccess['statistics']) || $currentUser -> coreAccess['statistics'] != 'hidden') {
  233. $usersMenu[4] = array("id" => "statistics_user_a", "image" => "reports", "link" => "administrator.php?ctg=statistics&option=user", "title" => _USERSTATISTICS);
  234. }
  235. // Get users menu modules
  236. $moduleMenus = eF_getModuleMenu($modules, "users");
  237. foreach ($moduleMenus as $moduleMenu) {
  238. $usersMenu[] = $moduleMenu;
  239. }
  240. $newMenu-> insertMenuOption($usersMenu, false, _USERS);
  241. }
  242. // ORGANIZATION MENU
  243. // TOOLS MENU
  244. $toolsMenuId = $newMenu -> createMenu( array("title" => _PERSONALOPTIONS));
  245. //$newMenu -> insertMenuOption(array("id" => "forum_a", "image" => "messages", "link" => basename($_SERVER['PHP_SELF'])."?ctg=forum", "title" => _ALLFORUMS), $toolsMenuId);
  246. if ($_SESSION['s_type'] == 'administrator') {
  247. if ($GLOBALS['configuration']['disable_dashboard'] != 1 && (!isset($currentUser -> coreAccess['dashboard']) || $currentUser -> coreAccess['dashboard'] != 'hidden')) {
  248. $newMenu -> insertMenuOption(array("id" => "personal_a", "image" => "user", "link" => "administrator.php?ctg=personal&user=".$_SESSION['s_login']."&op=dashboard", "title" => _PERSONALDATA), $toolsMenuId);
  249. }
  250. if ($GLOBALS['configuration']['disable_calendar'] != 1 && (!isset($currentUser -> coreAccess['calendar']) || $currentUser -> coreAccess['calendar'] != 'hidden')) {
  251. $newMenu -> insertMenuOption(array("id" => "calendar_a", "image" => "calendar", "link" => "administrator.php?ctg=calendar", "title" => _CALENDAR), $toolsMenuId);
  252. }
  253. } else {
  254. if ($GLOBALS['configuration']['disable_dashboard'] != 1 && (!isset($currentUser -> coreAccess['dashboard']) || $currentUser -> coreAccess['dashboard'] != 'hidden')) {
  255. $newMenu -> insertMenuOption(array("id" => "personal_a", "image" => "user", "link" => $_SESSION['s_type'].".php?ctg=personal", "title" => _PERSONALDATA), $toolsMenuId);
  256. }
  257. if ($GLOBALS['configuration']['disable_calendar'] != 1 && (!isset($currentUser -> coreAccess['calendar']) || $currentUser -> coreAccess['calendar'] != 'hidden')) {
  258. $newMenu -> insertMenuOption(array("id" => "calendar_a", "image" => "calendar", "link" => $_SESSION['s_type'].".php?ctg=calendar", "title" => _CALENDAR), $toolsMenuId);
  259. }
  260. if (!isset($currentUser -> coreAccess['statistics']) || $currentUser -> coreAccess['statistics'] != 'hidden') {
  261. $newMenu -> insertMenuOption(array("id" => "statistics_a", "image" => "reports", "link" => $_SESSION['s_type'].".php?ctg=statistics", "title" => _STATISTICS), $toolsMenuId);
  262. }
  263. if (!$GLOBALS['configuration']['disable_forum'] && (!isset($GLOBALS['currentUser'] -> coreAccess['forum']) || $GLOBALS['currentUser'] -> coreAccess['forum'] != 'hidden')) {
  264. $newMenu -> insertMenuOption(array("id" => "forum_general_a", "image" => "message", "link" => $_SESSION['s_type'].".php?ctg=forum", "title" => _FORUMS), $toolsMenuId);
  265. }
  266. }
  267. if (!$GLOBALS['configuration']['disable_messages'] && (!isset($currentUser -> coreAccess['personal_messages']) || $currentUser -> coreAccess['personal_messages'] != 'hidden')) {
  268. $newMenu -> insertMenuOption(array("id" => "messages_a", "image" => "mail", "link" => $_SESSION['s_type'].".php?ctg=messages", "title" => _MESSAGES), $toolsMenuId);
  269. }
  270. // Get tools menu modules
  271. $moduleMenus = eF_getModuleMenu($modules, "tools");
  272. foreach ($moduleMenus as $moduleMenu) {
  273. $newMenu -> insertMenuOption($moduleMenu, $toolsMenuId);
  274. }
  275. // MODULES MENU
  276. $other_menus = array();
  277. foreach ($modules as $key => $module) {
  278. $sidebarLinks = $module -> getSidebarLinkInfo();
  279. isset($sidebarLinks["other"]) ? $sidebarLinks = $sidebarLinks["other"] : $sidebarLinks = array();
  280. isset($sidebarLinks["menuTitle"]) ? $menuTitle = $sidebarLinks["menuTitle"] : $menuTitle = '';
  281. // Get the title set for this other menu
  282. // If this menu does not exist create it
  283. if ($menuTitle && !isset($other_menus["'".$menuTitle."'"])) {
  284. $other_menus["'".$menuTitle."'"] = array();
  285. }
  286. if (isset($sidebarLinks["links"])) {
  287. foreach ($sidebarLinks["links"] as $mod_link) {
  288. $other_menus["'".$menuTitle."'"][] = array("id" => $module -> className . (($mod_link['id'])? "_".$mod_link['id']:""),
  289. "image" => eF_getRelativeModuleImagePath($mod_link['image']),
  290. "link" => $mod_link['link'],
  291. "title" => $mod_link['title'],
  292. "moduleLink" => "1",
  293. "eFrontExtensions" => $mod_link['eFrontExtensions'],
  294. "target" => isset($mod_link['target'])?$mod_link['target']:"mainframe");
  295. }
  296. }
  297. }
  298. // If more than 8 new menus exist, then all will be put under the same menu called MODULES
  299. if (sizeof($other_menus) > 8) {
  300. $massModulesMenuId = $newMenu -> createMenu( array("title" => _MODULES));
  301. foreach ($other_menus as $other_module_menu) {
  302. $newMenu -> insertMenuOption($other_module_menu, $massModulesMenu);
  303. }
  304. } else {
  305. // Otherwise a new menu will be put for each of them
  306. foreach ($other_menus as $title => $other_module_menu) {
  307. $newMenu -> insertMenuOption($other_module_menu, false, substr($title,1,strlen($title)-2));
  308. }
  309. }
  310. // ONLINE USERS MENU
  311. if (isset($_SESSION['s_lessons_ID']) && isset($currentLesson)) {
  312. try{
  313. $lesson_name = $currentLesson -> lesson['name'];
  314. } catch (Exception $e){
  315. $lesson_name = "";
  316. }
  317. } else {
  318. $lesson_name = "";
  319. }
  320. // In case of reload, select the correct menu
  321. if (isset($_GET['sbctg'])) {
  322. $smarty -> assign("T_ACTIVE_ID",$_GET['sbctg']);
  323. /*
  324. if ($_GET['sbctg'] == "personal") {
  325. #ifdef ENTERPRISE
  326. if ($_SESSION['s_type'] == "administrator") {
  327. $active_menu = 5;
  328. } else if ($employee -> isSupervisor()) {
  329. $active_menu = 3;
  330. } else {
  331. $active_menu = 2;
  332. }
  333. #else
  334. ($_SESSION['s_type'] == "administrator") ? $active_menu = 4: $active_menu = 2;
  335. #endif
  336. } else {
  337. }
  338. */
  339. $active_menu = $newMenu -> getCategoryMenu($_GET['sbctg']);
  340. // echo $active_menu;
  341. }
  342. $smarty -> assign ("T_ACTIVE_MENU", $active_menu);
  343. $_SESSION['last_id'] = 0; // Each time the sidebar reloads you need to get the five last minuites
  344. $smarty -> assign("T_MENU",$newMenu -> menu);
  345. if ($currentUser -> getType() != "administrator" && !isset($currentLesson)) {
  346. $smarty -> assign("T_MENUCOUNT", $newMenu -> menuCount-1);
  347. } else {
  348. $smarty -> assign("T_MENUCOUNT", $newMenu -> menuCount);
  349. }
  350. }
  351. if ((isset($GLOBALS['currentTheme'] -> options['sidebar_interface']) && $GLOBALS['currentTheme'] -> options['sidebar_interface'] < 2) ||
  352. ($GLOBALS['currentTheme'] -> options['sidebar_interface'] == 2 && $GLOBALS['currentTheme'] -> options['show_header'] == 2)) {
  353. if (((isset($GLOBALS['currentLesson']) && $GLOBALS['currentLesson'] -> options['online']) && $GLOBALS['currentLesson'] -> options['online'] == 1) || $_SESSION['s_type'] == 'administrator' ){
  354. //$currentUser = EfrontUserFactory :: factory($_SESSION['s_login']);
  355. $onlineUsers = EfrontUser :: getUsersOnline($GLOBALS['configuration']['autologout_time'] * 60);
  356. if (!$_SESSION['s_login']) {
  357. eF_redirect("index.php?message=".rawurlencode(_INACTIVITYLOGOUT));
  358. }
  359. $size = sizeof($onlineUsers);
  360. if ($size) {
  361. $smarty -> assign("T_ONLINE_USERS_COUNT", $size);
  362. }
  363. $smarty -> assign("T_ONLINE_USERS_LIST", $onlineUsers);
  364. }
  365. }
  366. if (!isset($horizontal_inframe_version) || !$horizontal_inframe_version) {
  367. if (!$GLOBALS['configuration']['disable_messages']) {
  368. if (($currentUser -> coreAccess['personal_messages']) || $currentUser -> coreAccess['personal_messages'] != 'hidden') {
  369. $unreadMessages = $messages = eF_getTableData("f_personal_messages pm, f_folders ff", "count(*)", "pm.users_LOGIN='".$_SESSION['s_login']."' and viewed='no' and f_folders_ID=ff.id and ff.name='Incoming'");
  370. $smarty -> assign("T_UNREAD_MESSAGES", $messages[0]['count(*)']);
  371. } else {
  372. $smarty -> assign("T_NO_MESSAGES", true);
  373. }
  374. } else {
  375. $smarty -> assign("T_NO_PERSONAL_MESSAGES", true);
  376. }
  377. $initwidth = eF_getTableData("configuration", "value", "name = 'sidebar_width'");
  378. if (empty($initwidth)) {
  379. $sideframe_width = 175;
  380. } else {
  381. $sideframe_width = $initwidth[0]['value'];
  382. }
  383. }
  384. if ($GLOBALS['configuration']['social_modules_activated'] & FB_FUNC_CONNECT) {
  385. $smarty -> assign("T_FACEBOOK_API_KEY", $GLOBALS['configuration']['facebook_api_key']);
  386. $smarty -> assign("T_OPEN_FACEBOOK_SESSION", "1");
  387. if (!isset($_SESSION['facebook_user'])) {
  388. $smarty -> assign("T_PROMPT_FB_CONNECTION", 1);
  389. }
  390. }
  391. if (unserialize($currentUser -> user['additional_accounts'])) {
  392. $accounts = unserialize($currentUser -> user['additional_accounts']);
  393. $queryString = "'".implode("','", array_values($accounts))."'";
  394. $result = eF_getTableData("users", "login, user_type", "login in (".$queryString.")");
  395. $smarty -> assign("T_BAR_ADDITIONAL_ACCOUNTS", $result);
  396. }
  397. $smarty -> load_filter('output', 'eF_template_formatTimestamp');
  398. $smarty -> load_filter('output', 'eF_template_formatLogins');
  399. $loadScripts[] = 'EfrontScripts';
  400. $loadScripts[] = 'print-script';
  401. $loadScripts[] = 'scriptaculous/prototype';
  402. $loadScripts[] = 'scriptaculous/effects';
  403. $loadScripts[] = 'efront_ajax';
  404. $loadScripts[] = 'sidebar';
  405. //array('EfrontScripts', 'print-script', 'scriptaculous/prototype', 'scriptaculous/effects', 'sidebar');
  406. $smarty -> assign("T_HEADER_LOAD_SCRIPTS", implode(",", array_unique($loadScripts))); //array_unique, so it doesn't send duplicate entries
  407. if (preg_match("/compatible; MSIE 6/", $_SERVER['HTTP_USER_AGENT']) && !preg_match("/compatible; MSIE 7/", $_SERVER['HTTP_USER_AGENT'])) {
  408. $smarty -> assign("globalImageExtension", "gif");
  409. } else {
  410. $smarty -> assign("globalImageExtension", "png");
  411. }
  412. if (!(isset($GLOBALS['currentTheme'] -> options['images_displaying']) && $GLOBALS['currentTheme'] -> options['images_displaying'] != 0)) {
  413. $smarty -> assign ("T_SHOW_SIDEBAR_IMAGES", 1);
  414. }
  415. /**** FOR USER STATUS ****/
  416. if ($GLOBALS['configuration']['social_modules_activated'] & SOCIAL_FUNC_USERSTATUS) {
  417. if ($currentUser -> coreAccess['dashboard'] != 'hidden') {
  418. $smarty -> assign("T_SHOW_USER_STATUS",1);
  419. }
  420. }
  421. $smarty -> assign("T_SIDEBARWIDTH", $sideframe_width);
  422. //$smarty -> assign("T_REALNAME", $realname);
  423. $smarty -> assign("T_SB_CTG", isset($_GET['sbctg']) ? $_GET['sbctg'] : false);
  424. $smarty -> assign("T_TYPE", $efront_type);
  425. $benchmark -> set('script');
  426. if (!isset($horizontal_inframe_version) || !$horizontal_inframe_version) {
  427. $smarty -> assign("T_NO_HORIZONTAL_MENU", 1);
  428. $smarty -> display('new_sidebar.tpl');
  429. }
  430. $benchmark -> set('smarty');
  431. $benchmark -> stop();
  432. $output = $benchmark -> display();
  433. if (G_DEBUG) {
  434. //echo $output; //Don't display, it's annoying
  435. }
  436. ?>