PageRenderTime 63ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 1ms

/community/www/student.php

https://github.com/svn2github/efront-lms
PHP | 638 lines | 503 code | 22 blank | 113 comment | 219 complexity | 13ea4239e2a703a605707e9896ccdc2f MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0
  1. <?php
  2. /**
  3. * Student main page
  4. *
  5. * This page performs all student function
  6. * @package eFront
  7. * @version 1.0
  8. */
  9. session_cache_limiter('none'); //Initialize session
  10. session_start();
  11. $path = "../libraries/"; //Define default path
  12. /** The configuration file.*/
  13. require_once $path."configuration.php";
  14. $benchmark = new EfrontBenchmark($debug_TimeStart);
  15. $benchmark -> set('init');
  16. //Set headers in order to eliminate browser cache (especially IE's)
  17. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  18. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  19. //If the page is shown as a popup, make sure it remains in such mode
  20. if (!isset($_GET['reset_popup']) && (isset($_GET['popup']) || isset($_POST['popup']) || (isset($_SERVER['HTTP_REFERER']) && strpos(strtolower($_SERVER['HTTP_REFERER']), 'popup') !== false && strpos(strtolower($_SERVER['HTTP_REFERER']), 'reset_popup') === false))) {
  21. output_add_rewrite_var('popup', 1);
  22. $smarty -> assign("T_POPUP_MODE", true);
  23. $popup = 1;
  24. }
  25. $search_message = $message = $message_type = ''; //Initialize messages, because if register_globals is turned on, some messages will be displayed twice
  26. $load_editor = false;
  27. $loadScripts = array();
  28. try {
  29. $currentUser = EfrontUser :: checkUserAccess(false, 'student');
  30. if ($currentUser -> user['user_type'] == 'administrator') {
  31. throw new Exception(_ADMINISTRATORCANNOTACCESSLESSONPAGE, EfrontUserException :: RESTRICTED_USER_TYPE);
  32. }
  33. $smarty -> assign("T_CURRENT_USER", $currentUser);
  34. } catch (Exception $e) {
  35. if ($e -> getCode() == EfrontUserException :: USER_NOT_LOGGED_IN && !isset($_GET['ajax'])) {
  36. setcookie('c_request', htmlspecialchars_decode(basename($_SERVER['REQUEST_URI'])), time() + 300);
  37. }
  38. eF_redirect("index.php?ctg=expired");
  39. exit;
  40. }
  41. if (isset($_SESSION['s_index_comply'])) {
  42. eF_redirect("index.php?ctg=".$_SESSION['s_index_comply']);
  43. exit;
  44. } else if (isset($_SESSION['missing_fields']) && ($_GET['ctg'] != 'personal' || $_GET['user'] != $currentUser->user['login'] || $_GET['op'] != 'profile')) {
  45. eF_redirect(basename($_SERVER['PHP_SELF'])."?ctg=personal&user=".$currentUser->user['login']."&op=profile&message=".urlencode(_PLEASEFILLINMISSINGMANDATORYFIELDS)."&message_type=success");
  46. exit;
  47. }
  48. if (!isset($_GET['ajax']) && !isset($_GET['postAjaxRequest']) && !isset($popup) && !isset($_GET['tabberajax'])) {
  49. $_SESSION['previousMainUrl'] = $_SERVER['REQUEST_URI'];
  50. }
  51. if (isset($_COOKIE['c_request']) && $_COOKIE['c_request']) {
  52. setcookie('c_request', '', time() - 86400);
  53. if (mb_strpos($_COOKIE['c_request'], '.php') !== false) {
  54. $urlParts = parse_url($_COOKIE['c_request']);
  55. if (basename($urlParts['path']) == 'student.php') {
  56. eF_redirect($_COOKIE['c_request']);
  57. }
  58. } else {
  59. eF_redirect($_SESSION['s_type'].'.php?'.$_COOKIE['c_request']);
  60. }
  61. }
  62. try {
  63. if (isset($_GET['view_unit']) || isset($_GET['package_ID'])) {
  64. if ($_GET['view_unit']) {
  65. $unit = new EfrontUnit($_GET['view_unit']);
  66. } elseif ($_GET['package_ID']) {
  67. $unit = new EfrontUnit($_GET['package_ID']);
  68. }
  69. if (!$unit['active'] && $_SESSION['s_lesson_user_type'] == "student") {
  70. $message = _YOUCANNOTACCESSTHISPAGE;
  71. eF_redirect("student.php?message=".urlencode($message)."&message_type=failure");
  72. }
  73. $currentLesson = new EfrontLesson($unit['lessons_ID']);
  74. $_SESSION['s_lessons_ID'] = $currentLesson -> lesson['id'];
  75. //$_SESSION['s_time_target'] = array($_SESSION['s_lessons_ID'] => 'lesson');
  76. }
  77. } catch (Exception $e) {
  78. unset($_GET['view_unit']);
  79. $smarty -> assign("T_EXCEPTION_TRACE", $e -> getTraceAsString());
  80. $message = $e -> getMessage().' ('.$e -> getCode().') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(\''._ERRORDETAILS.'\', 2, \'error_details\')">'._MOREINFO.'</a>';
  81. $message_type = 'failure';
  82. }
  83. $roles = EfrontLessonUser :: getLessonsRoles();
  84. $userLessons = $currentUser -> getLessons();
  85. if ($_SESSION['s_lessons_ID'] && $_GET['ctg'] != 'lessons') {
  86. try {
  87. $currentLesson = new EfrontLesson($_SESSION['s_lessons_ID']); //Initialize lesson
  88. //$_SESSION['s_time_target'] = array($_SESSION['s_lessons_ID'] => 'lesson');
  89. } catch (Exception $e) {
  90. unset($_SESSION['s_lessons_ID']);
  91. $smarty -> assign("T_REFRESH_SIDE", "true");
  92. }
  93. }
  94. /* This is used to allow users to enter directly internal lesson specific pages from external pages*/
  95. if (isset($_GET['new_lessons_ID']) && eF_checkParameter($_GET['new_lessons_ID'], 'id')) {
  96. if ($_GET['new_lessons_ID'] != $_SESSION['s_lessons_ID']) {
  97. $_SESSION['s_lessons_ID'] = $_GET['new_lessons_ID'];
  98. if (isset($_GET['sbctg'])) {
  99. // echo "swsta";
  100. $smarty -> assign("T_SPECIFIC_LESSON_CTG", $_GET['sbctg']);
  101. }
  102. $smarty -> assign("T_REFRESH_SIDE","true");
  103. } else if ($_GET['new_lessons_ID'] == $_SESSION['s_lessons_ID']) {
  104. $smarty -> assign("T_SHOW_LOADED_LESSON_OPTIONS", 1);
  105. }
  106. }
  107. /*This is the first time the professor enters this lesson, so register the lesson id to the session*/
  108. if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) {
  109. if (!isset($_SESSION['s_lessons_ID']) || $_GET['lessons_ID'] != $_SESSION['s_lessons_ID'] || (isset($_GET['from_course']) && $_GET['from_course'] != $_SESSION['s_courses_ID'])) {
  110. if (isset($_GET['course']) || isset($_GET['from_course'])) {
  111. if ($_GET['course']) {
  112. $course = new EfrontCourse($_GET['course']);
  113. } else {
  114. $course = new EfrontCourse($_GET['from_course']);
  115. }
  116. $eligibility = $course -> checkRules($_SESSION['s_login']);
  117. if ($eligibility[$_GET['lessons_ID']] == 0){
  118. unset($_GET['lessons_ID']);
  119. $message = _YOUCANNOTACCESSTHISLESSONBECAUSEOFCOURSERULES;
  120. eF_redirect("student.php?ctg=lessons&message=".urlencode($message)."&message_type=failure");
  121. }
  122. $_SESSION['s_courses_ID'] = $course -> course['id'];
  123. } else {
  124. unset($_SESSION['s_courses_ID']);
  125. }
  126. if (in_array($_GET['lessons_ID'], array_keys($userLessons))) {
  127. $newLesson = new EfrontLesson($_GET['lessons_ID']);
  128. if (!isset($_GET['course']) && !isset($_GET['from_course']) && $roles[$userLessons[$_GET['lessons_ID']]] == 'student' && (($newLesson -> lesson['from_timestamp'] && $newLesson -> lesson['from_timestamp'] > time()) || ($newLesson -> lesson['to_timestamp'] && $newLesson -> lesson['to_timestamp'] < time()))) {
  129. eF_redirect("student.php?ctg=lessons&message=".urlencode(_YOUCANNOTACCESSTHISLESSONORITDOESNOTEXIST));
  130. }
  131. $_SESSION['s_lessons_ID'] = $_GET['lessons_ID'];
  132. $_SESSION['s_type'] = $roles[$userLessons[$_GET['lessons_ID']]];
  133. //$justVisited = 1; // used to trigger the event when the lesson info is available
  134. // The justVisited flag is set to one during the first visit to this lesson
  135. //if ($justVisited) {
  136. //Trigger onLessonVisited event
  137. EfrontEvent::triggerEvent(array("type" => EfrontEvent::LESSON_VISITED, "users_LOGIN" => $currentUser -> user['login'], "users_name" => $currentUser -> user['name'], "users_surname" => $currentUser -> user['surname'], "lessons_ID" => $_SESSION['s_lessons_ID']));
  138. //}
  139. $smarty -> assign("T_CHANGE_LESSON", "true");
  140. $smarty -> assign("T_REFRESH_SIDE", "true");
  141. } else {
  142. unset($_GET['lessons_ID']);
  143. $message = _YOUCANNOTACCESSTHISLESSONORITDOESNOTEXIST;
  144. $message_type = 'failure';
  145. $ctg = 'personal';
  146. }
  147. } else if ($_GET['lessons_ID'] == $_SESSION['s_lessons_ID']) {
  148. $smarty -> assign("T_SHOW_LOADED_LESSON_OPTIONS", 1);
  149. }
  150. }
  151. if ($_SESSION['s_lessons_ID'] && $roles[$userLessons[$_SESSION['s_lessons_ID']]].'.php' != basename($_SERVER['PHP_SELF'])) {
  152. if ($_GET['ctg'] != 'lessons') {
  153. eF_redirect(''.$roles[$userLessons[$_SESSION['s_lessons_ID']]].'.php');
  154. exit;
  155. }
  156. }
  157. if (isset($_SESSION['s_lessons_ID']) && $_SESSION['s_lessons_ID'] && $_GET['ctg'] != 'lessons') { //Check validity of current lesson
  158. $userLessons = $currentUser -> getLessons();
  159. if (!isset($userLessons[$_SESSION['s_lessons_ID']]) || $roles[$userLessons[$_SESSION['s_lessons_ID']]] != 'student') {
  160. eF_redirect("student.php?ctg=lessons"); //redirect to student's lessons page
  161. exit;
  162. }
  163. try {
  164. $currentUser -> applyRoleOptions($userLessons[$_SESSION['s_lessons_ID']]); //Initialize user's role options for this lesson
  165. $currentLesson = new EfrontLesson($_SESSION['s_lessons_ID']); //Initialize lesson
  166. $smarty -> assign("T_TITLE_BAR", $currentLesson -> lesson['name']);
  167. //$_SESSION['s_time_target'] = array($_SESSION['s_lessons_ID'] => 'lesson');
  168. $_SESSION['s_lesson_user_type'] = $roles[$userLessons[$_SESSION['s_lessons_ID']]]; //needed for outputfilter.eF_template_setInnerLinks
  169. $currentUser -> coreAccess['content'] != 'change' ? $currentLesson -> mode = 'browse' : $currentLesson -> mode = 'normal'; //If the user type's setting is other than 'change' from content, then set lesson mode to 'browse', which means that no unit completion or ' or whatever progress is recorded
  170. } catch (Exception $e) {
  171. unset($_SESSION['s_lessons_ID']);
  172. $message = $e -> getMessage().' ('.$e -> getCode().')';
  173. eF_redirect("".basename($_SERVER['PHP_SELF'])."?message=".urlencode($message)."&message_type=failure"); //redirect to user lessons page
  174. }
  175. }
  176. //@todo: remove package_ID from $_SESSION, beware package_ID is needed in lms_commit
  177. if (isset($_SESSION['package_ID']) && !$_GET['commit_lms']) {
  178. unset($_SESSION['package_ID']);
  179. }
  180. try {
  181. if (isset($_GET['view_unit']) && eF_checkParameter($_GET['view_unit'], 'id')) {
  182. $currentContent = new EfrontContentTree($currentLesson); //Initialize content
  183. $currentContent -> markSeenNodes($currentUser);
  184. if ($currentLesson->lesson['access_limit']) {
  185. $result = eF_getTableData("users_to_lessons", "access_counter", "users_LOGIN='".$currentUser->user['login']."' and lessons_ID='".$currentLesson->lesson['id']."'");
  186. if ($result[0]['access_counter'] >= $currentLesson->lesson['access_limit']) {
  187. eF_redirect(basename($_SERVER['PHP_SELF'])."?ctg=lessons&message=".urlencode(_ACCESSDEPLETED)."&message_type=failure");
  188. } else {
  189. eF_updateTableData("users_to_lessons", array('access_counter' => $result[0]['access_counter']+1), "users_LOGIN='".$currentUser->user['login']."' and lessons_ID='".$currentLesson->lesson['id']."'");
  190. }
  191. }
  192. if ($currentUser -> coreAccess['content'] == 'hidden') {
  193. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  194. }
  195. if (!$currentLesson || !$currentContent) {
  196. eF_redirect("".basename($_SERVER['PHP_SELF']));
  197. }
  198. $currentUnit = $currentContent -> seekNode($_GET['view_unit']); //Initialize current unit
  199. //The content tree does not hold data, so assign this unit its data
  200. $unitData = new EfrontUnit($_GET['view_unit']);
  201. //$_SESSION['s_time_target'] = array($_GET['view_unit'] => 'unit');
  202. $currentUnit['data'] = $unitData['data'];
  203. if (!$_GET['ctg']) {
  204. $_GET['ctg'] = 'content';
  205. }
  206. } elseif (isset($_GET['package_ID']) && $currentContent) {
  207. $_GET['ctg'] = 'content';
  208. }
  209. } catch (Exception $e) {
  210. unset($_GET['view_unit']);
  211. $smarty -> assign("T_EXCEPTION_TRACE", $e -> getTraceAsString());
  212. $message = $e -> getMessage().' ('.$e -> getCode().') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(\''._ERRORDETAILS.'\', 2, \'error_details\')">'._MOREINFO.'</a>';
  213. $message_type = 'failure';
  214. }
  215. $redirectPage = $GLOBALS['configuration']['login_redirect_page'];
  216. if ($redirectPage == "user_dashboard" && $user_type != "administrator") {
  217. $location = "student.php?ctg=personal&user=".$_SESSION['s_login']."&op=dashboard";
  218. } elseif (strpos($redirectPage, "module") !== false) {
  219. $location = "student.php?ctg=landing_page";
  220. } else {
  221. $location = "student.php?ctg=lessons";
  222. }
  223. $smarty->assign("T_HOME_LINK", $location);
  224. ///MODULE1: Import
  225. try {
  226. $loadedModules = $currentUser -> getModules();
  227. $module_css_array = array();
  228. $module_js_array = array();
  229. // Include module languages
  230. foreach ($loadedModules as $module) {
  231. // The $setLanguage variable is defined in globals.php
  232. $mod_lang_file = $module -> getLanguageFile($setLanguage);
  233. if (is_file ($mod_lang_file)) {
  234. require_once $mod_lang_file;
  235. }
  236. // Get module css
  237. if($mod_css_file = $module -> getModuleCSS()) {
  238. if (is_file ($mod_css_file)) {
  239. // Get the relative path
  240. if ($position = strpos($mod_css_file, "modules")) {
  241. $mod_css_file = substr($mod_css_file, $position);
  242. }
  243. $module_css_array[] = $mod_css_file;
  244. }
  245. }
  246. // Get module js
  247. if($mod_js_file = $module -> getModuleJS()) {
  248. if (is_file($mod_js_file)) {
  249. // Get the relative path
  250. if ($position = strpos($mod_js_file, "modules")) {
  251. $mod_js_file = substr($mod_js_file, $position);
  252. }
  253. $module_js_array[] = $mod_js_file;
  254. }
  255. }
  256. // Run onNewPageLoad code of the module (if such is defined)
  257. $module -> onNewPageLoad();
  258. }
  259. } catch (Exception $e) {
  260. handleNormalFlowExceptions($e);
  261. }
  262. /*Ajax call to enter group and get group lessons */
  263. if (isset($_GET['ajax']) && isset($_GET['group_key'])) {
  264. try {
  265. if (!eF_checkParameter($_GET['group_key'], 'alnum_general')) {
  266. throw new Exception(_INVALIDDATA.': '.$_GET['group_key']);
  267. }
  268. $result = eF_getTableData("groups", "*", "unique_key = '" . $_GET['group_key'] . "'");
  269. if (sizeof($result) > 0) {
  270. $group = new EfrontGroup($result[0]);
  271. echo json_encode($group -> useKeyForUser($currentUser));
  272. } else {
  273. throw new Exception(_INVALIDKEY.': '.$_GET['group_key']);
  274. }
  275. } catch (Exception $e) {
  276. handleAjaxExceptions($e);
  277. }
  278. exit;
  279. }
  280. if (isset($_GET['bookmarks']) && $GLOBALS['configuration']['disable_bookmarks'] != 1) {
  281. try {
  282. $bookmarks = bookmarks :: getBookmarks($currentUser, $currentLesson);
  283. if ($_GET['bookmarks'] == 'remove' && in_array($_GET['id'], array_keys($bookmarks))) {
  284. $bookmark = new bookmarks($_GET['id']);
  285. $bookmark -> delete();
  286. } elseif ($_GET['bookmarks'] == 'add') {
  287. foreach ($bookmarks as $value) {
  288. $urls[] = $value['url'];
  289. }
  290. if (!in_array($_SERVER['PHP_SELF']."?view_unit=".$currentUnit['id'], $urls)) {
  291. $fields = array('users_LOGIN' => $currentUser -> user['login'],
  292. 'lessons_ID' => $currentLesson -> lesson['id'],
  293. 'name' => $currentUnit['name'],
  294. 'url' => $_SERVER['PHP_SELF']."?view_unit=".$currentUnit['id']);
  295. bookmarks :: create($fields);
  296. }
  297. } else {
  298. echo json_encode($bookmarks);
  299. }
  300. } catch (Exception $e) {
  301. handleAjaxExceptions($e);
  302. }
  303. exit;
  304. }
  305. /*Added Session variable for search results*/
  306. $_SESSION['referer'] = $_SERVER['REQUEST_URI'];
  307. //$_SESSION['last_action_timestamp'] = time(); //Keep the last time something happened to the session
  308. /*Horizontal menus*/
  309. $onlineUsers = EfrontUser :: getUsersOnline($GLOBALS['configuration']['autologout_time'] * 60);
  310. if ($GLOBALS['currentTheme'] -> options['sidebar_interface']) {
  311. $smarty -> assign("T_ONLINE_USERS_LIST", $onlineUsers);
  312. if ($accounts = unserialize($currentUser -> user['additional_accounts'])) {
  313. $result = eF_getTableData("users", "login, user_type", 'login in ("'.implode('","', array_values($accounts)).'")');
  314. $smarty -> assign("T_MAPPED_ACCOUNTS", $result);
  315. }
  316. } else {
  317. $smarty -> assign("T_NO_HORIZONTAL_MENU", 1);
  318. }
  319. refreshLogin();//Important: It must be called AFTER EfrontUser :: getUsersOnline
  320. !isset($_GET['ctg']) || !eF_checkParameter($_GET['ctg'], 'alnum_general') ? $ctg = "control_panel" : $ctg = $_GET['ctg'];
  321. if (!$_SESSION['s_lessons_ID'] && $ctg != 'personal' && $ctg != 'statistics' && ($ctg == 'control_panel' && (!isset($_GET['op']) || $_GET['op'] != "search"))) { //If there is not a lesson in the session, then the user just logged into the system. Redirect him to lessons page, except for the case he is viewing his personal information 2007/07/27 added search control. It was a problem when user had not choose a lesson.
  322. $ctg = 'lessons';
  323. }
  324. $smarty -> assign("T_CTG", $ctg); //As soon as we derive the current ctg, assign it to smarty.
  325. $smarty -> assign("T_OP", isset($_GET['op']) ? $_GET['op'] : false);
  326. $smarty -> assign("T_FCT", isset($_GET['fct']) ? $_GET['fct'] : false);
  327. //Create shorthands for user type, to avoid long variable names
  328. $_student_ = $_professor_ = $_admin_ = 0;
  329. if ((isset($_SESSION['s_lesson_user_type']) && $_SESSION['s_lesson_user_type'] == 'student') || (!isset($_SESSION['s_lesson_user_type']) && $_SESSION['s_type'] == 'student')) {
  330. $_student_ = 1;
  331. } else if ((isset($_SESSION['s_lesson_user_type']) && $_SESSION['s_lesson_user_type'] == 'professor') || (!isset($_SESSION['s_lesson_user_type']) && $_SESSION['s_type'] == 'professor')) {
  332. $_professor_ = 1;
  333. } else {
  334. $_admin_ = 1;
  335. }
  336. $smarty -> assign("_student_", $_student_);
  337. $smarty -> assign("_professor_", $_professor_);
  338. $smarty -> assign("_admin_", $_admin_);
  339. try {
  340. if ($ctg == 'control_panel') {
  341. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  342. /***/
  343. require_once("control_panel.php");
  344. }
  345. elseif ($ctg == 'landing_page') {
  346. /***/
  347. require_once ("landing_page.php");
  348. }
  349. elseif ($ctg == 'news') {
  350. //$_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF'])); //Commented out so that dashboard news links are working
  351. /***/
  352. require_once ("news.php");
  353. }
  354. elseif ($ctg == 'progress') {
  355. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  356. /***/
  357. require_once("progress.php");
  358. }
  359. elseif ($ctg == 'comments') {
  360. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  361. /***/
  362. require_once ("comments.php");
  363. }
  364. elseif ($ctg== 'lesson_information') {
  365. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  366. /***/
  367. require_once("lesson_information.php");
  368. }
  369. elseif ($ctg== 'digital_library' && $currentLesson -> options['digital_library']) {
  370. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  371. /***/
  372. require_once("digital_library.php");
  373. }
  374. elseif ($ctg == 'projects') {
  375. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  376. /**The file that handles the projects*/
  377. require_once("projects.php");
  378. }
  379. elseif ($ctg == 'content') {
  380. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  381. if (isset($_GET['commit_lms'])) {
  382. /***/
  383. require_once("lms_commit.php");
  384. exit;
  385. } else {
  386. /***/
  387. require_once("common_content.php");
  388. }
  389. }
  390. elseif ($ctg == 'tests') {
  391. //$_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  392. /***/
  393. require_once("module_tests.php");
  394. }
  395. elseif ($ctg == 'feedback') {
  396. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  397. require_once("module_tests.php");
  398. }
  399. elseif ($ctg == 'lessons') {
  400. /***/
  401. require_once("includes/lessons_list.php");
  402. }
  403. elseif ($ctg == 'forum') {
  404. /***/
  405. require_once("includes/forum.php");
  406. }
  407. elseif ($ctg == 'messages') {
  408. /***/
  409. require_once("includes/messages.php");
  410. }
  411. elseif ($ctg == 'module') {
  412. /***/
  413. require_once("module.php");
  414. }
  415. elseif ($ctg == "social") {
  416. /***/
  417. require_once("social.php");
  418. }
  419. else if ($ctg == 'facebook') {
  420. /***/
  421. require_once "module_facebook.php";
  422. }
  423. elseif ($ctg == 'calendar') {
  424. if ($currentUser -> coreAccess['calendar'] != 'hidden' && $GLOBALS['configuration']['disable_calendar'] != 1) {
  425. require_once "calendar.php";
  426. } else {
  427. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  428. }
  429. }
  430. elseif ($ctg == 'glossary') {
  431. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  432. /***/
  433. require_once("glossary.php");
  434. }
  435. elseif ($ctg == 'survey') {
  436. if ($currentUser -> coreAccess['surveys'] == 'hidden' || $GLOBALS['configuration']['disable_surveys'] == 1) {
  437. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  438. }
  439. $load_editor=true;
  440. include_once "module_surveys.php";
  441. }
  442. elseif ($ctg == 'statistics') {
  443. if (isset($_GET['show_solved_test']) && eF_checkParameter($_GET['show_solved_test'], 'id') && isset($_GET['lesson']) && eF_checkParameter($_GET['lesson'], 'id')) {
  444. try {
  445. //pr($_GET['lesson']);pr($currentUser -> getLessons());
  446. if (in_array($_GET['lesson'], array_keys($currentUser -> getLessons()))) {
  447. $result = eF_getTableData("done_tests, tests, content", "done_tests.tests_ID, done_tests.users_LOGIN", "content.id=tests.content_ID and content.lessons_ID=".$_GET['lesson']." and tests.id = done_tests.tests_ID and done_tests.users_LOGIN = '".$currentUser -> user['login']."' and done_tests.id=".$_GET['show_solved_test']);
  448. if (sizeof($result) > 0) {
  449. $showTest = new EfrontTest($result[0]['tests_ID']);
  450. //Set "show answers" and "show given answers" to true, since if it is not the student that sees the test
  451. if ($currentUser -> user['user_type'] != 'student') {
  452. $showTest -> options['answers'] = 1;
  453. $showTest -> options['given_answers'] = 1;
  454. }
  455. $showTest -> setDone($result[0]['users_LOGIN']);
  456. $smarty -> assign("T_CURRENT_TEST", $showTest -> test);
  457. $smarty -> assign("T_SOLVED_TEST_DATA", $showTest -> doneInfo);
  458. $smarty -> assign("T_TEST_SOLVED", $showTest -> toHTMLQuickForm(new HTML_Quickform(), false, true));
  459. } else {
  460. $message = _USERHASNOTDONETEST;
  461. $message_type = 'failure';
  462. }
  463. } else {
  464. $message = _USERHASNOTTHISLESSON;
  465. $message_type = 'failure';
  466. }
  467. } catch (Exception $e) {
  468. $smarty -> assign("T_EXCEPTION_TRACE", $e -> getTraceAsString());
  469. $message = $e -> getMessage().' ('.$e -> getCode().') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(\''._ERRORDETAILS.'\', 2, \'error_details\')">'._MOREINFO.'</a>';
  470. $message_type = 'failure';
  471. }
  472. } else {
  473. /**The statistics funtions*/
  474. if ($currentUser -> coreAccess['statistics'] != 'hidden') {
  475. require_once "statistics.php";
  476. } else {
  477. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  478. }
  479. }
  480. }
  481. elseif ($ctg == 'personal') {
  482. /**This part is used to display the user's personal information*/
  483. include "includes/personal.php";
  484. }
  485. /*
  486. At this point, we apply module functionality
  487. */
  488. elseif (sizeof($modules) > 0 && in_array($ctg, array_keys($module_ctgs))) {
  489. $module_mandatory = eF_getTableData("modules", "mandatory", "name = '".$ctg."'");
  490. if ($module_mandatory[0]['mandatory'] != 'false' || ($GLOBALS['currentLesson'] -> options[$ctg])) {
  491. include(G_MODULESPATH.$ctg.'/module.php');
  492. $smarty -> assign("T_CTG_MODULE", $module_ctgs[$ctg]);
  493. }
  494. }
  495. $fields_log = array ('users_LOGIN' => $_SESSION['s_login'], //This is the log entry array
  496. 'timestamp' => time(),
  497. 'session_ip' => eF_encodeIP($_SERVER['REMOTE_ADDR']));
  498. /*
  499. if (isset($log_comments)) { //If there is a $log_comments variable, it indicates the current action (i.e. the unit that the user saw)
  500. $fields_log['action'] = $ctg;
  501. $fields_log['comments'] = $log_comments;
  502. ($_SESSION['s_lessons_ID']) ? $fields_log['lessons_ID'] = $_SESSION['s_lessons_ID'] : $fields_log['lessons_ID'] = 0;
  503. eF_insertTableData("logs", $fields_log);
  504. } else { //Any other move, that has not set the $log_comments variable, is considered a 'lastmove' action
  505. $fields_log['action'] = "lastmove";
  506. $fields_log['comments'] = "";
  507. ($_SESSION['s_lessons_ID']) ? $fields_log['lessons_ID'] = $_SESSION['s_lessons_ID'] : $fields_log['lessons_ID'] = 0;
  508. eF_deleteTableData("logs", "users_LOGIN='".$_SESSION['s_login']."' AND action='lastmove'"); //Only one lastmove action interests us, so delete any other
  509. eF_insertTableData("logs", $fields_log);
  510. }
  511. */
  512. if (detectBrowser() == 'mobile') {
  513. $load_editor = false;
  514. }
  515. $smarty -> assign("T_HEADER_EDITOR", $load_editor); //Specify whether we need to load the editor
  516. /*
  517. * Check if you should input the JS code to
  518. * trigger sending the next notificatoin emails
  519. * Since 3.6.0
  520. */
  521. if (EfrontNotification::shouldSendNextNotifications()) {
  522. $smarty -> assign("T_TRIGGER_NEXT_NOTIFICATIONS_SEND", 1);
  523. $_SESSION['send_next_notifications_now'] = 0; // the msg that triggered the immediate send should be sent now
  524. }
  525. } catch (Exception $e) {
  526. $smarty -> assign("T_EXCEPTION_TRACE", $e -> getTraceAsString());
  527. $message = $e -> getMessage().' ('.$e -> getCode().') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(\''._ERRORDETAILS.'\', 2, \'error_details\')">'._MOREINFO.'</a>';
  528. $message_type = 'failure';
  529. }
  530. if (isset($_GET['refresh'])) {
  531. $smarty -> assign("T_REFRESH_SIDE","true");
  532. }
  533. $smarty -> assign("T_MODULE_CSS", $module_css_array);
  534. $smarty -> assign("T_MODULE_JS", $module_js_array);
  535. foreach ($loadedModules as $module) {
  536. $loadScripts = array_merge($loadScripts, $module -> addScripts());
  537. }
  538. //Main scripts, such as prototype
  539. $mainScripts = getMainScripts();
  540. $smarty -> assign("T_HEADER_MAIN_SCRIPTS", implode(",", $mainScripts));
  541. //Operation/file specific scripts
  542. $loadScripts = array_diff($loadScripts, $mainScripts); //Clear out duplicates
  543. $smarty -> assign("T_HEADER_LOAD_SCRIPTS", implode(",", array_unique($loadScripts))); //array_unique, so it doesn't send duplicate entries
  544. $smartyClosingFiles = array();
  545. foreach ($loadedModules as $module) {
  546. if ($smartyClosingFile = $module -> onPageFinishLoadingSmartyTpl()) {
  547. $smartyClosingFiles[] = $smartyClosingFile;
  548. }
  549. }
  550. $smarty -> assign("T_PAGE_FINISH_MODULES", $smartyClosingFiles);
  551. $smarty -> assign("T_CURRENT_CTG", $ctg);
  552. $smarty -> assign("T_MENUCTG", $ctg);
  553. //$smarty -> assign("T_MENU", eF_getMenu());
  554. //$smarty -> assign("T_QUERIES", $numberOfQueries);
  555. if ($_SESSION['s_message']) {
  556. $message .= urldecode($_SESSION['s_message']);
  557. $message_type = $_SESSION['s_message_type'];
  558. unset($_SESSION['s_message']);
  559. unset($_SESSION['s_message_type']);
  560. }
  561. $smarty -> assign("T_MESSAGE", $message);
  562. $smarty -> assign("T_MESSAGE_TYPE", $message_type);
  563. $smarty -> assign("T_SEARCH_MESSAGE", $search_message);
  564. $smarty -> assign("T_CONFIGURATION", $configuration); //Assign global configuration values to smarty
  565. $smarty -> assign("T_CURRENT_USER", $currentUser);
  566. $smarty -> assign("T_CURRENT_LESSON", isset($currentLesson) ? $currentLesson : false);
  567. if (isset($currentLesson)) {
  568. $directions = new EfrontDirectionsTree();
  569. $paths = $directions -> toPathString();
  570. $categoryPath = $paths[$currentLesson->lesson["directions_ID"]];
  571. //$categoryPath = str_replace("&rarr", "&raquo", $categoryPath);
  572. $smarty -> assign("T_CURRENT_CATEGORY_PATH", $categoryPath);
  573. if ($currentLesson -> lesson['course_only'] == 1 && $_SESSION['s_courses_ID']) {
  574. $currentCourse = new EfrontCourse($_SESSION['s_courses_ID']);
  575. $smarty -> assign("T_CURRENT_COURSE_NAME", htmlspecialchars($currentCourse->course['name'], ENT_QUOTES));
  576. $smarty -> assign("T_CURRENT_COURSE_ID", $currentCourse->course['id']);
  577. }
  578. }
  579. $smarty -> load_filter('output', 'eF_template_formatTimestamp');
  580. $smarty -> load_filter('output', 'eF_template_formatLogins');
  581. $smarty -> load_filter('output', 'eF_template_setInnerLinks');
  582. $smarty -> load_filter('output', 'eF_template_setEditorOffset');
  583. $benchmark -> set('script');
  584. $smarty -> display('student.tpl');
  585. $benchmark -> set('smarty');
  586. $benchmark -> stop();
  587. $output = $benchmark -> display();
  588. if (G_DEBUG) {
  589. echo $output;
  590. }
  591. ?>