user_portal.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. <?php
  2. // $Id: user_portal.php,v 1.10 2006/08/19 09:33:14 yannoo Exp $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2004-2005 Dokeos S.A.
  7. Copyright (c) 2003 Ghent University (UGent)
  8. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9. Copyright (c) various contributors
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  18. Mail: info@dokeos.com
  19. ==============================================================================
  20. */
  21. /**
  22. ==============================================================================
  23. * This is the index file displayed when a user is logged in on Dokeos.
  24. *
  25. * It displays:
  26. * - personal course list
  27. * - menu bar
  28. *
  29. * Part of the what's new ideas were based on a rene haentjens hack
  30. *
  31. * Search for
  32. * CONFIGURATION parameters
  33. * to modify settings
  34. *
  35. * @todo rewrite code to separate display, logic, database code
  36. * @package dokeos.main
  37. ==============================================================================
  38. */
  39. /**
  40. * @todo shouldn't the SCRIPTVAL_ and CONFVAL_ constant be moved to the config page? Has anybody any idea what the are used for?
  41. * if these are really configuration settings then we can add those to the dokeos config settings
  42. * @todo move get_personal_course_list and some other functions to a more appripriate place course.lib.php or user.lib.php
  43. * @todo use api_get_path instead of $rootAdminWeb
  44. * @todo check for duplication of functions with index.php (user_portal.php is orginally a copy of index.php)
  45. * @todo display_digest, shouldn't this be removed and be made into an extension?
  46. */
  47. /*
  48. ==============================================================================
  49. INIT SECTION
  50. ==============================================================================
  51. */
  52. // Don't change these settings
  53. define('SCRIPTVAL_No', 0);
  54. define('SCRIPTVAL_InCourseList', 1);
  55. define('SCRIPTVAL_UnderCourseList', 2);
  56. define('SCRIPTVAL_Both', 3);
  57. define('SCRIPTVAL_NewEntriesOfTheDay', 4);
  58. define('SCRIPTVAL_NewEntriesOfTheDayOfLastLogin', 5);
  59. define('SCRIPTVAL_NoTimeLimit', 6);
  60. // End 'don't change' section
  61. // name of the language file that needs to be included
  62. $language_file = array ('courses', 'index');
  63. $cidReset = true; /* Flag forcing the 'current course' reset,
  64. as we're not inside a course anymore */
  65. /*
  66. -----------------------------------------------------------
  67. Included libraries
  68. -----------------------------------------------------------
  69. */
  70. include_once ('./main/inc/global.inc.php');
  71. include_once (api_get_path(LIBRARY_PATH).'course.lib.php');
  72. include_once (api_get_path(LIBRARY_PATH).'debug.lib.inc.php');
  73. include_once (api_get_path(LIBRARY_PATH).'system_announcements.lib.php');
  74. include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  75. api_block_anonymous_users(); // only users who are logged in can proceed
  76. /*
  77. -----------------------------------------------------------
  78. Table definitions
  79. -----------------------------------------------------------
  80. */
  81. //Database table definitions
  82. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  83. $main_admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
  84. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
  85. $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  86. $main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
  87. /*
  88. -----------------------------------------------------------
  89. Constants and CONFIGURATION parameters
  90. -----------------------------------------------------------
  91. */
  92. // ---- Course list options ----
  93. define('CONFVAL_showCourseLangIfNotSameThatPlatform', TRUE);
  94. // Preview of course content
  95. // to disable all: set CONFVAL_maxTotalByCourse = 0
  96. // to enable all: set e.g. CONFVAL_maxTotalByCourse = 5
  97. // by default disabled since what's new icons are better (see function display_digest() )
  98. define('CONFVAL_maxValvasByCourse', 2); // Maximum number of entries
  99. define('CONFVAL_maxAgendaByCourse', 2); // collected from each course
  100. define('CONFVAL_maxTotalByCourse', 0); // and displayed in summary.
  101. define('CONFVAL_NB_CHAR_FROM_CONTENT', 80);
  102. // Order to sort data
  103. $orderKey = array('keyTools', 'keyTime', 'keyCourse'); // default "best" Choice
  104. //$orderKey = array('keyTools', 'keyCourse', 'keyTime');
  105. //$orderKey = array('keyCourse', 'keyTime', 'keyTools');
  106. //$orderKey = array('keyCourse', 'keyTools', 'keyTime');
  107. define('CONFVAL_showExtractInfo', SCRIPTVAL_UnderCourseList);
  108. // SCRIPTVAL_InCourseList // best choice if $orderKey[0] == 'keyCourse'
  109. // SCRIPTVAL_UnderCourseList // best choice
  110. // SCRIPTVAL_Both // probably only for debug
  111. //define('CONFVAL_dateFormatForInfosFromCourses', get_lang('dateFormatShort'));
  112. define('CONFVAL_dateFormatForInfosFromCourses', get_lang('dateFormatLong'));
  113. //define("CONFVAL_limitPreviewTo",SCRIPTVAL_NewEntriesOfTheDay);
  114. //define("CONFVAL_limitPreviewTo",SCRIPTVAL_NoTimeLimit);
  115. define("CONFVAL_limitPreviewTo", SCRIPTVAL_NewEntriesOfTheDayOfLastLogin);
  116. if(api_is_allowed_to_create_course() && !isset($_GET['sessionview'])){
  117. $nosession = true;
  118. }
  119. else {
  120. $nosession = false;
  121. }
  122. if(api_get_setting('use_session_mode')=='true' && !$nosession)
  123. {
  124. if (isset($_GET['inactives'])){
  125. $display_actives = false;
  126. }
  127. else {
  128. $display_actives = true;
  129. }
  130. }
  131. $nameTools = get_lang('MyCourses');
  132. $this_section = SECTION_COURSES;
  133. /*
  134. -----------------------------------------------------------
  135. Check configuration parameters integrity
  136. -----------------------------------------------------------
  137. */
  138. if (CONFVAL_showExtractInfo != SCRIPTVAL_UnderCourseList and $orderKey[0] != "keyCourse")
  139. {
  140. // CONFVAL_showExtractInfo must be SCRIPTVAL_UnderCourseList to accept $orderKey[0] !="keyCourse"
  141. if (DEBUG || api_is_platform_admin()) // Show bug if admin. Else force a new order
  142. die('
  143. <strong>config error:'.__FILE__.'</strong><br />
  144. set
  145. <ul>
  146. <li>
  147. CONFVAL_showExtractInfo = SCRIPTVAL_UnderCourseList
  148. (actually : '.CONFVAL_showExtractInfo.')
  149. </li>
  150. </ul>
  151. or
  152. <ul>
  153. <li>
  154. $orderKey[0] != "keyCourse"
  155. (actually : '.$orderKey[0].')
  156. </li>
  157. </ul>');
  158. else
  159. {
  160. $orderKey = array ('keyCourse', 'keyTools', 'keyTime');
  161. }
  162. }
  163. /*
  164. -----------------------------------------------------------
  165. Header
  166. include the HTTP, HTML headers plus the top banner
  167. -----------------------------------------------------------
  168. */
  169. Display :: display_header($nameTools);
  170. /*
  171. ==============================================================================
  172. FUNCTIONS
  173. display_admin_links()
  174. display_create_course_link()
  175. display_edit_course_list_links()
  176. display_digest($toolsList, $digest, $orderKey, $courses)
  177. show_notification($my_course)
  178. get_personal_course_list($user_id)
  179. get_logged_user_course_html($my_course)
  180. get_user_course_categories()
  181. ==============================================================================
  182. */
  183. /*
  184. -----------------------------------------------------------
  185. Database functions
  186. some of these can go to database layer.
  187. -----------------------------------------------------------
  188. */
  189. /**
  190. * Database function that gets the list of courses for a particular user.
  191. * @param $user_id, the id of the user
  192. * @return an array with courses
  193. */
  194. function get_personal_course_list($user_id)
  195. {
  196. // initialisation
  197. $personal_course_list = array();
  198. // table definitions
  199. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  200. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
  201. $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  202. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  203. $tbl_session_course_user= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  204. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  205. $personal_course_list = array ();
  206. $personal_course_list_sql = "SELECT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i,
  207. course.tutor_name t, course.course_language l, course_rel_user.status s, course_rel_user.sort sort,
  208. course_rel_user.user_course_cat user_course_cat
  209. FROM ".$main_course_table." course,".$main_course_user_table." course_rel_user
  210. WHERE course.code = course_rel_user.course_code"."
  211. AND course_rel_user.user_id = '".$user_id."'
  212. ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC,course.title,course.code";
  213. $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__);
  214. while ($result_row = mysql_fetch_array($course_list_sql_result))
  215. {
  216. $personal_course_list[] = $result_row;
  217. }
  218. //$personal_course_list = array_merge($personal_course_list, $course_list_sql_result);
  219. $personal_course_list_sql = "SELECT DISTINCT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, course.tutor_name t, course.course_language l, 5 as s
  220. FROM $main_course_table as course, $tbl_session_course_user as srcru
  221. WHERE srcru.course_code=course.code AND srcru.id_user='$user_id'";
  222. $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__);
  223. while ($result_row = mysql_fetch_array($course_list_sql_result))
  224. {
  225. $personal_course_list[] = $result_row;
  226. }
  227. //$personal_course_list = array_merge($personal_course_list, $course_list_sql_result);
  228. $personal_course_list_sql = "SELECT DISTINCT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, course.tutor_name t, course.course_language l, 2 as s
  229. FROM $main_course_table as course, $tbl_session_course as src, $tbl_session as session
  230. WHERE session.id_coach='$user_id' AND session.id=src.id_session AND src.course_code=course.code";
  231. $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__);
  232. //$personal_course_list = array_merge($personal_course_list, $course_list_sql_result);
  233. while ($result_row = mysql_fetch_array($course_list_sql_result))
  234. {
  235. $personal_course_list[] = $result_row;
  236. }
  237. return $personal_course_list;
  238. }
  239. /**
  240. * Enter description here...
  241. *
  242. * @param unknown_type $user_id
  243. * @param unknown_type $list_sessions
  244. * @return unknown
  245. *
  246. */
  247. function get_personal_session_course_list($user_id, $list_sessions)
  248. {
  249. // Database Table Definitions
  250. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  251. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  252. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  253. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  254. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  255. $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  256. $tbl_session_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER);
  257. // variable initialisation
  258. $personal_course_list_sql = '';
  259. $personal_course_list = array();
  260. // get the list of sessions where the user is subscribed as student
  261. $result=api_sql_query("SELECT DISTINCT id, name, date_start, date_end, 5 as s
  262. FROM session_rel_user, session
  263. WHERE id_session=id AND id_user=$user_id ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  264. $Sessions=api_store_result($result);
  265. $Sessions = array_merge($Sessions , api_store_result($result));
  266. // get the list of sessions where the user is subscribed as coach in a course
  267. $result=api_sql_query("SELECT DISTINCT id, name, date_start, date_end, 2 as s
  268. FROM $tbl_session as session
  269. INNER JOIN $tbl_session_course as session_rel_course
  270. ON session_rel_course.id_coach = $user_id
  271. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  272. //global $sessionIsCoach;
  273. $sessionIsCoach = api_store_result($result);
  274. $Sessions = array_merge($Sessions , $sessionIsCoach);
  275. // get the list of sessions where the user is subscribed as coach
  276. $result=api_sql_query("SELECT DISTINCT id, name, date_start, date_end, 2 as s
  277. FROM $tbl_session as session
  278. WHERE session.id_coach = $user_id
  279. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  280. $Sessions = array_merge($Sessions , api_store_result($result));
  281. if(api_is_allowed_to_create_course())
  282. {
  283. foreach($Sessions as $enreg)
  284. {
  285. $id_session = $enreg['id'];
  286. $personal_course_list_sql = "SELECT DISTINCT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, CONCAT(user.lastname,' ',user.firstname) t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name
  287. FROM $tbl_session_course as session_course
  288. INNER JOIN $tbl_course AS course
  289. ON course.code = session_course.course_code
  290. INNER JOIN $tbl_session as session
  291. ON session.id = session_course.id_session
  292. LEFT JOIN $tbl_user as user
  293. ON user.user_id = session_course.id_coach
  294. WHERE session_course.id_session = $id_session
  295. AND (session_course.id_coach=$user_id OR session.id_coach=$user_id)
  296. ORDER BY i";
  297. $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__);
  298. while ($result_row = mysql_fetch_array($course_list_sql_result))
  299. {
  300. $result_row['s'] = 2;
  301. $key = $result_row['id_session'].' - '.$result_row['k'];
  302. $personal_course_list[$key] = $result_row;
  303. }
  304. }
  305. }
  306. foreach($Sessions as $enreg)
  307. {
  308. $id_session = $enreg['id'];
  309. $personal_course_list_sql = "SELECT DISTINCT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, CONCAT(user.lastname,' ',user.firstname) t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name
  310. FROM $tbl_session_course as session_course
  311. INNER JOIN $tbl_course AS course
  312. ON course.code = session_course.course_code
  313. LEFT JOIN $tbl_user as user
  314. ON user.user_id = session_course.id_coach
  315. INNER JOIN $tbl_session_course_user
  316. ON $tbl_session_course_user.id_session = $id_session
  317. AND $tbl_session_course_user.id_user = $user_id
  318. INNER JOIN $tbl_session as session
  319. ON session_course.id_session = session.id
  320. WHERE session_course.id_session = $id_session
  321. ORDER BY i";
  322. $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__);
  323. while ($result_row = mysql_fetch_array($course_list_sql_result))
  324. {
  325. $key = $result_row['id_session'].' - '.$result_row['k'];
  326. $result_row['s'] = $enreg['s'];
  327. if(!isset($personal_course_list[$key]))
  328. {
  329. $personal_course_list[$key] = $result_row;
  330. }
  331. }
  332. }
  333. return $personal_course_list;
  334. }
  335. /*
  336. -----------------------------------------------------------
  337. Display functions
  338. -----------------------------------------------------------
  339. */
  340. /**
  341. * Warning: this function defines a global.
  342. * @todo use the correct get_path function
  343. */
  344. function display_admin_links()
  345. {
  346. global $rootAdminWeb;
  347. echo "<li><a href=\"".$rootAdminWeb."\">".get_lang("PlatformAdmin")."</a></li>";
  348. }
  349. /**
  350. * Enter description here...
  351. *
  352. */
  353. function display_create_course_link()
  354. {
  355. echo "<li><a href=\"main/create_course/add_course.php\">".get_lang("CourseCreate")."</a></li>";
  356. }
  357. /**
  358. * Enter description here...
  359. *
  360. */
  361. function display_edit_course_list_links()
  362. {
  363. echo "<li><a href=\"main/auth/courses.php\">".get_lang("CourseManagement")."</a></li>";
  364. }
  365. /**
  366. * Displays a digest e.g. short summary of new agenda and announcements items.
  367. * This used to be displayed in the right hand menu, but is now
  368. * disabled by default (see config settings in this file) because most people like
  369. * the what's new icons better.
  370. *
  371. * @version 1.0
  372. */
  373. function display_digest($toolsList, $digest, $orderKey, $courses)
  374. {
  375. if (is_array($digest) && (CONFVAL_showExtractInfo == SCRIPTVAL_UnderCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both))
  376. {
  377. // // // LEVEL 1 // // //
  378. reset($digest);
  379. echo "<br/><br/>\n";
  380. while (list ($key1) = each($digest))
  381. {
  382. if (is_array($digest[$key1]))
  383. {
  384. // // // Title of LEVEL 1 // // //
  385. echo "<b>\n";
  386. if ($orderKey[0] == 'keyTools')
  387. {
  388. $tools = $key1;
  389. echo $toolsList[$key1][name];
  390. }
  391. elseif ($orderKey[0] == 'keyCourse')
  392. {
  393. $courseSysCode = $key1;
  394. echo "<a href=\"", api_get_path(WEB_COURSE_PATH), $courses[$key1][coursePath], "\">", $courses[$key1][courseCode], "</a>\n";
  395. }
  396. elseif ($orderKey[0] == 'keyTime')
  397. {
  398. echo format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($digest[$key1]));
  399. }
  400. echo "</b>\n";
  401. // // // End Of Title of LEVEL 1 // // //
  402. // // // LEVEL 2 // // //
  403. reset($digest[$key1]);
  404. while (list ($key2) = each($digest[$key1]))
  405. {
  406. // // // Title of LEVEL 2 // // //
  407. echo "<p>\n", "\n";
  408. if ($orderKey[1] == 'keyTools')
  409. {
  410. $tools = $key2;
  411. echo $toolsList[$key2][name];
  412. }
  413. elseif ($orderKey[1] == 'keyCourse')
  414. {
  415. $courseSysCode = $key2;
  416. echo "<a href=\"", api_get_path(WEB_COURSE_PATH), $courses[$key2]['coursePath'], "\">", $courses[$key2]['courseCode'], "</a>\n";
  417. }
  418. elseif ($orderKey[1] == 'keyTime')
  419. {
  420. echo format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key2));
  421. }
  422. echo "\n";
  423. echo "</p>";
  424. // // // End Of Title of LEVEL 2 // // //
  425. // // // LEVEL 3 // // //
  426. reset($digest[$key1][$key2]);
  427. while (list ($key3, $dataFromCourse) = each($digest[$key1][$key2]))
  428. {
  429. // // // Title of LEVEL 3 // // //
  430. if ($orderKey[2] == 'keyTools')
  431. {
  432. $level3title = "<a href=\"".$toolsList[$key3]["path"].$courseSysCode."\">".$toolsList[$key3]["name"]."</a>";
  433. }
  434. elseif ($orderKey[2] == 'keyCourse')
  435. {
  436. $level3title = "&#8226; <a href=\"".$toolsList[$tools]["path"].$key3."\">".$courses[$key3]['courseCode']."</a>\n";
  437. }
  438. elseif ($orderKey[2] == 'keyTime')
  439. {
  440. $level3title = "&#8226; <a href=\"".$toolsList[$tools]["path"].$courseSysCode."\">".format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key3))."</a>";
  441. }
  442. // // // End Of Title of LEVEL 3 // // //
  443. // // // LEVEL 4 (data) // // //
  444. reset($digest[$key1][$key2][$key3]);
  445. while (list ($key4, $dataFromCourse) = each($digest[$key1][$key2][$key3]))
  446. {
  447. echo $level3title, ' &ndash; ', substr(strip_tags($dataFromCourse), 0, CONFVAL_NB_CHAR_FROM_CONTENT);
  448. //adding ... (three dots) if the texts are too large and they are shortened
  449. if (strlen($dataFromCourse) >= CONFVAL_NB_CHAR_FROM_CONTENT)
  450. {
  451. echo '...';
  452. }
  453. }
  454. echo "<br/>\n";
  455. }
  456. }
  457. }
  458. }
  459. }
  460. } // end function display_digest
  461. /**
  462. * Display code for one specific course a logged in user is subscribed to.
  463. * Shows a link to the course, what's new icons...
  464. *
  465. * $my_course['d'] - course directory
  466. * $my_course['i'] - course title
  467. * $my_course['c'] - visual course code
  468. * $my_course['k'] - system course code
  469. * $my_course['db'] - course database
  470. *
  471. * @version 1.0.3
  472. * @todo refactor into different functions for database calls | logic | display
  473. * @todo replace single-character $my_course['d'] indices
  474. * @todo move code for what's new icons to a separate function to clear things up
  475. * @todo add a parameter user_id so that it is possible to show the courselist of other users (=generalisation). This will prevent having to write a new function for this.
  476. */
  477. function get_logged_user_course_html($my_course)
  478. {
  479. global $nosession;
  480. if(api_get_setting('use_session_mode')=='true' && !$nosession)
  481. {
  482. global $now, $date_start, $date_end;
  483. }
  484. //initialise
  485. $result = '';
  486. // Table definitions
  487. //$statistic_database = Database::get_statistic_database();
  488. $course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST, $course_database);
  489. $tool_edit_table = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_database);
  490. $course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database);
  491. $user_id = api_get_user_id();
  492. $course_database = $my_course['db'];
  493. $course_system_code = $my_course['k'];
  494. $course_visual_code = $my_course['c'];
  495. $course_title = $my_course['i'];
  496. $course_directory = $my_course['d'];
  497. $course_teacher = $my_course['t'];
  498. $course_info = Database :: get_course_info($course_system_code);
  499. $course_access_settings = CourseManager :: get_access_settings($course_system_code);
  500. $course_id = $course_info['course_id'];
  501. $course_visibility = $course_access_settings['visibility'];
  502. $user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_system_code);
  503. //function logic - act on the data
  504. $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['c']);
  505. if ($is_virtual_course)
  506. {
  507. // If the current user is also subscribed in the real course to which this
  508. // virtual course is linked, we don't need to display the virtual course entry in
  509. // the course list - it is combined with the real course entry.
  510. $target_course_code = CourseManager :: get_target_of_linked_course($course_system_code);
  511. $is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code);
  512. if ($is_subscribed_in_target_course)
  513. {
  514. return; //do not display this course entry
  515. }
  516. }
  517. $has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_system_code, api_get_user_id());
  518. if ($has_virtual_courses)
  519. {
  520. $return_result = CourseManager :: determine_course_title_from_course_info(api_get_user_id(), $course_info);
  521. $course_display_title = $return_result['title'];
  522. $course_display_code = $return_result['code'];
  523. }
  524. else
  525. {
  526. $course_display_title = $course_title;
  527. $course_display_code = $course_visual_code;
  528. }
  529. $s_course_status=$my_course["s"];
  530. $s_htlm_status_icon="";
  531. if($s_course_status==1){
  532. $s_htlm_status_icon="<img src='main/img/teachers.gif'>";
  533. }
  534. if($s_course_status==2){
  535. $s_htlm_status_icon="<img src='main/img/coachs.gif'>";
  536. }
  537. if($s_course_status==5){
  538. $s_htlm_status_icon="<img src='main/img/students.gif'>";
  539. }
  540. //display course entry
  541. $result.="\n\t";
  542. $result .= '<li style="list-style-type: none; margin-bottom: 5px;"><div style="border:0px solid #000; width: auto; float:left;padding-right: 5px;">'.$s_htlm_status_icon.'</div>';
  543. //show a hyperlink to the course, unless the course is closed and user is not course admin
  544. if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER)
  545. {
  546. if(api_get_setting('use_session_mode')=='true' && !$nosession)
  547. {
  548. if(empty($my_course['id_session']))
  549. {
  550. $my_course['id_session'] = 0;
  551. }
  552. if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00')
  553. {
  554. $result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>';
  555. }
  556. }
  557. else
  558. {
  559. $result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
  560. }
  561. }
  562. else
  563. {
  564. $result .= $course_display_title." "." ".get_lang("CourseClosed")."";
  565. }
  566. // show the course_code and teacher if chosen to display this
  567. if (get_setting("display_coursecode_in_courselist") == "true" OR get_setting("display_teacher_in_courselist") == "true")
  568. {
  569. $result .= "<br/>";
  570. }
  571. if (get_setting("display_coursecode_in_courselist") == "true")
  572. {
  573. $result .= $course_display_code;
  574. }
  575. if (get_setting("display_coursecode_in_courselist") == "true" AND get_setting("display_teacher_in_courselist") == "true")
  576. {
  577. $result .= ' &ndash; ';
  578. }
  579. if (get_setting("display_teacher_in_courselist") == "true")
  580. {
  581. $result .= $course_teacher;
  582. }
  583. // display the what's new icons
  584. $result .= show_notification($my_course);
  585. /*
  586. // get the user's last access dates to all tools of this course
  587. $sqlLastTrackInCourse = "SELECT * FROM $statistic_database.track_e_lastaccess"
  588. ." WHERE access_user_id = ".$user_id
  589. ." AND access_cours_code = '".$my_course['k']."'";
  590. $resLastTrackInCourse = api_sql_query($sqlLastTrackInCourse,__FILE__,__LINE__);
  591. while($lastTrackInCourse = mysql_fetch_array($resLastTrackInCourse))
  592. {
  593. $lastTrackInCourseDate[$lastTrackInCourse["access_tool"]] = $lastTrackInCourse["access_date"];
  594. }
  595. // get the last edits of all tools of this course
  596. $sql = "SELECT tooledit.lastedit_date last_date, tooledit.tool tool, tooledit.ref ref,
  597. tooledit.lastedit_type type, tooledit.to_group_id group_id,
  598. accueil.image image, accueil.link link
  599. FROM $tool_edit_table tooledit, $course_tool_table accueil
  600. WHERE accueil.name = tooledit.tool
  601. AND accueil.visibility = '1'
  602. AND tooledit.insert_user_id != $user_id
  603. AND (tooledit.to_user_id = '$user_id' OR tooledit.to_user_id = 0)";
  604. $res = api_sql_query($sql,__FILE__,__LINE__);
  605. $sql = "SELECT group_id FROM $course_group_user_table WHERE user_id = '$user_id'";
  606. $groupres = api_sql_query($sql,__FILE__,__LINE__);
  607. $groups = mysql_fetch_array($groupres);
  608. $groups[] = 0;
  609. //show icons of tools where there is something new
  610. while($lastToolEdit = mysql_fetch_array($res))
  611. {
  612. if ($lastTrackInCourseDate[$lastToolEdit["tool"]]<$lastToolEdit["last_date"] && in_array($lastToolEdit["group_id"], $groups))
  613. {
  614. $lastDate = date("d/m/Y H:i", convert_mysql_date($lastToolEdit["last_date"]));
  615. $type = ($lastToolEdit["type"]=="" || $lastToolEdit["type"]==NULL) ? get_lang('_new_item') : $lastToolEdit["type"];
  616. $result.= '<a href="'.api_get_path(WEB_CODE_PATH).$lastToolEdit['link'].'?cidReq='.$my_course['k'].'">'.
  617. '<img title="&mdash; '.$lastToolEdit['tool'].' &mdash; '.get_lang('_title_notification').": $type ($lastDate).\""
  618. .' src="'.api_get_path(WEB_IMG_PATH).$lastToolEdit['image'].'" border="0" align="middle" alt="'.$lastToolEdit['image'].'" /></a>';
  619. }
  620. }
  621. unset($lastTrackInCourseDate);
  622. unset($groups);*/
  623. if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0)
  624. {
  625. reset($digest);
  626. $result .= "<ul>";
  627. while (list ($key2) = each($digest[$thisCourseSysCode]))
  628. {
  629. $result .= "<li>";
  630. if ($orderKey[1] == 'keyTools')
  631. {
  632. $result .= "<a href=\"$toolsList[$key2] [\"path\"] $thisCourseSysCode \">";
  633. $result .= "$toolsList[$key2][\"name\"]</a>";
  634. }
  635. else
  636. {
  637. $result .= format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key2));
  638. }
  639. $result .= "</li>";
  640. $result .= "<ul>";
  641. reset($digest[$thisCourseSysCode][$key2]);
  642. while (list ($key3, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2]))
  643. {
  644. $result .= "<li>";
  645. if ($orderKey[2] == 'keyTools')
  646. {
  647. $result .= "<a href=\"$toolsList[$key3] [\"path\"] $thisCourseSysCode \">";
  648. $result .= "$toolsList[$key3][\"name\"]</a>";
  649. }
  650. else
  651. {
  652. $result .= format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key3));
  653. }
  654. $result .= "<ul compact=\"compact\">";
  655. reset($digest[$thisCourseSysCode][$key2][$key3]);
  656. while (list ($key4, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2][$key3]))
  657. {
  658. $result .= "<li>";
  659. $result .= htmlspecialchars(substr(strip_tags($dataFromCourse), 0, CONFVAL_NB_CHAR_FROM_CONTENT));
  660. $result .= "</li>";
  661. }
  662. $result .= "</ul>";
  663. $result .= "</li>";
  664. }
  665. $result .= "</ul>";
  666. $result .= "</li>";
  667. }
  668. $result .= "</ul>";
  669. }
  670. $result .= "</li>";
  671. if(api_get_setting('use_session_mode')=='true' && !$nosession)
  672. {
  673. if(!empty($my_course['session_name']))
  674. {
  675. $session = $my_course['session_name'];
  676. if($date_start=='0000-00-00')
  677. {
  678. $session .= ' - '.get_lang('Without time limits');
  679. $active = true;
  680. }
  681. else
  682. {
  683. $session .= ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end'];
  684. $active = ($date_start <= $now && $date_end >= $now)?true:false;
  685. }
  686. }
  687. $output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active);
  688. }
  689. else
  690. {
  691. $output = array ($my_course['user_course_cat'], $result);
  692. }
  693. return $output;
  694. }
  695. /**
  696. * Returns the "what's new" icon notifications
  697. * @version
  698. */
  699. function show_notification($my_course)
  700. {
  701. $statistic_database = Database :: get_statistic_database();
  702. $user_id = api_get_user_id();
  703. $course_database = $my_course['db'];
  704. $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST, $course_database);
  705. $tool_edit_table = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_database);
  706. $course_group_user_table = Database :: get_course_table(TABLE_GROUP_USER, $course_database);
  707. // get the user's last access dates to all tools of this course
  708. $sqlLastTrackInCourse = "SELECT * FROM $statistic_database.track_e_lastaccess
  709. USE INDEX (access_cours_code, access_user_id)
  710. WHERE access_cours_code = '".$my_course['k']."'
  711. AND access_user_id = '$user_id'";
  712. $resLastTrackInCourse = api_sql_query($sqlLastTrackInCourse, __FILE__, __LINE__);
  713. $oldestTrackDate = "3000-01-01 00:00:00";
  714. while ($lastTrackInCourse = mysql_fetch_array($resLastTrackInCourse))
  715. {
  716. $lastTrackInCourseDate[$lastTrackInCourse["access_tool"]] = $lastTrackInCourse["access_date"];
  717. if ($oldestTrackDate > $lastTrackInCourse["access_date"])
  718. $oldestTrackDate = $lastTrackInCourse["access_date"];
  719. }
  720. // get the last edits of all tools of this course
  721. $sql = "SELECT tet.*, tet.lastedit_date last_date, tet.tool tool, tet.ref ref,
  722. tet.lastedit_type type, tet.to_group_id group_id,
  723. ctt.image image, ctt.link link
  724. FROM $tool_edit_table tet, $course_tool_table ctt
  725. WHERE tet.lastedit_date > '$oldestTrackDate'
  726. AND ctt.name = tet.tool
  727. AND ctt.visibility = '1'
  728. AND tet.lastedit_user_id != $user_id
  729. ORDER BY tet.lastedit_date";
  730. $res = api_sql_query($sql);
  731. //get the group_id's with user membership
  732. $group_ids = GroupManager :: get_group_ids($course_database, $user_id);
  733. $groups_ids[] = 0; //add group 'everyone'
  734. //filter all selected items
  735. while ($res && ($item_property = mysql_fetch_array($res)))
  736. {
  737. if ((!isset ($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date']) && (in_array($item_property['to_group_id'], $groups_ids) || $item_property['to_user_id'] == $user_id) && ($item_property['visibility'] == '1' || ($my_course['s'] == '1' && $item_property['visibility'] == '0') || !isset ($item_property['visibility'])))
  738. {
  739. $notifications[$item_property['tool']] = $item_property;
  740. }
  741. }
  742. //show all tool icons where there is something new
  743. $retvalue = '&nbsp;';
  744. if (isset ($notifications))
  745. {
  746. while (list ($key, $notification) = each($notifications))
  747. {
  748. $lastDate = date("d/m/Y H:i", convert_mysql_date($notification['lastedit_date']));
  749. $type = $notification['lastedit_type'];
  750. //$notification[image]=str_replace(".png","gif",$notification[image]);
  751. //$notification[image]=str_replace(".gif","_s.gif",$notification[image]);
  752. $retvalue .= '<a href="'.api_get_path(WEB_CODE_PATH).$notification['link'].'?cidReq='.$my_course['k'].'&amp;ref='.$notification['ref'].'">'.'<img title="-- '.get_lang($notification['tool']).' -- '.get_lang('_title_notification').": $type ($lastDate).\"".' src="'.api_get_path(WEB_CODE_PATH).'img/'.$notification['image'].'" border="0" align="middle" /></a>&nbsp;';
  753. }
  754. }
  755. return $retvalue;
  756. }
  757. /**
  758. * retrieves the user defined course categories
  759. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  760. * @return array containing all the titles of the user defined courses with the id as key of the array
  761. */
  762. function get_user_course_categories()
  763. {
  764. global $_user;
  765. $table_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
  766. $sql = "SELECT * FROM ".$table_category." WHERE user_id='".$_user['user_id']."'";
  767. $result = api_sql_query($sql,__FILE__,__LINE__);
  768. while ($row = mysql_fetch_array($result))
  769. {
  770. $output[$row['id']] = $row['title'];
  771. }
  772. return $output;
  773. }
  774. /*
  775. ==============================================================================
  776. MAIN CODE
  777. ==============================================================================
  778. */
  779. /*
  780. ==============================================================================
  781. PERSONAL COURSE LIST
  782. ==============================================================================
  783. */
  784. if (!isset ($maxValvas))
  785. {
  786. $maxValvas = CONFVAL_maxValvasByCourse; // Maximum number of entries
  787. }
  788. if (!isset ($maxAgenda))
  789. {
  790. $maxAgenda = CONFVAL_maxAgendaByCourse; // collected from each course
  791. }
  792. if (!isset ($maxCourse))
  793. {
  794. $maxCourse = CONFVAL_maxTotalByCourse; // and displayed in summary.
  795. }
  796. $maxValvas = (int) $maxValvas;
  797. $maxAgenda = (int) $maxAgenda;
  798. $maxCourse = (int) $maxCourse; // 0 if invalid
  799. if ($maxCourse > 0)
  800. {
  801. unset ($allentries); // we shall collect all summary$key1 entries in here:
  802. $toolsList['agenda']['name'] = get_lang('Agenda');
  803. $toolsList['agenda']['path'] = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=";
  804. $toolsList['valvas']['name'] = get_lang('Valvas');
  805. $toolsList['valvas']['path'] = api_get_path(WEB_CODE_PATH)."announcements/announcements.php?cidReq=";
  806. }
  807. /*
  808. -----------------------------------------------------------------------------
  809. Plugins for banner section
  810. -----------------------------------------------------------------------------
  811. */
  812. echo "<div class=\"maincontent\">"; // start of content for logged in users
  813. // link to see the session view or course view
  814. if(api_get_setting('use_session_mode')=='true' && api_is_allowed_to_create_course()) {
  815. if(isset($_GET['sessionview'])){
  816. echo '<a href="'.$_SERVER['PHP_SELF'].'">'.get_lang('CourseView').'</a>';
  817. }
  818. else {
  819. echo '<a href="'.$_SERVER['PHP_SELF'].'?sessionview=true">'.get_lang('SessionView').'</a>';
  820. }
  821. }
  822. /*
  823. -----------------------------------------------------------------------------
  824. System Announcements
  825. -----------------------------------------------------------------------------
  826. */
  827. $announcement = $_GET['announcement'] ? $_GET['announcement'] : -1;
  828. $visibility = api_is_allowed_to_create_course() ? VISIBLE_TEACHER : VISIBLE_STUDENT;
  829. SystemAnnouncementManager :: display_announcements($visibility, $announcement);
  830. if (!empty ($_GET['include']) && !strstr($_GET['include'], '/') && strstr($_GET['include'], '.html'))
  831. {
  832. include ('./home/'.$_GET['include']);
  833. $pageIncluded = true;
  834. }
  835. else
  836. {
  837. /*--------------------------------------
  838. DISPLAY COURSES
  839. --------------------------------------*/
  840. $list = '';
  841. if(api_get_setting('use_session_mode')=='true' && !$nosession)
  842. {
  843. $personal_course_list = get_personal_session_course_list($_user['user_id']);
  844. }
  845. else
  846. {
  847. $personal_course_list = get_personal_course_list($_user['user_id']);
  848. }
  849. foreach ($personal_course_list as $my_course)
  850. {
  851. $thisCourseDbName = $my_course['db'];
  852. $thisCourseSysCode = $my_course['k'];
  853. $thisCoursePublicCode = $my_course['c'];
  854. $thisCoursePath = $my_course['d'];
  855. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  856. /*
  857. currently disabled functionality, should return
  858. $thisCoursePath = $sys_course_path . $thisCoursePath;
  859. if(! file_exists($thisCoursePath))
  860. {
  861. echo "<li>".$my_course['i']."<br/>";
  862. echo "".get_lang("CourseDoesntExist")." (<a href=\"main/install/update_courses.php\">";
  863. echo "".get_lang("GetCourseFromOldPortal")."</a>)</li>";
  864. continue;
  865. }*/
  866. $dbname = $my_course['k'];
  867. $status[$dbname] = $my_course['s'];
  868. $nbDigestEntries = 0; // number of entries already collected
  869. if ($maxCourse < $maxValvas)
  870. $maxValvas = $maxCourse;
  871. if ($maxCourse > 0)
  872. {
  873. $courses[$thisCourseSysCode]['coursePath'] = $thisCoursePath;
  874. $courses[$thisCourseSysCode]['courseCode'] = $thisCoursePublicCode;
  875. }
  876. /*
  877. -----------------------------------------------------------
  878. Announcements
  879. -----------------------------------------------------------
  880. */
  881. $course_database = $my_course['db'];
  882. $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST, $course_database);
  883. $query = "SELECT visibility FROM $course_tool_table WHERE link = 'announcements/announcements.php' AND visibility = 1";
  884. $result = api_sql_query($query);
  885. // collect from announcements, but only if tool is visible for the course
  886. if ($result && $maxValvas > 0 && mysql_num_rows($result) > 0)
  887. {
  888. //Search announcements table
  889. //Take the entries listed at the top of advalvas/announcements tool
  890. $course_announcement_table = Database::get_course_table(TABLE_ANNOUNCEMENT);
  891. $sqlGetLastAnnouncements = "SELECT end_date publicationDate, content
  892. FROM ".$course_announcement_table;
  893. switch (CONFVAL_limitPreviewTo)
  894. {
  895. case SCRIPTVAL_NewEntriesOfTheDay :
  896. $sqlGetLastAnnouncements .= "WHERE DATE_FORMAT(end_date,'%Y %m %d') >= '".date("Y m d")."'";
  897. break;
  898. case SCRIPTVAL_NoTimeLimit :
  899. break;
  900. case SCRIPTVAL_NewEntriesOfTheDayOfLastLogin :
  901. // take care mysql -> DATE_FORMAT(time,format) php -> date(format,date)
  902. $sqlGetLastAnnouncements .= "WHERE DATE_FORMAT(end_date,'%Y %m %d') >= '".date("Y m d", $_user["lastLogin"])."'";
  903. }
  904. $sqlGetLastAnnouncements .= "ORDER BY end_date DESC
  905. LIMIT ".$maxValvas;
  906. $resGetLastAnnouncements = api_sql_query($sqlGetLastAnnouncements, __FILE__, __LINE__);
  907. if ($resGetLastAnnouncements)
  908. {
  909. while ($annoncement = mysql_fetch_array($resGetLastAnnouncements))
  910. {
  911. $keyTools = "valvas";
  912. $keyTime = $annoncement['publicationDate'];
  913. $keyCourse = $thisCourseSysCode;
  914. $digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = htmlspecialchars(substr(strip_tags($annoncement["content"]), 0, CONFVAL_NB_CHAR_FROM_CONTENT));
  915. $nbDigestEntries ++; // summary has same order as advalvas
  916. }
  917. }
  918. }
  919. /*
  920. -----------------------------------------------------------
  921. Agenda
  922. -----------------------------------------------------------
  923. */
  924. $course_database = $my_course['db'];
  925. $course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST,$course_database);
  926. $query = "SELECT visibility FROM $course_tool_table WHERE link = 'calendar/agenda.php' AND visibility = 1";
  927. $result = api_sql_query($query);
  928. $thisAgenda = $maxCourse - $nbDigestEntries; // new max entries for agenda
  929. if ($maxAgenda < $thisAgenda)
  930. $thisAgenda = $maxAgenda;
  931. // collect from agenda, but only if tool is visible for the course
  932. if ($result && $thisAgenda > 0 && mysql_num_rows($result) > 0)
  933. {
  934. $tableCal = $courseTablePrefix.$thisCourseDbName.$_configuration['db_glue']."calendar_event";
  935. $sqlGetNextAgendaEvent = "SELECT start_date , title content, start_time
  936. FROM $tableCal
  937. WHERE start_date >= CURDATE()
  938. ORDER BY start_date, start_time
  939. LIMIT $maxAgenda";
  940. $resGetNextAgendaEvent = api_sql_query($sqlGetNextAgendaEvent, __FILE__, __LINE__);
  941. if ($resGetNextAgendaEvent)
  942. {
  943. while ($agendaEvent = mysql_fetch_array($resGetNextAgendaEvent))
  944. {
  945. $keyTools = 'agenda';
  946. $keyTime = $agendaEvent['start_date'];
  947. $keyCourse = $thisCourseSysCode;
  948. $digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = htmlspecialchars(substr(strip_tags($agendaEvent["content"]), 0, CONFVAL_NB_CHAR_FROM_CONTENT));
  949. $nbDigestEntries ++; // summary has same order as advalvas
  950. }
  951. }
  952. }
  953. /*
  954. -----------------------------------------------------------
  955. Digest Display
  956. take collected data and display it
  957. -----------------------------------------------------------
  958. */
  959. $list[] = get_logged_user_course_html($my_course);
  960. } //end while mycourse...
  961. }
  962. if (is_array($list))
  963. {
  964. if(api_get_setting('use_session_mode')=='true' && !$nosession)
  965. {
  966. $listActives = $listInactives = $listCourses = array();
  967. foreach($list as $key=>$value){
  968. if($value['active'])
  969. $listActives[] = $value;
  970. else if(!empty($value[2]))
  971. $listInactives[] = $value;
  972. }
  973. $old_user_category = 0;
  974. $userdefined_categories = get_user_course_categories();
  975. //Courses which belong to no sessions
  976. //echo "<ul style=\"line-height: 20px;\">\n\n\n\t<ul class=\"user_course_category\"><li>".get_lang("Courses_no_sessions")."</li></ul>\n</ul>";
  977. if(count($listActives)>0 && $display_actives){
  978. echo "<ul style=\"line-height: 20px;\">\n";
  979. foreach ($listActives as $key => $value)
  980. {
  981. if(!empty($value[2])){
  982. if($old_session != $value[2]){
  983. $old_session = $value[2];
  984. if($key != 0){
  985. echo "\n</ul>";
  986. }
  987. echo "\n\n\t<ul class=\"user_course_category\"><li>".$value[3]."</li></ul>\n";
  988. echo "<ul>";
  989. }
  990. }
  991. echo $value[1];
  992. }
  993. echo "\n</ul></ul><br /><br />\n";
  994. }
  995. if(count($listInactives)>0 && !$display_actives){
  996. echo "<ul style=\"line-height: 20px;\">";
  997. foreach ($listInactives as $key => $value)
  998. {
  999. if(!empty($value[2])){
  1000. if($old_session != $value[2]){
  1001. $old_session = $value[2];
  1002. if($key != 0){
  1003. echo "\n</ul>";
  1004. }
  1005. echo "\n\n\t<ul class=\"user_course_category\"><li>".$value[3]."</li></ul>\n";
  1006. echo "<ul>";
  1007. }
  1008. }
  1009. echo $value[1];
  1010. }
  1011. echo "\n</ul><br /><br />\n";
  1012. }
  1013. }
  1014. else
  1015. {
  1016. $old_user_category = 0;
  1017. $userdefined_categories = get_user_course_categories();
  1018. echo "<ul>\n";
  1019. foreach ($list as $key => $value)
  1020. {
  1021. if ($old_user_category<>$value[0])
  1022. {
  1023. if ($key<>0 OR $value[0]<>0) // there are courses in the previous category
  1024. {
  1025. echo "\n</ul>";
  1026. }
  1027. echo "\n\n\t<ul class=\"user_course_category\"><li>".$userdefined_categories[$value[0]]."</li></ul>\n";
  1028. if ($key<>0 OR $value[0]<>0) // there are courses in the previous category
  1029. {
  1030. echo "<ul>";
  1031. }
  1032. $old_user_category=$value[0];
  1033. }
  1034. echo $value[1];
  1035. }
  1036. echo "\n</ul>\n";
  1037. }
  1038. }
  1039. echo "</div>"; // end of content section
  1040. // Register whether full admin or null admin course
  1041. // by course through an array dbname x user status
  1042. api_session_register('status');
  1043. /*
  1044. ==============================================================================
  1045. RIGHT MENU
  1046. ==============================================================================
  1047. */
  1048. echo "<div class=\"menu\">";
  1049. // api_display_language_form(); // moved to the profile page.
  1050. echo "<div class=\"menusection\">";
  1051. echo "<span class=\"menusectioncaption\">".get_lang("MenuUser")."</span>";
  1052. echo "<ul class=\"menulist\">";
  1053. $display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION["studentview"] != "studentenview");
  1054. if ($display_add_course_link)
  1055. display_create_course_link();
  1056. display_edit_course_list_links();
  1057. display_digest($toolsList, $digest, $orderKey, $courses);
  1058. $navigation=array();
  1059. // Link to my profile
  1060. $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  1061. $navigation['myprofile']['title'] = get_lang('ModifyProfile');
  1062. // Link to my agenda
  1063. $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/myagenda.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  1064. $navigation['myagenda']['title'] = get_lang('MyAgenda');
  1065. foreach($navigation as $section => $navigation_info)
  1066. {
  1067. $current = ($section == $GLOBALS['this_section'] ? ' id="current"' : '');
  1068. echo '<li'.$current.'>';
  1069. echo '<a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a>';
  1070. echo '</li>';
  1071. echo "\n";
  1072. }
  1073. echo "</ul>";
  1074. echo "</div>";
  1075. /*
  1076. -----------------------------------------------------------------------------
  1077. Plugins for banner section
  1078. -----------------------------------------------------------------------------
  1079. */
  1080. if (is_array($_plugins['mycourses_menu'])){
  1081. echo '<div class="note" style="background: none">';
  1082. api_plugin('mycourses_menu');
  1083. echo "</div>";
  1084. }
  1085. echo "</div>"; // end of menu
  1086. /*
  1087. ==============================================================================
  1088. FOOTER
  1089. ==============================================================================
  1090. */
  1091. Display :: display_footer();
  1092. ?>