user_portal.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  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','admin');
  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. } else {
  91. if (api_get_setting('hide_courses_in_sessions') == 'true') {
  92. //Check sessions
  93. $session_list = array();
  94. $only_session_id = 0;
  95. foreach($personal_course_list as $course_item) {
  96. $session_list[$course_item['id_session']] = $course_item;
  97. $only_session_id = $course_item['id_session'];
  98. }
  99. if (count($session_list) == 1 && !empty($only_session_id)) {
  100. header('Location:'.api_get_path(WEB_CODE_PATH).'session/?session_id='.$session_list[$only_session_id]['id_session']);
  101. }
  102. }
  103. }
  104. }
  105. $nosession = false;
  106. if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
  107. $display_actives = !isset($_GET['inactives']);
  108. }
  109. $nameTools = get_lang('MyCourses');
  110. $this_section = SECTION_COURSES;
  111. /* Check configuration parameters integrity */
  112. if (CONFVAL_showExtractInfo != SCRIPTVAL_UnderCourseList and $orderKey[0] != 'keyCourse') {
  113. // CONFVAL_showExtractInfo must be SCRIPTVAL_UnderCourseList to accept $orderKey[0] != 'keyCourse'
  114. if (DEBUG || api_is_platform_admin()){ // Show bug if admin. Else force a new order.
  115. die('
  116. <strong>config error:'.__FILE__.'</strong><br />
  117. set
  118. <ul>
  119. <li>
  120. CONFVAL_showExtractInfo = SCRIPTVAL_UnderCourseList
  121. (actually : '.CONFVAL_showExtractInfo.')
  122. </li>
  123. </ul>
  124. or
  125. <ul>
  126. <li>
  127. $orderKey[0] != \'keyCourse\'
  128. (actually : '.$orderKey[0].')
  129. </li>
  130. </ul>');
  131. } else {
  132. $orderKey = array('keyCourse', 'keyTools', 'keyTime');
  133. }
  134. }
  135. /*
  136. Header
  137. Include the HTTP, HTML headers plus the top banner.
  138. */
  139. Display :: display_header($nameTools);
  140. /* MAIN CODE */
  141. /* PERSONAL COURSE LIST */
  142. if (!isset ($maxValvas)) {
  143. $maxValvas = CONFVAL_maxValvasByCourse; // Maximum number of entries
  144. }
  145. if (!isset ($maxAgenda)) {
  146. $maxAgenda = CONFVAL_maxAgendaByCourse; // collected from each course
  147. }
  148. if (!isset ($maxCourse)) {
  149. $maxCourse = CONFVAL_maxTotalByCourse; // and displayed in summary.
  150. }
  151. $maxValvas = (int) $maxValvas;
  152. $maxAgenda = (int) $maxAgenda;
  153. $maxCourse = (int) $maxCourse; // 0 if invalid.
  154. if ($maxCourse > 0) {
  155. unset ($allentries); // We shall collect all summary$key1 entries in here:
  156. $toolsList['agenda']['name'] = get_lang('Agenda');
  157. $toolsList['agenda']['path'] = api_get_path(WEB_CODE_PATH).'calendar/agenda.php?cidReq=';
  158. $toolsList['valvas']['name'] = get_lang('Valvas');
  159. $toolsList['valvas']['path'] = api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq=';
  160. }
  161. echo ' <div class="maincontent" id="maincontent">'; // Start of content for logged in users.
  162. // Plugins for the my courses main area.
  163. echo '<div id="plugin-mycourses_main">';
  164. api_plugin('mycourses_main');
  165. echo '</div>';
  166. /* System Announcements */
  167. $announcement = isset($_GET['announcement']) ? $_GET['announcement'] : -1;
  168. $visibility = api_is_allowed_to_create_course() ? VISIBLE_TEACHER : VISIBLE_STUDENT;
  169. SystemAnnouncementManager :: display_announcements($visibility, $announcement);
  170. if (!empty ($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/',$_GET['include'])) {
  171. include ('./home/'.$_GET['include']);
  172. $pageIncluded = true;
  173. } else {
  174. /* DISPLAY COURSES */
  175. // Compose a structured array of session categories, sessions and courses
  176. // for the current user.
  177. if (isset($_GET['history']) && intval($_GET['history']) == 1) {
  178. $courses_tree = UserManager::get_sessions_by_category($_user['user_id'], true, true);
  179. } else {
  180. $courses_tree = UserManager::get_sessions_by_category($_user['user_id'], true);
  181. }
  182. foreach ($courses_tree as $cat => $sessions) {
  183. $courses_tree[$cat]['details'] = SessionManager::get_session_category($cat);
  184. if ($cat == 0) {
  185. $courses_tree[$cat]['courses'] = CourseManager::get_courses_list_by_user_id($_user['user_id'], false);
  186. }
  187. $courses_tree[$cat]['sessions'] = array_flip(array_flip($sessions));
  188. if (count($courses_tree[$cat]['sessions']) > 0) {
  189. foreach ($courses_tree[$cat]['sessions'] as $k => $s_id) {
  190. $courses_tree[$cat]['sessions'][$k] = array('details' => SessionManager::fetch($s_id));
  191. $courses_tree[$cat]['sessions'][$k]['courses'] = UserManager::get_courses_list_by_session($_user['user_id'], $s_id);
  192. }
  193. }
  194. }
  195. $list = '';
  196. foreach ($personal_course_list as $my_course) {
  197. $thisCourseDbName = $my_course['db'];
  198. $thisCourseSysCode = $my_course['k'];
  199. $thisCoursePublicCode = $my_course['c'];
  200. $thisCoursePath = $my_course['d'];
  201. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  202. $dbname = $my_course['k'];
  203. $status = array();
  204. $status[$dbname] = $my_course['s'];
  205. $nbDigestEntries = 0; // Number of entries already collected.
  206. if ($maxCourse < $maxValvas) {
  207. $maxValvas = $maxCourse;
  208. }
  209. if ($maxCourse > 0) {
  210. $courses[$thisCourseSysCode]['coursePath'] = $thisCoursePath;
  211. $courses[$thisCourseSysCode]['courseCode'] = $thisCoursePublicCode;
  212. }
  213. /* Announcements */
  214. $course_database = $my_course['db'];
  215. $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST, $course_database);
  216. $query = "SELECT visibility FROM $course_tool_table WHERE link = 'announcements/announcements.php' AND visibility = 1";
  217. $result = Database::query($query);
  218. // Collect from announcements, but only if tool is visible for the course.
  219. if ($result && $maxValvas > 0 && Database::num_rows($result) > 0) {
  220. // Search announcements table.
  221. // Take the entries listed at the top of advalvas/announcements tool.
  222. $course_announcement_table = Database::get_course_table(TABLE_ANNOUNCEMENT);
  223. $sqlGetLastAnnouncements = "SELECT end_date publicationDate, content
  224. FROM ".$course_announcement_table;
  225. switch (CONFVAL_limitPreviewTo) {
  226. case SCRIPTVAL_NewEntriesOfTheDay :
  227. $sqlGetLastAnnouncements .= "WHERE DATE_FORMAT(end_date,'%Y %m %d') >= '".date('Y m d')."'";
  228. break;
  229. case SCRIPTVAL_NoTimeLimit :
  230. break;
  231. case SCRIPTVAL_NewEntriesOfTheDayOfLastLogin :
  232. // take care mysql -> DATE_FORMAT(time,format) php -> date(format,date)
  233. $sqlGetLastAnnouncements .= "WHERE DATE_FORMAT(end_date,'%Y %m %d') >= '".date('Y m d', $_user['lastLogin'])."'";
  234. }
  235. $sqlGetLastAnnouncements .= "ORDER BY end_date DESC LIMIT ".$maxValvas;
  236. $resGetLastAnnouncements = Database::query($sqlGetLastAnnouncements);
  237. if ($resGetLastAnnouncements) {
  238. while ($annoncement = Database::fetch_array($resGetLastAnnouncements)) {
  239. $keyTools = 'valvas';
  240. $keyTime = $annoncement['publicationDate'];
  241. $keyCourse = $thisCourseSysCode;
  242. $digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = @htmlspecialchars(api_substr(strip_tags($annoncement['content']), 0, CONFVAL_NB_CHAR_FROM_CONTENT), ENT_QUOTES, $charset);
  243. $nbDigestEntries ++; // summary has same order as advalvas
  244. }
  245. }
  246. }
  247. /* Agenda */
  248. $course_database = $my_course['db'];
  249. $course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST, $course_database);
  250. $query = "SELECT visibility FROM $course_tool_table WHERE link = 'calendar/agenda.php' AND visibility = 1";
  251. $result = Database::query($query);
  252. $thisAgenda = $maxCourse - $nbDigestEntries; // New max entries for agenda.
  253. if ($maxAgenda < $thisAgenda) {
  254. $thisAgenda = $maxAgenda;
  255. }
  256. // Collect from agenda, but only if tool is visible for the course.
  257. if ($result && $thisAgenda > 0 && Database::num_rows($result) > 0) {
  258. $tableCal = $courseTablePrefix.$thisCourseDbName.$_configuration['db_glue'].'calendar_event';
  259. $sqlGetNextAgendaEvent = "SELECT start_date, title content, start_time
  260. FROM $tableCal
  261. WHERE start_date >= CURDATE()
  262. ORDER BY start_date, start_time
  263. LIMIT $maxAgenda";
  264. $resGetNextAgendaEvent = Database::query($sqlGetNextAgendaEvent);
  265. if ($resGetNextAgendaEvent) {
  266. while ($agendaEvent = Database::fetch_array($resGetNextAgendaEvent)) {
  267. $keyTools = 'agenda';
  268. $keyTime = $agendaEvent['start_date'];
  269. $keyCourse = $thisCourseSysCode;
  270. $digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = @htmlspecialchars(api_substr(strip_tags($agendaEvent['content']), 0, CONFVAL_NB_CHAR_FROM_CONTENT), ENT_QUOTES, $charset);
  271. $nbDigestEntries ++; // Summary has same order as advalvas.
  272. }
  273. }
  274. }
  275. /*
  276. Digest Display
  277. Take collected data and display it.
  278. */
  279. } // End while mycourse...
  280. }
  281. if (isset($_GET['history']) && intval($_GET['history']) == 1) {
  282. echo '<h3>'.get_lang('HistoryTrainingSession').'</h3>';
  283. if (empty($courses_tree[0]['sessions'])){
  284. echo get_lang('YouDoNotHaveAnySessionInItsHistory');
  285. }
  286. }
  287. if (is_array($courses_tree)) {
  288. foreach ($courses_tree as $key => $category) {
  289. if ($key == 0) {
  290. // Sessions and courses that are not in a session category.
  291. if (!isset($_GET['history'])) { // Check if it's not history trainnign session list.
  292. CourseManager :: display_special_courses(api_get_user_id());
  293. CourseManager :: display_courses(api_get_user_id());
  294. }
  295. // Independent sessions.
  296. foreach ($category['sessions'] as $session) {
  297. // Don't show empty sessions.
  298. if (count($session['courses']) < 1) { continue; }
  299. // Courses inside the current session.
  300. $date_session_start = $session['details']['date_start'];
  301. $days_access_before_beginning = $session['details']['nb_days_access_before_beginning'] * 24 * 3600;
  302. $session_now = time();
  303. $html_courses_session = '';
  304. $count_courses_session = 0;
  305. foreach ($session['courses'] as $course) {
  306. $is_coach_course = api_is_coach($session['details']['id'], $course['code']);
  307. if ($is_coach_course) {
  308. $allowed_time = api_strtotime($date_session_start) - $days_access_before_beginning;
  309. } else {
  310. $allowed_time = api_strtotime($date_session_start);
  311. }
  312. if ($session_now > $allowed_time) { //read only and accesible
  313. if (api_get_setting('hide_courses_in_sessions') == 'false') {
  314. $c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item',true);
  315. //$c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item',($session['details']['visibility']==3?false:true));
  316. $html_courses_session .= $c[1];
  317. }
  318. $count_courses_session++;
  319. }
  320. }
  321. if ($count_courses_session > 0) {
  322. echo '<div class="userportal-session-item"><ul class="session_box">';
  323. echo '<li class="session_box_title" id="session_'.$session['details']['id'].'" >';
  324. echo Display::return_icon('window_list.png', get_lang('Expand').'/'.get_lang('Hide'), array('width' => '48px', 'align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' ';
  325. $s = Display :: get_session_title_box($session['details']['id']);
  326. $extra_info = (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates'];
  327. /*if ($session['details']['visibility'] == 3) {
  328. $session_link = $s['title'];
  329. } else {*/
  330. $session_link = Display::tag('a',$s['title'], array('href'=>api_get_path(WEB_CODE_PATH).'session/?session_id='.$session['details']['id']));
  331. //}
  332. echo Display::tag('span',$session_link. ' </span> <span style="padding-left: 10px; font-size: 90%; font-weight: normal;">'.$extra_info);
  333. if (api_is_platform_admin()) {
  334. 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.png', get_lang('Edit'), array('align' => 'absmiddle'),22).'</a></div>';
  335. }
  336. echo '</li>';
  337. if (api_get_setting('hide_courses_in_sessions') == 'false') {
  338. echo $html_courses_session;
  339. }
  340. echo '</ul></div>';
  341. }
  342. }
  343. } else {
  344. // All sessions included in.
  345. if (!empty($category['details'])) {
  346. $count_courses_session = 0;
  347. $html_sessions = '';
  348. foreach ($category['sessions'] as $session) {
  349. // Don't show empty sessions.
  350. if (count($session['courses']) < 1) { continue; }
  351. $date_session_start = $session['details']['date_start'];
  352. $days_access_before_beginning = $session['details']['nb_days_access_before_beginning'] * 24 * 3600;
  353. $session_now = time();
  354. $html_courses_session = '';
  355. $count = 0;
  356. foreach ($session['courses'] as $course) {
  357. $is_coach_course = api_is_coach($session['details']['id'], $course['code']);
  358. if ($is_coach_course) {
  359. $allowed_time = strtotime($date_session_start) - $days_access_before_beginning;
  360. } else {
  361. $allowed_time = strtotime($date_session_start);
  362. }
  363. if ($session_now > $allowed_time) {
  364. $c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item');
  365. $html_courses_session .= $c[1];
  366. $count_courses_session++;
  367. $count++;
  368. }
  369. }
  370. if ($count > 0) {
  371. $s = Display :: get_session_title_box($session['details']['id']);
  372. $html_sessions .= '<ul class="sub_session_box" id="session_'.$session['details']['id'].'">';
  373. $html_sessions .= '<li class="sub_session_box_title" id="session_'.$session['details']['id'].'">';
  374. //$html_sessions .= Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' ';
  375. $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'])) . ' ';
  376. $session_link = Display::tag('a',$s['title'], array('href'=>api_get_path(WEB_CODE_PATH).'session/?session_id='.$session['details']['id']));
  377. $html_sessions .= '<span>' . $session_link. ' </span> ';
  378. $html_sessions .= '<span style="padding-left: 10px; font-size: 90%; font-weight: normal;">';
  379. $html_sessions .= (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates'];
  380. $html_sessions .= '</span>';
  381. if (api_is_platform_admin()) {
  382. $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.png', get_lang('Edit'), array('align' => 'absmiddle'),22).'</a></div>';
  383. }
  384. $html_sessions .= '</li>';
  385. $html_sessions .= $html_courses_session;
  386. $html_sessions .= '</ul>';
  387. }
  388. }
  389. if ($count_courses_session > 0) {
  390. echo '<div class="userportal-session-category-item" id="session_category_'.$category['details']['id'].'">';
  391. echo '<div class="session_category_title_box" id="session_category_title_box_'.$category['details']['id'].'" style="color: #555555;">';
  392. //echo Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'category_img_'.$category['details']['id']));
  393. echo Display::return_icon('folder_blue.png', get_lang('SessionCategory'), array('width'=>'48px', 'align' => 'absmiddle'));
  394. if (api_is_platform_admin()) {
  395. 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.png', get_lang('Edit'), array(),22).'</a></div>';
  396. }
  397. echo '<span id="session_category_title">';
  398. echo $category['details']['name'];
  399. echo '</span>';
  400. echo '<span style="padding-left: 10px; font-size: 90%; font-weight: normal;">';
  401. if ($category['details']['date_end'] != '0000-00-00') {
  402. printf(get_lang('FromDateXToDateY'),$category['details']['date_start'],$category['details']['date_end']);
  403. }
  404. echo '</span></div>';
  405. echo $html_sessions;
  406. echo '</div>';
  407. }
  408. }
  409. }
  410. }
  411. }
  412. echo '</div>'; // End of content section.
  413. // Register whether full admin or null admin course
  414. // by course through an array dbname x user status.
  415. api_session_register('status');
  416. /* RIGHT MENU */
  417. $show_menu = false;
  418. $show_create_link = false;
  419. $show_course_link = false;
  420. $show_digest_link = false;
  421. $display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview');
  422. if ($display_add_course_link) {
  423. $show_menu = true;
  424. $show_create_link = true;
  425. }
  426. if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
  427. $show_menu = true;
  428. $show_course_link = true;
  429. } else {
  430. if (api_get_setting('allow_students_to_browse_courses') == 'true') {
  431. $show_menu = true;
  432. $show_course_link = true;
  433. }
  434. }
  435. if (isset($toolsList) && is_array($toolsList) && isset($digest)) {
  436. $show_digest_link = true;
  437. $show_menu = true;
  438. }
  439. //Always show the user image
  440. $img_array = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', true, true);
  441. $no_image = false;
  442. if ($img_array['file'] == 'unknown.jpg') {
  443. $no_image = true;
  444. }
  445. $img_array = UserManager::get_picture_user(api_get_user_id(), $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" ');
  446. $profile_content ='<div class="clear"></div>';
  447. $profile_content .='<div id="social_widget">';
  448. $profile_content .= ' <div id="social_widget_image">';
  449. if (api_get_setting('allow_social_tool') == 'true') {
  450. if (!$no_image) {
  451. $profile_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/home.php"><img src="'.$img_array['file'].'" '.$img_array['style'].' border="1"></a>';
  452. } else {
  453. $profile_content .='<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>';
  454. }
  455. } else {
  456. $profile_content .='<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>';
  457. }
  458. $profile_content .= ' </div>';
  459. // @todo Add a platform setting to add the user image.
  460. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  461. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  462. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  463. require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  464. // New messages.
  465. $number_of_new_messages = MessageManager::get_new_messages();
  466. // New contact invitations.
  467. $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
  468. // New group invitations sent by a moderator.
  469. $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
  470. $group_pending_invitations = count($group_pending_invitations);
  471. $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
  472. $cant_msg = '';
  473. if ($number_of_new_messages > 0) {
  474. $cant_msg = ' ('.$number_of_new_messages.')';
  475. }
  476. $profile_content .= '<div class="clear"></div>';
  477. $profile_content .= '<div class="message-content"><ul class="menulist">';
  478. $link = '';
  479. if (api_get_setting('show_tabs', 'social') == 'true') {
  480. $link = '?f=social';
  481. }
  482. $profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'" class="message-body">'.get_lang('Inbox').$cant_msg.' </a></li>';
  483. $profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'" class="message-body">'.get_lang('Compose').' </a></li>';
  484. if ($total_invitations == 0) {
  485. $total_invitations = '';
  486. } else {
  487. $total_invitations = ' ('.$total_invitations.')';
  488. }
  489. $profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php" class="message-body">'.get_lang('PendingInvitations').' '.$total_invitations.' </a></li>';
  490. $profile_content .= '</ul>';
  491. $profile_content .= '</div>';
  492. }
  493. //Profile content
  494. echo show_right_block(get_lang('Profile'), $profile_content);
  495. // My account section.
  496. if ($show_menu) {
  497. $my_account_content .= '<ul class="menulist">';
  498. if ($show_create_link) {
  499. $my_account_content .= '<li><a href="main/create_course/add_course.php">'.(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')).'</a></li>';
  500. }
  501. if ($show_course_link) {
  502. if (!api_is_drh()) {
  503. $my_account_content .= '<li><a href="main/auth/courses.php">'.get_lang('CourseManagement').'</a></li>';
  504. if (api_get_setting('use_session_mode') == 'true') {
  505. if (isset($_GET['history']) && intval($_GET['history']) == 1) {
  506. $my_account_content .= '<li><a href="user_portal.php">'.get_lang('DisplayTrainingList').'</a></li>';
  507. } else {
  508. $my_account_content .= '<li><a href="user_portal.php?history=1">'.get_lang('HistoryTrainingSessions').'</a></li>';
  509. }
  510. }
  511. } else {
  512. $my_account_content .= '<li><a href="main/dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
  513. }
  514. }
  515. if ($show_digest_link) {
  516. $my_account_content .= Display :: display_digest($toolsList, $digest, $orderKey, $courses);
  517. }
  518. $my_account_content .= '</ul>';
  519. }
  520. echo show_right_block(get_lang('MenuUser'), $my_account_content);
  521. // Deleting the myprofile link.
  522. if (api_get_setting('allow_social_tool') == 'true') {
  523. unset($menu_navigation['myprofile']);
  524. }
  525. // Main navigation section.
  526. // Tabs that are deactivated are added here.
  527. if (!empty($menu_navigation)) {
  528. $main_navigation_content .= '<ul class="menulist">';
  529. foreach ($menu_navigation as $section => $navigation_info) {
  530. $current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
  531. $main_navigation_content .= '<li'.$current.'>';
  532. $main_navigation_content .= '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>';
  533. $main_navigation_content .= '</li>';
  534. }
  535. $main_navigation_content .= '</ul>';
  536. echo show_right_block(get_lang('MainNavigation'), $main_navigation_content);
  537. }
  538. // Plugins for the my courses menu.
  539. if (isset($_plugins['mycourses_menu']) && is_array($_plugins['mycourses_menu'])) {
  540. ob_start();
  541. api_plugin('mycourses_menu');
  542. $plugin_content = ob_get_contents();
  543. ob_end_clean();
  544. echo show_right_block(get_lang(''), $plugin_content);
  545. }
  546. if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course()) {
  547. $booking_content .='<ul class="menulist">';
  548. $booking_content .='<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />';
  549. $booking_content .='</ul>';
  550. echo show_right_block(get_lang('Booking'), $booking_content);
  551. }
  552. // Deleting the session_id.
  553. api_session_unregister('session_id');
  554. // Search textbox.
  555. if (api_get_setting('search_enabled') == 'true') {
  556. echo '<div class="searchbox">';
  557. $search_btn = get_lang('Search');
  558. $search_text_default = get_lang('YourTextHere');
  559. $search_content = '<br />
  560. <form action="main/search/" method="post">
  561. <input type="text" id="query" size="15" name="query" value="" />
  562. <button class="save" type="submit" name="submit" value="'.$search_btn.'" />'.$search_btn.' </button>
  563. </form></div>';
  564. echo show_right_block(get_lang('Search'), $search_content);
  565. }
  566. if (api_get_setting('show_groups_to_users') == 'true') {
  567. require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php';
  568. $usergroup = new Usergroup();
  569. $usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id());
  570. $classes = '';
  571. if (!empty($usergroup_list)) {
  572. foreach($usergroup_list as $group_id) {
  573. $data = $usergroup->get($group_id);
  574. $data['name'] = Display::url($data['name'], api_get_path(WEB_PATH).'classes.php?id='.$data['id']);
  575. $classes .= Display::tag('li', $data['name']);
  576. }
  577. }
  578. if (api_is_platform_admin()) {
  579. $classes .= Display::tag('li', Display::url(get_lang('AddClasses') ,api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add'));
  580. }
  581. if (!empty($classes)) {
  582. $classes = Display::tag('ul', $classes, array('class'=>'menulist'));
  583. echo show_right_block(get_lang('Classes'), $classes);
  584. }
  585. }
  586. echo '</div>'; // End of menu wrapper
  587. function show_right_block($title, $content) {
  588. $html = '';
  589. $html.= '<div id="menu-wrapper">';
  590. $html.= '<div id="menu" class="menu">';
  591. $html.= '<div class="menusection">';
  592. $html.= '<span class="menusectioncaption">'.$title.'</span>';
  593. $html.= $content;
  594. $html.= '</div>';
  595. $html.= '</div>';
  596. $html.= '</div>';
  597. return $html;
  598. }
  599. // Footer
  600. Display :: display_footer();