user_portal.php 45 KB

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