user_portal.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is the index file displayed when a user is logged in on Chamilo.
  5. *
  6. * It displays:
  7. * - personal course list
  8. * - menu bar
  9. * Search for CONFIGURATION parameters to modify settings
  10. * @todo rewrite code to separate display, logic, database code
  11. * @package chamilo.main
  12. * @todo Shouldn't the SCRIPTVAL_ and CONFVAL_ constant be moved to the config page? Has anybody any idea what the are used for?
  13. * If these are really configuration settings then we can add those to the dokeos config settings.
  14. * @todo move display_courses and some other functions to a more appripriate place course.lib.php or user.lib.php
  15. * @todo use api_get_path instead of $rootAdminWeb
  16. * @todo check for duplication of functions with index.php (user_portal.php is orginally a copy of index.php)
  17. * @todo display_digest, shouldn't this be removed and be made into an extension?
  18. */
  19. /* INIT SECTION */
  20. // Don't change these settings
  21. define('SCRIPTVAL_No', 0);
  22. define('SCRIPTVAL_InCourseList', 1);
  23. define('SCRIPTVAL_UnderCourseList', 2);
  24. define('SCRIPTVAL_Both', 3);
  25. define('SCRIPTVAL_NewEntriesOfTheDay', 4);
  26. define('SCRIPTVAL_NewEntriesOfTheDayOfLastLogin', 5);
  27. define('SCRIPTVAL_NoTimeLimit', 6);
  28. // End 'don't change' section
  29. // Language files that should be included.
  30. $language_file = array('courses', 'index');
  31. $cidReset = true; /* Flag forcing the 'current course' reset,
  32. as we're not inside a course anymore */
  33. if (isset($_SESSION['this_section']))
  34. unset($_SESSION['this_section']); // For HTML editor repository.
  35. /* Included libraries */
  36. require_once './main/inc/global.inc.php';
  37. $libpath = api_get_path(LIBRARY_PATH);
  38. require_once $libpath.'course.lib.php';
  39. require_once $libpath.'system_announcements.lib.php';
  40. require_once $libpath.'groupmanager.lib.php';
  41. require_once $libpath.'usermanager.lib.php';
  42. require_once 'main/survey/survey.lib.php';
  43. require_once $libpath.'sessionmanager.lib.php';
  44. api_block_anonymous_users(); // Only users who are logged in can proceed.
  45. //$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>';
  46. //$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.toggle.js" type="text/javascript" language="javascript"></script>';
  47. /* Table definitions */
  48. // Database table definitions.
  49. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  50. $main_admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
  51. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
  52. $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  53. $main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
  54. /* Constants and CONFIGURATION parameters */
  55. // ---- Course list options ----
  56. define('CONFVAL_showCourseLangIfNotSameThatPlatform', true);
  57. // Preview of course content
  58. // to disable all: set CONFVAL_maxTotalByCourse = 0
  59. // to enable all: set e.g. CONFVAL_maxTotalByCourse = 5
  60. // by default disabled since what's new icons are better (see function display_digest() )
  61. define('CONFVAL_maxValvasByCourse', 2); // Maximum number of entries
  62. define('CONFVAL_maxAgendaByCourse', 2); // collected from each course
  63. define('CONFVAL_maxTotalByCourse', 0); // and displayed in summary.
  64. define('CONFVAL_NB_CHAR_FROM_CONTENT', 80);
  65. // Order to sort data
  66. $orderKey = array('keyTools', 'keyTime', 'keyCourse'); // default "best" Choice
  67. //$orderKey = array('keyTools', 'keyCourse', 'keyTime');
  68. //$orderKey = array('keyCourse', 'keyTime', 'keyTools');
  69. //$orderKey = array('keyCourse', 'keyTools', 'keyTime');
  70. define('CONFVAL_showExtractInfo', SCRIPTVAL_UnderCourseList);
  71. // SCRIPTVAL_InCourseList // best choice if $orderKey[0] == 'keyCourse'
  72. // SCRIPTVAL_UnderCourseList // best choice
  73. // SCRIPTVAL_Both // probably only for debug
  74. //define('CONFVAL_dateFormatForInfosFromCourses', get_lang('dateFormatShort'));
  75. define('CONFVAL_dateFormatForInfosFromCourses', get_lang('dateFormatLong'));
  76. //define("CONFVAL_limitPreviewTo",SCRIPTVAL_NewEntriesOfTheDay);
  77. //define("CONFVAL_limitPreviewTo",SCRIPTVAL_NoTimeLimit);
  78. define("CONFVAL_limitPreviewTo", SCRIPTVAL_NewEntriesOfTheDayOfLastLogin);
  79. // This is the main function to get the course list.
  80. $personal_course_list = UserManager::get_personal_session_course_list($_user['user_id']);
  81. // Check if a user is enrolled only in one course for going directly to the course after the login.
  82. if (api_get_setting('go_to_course_after_login') == 'true') {
  83. if (!isset($_SESSION['coursesAlreadyVisited']) && is_array($personal_course_list) && count($personal_course_list) == 1) {
  84. $key = array_keys($personal_course_list);
  85. $course_info = $personal_course_list[$key[0]];
  86. $course_directory = $course_info['d'];
  87. $id_session = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
  88. header('location:'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$id_session);
  89. exit;
  90. }
  91. }
  92. $nosession = false;
  93. if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
  94. $display_actives = !isset($_GET['inactives']);
  95. }
  96. $nameTools = get_lang('MyCourses');
  97. $this_section = SECTION_COURSES;
  98. /* Check configuration parameters integrity */
  99. if (CONFVAL_showExtractInfo != SCRIPTVAL_UnderCourseList and $orderKey[0] != 'keyCourse') {
  100. // CONFVAL_showExtractInfo must be SCRIPTVAL_UnderCourseList to accept $orderKey[0] != 'keyCourse'
  101. if (DEBUG || api_is_platform_admin()){ // Show bug if admin. Else force a new order.
  102. die('
  103. <strong>config error:'.__FILE__.'</strong><br />
  104. set
  105. <ul>
  106. <li>
  107. CONFVAL_showExtractInfo = SCRIPTVAL_UnderCourseList
  108. (actually : '.CONFVAL_showExtractInfo.')
  109. </li>
  110. </ul>
  111. or
  112. <ul>
  113. <li>
  114. $orderKey[0] != \'keyCourse\'
  115. (actually : '.$orderKey[0].')
  116. </li>
  117. </ul>');
  118. } else {
  119. $orderKey = array('keyCourse', 'keyTools', 'keyTime');
  120. }
  121. }
  122. /*
  123. Header
  124. Include the HTTP, HTML headers plus the top banner.
  125. */
  126. Display :: display_header($nameTools);
  127. /* MAIN CODE */
  128. /* PERSONAL COURSE LIST */
  129. if (!isset ($maxValvas)) {
  130. $maxValvas = CONFVAL_maxValvasByCourse; // Maximum number of entries
  131. }
  132. if (!isset ($maxAgenda)) {
  133. $maxAgenda = CONFVAL_maxAgendaByCourse; // collected from each course
  134. }
  135. if (!isset ($maxCourse)) {
  136. $maxCourse = CONFVAL_maxTotalByCourse; // and displayed in summary.
  137. }
  138. $maxValvas = (int) $maxValvas;
  139. $maxAgenda = (int) $maxAgenda;
  140. $maxCourse = (int) $maxCourse; // 0 if invalid.
  141. if ($maxCourse > 0) {
  142. unset ($allentries); // We shall collect all summary$key1 entries in here:
  143. $toolsList['agenda']['name'] = get_lang('Agenda');
  144. $toolsList['agenda']['path'] = api_get_path(WEB_CODE_PATH).'calendar/agenda.php?cidReq=';
  145. $toolsList['valvas']['name'] = get_lang('Valvas');
  146. $toolsList['valvas']['path'] = api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq=';
  147. }
  148. echo ' <div class="maincontent" id="maincontent">'; // Start of content for logged in users.
  149. // Plugins for the my courses main area.
  150. echo '<div id="plugin-mycourses_main">';
  151. api_plugin('mycourses_main');
  152. echo '</div>';
  153. /* System Announcements */
  154. $announcement = isset($_GET['announcement']) ? $_GET['announcement'] : -1;
  155. $visibility = api_is_allowed_to_create_course() ? VISIBLE_TEACHER : VISIBLE_STUDENT;
  156. SystemAnnouncementManager :: display_announcements($visibility, $announcement);
  157. if (!empty ($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/',$_GET['include'])) {
  158. include ('./home/'.$_GET['include']);
  159. $pageIncluded = true;
  160. } else {
  161. /* DISPLAY COURSES */
  162. // Compose a structured array of session categories, sessions and courses
  163. // for the current user.
  164. if (isset($_GET['history']) && intval($_GET['history']) == 1) {
  165. $courses_tree = UserManager::get_sessions_by_category($_user['user_id'], true, true);
  166. } else {
  167. $courses_tree = UserManager::get_sessions_by_category($_user['user_id'], true);
  168. }
  169. foreach ($courses_tree as $cat => $sessions) {
  170. $courses_tree[$cat]['details'] = SessionManager::get_session_category($cat);
  171. if ($cat == 0) {
  172. $courses_tree[$cat]['courses'] = CourseManager::get_courses_list_by_user_id($_user['user_id'], false);
  173. }
  174. $courses_tree[$cat]['sessions'] = array_flip(array_flip($sessions));
  175. if (count($courses_tree[$cat]['sessions']) > 0) {
  176. foreach ($courses_tree[$cat]['sessions'] as $k => $s_id) {
  177. $courses_tree[$cat]['sessions'][$k] = array('details' => SessionManager::fetch($s_id));
  178. $courses_tree[$cat]['sessions'][$k]['courses'] = UserManager::get_courses_list_by_session($_user['user_id'], $s_id);
  179. }
  180. }
  181. }
  182. $list = '';
  183. foreach ($personal_course_list as $my_course) {
  184. $thisCourseDbName = $my_course['db'];
  185. $thisCourseSysCode = $my_course['k'];
  186. $thisCoursePublicCode = $my_course['c'];
  187. $thisCoursePath = $my_course['d'];
  188. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  189. $dbname = $my_course['k'];
  190. $status = array();
  191. $status[$dbname] = $my_course['s'];
  192. $nbDigestEntries = 0; // Number of entries already collected.
  193. if ($maxCourse < $maxValvas) {
  194. $maxValvas = $maxCourse;
  195. }
  196. if ($maxCourse > 0) {
  197. $courses[$thisCourseSysCode]['coursePath'] = $thisCoursePath;
  198. $courses[$thisCourseSysCode]['courseCode'] = $thisCoursePublicCode;
  199. }
  200. /* Announcements */
  201. $course_database = $my_course['db'];
  202. $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST, $course_database);
  203. $query = "SELECT visibility FROM $course_tool_table WHERE link = 'announcements/announcements.php' AND visibility = 1";
  204. $result = Database::query($query);
  205. // Collect from announcements, but only if tool is visible for the course.
  206. if ($result && $maxValvas > 0 && Database::num_rows($result) > 0) {
  207. // Search announcements table.
  208. // Take the entries listed at the top of advalvas/announcements tool.
  209. $course_announcement_table = Database::get_course_table(TABLE_ANNOUNCEMENT);
  210. $sqlGetLastAnnouncements = "SELECT end_date publicationDate, content
  211. FROM ".$course_announcement_table;
  212. switch (CONFVAL_limitPreviewTo) {
  213. case SCRIPTVAL_NewEntriesOfTheDay :
  214. $sqlGetLastAnnouncements .= "WHERE DATE_FORMAT(end_date,'%Y %m %d') >= '".date('Y m d')."'";
  215. break;
  216. case SCRIPTVAL_NoTimeLimit :
  217. break;
  218. case SCRIPTVAL_NewEntriesOfTheDayOfLastLogin :
  219. // take care mysql -> DATE_FORMAT(time,format) php -> date(format,date)
  220. $sqlGetLastAnnouncements .= "WHERE DATE_FORMAT(end_date,'%Y %m %d') >= '".date('Y m d', $_user['lastLogin'])."'";
  221. }
  222. $sqlGetLastAnnouncements .= "ORDER BY end_date DESC LIMIT ".$maxValvas;
  223. $resGetLastAnnouncements = Database::query($sqlGetLastAnnouncements);
  224. if ($resGetLastAnnouncements) {
  225. while ($annoncement = Database::fetch_array($resGetLastAnnouncements)) {
  226. $keyTools = 'valvas';
  227. $keyTime = $annoncement['publicationDate'];
  228. $keyCourse = $thisCourseSysCode;
  229. $digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = @htmlspecialchars(api_substr(strip_tags($annoncement['content']), 0, CONFVAL_NB_CHAR_FROM_CONTENT), ENT_QUOTES, $charset);
  230. $nbDigestEntries ++; // summary has same order as advalvas
  231. }
  232. }
  233. }
  234. /* Agenda */
  235. $course_database = $my_course['db'];
  236. $course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST, $course_database);
  237. $query = "SELECT visibility FROM $course_tool_table WHERE link = 'calendar/agenda.php' AND visibility = 1";
  238. $result = Database::query($query);
  239. $thisAgenda = $maxCourse - $nbDigestEntries; // New max entries for agenda.
  240. if ($maxAgenda < $thisAgenda) {
  241. $thisAgenda = $maxAgenda;
  242. }
  243. // Collect from agenda, but only if tool is visible for the course.
  244. if ($result && $thisAgenda > 0 && Database::num_rows($result) > 0) {
  245. $tableCal = $courseTablePrefix.$thisCourseDbName.$_configuration['db_glue'].'calendar_event';
  246. $sqlGetNextAgendaEvent = "SELECT start_date, title content, start_time
  247. FROM $tableCal
  248. WHERE start_date >= CURDATE()
  249. ORDER BY start_date, start_time
  250. LIMIT $maxAgenda";
  251. $resGetNextAgendaEvent = Database::query($sqlGetNextAgendaEvent);
  252. if ($resGetNextAgendaEvent) {
  253. while ($agendaEvent = Database::fetch_array($resGetNextAgendaEvent)) {
  254. $keyTools = 'agenda';
  255. $keyTime = $agendaEvent['start_date'];
  256. $keyCourse = $thisCourseSysCode;
  257. $digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = @htmlspecialchars(api_substr(strip_tags($agendaEvent['content']), 0, CONFVAL_NB_CHAR_FROM_CONTENT), ENT_QUOTES, $charset);
  258. $nbDigestEntries ++; // Summary has same order as advalvas.
  259. }
  260. }
  261. }
  262. /*
  263. Digest Display
  264. Take collected data and display it.
  265. */
  266. } // End while mycourse...
  267. }
  268. if (isset($_GET['history']) && intval($_GET['history']) == 1) {
  269. echo '<h3>'.get_lang('HistoryTrainingSession').'</h3>';
  270. if (empty($courses_tree[0]['sessions'])){
  271. echo get_lang('YouDoNotHaveAnySessionInItsHistory');
  272. }
  273. }
  274. if (is_array($courses_tree)) {
  275. foreach ($courses_tree as $key => $category) {
  276. if ($key == 0) {
  277. // Sessions and courses that are not in a session category.
  278. if (!isset($_GET['history'])) { // Check if it's not history trainnign session list.
  279. CourseManager :: display_special_courses(api_get_user_id());
  280. CourseManager :: display_courses(api_get_user_id());
  281. }
  282. // Independent sessions.
  283. foreach ($category['sessions'] as $session) {
  284. // Don't show empty sessions.
  285. if (count($session['courses']) < 1) { continue; }
  286. // Courses inside the current session.
  287. $date_session_start = $session['details']['date_start'];
  288. $days_access_before_beginning = $session['details']['nb_days_access_before_beginning'] * 24 * 3600;
  289. $session_now = time();
  290. $html_courses_session = '';
  291. $count_courses_session = 0;
  292. foreach ($session['courses'] as $course) {
  293. $is_coach_course = api_is_coach($session['details']['id'], $course['code']);
  294. if ($is_coach_course) {
  295. $allowed_time = strtotime($date_session_start) - $days_access_before_beginning;
  296. } else {
  297. $allowed_time = strtotime($date_session_start);
  298. }
  299. if ($session_now > $allowed_time) {
  300. $c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item');
  301. $html_courses_session .= $c[1];
  302. $count_courses_session++;
  303. }
  304. }
  305. if ($count_courses_session > 0) {
  306. //echo '<div class="clear"></div>';
  307. echo '<div class="userportal-session-item"><ul class="session_box">';
  308. echo '<li class="session_box_title" id="session_'.$session['details']['id'].'" >';
  309. //echo Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' ';
  310. echo Display::return_icon('window_list.png', get_lang('Expand').'/'.get_lang('Hide'), array('width' => '48px', 'align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' ';
  311. $s = Display :: get_session_title_box($session['details']['id']);
  312. $extra_info = (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates'];
  313. $session_link = Display::tag('a',$s['title'], array('href'=>api_get_path(WEB_CODE_PATH).'session/?session_id='.$session['details']['id']));
  314. echo Display::tag('span',$session_link. ' </span> <span style="padding-left: 10px; font-size: 90%; font-weight: normal;">'.$extra_info);
  315. if (api_is_platform_admin()) {
  316. echo '<div style="float:right;"><a href="'.api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$session['details']['id'].'">'.Display::return_icon('edit.gif', get_lang('Edit'), array('align' => 'absmiddle')).'</a></div>';
  317. }
  318. echo '</li>';
  319. echo $html_courses_session;
  320. echo '</ul></div>';
  321. }
  322. }
  323. } else {
  324. // All sessions included in.
  325. if (!empty($category['details'])) {
  326. $count_courses_session = 0;
  327. $html_sessions = '';
  328. foreach ($category['sessions'] as $session) {
  329. // Don't show empty sessions.
  330. if (count($session['courses']) < 1) { continue; }
  331. $date_session_start = $session['details']['date_start'];
  332. $days_access_before_beginning = $session['details']['nb_days_access_before_beginning'] * 24 * 3600;
  333. $session_now = time();
  334. $html_courses_session = '';
  335. $count = 0;
  336. foreach ($session['courses'] as $course) {
  337. $is_coach_course = api_is_coach($session['details']['id'], $course['code']);
  338. if ($is_coach_course) {
  339. $allowed_time = strtotime($date_session_start) - $days_access_before_beginning;
  340. } else {
  341. $allowed_time = strtotime($date_session_start);
  342. }
  343. if ($session_now > $allowed_time) {
  344. $c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item');
  345. $html_courses_session .= $c[1];
  346. $count_courses_session++;
  347. $count++;
  348. }
  349. }
  350. if ($count > 0) {
  351. $s = Display :: get_session_title_box($session['details']['id']);
  352. $html_sessions .= '<ul class="sub_session_box" id="session_'.$session['details']['id'].'">';
  353. $html_sessions .= '<li class="sub_session_box_title" id="session_'.$session['details']['id'].'">';
  354. //$html_sessions .= Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' ';
  355. $html_sessions .= Display::return_icon('window_list.png', get_lang('Expand').'/'.get_lang('Hide'), array('width' => '48px', 'align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' ';
  356. $html_sessions .= '<span>' . $s['title']. ' </span> ';
  357. $html_sessions .= '<span style="padding-left: 10px; font-size: 90%; font-weight: normal;">';
  358. $html_sessions .= (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates'];
  359. $html_sessions .= '</span>';
  360. if (api_is_platform_admin()) {
  361. $html_sessions .= '<div style="float: right;"><a href="'.api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$session['details']['id'].'">'.Display::return_icon('edit.gif', get_lang('Edit'), array('align' => 'absmiddle')).'</a></div>';
  362. }
  363. $html_sessions .= '</li>';
  364. $html_sessions .= $html_courses_session;
  365. $html_sessions .= '</ul>';
  366. }
  367. }
  368. if ($count_courses_session > 0) {
  369. echo '<div class="userportal-session-category-item" id="session_category_'.$category['details']['id'].'">';
  370. echo '<div class="session_category_title_box" id="session_category_title_box_'.$category['details']['id'].'" style="color: #555555;">';
  371. //echo Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'category_img_'.$category['details']['id']));
  372. echo Display::return_icon('folder_blue.png', get_lang('SessionCategory'), array('width'=>'48px', 'align' => 'absmiddle'));
  373. if (api_is_platform_admin()) {
  374. echo'<div style="float: right;"><a href="'.api_get_path(WEB_CODE_PATH).'admin/session_category_edit.php?&id='.$category['details']['id'].'">'.Display::return_icon('edit.gif', get_lang('Edit'), array('align' => 'absmiddle')).'</a></div>';
  375. }
  376. echo '<span id="session_category_title">';
  377. echo $category['details']['name'];
  378. echo '</span>';
  379. echo '<span style="padding-left: 10px; font-size: 90%; font-weight: normal;">';
  380. echo get_lang('From').' '.$category['details']['date_start'].' '.get_lang('Until').' '.$category['details']['date_end'].'</div>';
  381. echo '</span>';
  382. echo $html_sessions;
  383. echo '</div>';
  384. }
  385. }
  386. }
  387. }
  388. }
  389. echo '</div>'; // End of content section.
  390. // Register whether full admin or null admin course
  391. // by course through an array dbname x user status.
  392. api_session_register('status');
  393. /* RIGHT MENU */
  394. echo ' <div id="menu-wrapper">';
  395. echo ' <div id="menu" class="menu">';
  396. // api_display_language_form(); // Moved to the profile page.
  397. $show_menu = false;
  398. $show_create_link = false;
  399. $show_course_link = false;
  400. $show_digest_link = false;
  401. $display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview');
  402. if ($display_add_course_link) {
  403. $show_menu = true;
  404. $show_create_link = true;
  405. }
  406. if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
  407. $show_menu = true;
  408. $show_course_link = true;
  409. } else {
  410. if (api_get_setting('allow_students_to_browse_courses') == 'true') {
  411. $show_menu = true;
  412. $show_course_link = true;
  413. }
  414. }
  415. if (isset($toolsList) && is_array($toolsList) && isset($digest)) {
  416. $show_digest_link = true;
  417. $show_menu = true;
  418. }
  419. echo '<div class="menusection">';
  420. echo '<span class="menusectioncaption">'.get_lang('Profile').'</span>';
  421. //Always show the user image
  422. $img_array = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', true, true);
  423. $no_image = false;
  424. if ($img_array['file'] == 'unknown.jpg') {
  425. $no_image = true;
  426. }
  427. $img_array = UserManager::get_picture_user(api_get_user_id(), $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" ');
  428. echo '<div class="clear"></div>';
  429. echo '<div id="social_widget">';
  430. echo ' <div id="social_widget_image">';
  431. if (api_get_setting('allow_social_tool') == 'true') {
  432. if (!$no_image) {
  433. echo '<a href="'.api_get_path(WEB_PATH).'main/social/home.php"><img src="'.$img_array['file'].'" '.$img_array['style'].' border="1"></a>';
  434. } else {
  435. echo '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php"><img title="'.get_lang('EditProfile').'" src="'.$img_array['file'].'" '.$img_array['style'].' border="1"></a>';
  436. }
  437. } else {
  438. echo '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php"><img title="'.get_lang('EditProfile').'" src="'.$img_array['file'].'" '.$img_array['style'].' border="1"></a>';
  439. }
  440. echo '</div>';
  441. // @todo Add a platform setting to add the user image.
  442. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  443. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  444. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  445. require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  446. // New messages.
  447. $number_of_new_messages = MessageManager::get_new_messages();
  448. // New contact invitations.
  449. $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
  450. // New group invitations sent by a moderator.
  451. $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
  452. $group_pending_invitations = count($group_pending_invitations);
  453. $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
  454. $cant_msg = '';
  455. if ($number_of_new_messages > 0) {
  456. $cant_msg = ' ('.$number_of_new_messages.')';
  457. }
  458. //<h2 class="message-title">'.get_lang('Messages').'</h2>
  459. echo '<div class="clear"></div>';
  460. echo '<div class="message-content"><ul class="menulist">';
  461. $link = '';
  462. if (api_get_setting('show_tabs', 'social') == 'true') {
  463. $link = '?f=social';
  464. }
  465. echo '<li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'" class="message-body">'.get_lang('Inbox').$cant_msg.' </a></li>';
  466. echo '<li><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'" class="message-body">'.get_lang('Compose').' </a></li>';
  467. //echo '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php" class="message-body">'.get_lang('EditMyProfile').' </a><br />';
  468. //if ($total_invitations > 0) {
  469. echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php" class="message-body">'.get_lang('PendingInvitations').' ('.$total_invitations.') </a></li>';
  470. //}
  471. echo '</ul>';
  472. echo '</div>';
  473. }
  474. echo '</div>'; // End
  475. echo '</div>';
  476. echo '</div>'; // End of menu
  477. echo ' <div id="menu" class="menu">';
  478. echo '<div class="menusection">';
  479. echo '<span class="menusectioncaption">'.get_lang('MenuUser').'</span>';
  480. // My account section.
  481. if ($show_menu) {
  482. echo '<ul class="menulist">';
  483. if ($show_create_link) {
  484. Display :: display_create_course_link();
  485. }
  486. if ($show_course_link) {
  487. if (!api_is_drh()) {
  488. Display :: display_edit_course_list_links();
  489. Display :: display_history_course_session();
  490. } else {
  491. Display :: display_dashboard_link();
  492. }
  493. }
  494. if ($show_digest_link) {
  495. Display :: display_digest($toolsList, $digest, $orderKey, $courses);
  496. }
  497. echo '</ul>';
  498. }
  499. echo '</div>'; // Close menusection.
  500. // Deleting the myprofile link.
  501. if (api_get_setting('allow_social_tool') == 'true') {
  502. unset($menu_navigation['myprofile']);
  503. }
  504. // Main navigation section.
  505. // Tabs that are deactivated are added here.
  506. if (!empty($menu_navigation)) {
  507. echo '<div class="menusection">';
  508. echo '<span class="menusectioncaption">'.get_lang('MainNavigation').'</span>';
  509. echo '<ul class="menulist">';
  510. foreach ($menu_navigation as $section => $navigation_info) {
  511. $current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
  512. echo '<li'.$current.'>';
  513. echo '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>';
  514. echo '</li>';
  515. }
  516. echo '</ul>';
  517. echo '</div>';
  518. }
  519. // Plugins for the my courses menu.
  520. if (isset($_plugins['mycourses_menu']) && is_array($_plugins['mycourses_menu'])) {
  521. echo '<div class="note">';
  522. echo '<div id="plugin-mycourses_menu">';
  523. api_plugin('mycourses_menu');
  524. echo '</div>';
  525. }
  526. if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course()) {
  527. echo '<div class="menusection">';
  528. echo '<span class="menusectioncaption">'.get_lang('Booking').'</span>';
  529. echo '<ul class="menulist">';
  530. echo '<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />';
  531. echo '</ul>';
  532. echo '</div>';
  533. }
  534. // Deleting the session_id.
  535. api_session_unregister('session_id');
  536. // Search textbox.
  537. if (api_get_setting('search_enabled') == 'true') {
  538. echo '<div class="searchbox">';
  539. $search_btn = get_lang('Search');
  540. $search_text_default = get_lang('YourTextHere');
  541. echo <<<EOD
  542. <br />
  543. <form action="main/search/" method="post">
  544. &nbsp;&nbsp;<input type="text" id="query" size="15" name="query" value="" />
  545. &nbsp;&nbsp;<button class="save" type="submit" name="submit" value="$search_btn"/>$search_btn </button>
  546. </form>
  547. EOD;
  548. echo '</div>';
  549. }
  550. echo '<div class="clear"></div>';
  551. echo '</div>'; // End of menu
  552. echo '</div>'; // End of menu wrapper
  553. // Footer
  554. Display :: display_footer();