banner.inc.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <?php //$id: $
  2. /* For licensing terms, see /dokeos_license.txt */
  3. /**
  4. ==============================================================================
  5. * This script contains the actual html code to display the "header"
  6. * or "banner" on top of every Dokeos page.
  7. *
  8. * @package dokeos.include
  9. ==============================================================================
  10. */
  11. ?>
  12. <div id="wrapper">
  13. <div id="header">
  14. <div id="header1">
  15. <div id="top_corner"></div>
  16. <div id="institution">
  17. <a href="<?php echo api_get_path(WEB_PATH);?>index.php" target="_top"><?php echo api_get_setting('siteName') ?></a>
  18. <?php
  19. $iurl = api_get_setting('InstitutionUrl');
  20. $iname = api_get_setting('Institution');
  21. if (!empty($iname))
  22. {
  23. echo '-&nbsp;<a href="'.$iurl.'" target="_top">'.$iname.'</a>';
  24. }
  25. ?>
  26. </div>
  27. <?php
  28. /*
  29. -----------------------------------------------------------------------------
  30. Course title section
  31. -----------------------------------------------------------------------------
  32. */
  33. if (!empty($_cid) and $_cid != -1 and isset($_course)) {
  34. //Put the name of the course in the header
  35. ?>
  36. <div id="my_courses"><a href="<?php echo api_get_path(WEB_COURSE_PATH).$_course['path']; ?>/index.php" target="_top">
  37. <?php
  38. echo $_course['name']." ";
  39. /*echo '
  40. <div id="my_courses">
  41. <a href="'.api_get_path(WEB_COURSE_PATH).$_course['path'].'/index.php" target="_top">'.$_course['name'].' ';*/
  42. if (api_get_setting("display_coursecode_in_courselist") == "true") {
  43. echo $_course['official_code'];
  44. }
  45. if(api_get_setting("use_session_mode") == "true" && isset($_SESSION['session_name'])) {
  46. echo ' ('.$_SESSION['session_name'].')';
  47. }
  48. if (api_get_setting("display_coursecode_in_courselist") == "true" AND api_get_setting("display_teacher_in_courselist") == "true") {
  49. echo " - ";
  50. }
  51. if (api_get_setting("display_teacher_in_courselist") == "true") {
  52. echo stripslashes($_course['titular']);
  53. }
  54. echo "</a></div>";
  55. } elseif (isset ($nameTools) && $language_file != 'course_home') {
  56. //Put the name of the user-tools in the header
  57. if (!isset ($_user['user_id'])) {
  58. echo " ";
  59. } elseif(!$noPHP_SELF) {
  60. echo "<div id=\"my_courses\"><a href=\"".api_get_self()."?".api_get_cidreq(), "\" target=\"_top\">", $nameTools, "</a></div>", "\n";
  61. } else {
  62. echo "<div id=\"my_courses\">$nameTools</div>\n";
  63. }
  64. }
  65. //not to let the header disappear if there's nothing on the left
  66. echo ' <div class="clear">&nbsp;</div>';
  67. /*
  68. -----------------------------------------------------------------------------
  69. Plugins for banner section
  70. -----------------------------------------------------------------------------
  71. */
  72. api_plugin('header');
  73. $web_course_path = api_get_path(WEB_COURSE_PATH);
  74. /*
  75. -----------------------------------------------------------------------------
  76. External link section
  77. -----------------------------------------------------------------------------
  78. */
  79. if (isset($_course['extLink']) && $_course['extLink']['name'] != "") {
  80. echo "<span class=\"extLinkSeparator\"> / </span>";
  81. if ($_course['extLink']['url'] != "") {
  82. echo "<a class=\"extLink\" href=\"".$_course['extLink']['url']."\" target=\"_top\">";
  83. echo $_course['extLink']['name'];
  84. echo "</a>";
  85. } else {
  86. echo $_course['extLink']['name'];
  87. }
  88. }
  89. ?>
  90. </div>
  91. <div id="header2">
  92. <div id="Header2Right">
  93. <ul>
  94. <?php
  95. if ((api_get_setting('showonline','world') == "true" AND !$_user['user_id']) OR (api_get_setting('showonline','users') == "true" AND $_user['user_id']) OR (api_get_setting('showonline','course') == "true" AND $_user['user_id'] AND $_cid)) {
  96. if (api_get_setting("use_session_mode") == "true" && isset($_user['user_id']) && api_is_coach()) {
  97. echo ' <li><a href="'.api_get_path(WEB_PATH).'whoisonlinesession.php?id_coach='.$_user['user_id'].'&amp;referer='.urlencode($_SERVER['REQUEST_URI']).'" target="_top">'.get_lang('UsersConnectedToMySessions').'</a></li>';
  98. }
  99. $statistics_database = Database :: get_statistic_database();
  100. $number = count(WhoIsOnline(api_get_user_id(), $statistics_database, api_get_setting('time_limit_whosonline')));
  101. if(!empty($_course['id'])) {
  102. $online_in_course = who_is_online_in_this_course(api_get_user_id(), api_get_setting('time_limit_whosonline'), $_course['id']);
  103. $number_online_in_course= count( $online_in_course );
  104. } else {
  105. $number_online_in_course = 0;
  106. }
  107. echo "<li>";
  108. // Display the who's online of the platform
  109. if ((api_get_setting('showonline','world') == "true" AND !$_user['user_id']) OR (api_get_setting('showonline','users') == "true" AND $_user['user_id'])) {
  110. //echo '<a href="'.api_get_path(WEB_PATH).'whoisonline.php" target="_top">'.$number.'</a>';
  111. echo '<a href="'.api_get_path(WEB_PATH).'whoisonline.php" target="_top">'.get_lang('UsersOnline').': '.$number.'</a>';
  112. }
  113. // Display the who's online for the course
  114. if (is_array($_course) AND api_get_setting('showonline','course') == "true" AND isset($_course['sysCode'])) {
  115. echo "(<a href='".api_get_path(WEB_PATH)."whoisonline.php?cidReq=".$_course['sysCode']."' target='_top'>$number_online_in_course ".get_lang('InThisCourse')."</a>)";
  116. }
  117. echo '</li>';
  118. }
  119. if ($_user['user_id'] && isset($_cid)) {
  120. if ((api_is_course_admin() || api_is_platform_admin()) && api_get_setting('student_view_enabled') == 'true') {
  121. echo '<li>| ';
  122. api_display_tool_view_option();
  123. echo '</li>';
  124. }
  125. }
  126. if ( api_is_allowed_to_edit() ) {
  127. if(!empty($help)) {
  128. // Show help
  129. ?>
  130. <li>|
  131. <a href="#" onclick="MyWindow=window.open('<?php echo api_get_path(WEB_CODE_PATH)."help/help.php"; ?>?open=<?php echo $help; ?>','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=620,height=600,left=200,top=20'); return false;">
  132. <img src="<?php echo api_get_path(WEB_CODE_PATH); ?>img/khelpcenter.gif" style="vertical-align: middle;" alt="<?php echo get_lang("Help") ?>"/>&nbsp;<?php echo get_lang("Help") ?></li></a>
  133. <?php
  134. }
  135. }
  136. ?>
  137. </ul>
  138. </div>
  139. <div class="clear">&nbsp;</div>
  140. </div>
  141. <div id="header3">
  142. <?php
  143. /*
  144. -----------------------------------------------------------------------------
  145. User section
  146. -----------------------------------------------------------------------------
  147. */
  148. if ($_user['user_id']) {
  149. $login = '';
  150. if(api_is_anonymous()) {
  151. $login = '('.get_lang('Anonymous').')';
  152. } else {
  153. $uinfo = api_get_user_info(api_get_user_id());
  154. $login = '('.$uinfo['username'].')';
  155. }
  156. ?>
  157. <!-- start user section line with name, my course, my profile, scorm info, etc -->
  158. <ul id="logout">
  159. <li><a href="<?php echo api_get_path(WEB_PATH); ?>index.php?logout=logout&uid=<?php echo $_user['user_id']; ?>" target="_top"><span><?php echo get_lang('Logout').' '.$login; ?></span></a></li>
  160. </ul>
  161. <?php
  162. }
  163. ?>
  164. <ul>
  165. <?php
  166. $navigation = array();
  167. $possible_tabs = get_tabs();
  168. // Campus Homepage
  169. if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
  170. $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  171. } else {
  172. $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  173. }
  174. if ($_user['user_id'] && !api_is_anonymous()) {
  175. // My Courses
  176. if (api_get_setting('show_tabs', 'my_courses') == 'true') {
  177. $navigation['mycourses'] = $possible_tabs['mycourses'];
  178. } else{
  179. $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
  180. }
  181. // My Profile
  182. if (api_get_setting('show_tabs', 'my_profile') == 'true') {
  183. $navigation['myprofile'] = $possible_tabs['myprofile'];
  184. } else {
  185. $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
  186. }
  187. // My Agenda
  188. if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
  189. $navigation['myagenda'] = $possible_tabs['myagenda'];
  190. } else {
  191. $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
  192. }
  193. // Gradebook
  194. if (api_get_setting('gradebook_enable') == 'true') {
  195. if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
  196. $navigation['mygradebook'] = $possible_tabs['mygradebook'];
  197. } else{
  198. $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
  199. }
  200. }
  201. // Reporting
  202. if (api_get_setting('show_tabs', 'reporting') == 'true') {
  203. if(api_is_allowed_to_create_course() || $_user['status'] == DRH) {
  204. $navigation['session_my_space'] = $possible_tabs['session_my_space'];
  205. } else {
  206. $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  207. }
  208. } else {
  209. if(api_is_allowed_to_create_course() || $_user['status'] == DRH) {
  210. $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
  211. } else {
  212. $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  213. }
  214. }
  215. if(api_is_platform_admin(true)) {
  216. if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
  217. $navigation['platform_admin'] = $possible_tabs['platform_admin'];
  218. } else {
  219. $menu_navigation['platform_admin'] = $possible_tabs['platform_admin'];
  220. }
  221. }
  222. }
  223. // Displaying the tabs
  224. foreach($navigation as $section => $navigation_info) {
  225. if(isset($GLOBALS['this_section'])) {
  226. $current = ($section == $GLOBALS['this_section'] ? ' id="current"' : '');
  227. } else {
  228. $current = '';
  229. }
  230. echo '<li'.$current.'><a href="'.$navigation_info['url'].'" target="_top"><span>'.$navigation_info['title'].'</span></a></li>'."\n";
  231. }
  232. ?>
  233. </ul>
  234. <div style="clear: both;" class="clear"> </div>
  235. </div>
  236. <?php
  237. /*
  238. * if the user is a coach he can see the users who are logged in its session
  239. */
  240. $navigation = array();
  241. // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage
  242. //hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
  243. $session_id = api_get_session_id();
  244. $session_name = api_get_session_name($my_session_id);
  245. $my_session_name= ($session_name==null) ? '' : '&nbsp;('.$session_name.')';
  246. if (isset ($_cid) and $_cid!=-1 and isset($_course) and !isset($_GET['hide_course_breadcrumb'])) {
  247. $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php';
  248. switch(api_get_setting('breadcrumbs_course_homepage')) {
  249. case 'get_lang':
  250. $navigation_item['title'] = get_lang('CourseHomepageLink');
  251. break;
  252. case 'course_code':
  253. $navigation_item['title'] = $_course['official_code'];
  254. break;
  255. case 'session_name_and_course_title':
  256. $navigation_item['title'] = $_course['name'].$my_session_name;
  257. break;
  258. default:
  259. $navigation_item['title'] = $_course['name'];
  260. break;
  261. }
  262. $navigation[] = $navigation_item;
  263. }
  264. // part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself)
  265. if (isset($interbreadcrumb) && is_array($interbreadcrumb)) {
  266. foreach($interbreadcrumb as $breadcrumb_step) {
  267. $sep = (strrchr($breadcrumb_step['url'], '?') ? '&amp;' : '?');
  268. $navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq();
  269. $navigation_item['title'] = $breadcrumb_step['name'];
  270. $navigation[] = $navigation_item;
  271. }
  272. }
  273. // part 3: The tool itself. If we are on the course homepage we do not want to display the title of the course because this
  274. // is the same as the first part of the breadcrumbs (see part 1)
  275. if (isset ($nameTools) AND $language_file<>"course_home") {
  276. $navigation_item['url'] = '#';
  277. $navigation_item['title'] = $nameTools;
  278. $navigation[] = $navigation_item;
  279. }
  280. $final_navigation = array();
  281. foreach($navigation as $index => $navigation_info) {
  282. if(!empty($navigation_info['title'])) {
  283. $final_navigation[$index] = '<a href="'.$navigation_info['url'].'" class="breadcrumb breadcrumb'.$index.'" target="_top">'.$navigation_info['title'].'</a>';
  284. }
  285. }
  286. if (!empty($final_navigation)) {
  287. echo '<div id="header4">';
  288. echo implode(' &gt; ',$final_navigation);
  289. echo '</div>';
  290. }
  291. if(api_get_setting('show_toolshortcuts')=='true') {
  292. echo '<div id="toolshortcuts">';
  293. require_once('tool_navigation_menu.inc.php');
  294. show_navigation_tool_shortcuts();
  295. echo '</div>';
  296. }
  297. if (isset ($dokeos_database_connection)) {
  298. // connect to the main database.
  299. // if single database, don't pefix table names with the main database name in SQL queries
  300. // (ex. SELECT * FROM `table`)
  301. // if multiple database, prefix table names with the course database name in SQL queries (or no prefix if the table is in
  302. // the main database)
  303. // (ex. SELECT * FROM `table_from_main_db` - SELECT * FROM `courseDB`.`table_from_course_db`)
  304. mysql_select_db($_configuration['main_database'], $dokeos_database_connection);
  305. }
  306. ?>
  307. </div> <!-- end of the whole #header section -->
  308. <div class="clear">&nbsp;</div>
  309. <?php
  310. //to mask the main div, set $header_hide_main_div to true in any script just before calling Display::display_header();
  311. global $header_hide_main_div;
  312. if (!empty($header_hide_main_div) && $header_hide_main_div===true) {
  313. //do nothing
  314. } else {
  315. ?>
  316. <div id="main"> <!-- start of #main wrapper for #content and #menu divs -->
  317. <?php
  318. }
  319. /*
  320. -----------------------------------------------------------------------------
  321. "call for chat" module section
  322. -----------------------------------------------------------------------------
  323. */
  324. $chat = strpos(api_get_self(), 'chat_banner.php');
  325. if (!$chat) {
  326. include_once (api_get_path(LIBRARY_PATH)."online.inc.php");
  327. //echo $accept;
  328. $chatcall = chatcall();
  329. if ($chatcall) {
  330. Display :: display_normal_message($chatcall);
  331. }
  332. }
  333. /*
  334. -----------------------------------------------------------------------------
  335. Navigation menu section
  336. -----------------------------------------------------------------------------
  337. */
  338. if(api_get_setting('show_navigation_menu') != 'false' && api_get_setting('show_navigation_menu') != 'icons') {
  339. Display::show_course_navigation_menu($_GET['isHidden']);
  340. $course_id = api_get_course_id();
  341. if (!empty($course_id) && ($course_id != -1)) {
  342. echo '<div id="menuButton">';
  343. echo $output_string_menu;
  344. echo '</div>';
  345. if(isset($_SESSION['hideMenu'])) {
  346. if($_SESSION['hideMenu'] =="shown") {
  347. if (isset($_cid) ) {
  348. echo '<div id="centerwrap"> <!-- start of #centerwrap -->';
  349. echo '<div id="center"> <!-- start of #center -->';
  350. }
  351. }
  352. } else {
  353. if (isset($_cid) ) {
  354. echo '<div id="centerwrap"> <!-- start of #centerwrap -->';
  355. echo '<div id="center"> <!-- start of #center -->';
  356. }
  357. }
  358. }
  359. }
  360. /**
  361. * Determines the possible tabs (=sections) that are available.
  362. * This function is used when creating the tabs in the third header line and all the sections
  363. * that do not appear there (as determined by the platform admin on the Dokeos configuration settings page)
  364. * will appear in the right hand menu that appears on several other pages
  365. *
  366. * @return array containing all the possible tabs
  367. *
  368. * @version Dokeos 1.8.4
  369. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  370. */
  371. function get_tabs() {
  372. global $_course, $rootAdminWeb, $_user;
  373. // Campus Homepage
  374. $navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
  375. $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
  376. // My Courses
  377. if(api_get_setting('use_session_mode')=='true') {
  378. if(api_is_allowed_to_create_course()) {
  379. // Link to my courses for teachers
  380. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
  381. $navigation['mycourses']['title'] = get_lang('MyCourses');
  382. } else {
  383. // Link to my courses for students
  384. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  385. $navigation['mycourses']['title'] = get_lang('MyCourses');
  386. }
  387. } else {
  388. // Link to my courses
  389. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  390. $navigation['mycourses']['title'] = get_lang('MyCourses');
  391. }
  392. // My Profile
  393. $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  394. $navigation['myprofile']['title'] = get_lang('ModifyProfile');
  395. // Link to my agenda
  396. $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/myagenda.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  397. $navigation['myagenda']['title'] = get_lang('MyAgenda');
  398. // Gradebook
  399. if (api_get_setting('gradebook_enable') == 'true') {
  400. $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  401. $navigation['mygradebook']['title'] = get_lang('MyGradebook');
  402. }
  403. // Reporting
  404. if(api_is_allowed_to_create_course() || $_user['status']==DRH) {
  405. // Link to my space
  406. $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/';
  407. $navigation['session_my_space']['title'] = get_lang('MySpace');
  408. } else {
  409. // Link to my progress
  410. $navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
  411. $navigation['session_my_progress']['title'] = get_lang('MyProgress');
  412. }
  413. // Platform administration
  414. if (api_is_platform_admin(true)) {
  415. //$navigation['platform_admin']['url'] = $rootAdminWeb;
  416. $navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
  417. $navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
  418. }
  419. return $navigation;
  420. }
  421. ?>
  422. <!-- Begin Of script Output -->