PageRenderTime 54ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/community/www/professor.php

https://github.com/svn2github/efront-lms
PHP | 648 lines | 541 code | 16 blank | 91 comment | 231 complexity | 187f74e80853184d1e6528cfc262e17e MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0
  1. <?php
  2. /**
  3. * Professor main page
  4. *
  5. * This page performs all professor functions
  6. * @package eFront
  7. * @version 3.6.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. setcookie("parent_sid", session_id(), time()+3600, "/"); //We use this for the editor, in order to work with branch urls. See also browse.php, image.php on how it's used
  26. $message = '';$message_type = ''; //Initialize messages, because if register_globals is turned on, some messages will be displayed twice
  27. try {
  28. $currentUser = EfrontUser :: checkUserAccess(false, 'professor');
  29. if ($currentUser -> user['user_type'] == 'administrator') {
  30. throw new Exception(_ADMINISTRATORCANNOTACCESSLESSONPAGE, EfrontUserException :: RESTRICTED_USER_TYPE);
  31. }
  32. $smarty -> assign("T_CURRENT_USER", $currentUser);
  33. } catch (Exception $e) {
  34. if ($e -> getCode() == EfrontUserException :: USER_NOT_LOGGED_IN && !isset($_GET['ajax'])) {
  35. setcookie('c_request', htmlspecialchars_decode(basename($_SERVER['REQUEST_URI'])), time() + 300, false, false, false, true);
  36. }
  37. eF_redirect("index.php?ctg=expired");
  38. exit;
  39. }
  40. if (isset($_SESSION['s_index_comply'])) {
  41. eF_redirect("index.php?ctg=".$_SESSION['s_index_comply']);
  42. exit;
  43. }
  44. if (!isset($_GET['ajax']) && !isset($_GET['postAjaxRequest']) && !isset($popup) && !isset($_GET['tabberajax'])) {
  45. $_SESSION['previousMainUrl'] = $_SERVER['REQUEST_URI'];
  46. }
  47. if (isset($_COOKIE['c_request']) && $_COOKIE['c_request']) {
  48. setcookie('c_request', '', time() - 86400);
  49. if (mb_strpos($_COOKIE['c_request'], '.php') !== false) {
  50. $urlParts = parse_url($_COOKIE['c_request']);
  51. if (basename($urlParts['path']) == 'professor.php') {
  52. eF_redirect($_COOKIE['c_request']);
  53. }
  54. } else {
  55. eF_redirect($_SESSION['s_type'].'.php?'.$_COOKIE['c_request']);
  56. }
  57. }
  58. $roles = EfrontLessonUser :: getLessonsRoles();
  59. try {
  60. if (isset($_GET['view_unit']) || isset($_GET['package_ID'])) {
  61. if ($_GET['view_unit']) {
  62. $unit = new EfrontUnit($_GET['view_unit']);
  63. } elseif ($_GET['package_ID']) {
  64. $unit = new EfrontUnit($_GET['package_ID']);
  65. }
  66. $currentLesson = new EfrontLesson($unit['lessons_ID']);
  67. $_SESSION['s_lessons_ID'] = $currentLesson -> lesson['id'];
  68. //$_SESSION['s_time_target'] = array($_SESSION['s_lessons_ID'] => 'lesson');
  69. }
  70. } catch (Exception $e) {
  71. unset($_GET['view_unit']);
  72. $smarty -> assign("T_EXCEPTION_TRACE", $e -> getTraceAsString());
  73. $message = $e -> getMessage().' ('.$e -> getCode().') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(\''._ERRORDETAILS.'\', 2, \'error_details\')">'._MOREINFO.'</a>';
  74. $message_type = 'failure';
  75. }
  76. /* This is used to allow users to enter directly internal lesson specific pages from external pages*/
  77. if (isset($_GET['new_lessons_ID']) && eF_checkParameter($_GET['new_lessons_ID'], 'id')) {
  78. if ($_GET['new_lessons_ID'] != $_SESSION['s_lessons_ID']) {
  79. $_SESSION['s_lessons_ID'] = $_GET['new_lessons_ID'];
  80. if (isset($_GET['sbctg'])) {
  81. $smarty -> assign("T_SPECIFIC_LESSON_CTG", $_GET['sbctg']);
  82. }
  83. $smarty -> assign("T_REFRESH_SIDE","true");
  84. } else if ($_GET['new_lessons_ID'] == $_SESSION['s_lessons_ID']) {
  85. $smarty -> assign("T_SHOW_LOADED_LESSON_OPTIONS", 1);
  86. }
  87. }
  88. /*This is the first time the professor enters this lesson, so register the lesson id to the session*/
  89. if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) {
  90. if (!isset($_SESSION['s_lessons_ID']) || $_GET['lessons_ID'] != $_SESSION['s_lessons_ID'] || (isset($_GET['from_course']) && $_GET['from_course'] != $_SESSION['s_courses_ID'])) {
  91. unset($_SESSION['s_courses_ID']);
  92. $userLessons = $currentUser -> getLessons();
  93. if (isset($_GET['course']) || isset($_GET['from_course'])) {
  94. if ($_GET['course']) {
  95. $course = new EfrontCourse($_GET['course']);
  96. } else {
  97. $course = new EfrontCourse($_GET['from_course']);
  98. }
  99. $_SESSION['s_courses_ID'] = $course -> course['id'];
  100. }
  101. if (in_array($_GET['lessons_ID'], array_keys($userLessons))) {
  102. $_SESSION['s_lessons_ID'] = $_GET['lessons_ID'];
  103. $_SESSION['s_type'] = $roles[$userLessons[$_GET['lessons_ID']]];
  104. $smarty -> assign("T_CHANGE_LESSON", "true");
  105. $smarty -> assign("T_REFRESH_SIDE", "true");
  106. } else {
  107. unset($_GET['lessons_ID']);
  108. $message = _YOUCANNOTACCESSTHISLESSONORITDOESNOTEXIST;
  109. $message_type = 'failure';
  110. $_GET['ctg'] = 'personal';
  111. }
  112. } else if ($_GET['lessons_ID'] == $_SESSION['s_lessons_ID']) {
  113. $smarty -> assign("T_SHOW_LOADED_LESSON_OPTIONS", 1);
  114. }
  115. }
  116. if (isset($_SESSION['s_lessons_ID']) && $_SESSION['s_lessons_ID'] && $_GET['ctg'] != 'lessons') { //Check validity of current lesson
  117. $userLessons = $currentUser -> getLessons();
  118. if ($_GET['ctg'] != 'personal' && (!isset($userLessons[$_SESSION['s_lessons_ID']]) || $roles[$userLessons[$_SESSION['s_lessons_ID']]] != 'professor')) {
  119. eF_redirect("student.php?ctg=lessons"); //redirect to student's lessons page
  120. exit;
  121. }
  122. try {
  123. $currentUser -> applyRoleOptions($userLessons[$_SESSION['s_lessons_ID']]); //Initialize user's role options for this lesson
  124. $currentLesson = new EfrontLesson($_SESSION['s_lessons_ID']); //Initialize lesson
  125. //$_SESSION['s_time_target'] = array($_SESSION['s_lessons_ID'] => 'lesson');
  126. $_SESSION['s_lesson_user_type'] = $roles[$userLessons[$_SESSION['s_lessons_ID']]]; //needed for outputfilter.eF_template_setInnerLinks
  127. $smarty -> assign("T_TITLE_BAR", $currentLesson -> lesson['name']);
  128. } catch (Exception $e) {
  129. unset($_SESSION['s_lessons_ID']);
  130. $message = $e -> getMessage().' ('.$e -> getCode().')';
  131. eF_redirect("".basename($_SERVER['PHP_SELF'])."?message=".urlencode($message)."&message_type=failure");
  132. }
  133. }
  134. //@todo: remove package_ID from $_SESSION, beware package_ID is needed in lms_commit
  135. if (isset($_SESSION['package_ID']) && !$_GET['commit_lms']) {
  136. unset($_SESSION['package_ID']);
  137. }
  138. try {
  139. if (isset($_GET['view_unit']) && eF_checkParameter($_GET['view_unit'], 'id')) {
  140. $currentContent = new EfrontContentTree($currentLesson); //Initialize content
  141. if ($currentUser -> coreAccess['content'] == 'hidden') {
  142. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  143. }
  144. if (!$currentLesson || !$currentContent) {
  145. eF_redirect("".basename($_SERVER['PHP_SELF']));
  146. }
  147. $currentUnit = $currentContent -> seekNode($_GET['view_unit']); //Initialize current unit
  148. //The content tree does not hold data, so assign this unit its data
  149. $unitData = new EfrontUnit($_GET['view_unit']);
  150. //$_SESSION['s_time_target'] = array($_GET['view_unit'] => 'unit');
  151. $currentUnit['data'] = $unitData['data'];
  152. if (!$_GET['ctg']) {
  153. $_GET['ctg'] = 'content';
  154. }
  155. } elseif (isset($_GET['package_ID']) && $currentContent) {
  156. $_GET['ctg'] = 'content';
  157. }
  158. } catch (Exception $e) {
  159. unset($_GET['view_unit']);
  160. $smarty -> assign("T_EXCEPTION_TRACE", $e -> getTraceAsString());
  161. $message = $e -> getMessage().' ('.$e -> getCode().') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(\''._ERRORDETAILS.'\', 2, \'error_details\')">'._MOREINFO.'</a>';
  162. $message_type = 'failure';
  163. }
  164. /*Ajax call to enter group and get group lessons */
  165. if (isset($_GET['ajax']) && isset($_GET['group_key'])) {
  166. try {
  167. if (!eF_checkParameter($_GET['group_key'], 'alnum_general')) {
  168. throw new Exception(_INVALIDDATA.': '.$_GET['group_key']);
  169. }
  170. $result = eF_getTableData("groups", "*", "unique_key = '" . $_GET['group_key'] . "'");
  171. if (sizeof($result) > 0) {
  172. $group = new EfrontGroup($result[0]);
  173. echo json_encode($group -> useKeyForUser($currentUser));
  174. } else {
  175. throw new Exception(_INVALIDKEY.': '.$_GET['group_key']);
  176. }
  177. } catch (Exception $e) {
  178. handleAjaxExceptions($e);
  179. }
  180. exit;
  181. }
  182. $redirectPage = $GLOBALS['configuration']['login_redirect_page'];
  183. if ($redirectPage == "user_dashboard" && $user_type != "administrator") {
  184. $location = "professor.php?ctg=personal&user=".$_SESSION['s_login']."&op=dashboard";
  185. } elseif (strpos($redirectPage, "module") !== false) {
  186. $location = "professor.php?ctg=landing_page";
  187. } else {
  188. $location = "professor.php?ctg=lessons";
  189. }
  190. $smarty->assign("T_HOME_LINK", $location);
  191. try {
  192. ///MODULE1: Import
  193. $loadedModules = $currentUser -> getModules();
  194. $module_css_array = array();
  195. $module_js_array = array();
  196. // Include module languages
  197. foreach ($loadedModules as $module) {
  198. // The $setLanguage variable is defined in globals.php
  199. $mod_lang_file = $module -> getLanguageFile($setLanguage);
  200. if (is_file ($mod_lang_file)) {
  201. require_once $mod_lang_file;
  202. }
  203. // Get module css
  204. if($mod_css_file = $module -> getModuleCSS()) {
  205. if (is_file ($mod_css_file)) {
  206. // Get the relative path
  207. if ($position = strpos($mod_css_file, "modules")) {
  208. $mod_css_file = substr($mod_css_file, $position);
  209. }
  210. $module_css_array[] = $mod_css_file;
  211. }
  212. }
  213. // Get module js
  214. if($mod_js_file = $module -> getModuleJS()) {
  215. if (is_file($mod_js_file)) {
  216. // Get the relative path
  217. if ($position = strpos($mod_js_file, "modules")) {
  218. $mod_js_file = substr($mod_js_file, $position);
  219. }
  220. $module_js_array[] = $mod_js_file;
  221. }
  222. }
  223. // Run onNewPageLoad code of the module (if such is defined)
  224. $module -> onNewPageLoad();
  225. }
  226. } catch (Exception $e) {
  227. handleNormalFlowExceptions($e);
  228. }
  229. if (isset($_GET['bookmarks']) && $GLOBALS['configuration']['disable_bookmarks'] != 1) {
  230. try {
  231. $bookmarks = bookmarks :: getBookmarks($currentUser, $currentLesson);
  232. if ($_GET['bookmarks'] == 'remove' && in_array($_GET['id'], array_keys($bookmarks))) {
  233. $bookmark = new bookmarks($_GET['id']);
  234. $bookmark -> delete();
  235. } elseif ($_GET['bookmarks'] == 'add') {
  236. foreach ($bookmarks as $value) {
  237. $urls[] = $value['url'];
  238. }
  239. if (!in_array($_SERVER['PHP_SELF']."?view_unit=".$currentUnit['id'], $urls)) {
  240. $fields = array('users_LOGIN' => $currentUser -> user['login'],
  241. 'lessons_ID' => $currentLesson -> lesson['id'],
  242. 'name' => $currentUnit['name'],
  243. 'url' => $_SERVER['PHP_SELF']."?view_unit=".$currentUnit['id']);
  244. bookmarks :: create($fields);
  245. }
  246. } else {
  247. echo json_encode($bookmarks);
  248. }
  249. } catch (Exception $e) {
  250. handleAjaxExceptions($e);
  251. }
  252. exit;
  253. }
  254. /*Added Session variable for search results*/
  255. $_SESSION['referer'] = $_SERVER['REQUEST_URI'];
  256. /*Horizontal menus*/
  257. $onlineUsers = EfrontUser :: getUsersOnline($GLOBALS['configuration']['autologout_time'] * 60);
  258. if ($GLOBALS['currentTheme'] -> options['sidebar_interface']) {
  259. $smarty -> assign("T_ONLINE_USERS_LIST", $onlineUsers);
  260. if ($accounts = unserialize($currentUser -> user['additional_accounts'])) {
  261. $result = eF_getTableData("users", "login, user_type", 'login in ("'.implode('","', array_values($accounts)).'")');
  262. $smarty -> assign("T_MAPPED_ACCOUNTS", $result);
  263. }
  264. } else {
  265. $smarty -> assign("T_NO_HORIZONTAL_MENU", 1);
  266. }
  267. refreshLogin();//Important: It must be called AFTER EfrontUser :: getUsersOnline
  268. !isset($_GET['ctg']) || !eF_checkParameter($_GET['ctg'], 'alnum_general') ? $ctg = "control_panel" : $ctg = $_GET['ctg'];
  269. if (!$_SESSION['s_lessons_ID'] && ($ctg != 'personal' && $ctg != 'statistics') && ($ctg == 'control_panel' && $_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.
  270. $ctg = 'lessons';
  271. }
  272. $smarty -> assign("T_CTG", $ctg); //As soon as we derive the current ctg, assign it to smarty.
  273. $smarty -> assign("T_OP", isset($_GET['op']) ? $_GET['op'] : false);
  274. //Create shorthands for user type, to avoid long variable names
  275. $_student_ = $_professor_ = $_admin_ = 0;
  276. if ($_SESSION['s_lesson_user_type'] == 'student' || (!isset($_SESSION['s_lesson_user_type']) && $_SESSION['s_type'] == 'student')) {
  277. $_student_ = 1;
  278. } else if ($_SESSION['s_lesson_user_type'] == 'professor' || (!isset($_SESSION['s_lesson_user_type']) && $_SESSION['s_type'] == 'professor')) {
  279. $_professor_ = 1;
  280. } else {
  281. $_admin_ = 1;
  282. }
  283. if (isset($_GET['set_student_mode'])) {
  284. if ($_GET['set_student_mode']) {
  285. $_SESSION['student_mode'] = $_SESSION['s_lessons_ID'];
  286. } else {
  287. unset($_SESSION['student_mode']);
  288. }
  289. }
  290. if ($_SESSION['student_mode']) {
  291. if ($_SESSION['student_mode'] == $_SESSION['s_lessons_ID']) {
  292. $_student_ = 1;
  293. $_professor_ = 0;
  294. } else {
  295. unset($_SESSION['student_mode']); //Unset "student mode" when changing lesson
  296. }
  297. }
  298. $smarty -> assign("_student_", $_student_);
  299. $smarty -> assign("_professor_", $_professor_);
  300. $smarty -> assign("_admin_", $_admin_);
  301. try {
  302. if ($ctg == 'control_panel') {
  303. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  304. /***/
  305. require_once ("control_panel.php");
  306. }
  307. elseif ($ctg == 'landing_page') {
  308. /***/
  309. require_once ("landing_page.php");
  310. }
  311. elseif ($ctg == 'content') {
  312. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  313. if (isset($_GET['commit_lms'])) {
  314. /***/
  315. require_once("lms_commit.php");
  316. exit;
  317. } else {
  318. /***/
  319. require_once("common_content.php");
  320. }
  321. }
  322. elseif ($ctg == 'metadata') {
  323. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  324. /***/
  325. require_once("metadata.php");
  326. }
  327. elseif ($ctg == 'comments') {
  328. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  329. /***/
  330. require_once ("comments.php");
  331. }
  332. else if ($ctg == 'facebook') {
  333. /***/
  334. require_once "module_facebook.php";
  335. }
  336. elseif ($ctg == 'copy') {
  337. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  338. /***/
  339. require_once("copy.php");
  340. }
  341. elseif ($ctg == 'order') {
  342. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  343. /***/
  344. require_once("order.php");
  345. }
  346. elseif ($ctg == 'scheduling') {
  347. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  348. /***/
  349. require_once("scheduling.php");
  350. }
  351. elseif ($ctg == 'projects') {
  352. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  353. /**The file that handles the projects*/
  354. require_once("projects.php");
  355. }
  356. elseif ($ctg == 'tests') {
  357. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  358. if ($GLOBALS['configuration']['disable_tests'] == 1) {
  359. eF_redirect("".basename($_SERVER['PHP_SELF']));
  360. }
  361. if (isset($currentUser -> coreAccess['content']) && $currentUser -> coreAccess['content'] == 'hidden') {
  362. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  363. }
  364. if ($configuration['math_content'] && $configuration['math_images']) {
  365. $loadScripts[] = 'ASCIIMath2Tex';
  366. } elseif ($configuration['math_content']) {
  367. $loadScripts[] = 'ASCIIMathML';
  368. }
  369. $loadScripts[] = 'scriptaculous/dragdrop';
  370. /**The tests module file*/
  371. require_once ('module_tests.php');
  372. }
  373. elseif ($ctg == 'feedback') {
  374. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  375. if ($GLOBALS['configuration']['disable_feedback'] == 1) {
  376. eF_redirect("".basename($_SERVER['PHP_SELF']));
  377. }
  378. if (isset($currentUser -> coreAccess['content']) && $currentUser -> coreAccess['content'] == 'hidden') {
  379. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  380. }
  381. if ($configuration['math_content'] && $configuration['math_images']) {
  382. $loadScripts[] = 'ASCIIMath2Tex';
  383. } elseif ($configuration['math_content']) {
  384. $loadScripts[] = 'ASCIIMathML';
  385. }
  386. $loadScripts[] = 'scriptaculous/dragdrop';
  387. /**The tests module file*/
  388. require_once ('module_tests.php');
  389. }
  390. elseif ($ctg == 'file_manager') {
  391. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  392. /***/
  393. if (isset($_GET['folder'])) {
  394. $basedir = G_CONTENTPATH . $_GET['folder']. "/";
  395. if (!is_dir($basedir)) {
  396. mkdir($basedir, 0755);
  397. }
  398. } else {
  399. if ($currentLesson) {
  400. $basedir = $currentLesson -> getDirectory();
  401. } else {
  402. eF_redirect(basename($_SERVER['PHP_SELF']));
  403. }
  404. }
  405. if (!isset($currentUser -> coreAccess['files']) || $currentUser -> coreAccess['files'] == 'change') {
  406. $options = array('lessons_ID' => $currentLesson -> lesson['id'], 'metadata' => 1);
  407. if (isset($loadedModules['module_shared_files']) && isset($currentLesson -> options['module_shared_files']) && $currentLesson -> options['module_shared_files'] && !$currentLesson -> options['digital_library']) {
  408. $options['share'] = false;
  409. }
  410. } else {
  411. $options = array('delete' => false, 'edit' => false, 'share' => false, 'upload' => false, 'create_folder' => false, 'zip' => false, 'lessons_ID' => $currentLesson -> lesson['id'], 'metadata' => 1);
  412. }
  413. if (isset($_GET['folder'])) {
  414. $url = basename($_SERVER['PHP_SELF']).'?ctg=file_manager&folder=' .$_GET['folder'];
  415. } else {
  416. $url = basename($_SERVER['PHP_SELF']).'?ctg=file_manager';
  417. }
  418. include "file_manager.php";
  419. }
  420. elseif ($ctg == 'rules') {
  421. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  422. /***/
  423. require_once("rules.php");
  424. }
  425. elseif ($ctg == 'statistics') {
  426. if ($currentUser -> coreAccess['statistics'] != 'hidden') {
  427. require_once "statistics.php";
  428. } else {
  429. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  430. }
  431. }
  432. elseif ($ctg == 'module') {
  433. /***/
  434. require_once("module.php");
  435. }
  436. elseif ($ctg == 'survey') {
  437. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  438. if ($currentUser -> coreAccess['surveys'] == 'hidden' && $GLOBALS['configuration']['disable_surveys'] != 1) {
  439. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");exit;
  440. }
  441. /**This file handles surveys*/
  442. require_once "module_surveys.php";
  443. }
  444. elseif ($ctg == "social") {
  445. require_once "social.php";
  446. }
  447. elseif ($ctg == 'glossary') {
  448. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  449. /***/
  450. require_once("glossary.php");
  451. }
  452. elseif ($ctg == 'calendar') {
  453. if ($GLOBALS['configuration']['disable_calendar'] == 1) {
  454. eF_redirect("".basename($_SERVER['PHP_SELF']));
  455. }
  456. if ($currentUser -> coreAccess['calendar'] != 'hidden') {
  457. require_once "calendar.php";
  458. } else {
  459. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  460. }
  461. }
  462. elseif ($ctg == 'settings') {
  463. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  464. if (isset($currentUser -> coreAccess['settings']) && $currentUser -> coreAccess['settings'] == 'hidden') {
  465. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  466. }
  467. $baseUrl = 'ctg=settings';
  468. $smarty -> assign("T_BASE_URL", $baseUrl);
  469. require_once "lesson_settings.php";
  470. }
  471. elseif ($ctg == 'courses') {
  472. /**This part is used to display the user's personal information*/
  473. include "includes/professor_courses.php";
  474. }
  475. elseif ($ctg == 'professor_lessons') {
  476. /**This part is used to display the user's personal information*/
  477. include "includes/professor_lessons.php";
  478. }
  479. /*
  480. The personal page is used to display the professor's personal information
  481. and provides the means to edit this information
  482. */
  483. elseif ($ctg == 'personal') {
  484. /**This part is used to display the user's personal information*/
  485. include "includes/personal.php";
  486. }
  487. /*
  488. At this point, we apply module functionality
  489. */
  490. elseif (sizeof($modules) > 0 && in_array($ctg, array_keys($module_ctgs))) {
  491. $module_mandatory = eF_getTableData("modules", "mandatory", "name = '".$ctg."'");
  492. if ($module_mandatory[0]['mandatory'] != 'false' || isset($currentLesson -> options[$ctg])) {
  493. include(G_MODULESPATH.$ctg.'/module.php');
  494. $smarty -> assign("T_CTG_MODULE", $module_ctgs[$ctg]);
  495. }
  496. }
  497. elseif ($ctg == 'lessons') {
  498. /***/
  499. require_once("lessons_list.php");
  500. }
  501. elseif ($ctg == 'forum') {
  502. /***/
  503. require_once("forum.php");
  504. }
  505. elseif ($ctg == 'messages') {
  506. /***/
  507. require_once("messages.php");
  508. }
  509. elseif ($ctg == 'import') {
  510. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  511. /***/
  512. require_once("import.php");
  513. }
  514. elseif ($ctg == 'scorm') {
  515. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  516. /***/
  517. require_once("scorm.php");
  518. }
  519. elseif ($ctg == 'ims') {
  520. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  521. /***/
  522. require_once("ims.php");
  523. }
  524. elseif ($ctg == 'lesson_information') {
  525. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  526. /***/
  527. require_once("lesson_information.php");
  528. }
  529. elseif ($ctg == 'news') {
  530. //$_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF'])); //Commented out so that dashboard news links are working
  531. /***/
  532. include ("news.php");
  533. }
  534. elseif ($ctg == 'progress') {
  535. $_SESSION['s_lessons_ID'] OR eF_redirect(basename($_SERVER['PHP_SELF']));
  536. /***/
  537. require_once("progress.php");
  538. }
  539. } catch (Exception $e) {
  540. $smarty -> assign("T_EXCEPTION_TRACE", $e -> getTraceAsString());
  541. $message = $e -> getMessage().' ('.$e -> getCode().') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(\''._ERRORDETAILS.'\', 2, \'error_details\')">'._MOREINFO.'</a>';
  542. $message_type = 'failure';
  543. }
  544. if (detectBrowser() == 'mobile') {
  545. $load_editor = false;
  546. }
  547. $smarty -> assign("T_HEADER_EDITOR", $load_editor); //Specify whether we need to load the editor
  548. if (isset($_GET['refresh']) || isset($_GET['refresh_side'])) {
  549. $smarty -> assign("T_REFRESH_SIDE","true");
  550. }
  551. /*
  552. * Check if you should input the JS code to
  553. * trigger sending the next notificatoin emails
  554. * Since 3.6.0
  555. */
  556. if (EfrontNotification::shouldSendNextNotifications()) {
  557. $smarty -> assign("T_TRIGGER_NEXT_NOTIFICATIONS_SEND", 1);
  558. $_SESSION['send_next_notifications_now'] = 0; // the msg that triggered the immediate send should be sent now
  559. }
  560. $smarty -> assign("T_MODULE_CSS", $module_css_array);
  561. $smarty -> assign("T_MODULE_JS", $module_js_array);
  562. foreach ($loadedModules as $module) {
  563. $loadScripts = array_merge($loadScripts, $module -> addScripts());
  564. }
  565. //Main scripts, such as prototype
  566. $mainScripts = getMainScripts();
  567. $smarty -> assign("T_HEADER_MAIN_SCRIPTS", implode(",", $mainScripts));
  568. //Operation/file specific scripts
  569. $loadScripts = array_diff($loadScripts, $mainScripts); //Clear out duplicates
  570. $smarty -> assign("T_HEADER_LOAD_SCRIPTS", implode(",", array_unique($loadScripts))); //array_unique, so it doesn't send duplicate entries
  571. $smartyClosingFiles = array();
  572. foreach ($loadedModules as $module) {
  573. if ($smartyClosingFile = $module -> onPageFinishLoadingSmartyTpl()) {
  574. $smartyClosingFiles[] = $smartyClosingFile;
  575. }
  576. }
  577. $smarty -> assign("T_PAGE_FINISH_MODULES", $smartyClosingFiles);
  578. $smarty -> assign("T_CURRENT_CTG", $ctg);
  579. $smarty -> assign("T_MENUCTG", $ctg);
  580. //$smarty -> assign("T_MENU", eF_getMenu());
  581. $smarty -> assign("T_QUERIES", $numberOfQueries);
  582. if ($_SESSION['s_message']) {
  583. $message .= urldecode($_SESSION['s_message']);
  584. $message_type = $_SESSION['s_message_type'];
  585. unset($_SESSION['s_message']);
  586. unset($_SESSION['s_message_type']);
  587. }
  588. $smarty -> assign("T_MESSAGE", $message);
  589. $smarty -> assign("T_MESSAGE_TYPE", $message_type);
  590. $smarty -> assign("T_SEARCH_MESSAGE", $search_message);
  591. $smarty -> assign("T_CURRENT_USER", $currentUser);
  592. $smarty -> assign("T_CURRENT_LESSON", $currentLesson);
  593. if (isset($currentLesson)) {
  594. $directions = new EfrontDirectionsTree();
  595. $paths = $directions -> toPathString();
  596. $categoryPath = $paths[$currentLesson->lesson["directions_ID"]];
  597. //$categoryPath = str_replace("&rarr", "&raquo", $categoryPath);
  598. $smarty -> assign("T_CURRENT_CATEGORY_PATH", $categoryPath);
  599. if ($currentLesson -> lesson['course_only'] == 1 && $_SESSION['s_courses_ID']) {
  600. $currentCourse = new EfrontCourse($_SESSION['s_courses_ID']);
  601. $smarty -> assign("T_CURRENT_COURSE_NAME", htmlspecialchars($currentCourse->course['name'], ENT_QUOTES));
  602. $smarty -> assign("T_CURRENT_COURSE_ID", $currentCourse->course['id']);
  603. }
  604. }
  605. if ((!isset($_GET['edit']) && $_GET['ctg'] == 'content') && !isset($_GET['edit_project']) && !isset($_GET['edit_question']) && !isset($_GET['edit_test'])) { // when updating a unit we must preserve the innerlink
  606. $smarty -> load_filter('output', 'eF_template_setInnerLinks');
  607. $smarty -> load_filter('output', 'eF_template_setEditorOffset');
  608. }
  609. $benchmark -> set('script');
  610. $smarty -> display('professor.tpl');
  611. $benchmark -> set('smarty');
  612. $benchmark -> stop();
  613. $output = $benchmark -> display();
  614. if (G_DEBUG) {
  615. echo $output;
  616. }
  617. ?>