user_portal.php 45 KB

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