banner.inc.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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 "<span class=\"extLinkSeparator\"> / </span>";
  80. if ($_course['extLink']['url'] != "") {
  81. echo "<a class=\"extLink\" 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>";
  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. echo '<a href="'.api_get_path(WEB_PATH).'whoisonline.php" target="_top">'.get_lang('UsersOnline').': '.$number.'</a>';
  111. }
  112. // Display the who's online for the course
  113. if (is_array($_course) AND api_get_setting('showonline','course') == "true" AND isset($_course['sysCode'])) {
  114. echo "(<a href='".api_get_path(WEB_PATH)."whoisonline.php?cidReq=".$_course['sysCode']."' target='_top'>$number_online_in_course ".get_lang('InThisCourse')."</a>)";
  115. }
  116. echo '</li>';
  117. }
  118. if ($_user['user_id'] && isset($_cid)) {
  119. if ((api_is_course_admin() || api_is_platform_admin()) && api_get_setting('student_view_enabled') == 'true') {
  120. echo '<li>| ';
  121. api_display_tool_view_option();
  122. echo '</li>';
  123. }
  124. }
  125. if ( api_is_allowed_to_edit() ) {
  126. if(!empty($help)) {
  127. // Show help
  128. ?>
  129. <li>|
  130. <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;">
  131. <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>
  132. <?php
  133. }
  134. }
  135. ?>
  136. </ul>
  137. </div>
  138. <div class="clear">&nbsp;</div>
  139. </div>
  140. <div id="header3">
  141. <?php
  142. /*
  143. -----------------------------------------------------------------------------
  144. User section
  145. -----------------------------------------------------------------------------
  146. */
  147. if ($_user['user_id']) {
  148. $login = '';
  149. if(api_is_anonymous()) {
  150. $login = '('.get_lang('Anonymous').')';
  151. } else {
  152. $uinfo = api_get_user_info(api_get_user_id());
  153. $login = '('.$uinfo['username'].')';
  154. }
  155. ?>
  156. <!-- start user section line with name, my course, my profile, scorm info, etc -->
  157. <ul id="logout">
  158. <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>
  159. </ul>
  160. <?php
  161. }
  162. ?>
  163. <ul>
  164. <?php
  165. $navigation = array();
  166. $possible_tabs = get_tabs();
  167. // Campus Homepage
  168. if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
  169. $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  170. } else {
  171. $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  172. }
  173. if ($_user['user_id'] && !api_is_anonymous()) {
  174. // My Courses
  175. if (api_get_setting('show_tabs', 'my_courses') == 'true') {
  176. $navigation['mycourses'] = $possible_tabs['mycourses'];
  177. } else{
  178. $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
  179. }
  180. // My Profile
  181. if (api_get_setting('show_tabs', 'my_profile') == 'true') {
  182. $navigation['myprofile'] = $possible_tabs['myprofile'];
  183. } else {
  184. $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
  185. }
  186. // My Agenda
  187. if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
  188. $navigation['myagenda'] = $possible_tabs['myagenda'];
  189. } else {
  190. $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
  191. }
  192. // Gradebook
  193. if (api_get_setting('gradebook_enable') == 'true') {
  194. if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
  195. $navigation['mygradebook'] = $possible_tabs['mygradebook'];
  196. } else{
  197. $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
  198. }
  199. }
  200. // Reporting
  201. if (api_get_setting('show_tabs', 'reporting') == 'true') {
  202. if(api_is_allowed_to_create_course() || $_user['status'] == DRH) {
  203. $navigation['session_my_space'] = $possible_tabs['session_my_space'];
  204. } else {
  205. $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  206. }
  207. } else {
  208. if(api_is_allowed_to_create_course() || $_user['status'] == DRH) {
  209. $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
  210. } else {
  211. $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  212. }
  213. }
  214. if(api_is_platform_admin(true)) {
  215. if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
  216. $navigation['platform_admin'] = $possible_tabs['platform_admin'];
  217. } else {
  218. $menu_navigation['platform_admin'] = $possible_tabs['platform_admin'];
  219. }
  220. }
  221. }
  222. // Displaying the tabs
  223. foreach($navigation as $section => $navigation_info) {
  224. if(isset($GLOBALS['this_section'])) {
  225. $current = ($section == $GLOBALS['this_section'] ? ' id="current"' : '');
  226. } else {
  227. $current = '';
  228. }
  229. echo '<li'.$current.'><a href="'.$navigation_info['url'].'" target="_top"><span>'.$navigation_info['title'].'</span></a></li>'."\n";
  230. }
  231. ?>
  232. </ul>
  233. <div style="clear: both;" class="clear"> </div>
  234. </div>
  235. <div id="header4">
  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. echo implode(' &gt; ',$final_navigation);
  287. ?>
  288. </div>
  289. <?php
  290. if(api_get_setting('show_toolshortcuts')=='true') {
  291. echo '<div id="toolshortcuts">';
  292. require_once('tool_navigation_menu.inc.php');
  293. show_navigation_tool_shortcuts();
  294. echo '</div>';
  295. }
  296. if (isset ($dokeos_database_connection)) {
  297. // connect to the main database.
  298. // if single database, don't pefix table names with the main database name in SQL queries
  299. // (ex. SELECT * FROM `table`)
  300. // if multiple database, prefix table names with the course database name in SQL queries (or no prefix if the table is in
  301. // the main database)
  302. // (ex. SELECT * FROM `table_from_main_db` - SELECT * FROM `courseDB`.`table_from_course_db`)
  303. mysql_select_db($_configuration['main_database'], $dokeos_database_connection);
  304. }
  305. ?>
  306. </div> <!-- end of the whole #header section -->
  307. <div class="clear">&nbsp;</div>
  308. <?php
  309. //to mask the main div, set $header_hide_main_div to true in any script just before calling Display::display_header();
  310. global $header_hide_main_div;
  311. if (!empty($header_hide_main_div) && $header_hide_main_div===true) {
  312. //do nothing
  313. } else {
  314. ?>
  315. <div id="main"> <!-- start of #main wrapper for #content and #menu divs -->
  316. <?php
  317. }
  318. /*
  319. -----------------------------------------------------------------------------
  320. "call for chat" module section
  321. -----------------------------------------------------------------------------
  322. */
  323. $chat = strpos(api_get_self(), 'chat_banner.php');
  324. if (!$chat) {
  325. include_once (api_get_path(LIBRARY_PATH)."online.inc.php");
  326. //echo $accept;
  327. $chatcall = chatcall();
  328. if ($chatcall) {
  329. Display :: display_normal_message($chatcall);
  330. }
  331. }
  332. /*
  333. -----------------------------------------------------------------------------
  334. Navigation menu section
  335. -----------------------------------------------------------------------------
  336. */
  337. if(api_get_setting('show_navigation_menu') != 'false' && api_get_setting('show_navigation_menu') != 'icons') {
  338. Display::show_course_navigation_menu($_GET['isHidden']);
  339. if (isset($_cid) ) {
  340. echo '<div id="menuButton">';
  341. echo $output_string_menu;
  342. echo '</div>';
  343. if(isset($_SESSION['hideMenu'])) {
  344. if($_SESSION['hideMenu'] =="shown") {
  345. if (isset($_cid) ) {
  346. echo '<div id="centerwrap"> <!-- start of #centerwrap -->';
  347. echo '<div id="center"> <!-- start of #center -->';
  348. }
  349. }
  350. } else {
  351. if (isset($_cid) ) {
  352. echo '<div id="centerwrap"> <!-- start of #centerwrap -->';
  353. echo '<div id="center"> <!-- start of #center -->';
  354. }
  355. }
  356. }
  357. }
  358. /**
  359. * Determines the possible tabs (=sections) that are available.
  360. * This function is used when creating the tabs in the third header line and all the sections
  361. * that do not appear there (as determined by the platform admin on the Dokeos configuration settings page)
  362. * will appear in the right hand menu that appears on several other pages
  363. *
  364. * @return array containing all the possible tabs
  365. *
  366. * @version Dokeos 1.8.4
  367. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  368. */
  369. function get_tabs() {
  370. global $_course, $rootAdminWeb, $_user;
  371. // Campus Homepage
  372. $navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
  373. $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
  374. // My Courses
  375. if(api_get_setting('use_session_mode')=='true') {
  376. if(api_is_allowed_to_create_course()) {
  377. // Link to my courses for teachers
  378. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
  379. $navigation['mycourses']['title'] = get_lang('MyCourses');
  380. } else {
  381. // Link to my courses for students
  382. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  383. $navigation['mycourses']['title'] = get_lang('MyCourses');
  384. }
  385. } else {
  386. // Link to my courses
  387. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  388. $navigation['mycourses']['title'] = get_lang('MyCourses');
  389. }
  390. // My Profile
  391. $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  392. $navigation['myprofile']['title'] = get_lang('ModifyProfile');
  393. // Link to my agenda
  394. $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/myagenda.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  395. $navigation['myagenda']['title'] = get_lang('MyAgenda');
  396. // Gradebook
  397. if (api_get_setting('gradebook_enable') == 'true') {
  398. $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  399. $navigation['mygradebook']['title'] = get_lang('MyGradebook');
  400. }
  401. // Reporting
  402. if(api_is_allowed_to_create_course() || $_user['status']==DRH) {
  403. // Link to my space
  404. $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/';
  405. $navigation['session_my_space']['title'] = get_lang('MySpace');
  406. } else {
  407. // Link to my progress
  408. $navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
  409. $navigation['session_my_progress']['title'] = get_lang('MyProgress');
  410. }
  411. // Platform administration
  412. if (api_is_platform_admin(true)) {
  413. //$navigation['platform_admin']['url'] = $rootAdminWeb;
  414. $navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
  415. $navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
  416. }
  417. return $navigation;
  418. }
  419. ?>
  420. <!-- Begin Of script Output -->