user_portal.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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',($session['details']['visibility']==3?false:true));
  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. if ($session['details']['visibility'] == 3) {
  314. $session_link = $s['title'];
  315. } else {
  316. $session_link = Display::tag('a',$s['title'], array('href'=>api_get_path(WEB_CODE_PATH).'session/?session_id='.$session['details']['id']));
  317. }
  318. echo Display::tag('span',$session_link. ' </span> <span style="padding-left: 10px; font-size: 90%; font-weight: normal;">'.$extra_info);
  319. if (api_is_platform_admin()) {
  320. 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>';
  321. }
  322. echo '</li>';
  323. echo $html_courses_session;
  324. echo '</ul></div>';
  325. }
  326. }
  327. } else {
  328. // All sessions included in.
  329. if (!empty($category['details'])) {
  330. $count_courses_session = 0;
  331. $html_sessions = '';
  332. foreach ($category['sessions'] as $session) {
  333. // Don't show empty sessions.
  334. if (count($session['courses']) < 1) { continue; }
  335. $date_session_start = $session['details']['date_start'];
  336. $days_access_before_beginning = $session['details']['nb_days_access_before_beginning'] * 24 * 3600;
  337. $session_now = time();
  338. $html_courses_session = '';
  339. $count = 0;
  340. foreach ($session['courses'] as $course) {
  341. $is_coach_course = api_is_coach($session['details']['id'], $course['code']);
  342. if ($is_coach_course) {
  343. $allowed_time = strtotime($date_session_start) - $days_access_before_beginning;
  344. } else {
  345. $allowed_time = strtotime($date_session_start);
  346. }
  347. if ($session_now > $allowed_time) {
  348. $c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item');
  349. $html_courses_session .= $c[1];
  350. $count_courses_session++;
  351. $count++;
  352. }
  353. }
  354. if ($count > 0) {
  355. $s = Display :: get_session_title_box($session['details']['id']);
  356. $html_sessions .= '<ul class="sub_session_box" id="session_'.$session['details']['id'].'">';
  357. $html_sessions .= '<li class="sub_session_box_title" id="session_'.$session['details']['id'].'">';
  358. //$html_sessions .= Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' ';
  359. $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'])) . ' ';
  360. $html_sessions .= '<span>' . $s['title']. ' </span> ';
  361. $html_sessions .= '<span style="padding-left: 10px; font-size: 90%; font-weight: normal;">';
  362. $html_sessions .= (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates'];
  363. $html_sessions .= '</span>';
  364. if (api_is_platform_admin()) {
  365. $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>';
  366. }
  367. $html_sessions .= '</li>';
  368. $html_sessions .= $html_courses_session;
  369. $html_sessions .= '</ul>';
  370. }
  371. }
  372. if ($count_courses_session > 0) {
  373. echo '<div class="userportal-session-category-item" id="session_category_'.$category['details']['id'].'">';
  374. echo '<div class="session_category_title_box" id="session_category_title_box_'.$category['details']['id'].'" style="color: #555555;">';
  375. //echo Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'category_img_'.$category['details']['id']));
  376. echo Display::return_icon('folder_blue.png', get_lang('SessionCategory'), array('width'=>'48px', 'align' => 'absmiddle'));
  377. if (api_is_platform_admin()) {
  378. 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>';
  379. }
  380. echo '<span id="session_category_title">';
  381. echo $category['details']['name'];
  382. echo '</span>';
  383. echo '<span style="padding-left: 10px; font-size: 90%; font-weight: normal;">';
  384. echo get_lang('From').' '.$category['details']['date_start'].' '.get_lang('Until').' '.$category['details']['date_end'].'</div>';
  385. echo '</span>';
  386. echo $html_sessions;
  387. echo '</div>';
  388. }
  389. }
  390. }
  391. }
  392. }
  393. echo '</div>'; // End of content section.
  394. // Register whether full admin or null admin course
  395. // by course through an array dbname x user status.
  396. api_session_register('status');
  397. /* RIGHT MENU */
  398. echo ' <div id="menu-wrapper">';
  399. echo ' <div id="menu" class="menu">';
  400. // api_display_language_form(); // Moved to the profile page.
  401. $show_menu = false;
  402. $show_create_link = false;
  403. $show_course_link = false;
  404. $show_digest_link = false;
  405. $display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview');
  406. if ($display_add_course_link) {
  407. $show_menu = true;
  408. $show_create_link = true;
  409. }
  410. if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
  411. $show_menu = true;
  412. $show_course_link = true;
  413. } else {
  414. if (api_get_setting('allow_students_to_browse_courses') == 'true') {
  415. $show_menu = true;
  416. $show_course_link = true;
  417. }
  418. }
  419. if (isset($toolsList) && is_array($toolsList) && isset($digest)) {
  420. $show_digest_link = true;
  421. $show_menu = true;
  422. }
  423. echo '<div class="menusection">';
  424. echo '<span class="menusectioncaption">'.get_lang('Profile').'</span>';
  425. //Always show the user image
  426. $img_array = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', true, true);
  427. $no_image = false;
  428. if ($img_array['file'] == 'unknown.jpg') {
  429. $no_image = true;
  430. }
  431. $img_array = UserManager::get_picture_user(api_get_user_id(), $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" ');
  432. echo '<div class="clear"></div>';
  433. echo '<div id="social_widget">';
  434. echo ' <div id="social_widget_image">';
  435. if (api_get_setting('allow_social_tool') == 'true') {
  436. if (!$no_image) {
  437. echo '<a href="'.api_get_path(WEB_PATH).'main/social/home.php"><img src="'.$img_array['file'].'" '.$img_array['style'].' border="1"></a>';
  438. } else {
  439. 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>';
  440. }
  441. } else {
  442. 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>';
  443. }
  444. echo '</div>';
  445. // @todo Add a platform setting to add the user image.
  446. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  447. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  448. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  449. require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  450. // New messages.
  451. $number_of_new_messages = MessageManager::get_new_messages();
  452. // New contact invitations.
  453. $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
  454. // New group invitations sent by a moderator.
  455. $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
  456. $group_pending_invitations = count($group_pending_invitations);
  457. $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
  458. $cant_msg = '';
  459. if ($number_of_new_messages > 0) {
  460. $cant_msg = ' ('.$number_of_new_messages.')';
  461. }
  462. //<h2 class="message-title">'.get_lang('Messages').'</h2>
  463. echo '<div class="clear"></div>';
  464. echo '<div class="message-content"><ul class="menulist">';
  465. $link = '';
  466. if (api_get_setting('show_tabs', 'social') == 'true') {
  467. $link = '?f=social';
  468. }
  469. echo '<li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'" class="message-body">'.get_lang('Inbox').$cant_msg.' </a></li>';
  470. echo '<li><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'" class="message-body">'.get_lang('Compose').' </a></li>';
  471. //echo '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php" class="message-body">'.get_lang('EditMyProfile').' </a><br />';
  472. //if ($total_invitations > 0) {
  473. echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php" class="message-body">'.get_lang('PendingInvitations').' ('.$total_invitations.') </a></li>';
  474. //}
  475. echo '</ul>';
  476. echo '</div>';
  477. }
  478. echo '</div>'; // End
  479. echo '</div>';
  480. echo '</div>'; // End of menu
  481. echo ' <div id="menu" class="menu">';
  482. echo '<div class="menusection">';
  483. echo '<span class="menusectioncaption">'.get_lang('MenuUser').'</span>';
  484. // My account section.
  485. if ($show_menu) {
  486. echo '<ul class="menulist">';
  487. if ($show_create_link) {
  488. Display :: display_create_course_link();
  489. }
  490. if ($show_course_link) {
  491. if (!api_is_drh()) {
  492. Display :: display_edit_course_list_links();
  493. Display :: display_history_course_session();
  494. } else {
  495. Display :: display_dashboard_link();
  496. }
  497. }
  498. if ($show_digest_link) {
  499. Display :: display_digest($toolsList, $digest, $orderKey, $courses);
  500. }
  501. echo '</ul>';
  502. }
  503. echo '</div>'; // Close menusection.
  504. // Deleting the myprofile link.
  505. if (api_get_setting('allow_social_tool') == 'true') {
  506. unset($menu_navigation['myprofile']);
  507. }
  508. // Main navigation section.
  509. // Tabs that are deactivated are added here.
  510. if (!empty($menu_navigation)) {
  511. echo '<div class="menusection">';
  512. echo '<span class="menusectioncaption">'.get_lang('MainNavigation').'</span>';
  513. echo '<ul class="menulist">';
  514. foreach ($menu_navigation as $section => $navigation_info) {
  515. $current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
  516. echo '<li'.$current.'>';
  517. echo '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>';
  518. echo '</li>';
  519. }
  520. echo '</ul>';
  521. echo '</div>';
  522. }
  523. // Plugins for the my courses menu.
  524. if (isset($_plugins['mycourses_menu']) && is_array($_plugins['mycourses_menu'])) {
  525. echo '<div class="note">';
  526. echo '<div id="plugin-mycourses_menu">';
  527. api_plugin('mycourses_menu');
  528. echo '</div>';
  529. }
  530. if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course()) {
  531. echo '<div class="menusection">';
  532. echo '<span class="menusectioncaption">'.get_lang('Booking').'</span>';
  533. echo '<ul class="menulist">';
  534. echo '<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />';
  535. echo '</ul>';
  536. echo '</div>';
  537. }
  538. // Deleting the session_id.
  539. api_session_unregister('session_id');
  540. // Search textbox.
  541. if (api_get_setting('search_enabled') == 'true') {
  542. echo '<div class="searchbox">';
  543. $search_btn = get_lang('Search');
  544. $search_text_default = get_lang('YourTextHere');
  545. echo <<<EOD
  546. <br />
  547. <form action="main/search/" method="post">
  548. &nbsp;&nbsp;<input type="text" id="query" size="15" name="query" value="" />
  549. &nbsp;&nbsp;<button class="save" type="submit" name="submit" value="$search_btn"/>$search_btn </button>
  550. </form>
  551. EOD;
  552. echo '</div>';
  553. }
  554. echo '<div class="clear"></div>';
  555. echo '</div>'; // End of menu
  556. echo '</div>'; // End of menu wrapper
  557. // Footer
  558. Display :: display_footer();