banner.inc.php 16 KB

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