index.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. <?php
  2. /*
  3. DOKEOS - elearning and course management software
  4. For a full list of contributors, see documentation/credits.html
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. See "documentation/licence.html" more details.
  10. Contact:
  11. Dokeos
  12. Rue des Palais 44 Paleizenstraat
  13. B-1030 Brussels - Belgium
  14. Tel. +32 (2) 211 34 56
  15. */
  16. /**
  17. * @package dokeos.main
  18. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Refactoring
  19. * @version $Id: index.php 13894 2007-12-03 21:43:34Z yannoo $
  20. * @todo check the different @todos in this page and really do them
  21. * @todo check if the news management works as expected
  22. */
  23. // only this script should have this constant defined. This is used to activate the javascript that
  24. // gives the login name automatic focus in header.inc.html.
  25. /** @todo Couldn't this be done using the $HtmlHeadXtra array? */
  26. define('DOKEOS_HOMEPAGE', true);
  27. // the language file
  28. $language_file = array ('courses', 'index');
  29. /* Flag forcing the 'current course' reset, as we're not inside a course anymore */
  30. // maybe we should change this into an api function? an example: Coursemanager::unset();
  31. $cidReset = true;
  32. /*
  33. -----------------------------------------------------------
  34. Included libraries
  35. -----------------------------------------------------------
  36. */
  37. /** @todo make all the library files consistent, use filename.lib.php and not filename.lib.inc.php */
  38. require_once ('main/inc/global.inc.php');
  39. include_once (api_get_path(LIBRARY_PATH).'course.lib.php');
  40. include_once (api_get_path(LIBRARY_PATH).'debug.lib.inc.php');
  41. include_once (api_get_path(LIBRARY_PATH).'events.lib.inc.php');
  42. include_once (api_get_path(LIBRARY_PATH).'system_announcements.lib.php');
  43. include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  44. include_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  45. $loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed);
  46. // the section (for the tabs)
  47. $this_section = SECTION_CAMPUS;
  48. /*
  49. -----------------------------------------------------------
  50. Action Handling
  51. -----------------------------------------------------------
  52. */
  53. /** @todo wouldn't it make more sense if this would be done in local.inc.php so that local.inc.php become the only place where authentication is done?
  54. * by doing this you could logout from any page instead of only from index.php. From the moment there is a logout=true in the url you will be logged out
  55. * this can be usefull when you are on an open course and you need to log in to edit something and you immediately want to check how anonymous users
  56. * will see it.
  57. */
  58. if ($_GET['logout'])
  59. {
  60. logout();
  61. }
  62. /*
  63. -----------------------------------------------------------
  64. Table definitions
  65. -----------------------------------------------------------
  66. */
  67. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
  68. $main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
  69. $track_login_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
  70. /*
  71. -----------------------------------------------------------
  72. Constants and CONFIGURATION parameters
  73. -----------------------------------------------------------
  74. */
  75. /** @todo these configuration settings should move to the dokeos config settings */
  76. /** defines wether or not anonymous visitors can see a list of the courses on the Dokeos homepage that are open to the world */
  77. $_setting['display_courses_to_anonymous_users'] = 'true';
  78. /** @todo remove this piece of code because this is not used */
  79. if (isset ($_user['user_id']))
  80. {
  81. $nameTools = api_get_setting('siteName');
  82. }
  83. /*
  84. ==============================================================================
  85. LOGIN
  86. ==============================================================================
  87. */
  88. /**
  89. * @todo This piece of code should probably move to local.inc.php where the actual login / logout procedure is handled.
  90. * @todo consider removing this piece of code because does nothing.
  91. */
  92. if ($_GET["submitAuth"] == 1)
  93. {
  94. // nice lie!!!
  95. echo "Attempted breakin - sysadmins notified.";
  96. session_destroy();
  97. die();
  98. }
  99. /**
  100. * @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled.
  101. * @todo check if this code is used. I think this code is never executed because after clicking the submit button
  102. * the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending
  103. * on api_get_setting('page_after_login')
  104. */
  105. if ($_POST["submitAuth"])
  106. {
  107. // the user is already authenticated, we now find the last login of the user.
  108. if (isset ($_user['user_id']))
  109. {
  110. $sql_last_login = "SELECT UNIX_TIMESTAMP(login_date)
  111. FROM $track_login_table
  112. WHERE login_user_id = '".$_user['user_id']."'
  113. ORDER BY login_date DESC LIMIT 1";
  114. $result_last_login = api_sql_query($sql_last_login, __FILE__, __LINE__);
  115. if (!$result_last_login)
  116. if (mysql_num_rows($result_last_login) > 0)
  117. {
  118. $user_last_login_datetime = mysql_fetch_array($result_last_login);
  119. $user_last_login_datetime = $user_last_login_datetime[0];
  120. api_session_register('user_last_login_datetime');
  121. }
  122. mysql_free_result($result_last_login);
  123. //event_login();
  124. if (api_is_platform_admin())
  125. {
  126. // decode all open event informations and fill the track_c_* tables
  127. include (api_get_path(LIBRARY_PATH)."stats.lib.inc.php");
  128. decodeOpenInfos();
  129. }
  130. }
  131. } // end login -- if($_POST["submitAuth"])
  132. else
  133. {
  134. // only if login form was not sent because if the form is sent the user was already on the page.
  135. event_open();
  136. }
  137. // the header
  138. Display :: display_header('', 'dokeos');
  139. /*
  140. ==============================================================================
  141. MAIN CODE
  142. ==============================================================================
  143. */
  144. echo '<div class="maincontent" id="content">';
  145. // Plugins for loginpage_main AND campushomepage_main
  146. if (!api_get_user_id())
  147. {
  148. api_plugin('loginpage_main');
  149. }
  150. else
  151. {
  152. api_plugin('campushomepage_main');
  153. }
  154. // Including the page for the news
  155. $page_included = false;
  156. if (!empty ($_GET['include']) && !strstr($_GET['include'], '/') && !strstr($_GET['include'], '\\') && strstr($_GET['include'], '.html'))
  157. {
  158. include ('./home/'.$_GET['include']);
  159. $page_included = true;
  160. }
  161. else
  162. {
  163. if(!empty($_SESSION['user_language_choice']))
  164. {
  165. $user_selected_language=$_SESSION['user_language_choice'];
  166. }
  167. elseif(!empty($_SESSION['_user']['language']))
  168. {
  169. $user_selected_language=$_SESSION['_user']['language'];
  170. }
  171. else
  172. {
  173. $user_selected_language=get_setting('platformLanguage');
  174. }
  175. if(!file_exists('home/home_news_'.$user_selected_language.'.html'))
  176. {
  177. $home_top_temp=file('home/home_top.html');
  178. $home_top_temp=implode('',$home_top_temp);
  179. $open=str_replace('{rel_path}',api_get_path(REL_PATH),$home_top_temp);
  180. echo $open;
  181. }
  182. else
  183. {
  184. if(file_exists('home/home_top_'.$user_selected_language.'.html'))
  185. {
  186. include('home/home_top_'.$user_selected_language.'.html');
  187. }
  188. else
  189. {
  190. include('home/home_top.html');
  191. }
  192. }
  193. }
  194. // Display System announcements
  195. $announcement = $_GET['announcement'] ? $_GET['announcement'] : -1;
  196. $announcement = intval($announcement);
  197. SystemAnnouncementManager :: display_announcements(VISIBLE_GUEST, $announcement);
  198. // Display courses and category list
  199. if (!$page_included)
  200. {
  201. if (api_get_setting('display_categories_on_homepage') == 'true')
  202. {
  203. echo '<div class="home_cats">';
  204. display_anonymous_course_list();
  205. echo '</div>';
  206. }
  207. }
  208. echo '</div>';
  209. // display right menu: language form, login section + useful weblinks
  210. echo '<div class="menu" id="menu">';
  211. display_anonymous_right_menu();
  212. echo '</div>';
  213. /*
  214. ==============================================================================
  215. FOOTER
  216. ==============================================================================
  217. */
  218. Display :: display_footer();
  219. /**
  220. * This function handles the logout and is called whenever there is a $_GET['logout']
  221. *
  222. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  223. */
  224. function logout()
  225. {
  226. global $_configuration, $extAuthSource;
  227. // variable initialisation
  228. $query_string='';
  229. if(!empty($_SESSION['user_language_choice']))
  230. {
  231. $query_string='?language='.$_SESSION['user_language_choice'];
  232. }
  233. // Database table definition
  234. $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
  235. // selecting the last login of the user
  236. $uid = intval($_GET['uid']);
  237. $sql_last_connection="SELECT login_id, login_date FROM $tbl_track_login WHERE login_user_id='$uid' ORDER BY login_date DESC LIMIT 0,1";
  238. $q_last_connection=api_sql_query($sql_last_connection);
  239. if(Database::num_rows($q_last_connection)>0)
  240. {
  241. $i_id_last_connection=mysql_result($q_last_connection,0,"login_id");
  242. }
  243. $s_sql_update_logout_date="UPDATE $tbl_track_login SET logout_date=NOW() WHERE login_id='$i_id_last_connection'";
  244. api_sql_query($s_sql_update_logout_date);
  245. LoginDelete($uid, $_configuration['statistics_database']); //from inc/lib/online.inc.php - removes the "online" status
  246. //the following code enables the use of an external logout function.
  247. //example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php
  248. // then a function called ldap_logout() inside that file
  249. // (using *authent_name*_logout as the function name) and the following code
  250. // will find and execute it
  251. $uinfo = api_get_user_info($uid);
  252. if(($uinfo['auth_source'] != PLATFORM_AUTH_SOURCE) && is_array($extAuthSource))
  253. {
  254. if(is_array($extAuthSource[$uinfo['auth_source']]))
  255. {
  256. $subarray = $extAuthSource[$uinfo['auth_source']];
  257. if(!empty($subarray['logout']) && file_exists($subarray['logout']))
  258. {
  259. include_once($subarray['logout']);
  260. $logout_function = $uinfo['auth_source'].'_logout';
  261. if(function_exists($logout_function))
  262. {
  263. $logout_function($uinfo);
  264. }
  265. }
  266. }
  267. }
  268. api_session_destroy();
  269. header("Location: index.php$query_string");
  270. exit();
  271. }
  272. /**
  273. * This function checks if there are courses that are open to the world in the platform course categories (=faculties)
  274. *
  275. * @param unknown_type $category
  276. * @return boolean
  277. */
  278. function category_has_open_courses($category)
  279. {
  280. $user_identified = (api_get_user_id()>0 && !api_is_anonymous());
  281. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
  282. $sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'";
  283. $sql_result = api_sql_query($sql_query, __FILE__, __LINE__);
  284. while ($course = mysql_fetch_array($sql_result))
  285. {
  286. if((api_get_user_id()>0
  287. and $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
  288. or ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD))
  289. {
  290. return true; //at least one open course
  291. }
  292. }
  293. return false;
  294. }
  295. function display_create_course_link()
  296. {
  297. echo "<li><a href=\"main/create_course/add_course.php\">".get_lang("CourseCreate")."</a></li>";
  298. }
  299. function display_edit_course_list_links()
  300. {
  301. echo "<li><a href=\"main/auth/courses.php\">".get_lang("CourseManagement")."</a></li>";
  302. }
  303. /**
  304. * Displays the right-hand menu for anonymous users:
  305. * login form, useful links, help section
  306. * Warning: function defines globals
  307. * @version 1.0.1
  308. * @todo does $_plugins need to be global?
  309. */
  310. function display_anonymous_right_menu()
  311. {
  312. global $loginFailed, $_plugins, $_user, $menu_navigation;
  313. $platformLanguage = api_get_setting('platformLanguage');
  314. if ( !($_user['user_id']) ) // only display if the user isn't logged in
  315. {
  316. api_display_language_form();
  317. echo '<br />';
  318. display_login_form();
  319. if ($loginFailed)
  320. {
  321. handle_login_failed();
  322. }
  323. if (api_get_setting('allow_lostpassword') == 'true' OR api_get_setting('allow_registration') == 'true')
  324. {
  325. echo '<div class="menusection"><span class="menusectioncaption">'.get_lang('MenuUser').'</span><ul class="menulist">';
  326. if (get_setting('allow_registration') <> 'false')
  327. {
  328. echo '<li><a href="main/auth/inscription.php">'.get_lang('Reg').'</a></li>';
  329. }
  330. if (get_setting('allow_lostpassword') == 'true')
  331. {
  332. display_lost_password_info();
  333. }
  334. echo '</ul></div>';
  335. }
  336. if(api_number_of_plugins('loginpage_menu') > 0)
  337. {
  338. echo '<div class="note" style="background: none">';
  339. api_plugin('loginpage_menu');
  340. echo '</div>';
  341. }
  342. }
  343. /*** hide right menu "general" and other parts on anonymous right menu *****/
  344. echo "<div class=\"menusection\">", "<span class=\"menusectioncaption\">".get_lang("MenuGeneral")."</span>";
  345. echo "<ul class=\"menulist\">";
  346. $user_selected_language = api_get_interface_language();
  347. if (!isset ($user_selected_language))
  348. $user_selected_language = $platformLanguage;
  349. if(!file_exists('home/home_menu_'.$user_selected_language.'.html'))
  350. {
  351. include ('home/home_menu.html');
  352. }
  353. else
  354. {
  355. include('home/home_menu_'.$user_selected_language.'.html');
  356. }
  357. echo '</ul>';
  358. echo '</div>';
  359. if ($_user['user_id'] && api_number_of_plugins('campushomepage_menu') > 0)
  360. {
  361. echo '<div class="note" style="background: none">';
  362. api_plugin('campushomepage_menu');
  363. echo '</div>';
  364. }
  365. /**
  366. * User section
  367. */
  368. if(isset($_SESSION['_user']['user_id']) && $_SESSION['_user']['user_id']!=0)
  369. {
  370. // tabs that are deactivated are added here
  371. if (!empty($menu_navigation))
  372. {
  373. echo "<div class=\"menusection\">";
  374. echo "<span class=\"menusectioncaption\">".get_lang("MainNavigation")."</span>";
  375. echo "<ul class=\"menulist\">";
  376. foreach($menu_navigation as $section => $navigation_info)
  377. {
  378. $current = ($section == $GLOBALS['this_section'] ? ' id="current"' : '');
  379. echo '<li'.$current.'>';
  380. echo '<a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a>';
  381. echo '</li>';
  382. echo "\n";
  383. }
  384. echo "</ul>";
  385. echo '</div>';
  386. }
  387. echo "<div class=\"menusection\">";
  388. echo "<span class=\"menusectioncaption\">".get_lang("MenuUser")."</span>";
  389. echo "<ul class=\"menulist\">";
  390. $display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION["studentview"] != "studentenview");
  391. if ($display_add_course_link)
  392. display_create_course_link();
  393. display_edit_course_list_links();
  394. echo "</ul>";
  395. echo "</div>";
  396. }
  397. // includes for any files to be displayed below anonymous right menu
  398. if(!file_exists('home/home_notice_'.$user_selected_language.'.html') && file_get_contents('home/home_notice.html')!='')
  399. {
  400. echo '<div class="note">';
  401. include ('home/home_notice.html');
  402. echo '</div>';
  403. }
  404. elseif(file_exists('home/home_notice_'.$user_selected_language.'.html') && file_get_contents('home/home_notice_'.$user_selected_language.'.html')!='')
  405. {
  406. echo '<div class="note">';
  407. include('home/home_notice_'.$user_selected_language.'.html');
  408. echo '</div>';
  409. }
  410. }
  411. /**
  412. * Reacts on a failed login:
  413. * displays an explanation with
  414. * a link to the registration form.
  415. *
  416. * @version 1.0.1
  417. */
  418. function handle_login_failed()
  419. {
  420. switch ($_GET['error'])
  421. {
  422. case '':
  423. $message = get_lang("InvalidId");
  424. if (api_is_self_registration_allowed())
  425. {
  426. $message = get_lang("InvalidForSelfRegistration");
  427. }
  428. break;
  429. case 'account_expired':
  430. $message=get_lang('AccountExpired');
  431. break;
  432. case 'account_inactive':
  433. $message=get_lang('AccountInactive');
  434. break;
  435. case 'user_password_incorrect':
  436. $message=get_lang('InvalidId');
  437. break;
  438. }
  439. echo "<div id=\"login_fail\">".$message."</div>";
  440. }
  441. /**
  442. * Adds a form to let users login
  443. * @version 1.1
  444. */
  445. function display_login_form()
  446. {
  447. $form = new FormValidator('formLogin');
  448. $form->addElement('text','login',get_lang('UserName'),array('size'=>15));
  449. $form->addElement('password','password',get_lang('Pass'),array('size'=>15));
  450. $form->addElement('submit','submitAuth',get_lang('Ok'));
  451. $renderer =& $form->defaultRenderer();
  452. $renderer->setElementTemplate('<div><label>{label}</label></div><div>{element}</div>');
  453. $form->display();
  454. if(api_get_setting('openid_authentication')=='true')
  455. {
  456. include_once('main/auth/openid/login.php');
  457. echo '<div>'.openid_form().'</div>';
  458. }
  459. }
  460. /**
  461. * Displays a link to the lost password section
  462. */
  463. function display_lost_password_info()
  464. {
  465. echo "<li><a href=\"main/auth/lostPassword.php\">".get_lang("LostPassword")."</a></li>";
  466. }
  467. /**
  468. * Display list of courses in a category.
  469. * (for anonymous users)
  470. *
  471. * @version 1.1
  472. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University - refactoring and code cleaning
  473. */
  474. function display_anonymous_course_list()
  475. {
  476. //init
  477. $user_identified = (api_get_user_id()>0 && !api_is_anonymous());
  478. $web_course_path = api_get_path(WEB_COURSE_PATH);
  479. $category = $_GET["category"];
  480. // Database table definitions
  481. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
  482. $main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
  483. $platformLanguage = api_get_setting('platformLanguage');
  484. //get list of courses in category $category
  485. $sql_get_course_list = "SELECT * FROM $main_course_table cours
  486. WHERE category_code = '".mysql_real_escape_string($_GET["category"])."'
  487. ORDER BY UPPER(visual_code)";
  488. //removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."'
  489. $sql_result_courses = api_sql_query($sql_get_course_list, __FILE__, __LINE__);
  490. while ($course_result = mysql_fetch_array($sql_result_courses))
  491. {
  492. $course_list[] = $course_result;
  493. }
  494. $platform_visible_courses = '';
  495. if($user_identified)
  496. {
  497. $platform_visible_courses = " OR t3.visibility='".COURSE_VISIBILITY_OPEN_PLATFORM."' ";
  498. }
  499. $sqlGetSubCatList = "
  500. SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse
  501. FROM $main_category_table t1
  502. LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id
  503. LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' $platform_visible_courses))
  504. WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")."
  505. GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos";
  506. $resCats = api_sql_query($sqlGetSubCatList, __FILE__, __LINE__);
  507. $thereIsSubCat = false;
  508. if (mysql_num_rows($resCats) > 0)
  509. {
  510. $htmlListCat = "<h4 style=\"margin-top: 0px;\">".get_lang("CatList")."</h4>"."<ul>";
  511. while ($catLine = mysql_fetch_array($resCats))
  512. {
  513. if ($catLine['code'] != $category)
  514. {
  515. $category_has_open_courses = category_has_open_courses($catLine['code']);
  516. if ($category_has_open_courses)
  517. {
  518. //the category contains courses accessible to anonymous visitors
  519. $htmlListCat .= "<li>";
  520. $htmlListCat .= "<a href=\"".api_get_self()."?category=".$catLine['code']."\">".$catLine['name']."</a>";
  521. if (api_get_setting('show_number_of_courses') == 'true')
  522. {
  523. $htmlListCat .= " (".$catLine['nbCourse']." ".get_lang("Courses").")";
  524. }
  525. $htmlListCat .= "</li>\n";
  526. $thereIsSubCat = true;
  527. }
  528. elseif ($catLine['children_count'] > 0)
  529. {
  530. //the category has children, subcategories
  531. $htmlListCat .= "<li>";
  532. $htmlListCat .= "<a href=\"".api_get_self()."?category=".$catLine['code']."\">".$catLine['name']."</a>";
  533. $htmlListCat .= "</li>\n";
  534. $thereIsSubCat = true;
  535. }
  536. /************************************************************************
  537. end changed code to eliminate the (0 courses) after empty categories
  538. ************************************************************************/
  539. elseif (api_get_setting('show_empty_course_categories') == 'true')
  540. {
  541. $htmlListCat .= "<li>";
  542. $htmlListCat .= $catLine['name'];
  543. $htmlListCat .= "</li>\n";
  544. $thereIsSubCat = true;
  545. }//else don't set thereIsSubCat to true to avoid printing things if not requested
  546. }
  547. else
  548. {
  549. $htmlTitre = "<p>";
  550. if (api_get_setting('show_back_link_on_top_of_tree') == 'true')
  551. {
  552. $htmlTitre .= "<a href=\"".api_get_self()."\">"."&lt;&lt; ".get_lang("BackToHomePage")."</a>";
  553. }
  554. if (!is_null($catLine['parent_id']) || (api_get_setting('show_back_link_on_top_of_tree') <> 'true' && !is_null($catLine['code'])))
  555. {
  556. $htmlTitre .= "<a href=\"".api_get_self()."?category=".$catLine['parent_id']."\">"."&lt;&lt; ".get_lang("Up")."</a>";
  557. }
  558. $htmlTitre .= "</p>\n";
  559. if ($category != "" && !is_null($catLine['code']))
  560. {
  561. $htmlTitre .= "<h3>".$catLine['name']."</h3>\n";
  562. }
  563. else
  564. {
  565. $htmlTitre .= "<h3>".get_lang("Categories")."</h3>\n";
  566. }
  567. }
  568. }
  569. $htmlListCat .= "</ul>\n";
  570. }
  571. echo $htmlTitre;
  572. if ($thereIsSubCat)
  573. {
  574. echo $htmlListCat;
  575. }
  576. while ($categoryName = mysql_fetch_array($resCats))
  577. {
  578. echo "<h3>", $categoryName['name'], "</h3>\n";
  579. }
  580. $numrows = mysql_num_rows($sql_result_courses);
  581. $courses_list_string = '';
  582. $courses_shown = 0;
  583. if ($numrows > 0)
  584. {
  585. if ($thereIsSubCat)
  586. {
  587. $courses_list_string .= "<hr size=\"1\" noshade=\"noshade\">\n";
  588. }
  589. $courses_list_string .= "<h4 style=\"margin-top: 0px;\">".get_lang("CourseList")."</h4>\n"."<ul>\n";
  590. foreach ($course_list AS $course)
  591. {
  592. if( ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
  593. or ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD))
  594. {
  595. $courses_shown++;
  596. $courses_list_string .= "<li>\n";
  597. $courses_list_string .= "<a href=\"".$web_course_path.$course['directory']."/\">".$course['title']."</a>";
  598. $courses_list_string .= "<br/>".$course['visual_code']." - ".$course['tutor_name'];
  599. if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] <> api_get_setting('platformLanguage'))
  600. {
  601. $courses_list_string .= ' - '.$course['course_language'];
  602. }
  603. $courses_list_string .= "</li>\n";
  604. }
  605. }
  606. $courses_list_string .= "</ul>\n";
  607. }
  608. else
  609. {
  610. // echo "<blockquote>",get_lang('_No_course_publicly_available'),"</blockquote>\n";
  611. }
  612. if($courses_shown > 0)
  613. { //only display the list of courses and categories if there was more than
  614. // 0 courses visible to the world (we're in the anonymous list here)
  615. echo $courses_list_string;
  616. }
  617. if ($category != "")
  618. {
  619. echo "<p>", "<a href=\"".api_get_self()."\"><b>&lt;&lt;</b> ", get_lang("BackToHomePage"), "</a>", "</p>\n";
  620. }
  621. }
  622. ?>