banner.inc.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <?php
  2. /**
  3. ==============================================================================
  4. * This script contains the actual html code to display the "header"
  5. * or "banner" on top of every Dokeos page.
  6. *
  7. * @package dokeos.include
  8. ==============================================================================
  9. */
  10. ?>
  11. <div id="header"> <!-- header section start -->
  12. <div id="header1"> <!-- top of banner with institution name/hompage link -->
  13. <div id="institution">
  14. <a href="<?php echo api_get_path(WEB_PATH);?>index.php" target="_top"><?php echo api_get_setting('siteName') ?></a>
  15. -
  16. <a href="<?php echo api_get_setting('InstitutionUrl') ?>" target="_top"><?php echo api_get_setting('Institution') ?></a>
  17. </div>
  18. <?php
  19. /*
  20. -----------------------------------------------------------------------------
  21. Course title section
  22. -----------------------------------------------------------------------------
  23. */
  24. if (isset ($_cid))
  25. {
  26. //Put the name of the course in the header
  27. ?>
  28. <div id="my_courses"><a href="<?php echo api_get_path(WEB_COURSE_PATH).$_course['path']; ?>/index.php" target="_top">
  29. <?php
  30. echo $_course['name']." ";
  31. if (api_get_setting("display_coursecode_in_courselist") == "true")
  32. {
  33. echo $_course['official_code'];
  34. }
  35. if(api_get_setting("use_session_mode") == "true" && isset($_SESSION['session_name']))
  36. {
  37. echo ' ('.$_SESSION['session_name'].')';
  38. }
  39. if (api_get_setting("display_coursecode_in_courselist") == "true" AND api_get_setting("display_teacher_in_courselist") == "true")
  40. {
  41. echo " - ";
  42. }
  43. if (api_get_setting("display_teacher_in_courselist") == "true")
  44. {
  45. echo stripslashes($_course['titular']);
  46. }
  47. echo "</a></div>";
  48. }
  49. elseif (isset ($nameTools) && $language_file != 'course_home')
  50. {
  51. //Put the name of the user-tools in the header
  52. if (!isset ($_user['user_id']))
  53. {
  54. echo " ";
  55. }
  56. elseif(!$noPHP_SELF)
  57. {
  58. echo "<div id=\"my_courses\"><a href=\"".api_get_self()."?".api_get_cidreq(), "\" target=\"_top\">", $nameTools, "</a></div>", "\n";
  59. }
  60. else
  61. {
  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 ($_course['extLink']['name'] != "") /* --- --- */
  80. {
  81. echo " / ";
  82. if ($_course['extLink']['url'] != "")
  83. {
  84. echo "<a href=\"".$_course['extLink']['url']."\" target=\"_top\">";
  85. echo $_course['extLink']['name'];
  86. echo "</a>";
  87. }
  88. else
  89. echo $_course['extLink']['name'];
  90. }
  91. echo "</div> <!-- end of #header1 -->";
  92. echo '<div id="header2">';
  93. echo '<div id="Header2Right">';
  94. echo '<ul>';
  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. {
  97. if(api_get_setting("use_session_mode") == "true" && isset($_user['user_id']) && api_is_coach())
  98. {
  99. echo "<li><a href='".api_get_path(WEB_PATH)."whoisonlinesession.php?id_coach=".$_user['user_id']."&referer=".urlencode($_SERVER['REQUEST_URI'])."' target='_top'>".get_lang('UsersConnectedToMySessions')."</a></li>";
  100. }
  101. $statistics_database = Database :: get_statistic_database();
  102. $number = count(WhoIsOnline(api_get_user_id(), $statistics_database, api_get_setting('time_limit_whosonline')));
  103. $online_in_course = who_is_online_in_this_course(api_get_user_id(), api_get_setting('time_limit_whosonline'), $_course['id']);
  104. $number_online_in_course= count( $online_in_course );
  105. echo "<li>".get_lang('UsersOnline').": ";
  106. // Display the who's online of the platform
  107. if ((api_get_setting('showonline','world') == "true" AND !$_user['user_id']) OR (api_get_setting('showonline','users') == "true" AND $_user['user_id']))
  108. {
  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 ($_course AND api_get_setting('showonline','course') == "true")
  113. {
  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. {
  120. if (api_is_course_admin() && api_get_setting('student_view_enabled') == 'true')
  121. {
  122. echo '<li>| ';
  123. api_display_tool_view_option();
  124. echo '</li>';
  125. }
  126. }
  127. if ( api_is_allowed_to_edit() )
  128. {
  129. if( $help != null)
  130. {
  131. // Show help
  132. ?>
  133. <li>|
  134. <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;">
  135. <img src="<?php echo api_get_path(WEB_CODE_PATH); ?>img/khelpcenter.png" style="vertical-align: middle;" alt="<?php echo get_lang("Help") ?>"/>&nbsp;<?php echo get_lang("Help") ?></li></a>
  136. <?php
  137. }
  138. }
  139. ?>
  140. </ul>
  141. </div>
  142. <!-- link to campus home (not logged in)
  143. <a href="<?php echo api_get_path(WEB_PATH); ?>index.php" target="_top"><?php echo api_get_setting('siteName'); ?></a>
  144. -->
  145. <?php
  146. //not to let the empty header disappear and ensure help pic is inside the header
  147. echo "<div class=\"clear\">&nbsp;</div>";
  148. ?>
  149. </div> <!-- End of header 2-->
  150. <div id="header3">
  151. <?php
  152. /*
  153. -----------------------------------------------------------------------------
  154. User section
  155. -----------------------------------------------------------------------------
  156. */
  157. if ($_user['user_id'])
  158. {
  159. $login = '';
  160. if(api_is_anonymous())
  161. {
  162. $login = '('.get_lang('Anonymous').')';
  163. }
  164. else
  165. {
  166. $uinfo = api_get_user_info(api_get_user_id());
  167. $login = '('.$uinfo['username'].')';
  168. }
  169. ?>
  170. <!-- start user section line with name, my course, my profile, scorm info, etc -->
  171. <form method="get" action="<?php echo api_get_path(WEB_PATH); ?>index.php" class="banner_links" target="_top">
  172. <input type="hidden" name="logout" value="true"/>
  173. <input type="hidden" name="uid" value="<?php echo $_user['user_id']; ?>"/>
  174. <ul id="logout">
  175. <li>
  176. <input type="submit" name="submit" value="<?php echo get_lang("Logout").' '.$login; ?>"
  177. onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'"
  178. class="logout" style=" height:20px;" />
  179. </li>
  180. </ul>
  181. </form>
  182. <?php
  183. }
  184. echo "<ul>\n";
  185. $navigation = array();
  186. $possible_tabs = get_tabs();
  187. // Campus Homepage
  188. if (api_get_setting('show_tabs', 'campus_homepage') == 'true')
  189. {
  190. $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  191. }
  192. else
  193. {
  194. $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  195. }
  196. if ($_user['user_id'] && !api_is_anonymous())
  197. {
  198. // My Courses
  199. if (api_get_setting('show_tabs', 'my_courses') == 'true')
  200. {
  201. $navigation['mycourses'] = $possible_tabs['mycourses'];
  202. }
  203. else
  204. {
  205. $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
  206. }
  207. // My Profile
  208. if (api_get_setting('show_tabs', 'my_profile') == 'true')
  209. {
  210. $navigation['myprofile'] = $possible_tabs['myprofile'];
  211. }
  212. else
  213. {
  214. $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
  215. }
  216. // My Agenda
  217. if (api_get_setting('show_tabs', 'my_agenda') == 'true')
  218. {
  219. $navigation['myagenda'] = $possible_tabs['myagenda'];
  220. }
  221. else
  222. {
  223. $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
  224. }
  225. // Gradebook
  226. if (api_get_setting('gradebook_enable') == 'true')
  227. {
  228. if (api_get_setting('show_tabs', 'my_gradebook') == 'true')
  229. {
  230. $navigation['mygradebook'] = $possible_tabs['mygradebook'];
  231. }
  232. else
  233. {
  234. $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
  235. }
  236. }
  237. // Reporting
  238. if (api_get_setting('show_tabs', 'reporting') == 'true')
  239. {
  240. if(api_is_allowed_to_create_course() || $_user['status'] == DRH)
  241. {
  242. $navigation['session_my_space'] = $possible_tabs['session_my_space'];
  243. }
  244. else
  245. {
  246. $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  247. }
  248. }
  249. else
  250. {
  251. if(api_is_allowed_to_create_course() || $_user['status'] == DRH)
  252. {
  253. $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
  254. }
  255. else
  256. {
  257. $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  258. }
  259. }
  260. if(api_is_platform_admin(true))
  261. {
  262. if (api_get_setting('show_tabs', 'platform_administration') == 'true')
  263. {
  264. $navigation['platform_admin'] = $possible_tabs['platform_admin'];
  265. }
  266. else
  267. {
  268. $menu_navigation['platform_admin'] = $possible_tabs['platform_admin'];
  269. }
  270. }
  271. }
  272. // Displaying the tabs
  273. foreach($navigation as $section => $navigation_info)
  274. {
  275. $current = ($section == $GLOBALS['this_section'] ? ' id="current"' : '');
  276. echo '<li'.$current.'>';
  277. echo '<a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a>';
  278. echo '</li>';
  279. echo "\n";
  280. }
  281. ?>
  282. </ul><!-- small hack to have it look good in opera -->&nbsp;
  283. </div> <!-- end of header3 (user) section -->
  284. <?php
  285. /*
  286. -----------------------------------------------------------------------------
  287. BREADCRUMBS
  288. -----------------------------------------------------------------------------
  289. */
  290. ?>
  291. <div id="header4">
  292. <?php
  293. /*
  294. * if the user is a coach he can see the users who are logged in its session
  295. */
  296. $navigation = array();
  297. // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage
  298. if (isset ($_cid))
  299. {
  300. $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php';
  301. switch(api_get_setting('breadcrumbs_course_homepage'))
  302. {
  303. case 'get_lang':
  304. $navigation_item['title'] = get_lang('CourseHomepageLink');
  305. break;
  306. case 'course_code':
  307. $navigation_item['title'] = $_course['official_code'];
  308. break;
  309. default:
  310. $navigation_item['title'] = $_course['name'];
  311. break;
  312. }
  313. $navigation[] = $navigation_item;
  314. }
  315. // part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself)
  316. if (is_array($interbreadcrumb))
  317. {
  318. foreach($interbreadcrumb as $breadcrumb_step)
  319. {
  320. $sep = (strrchr($breadcrumb_step['url'], '?') ? '&amp;' : '?');
  321. $navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq();
  322. $navigation_item['title'] = $breadcrumb_step['name'];
  323. $navigation[] = $navigation_item;
  324. }
  325. }
  326. // 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
  327. // is the same as the first part of the breadcrumbs (see part 1)
  328. if (isset ($nameTools) AND $language_file<>"course_home")
  329. {
  330. $navigation_item['url'] = '#';
  331. $navigation_item['title'] = $nameTools;
  332. $navigation[] = $navigation_item;
  333. }
  334. $final_navigation = array();
  335. foreach($navigation as $index => $navigation_info)
  336. {
  337. if(!empty($navigation_info['title']))
  338. {
  339. $final_navigation[$index] = '<a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a>';
  340. }
  341. }
  342. echo implode(' &gt; ',$final_navigation);
  343. ?>
  344. </div><!-- end of header4 -->
  345. <?php
  346. if(api_get_setting('show_toolshortcuts')=='true')
  347. {
  348. echo '<div id="toolshortcuts">';
  349. require_once('tool_navigation_menu.inc.php');
  350. show_navigation_tool_shortcuts();
  351. echo '</div>';
  352. }
  353. if (isset ($dokeos_database_connection))
  354. {
  355. // connect to the main database.
  356. // if single database, don't pefix table names with the main database name in SQL queries
  357. // (ex. SELECT * FROM `table`)
  358. // if multiple database, prefix table names with the course database name in SQL queries (or no prefix if the table is in
  359. // the main database)
  360. // (ex. SELECT * FROM `table_from_main_db` - SELECT * FROM `courseDB`.`table_from_course_db`)
  361. mysql_select_db($_configuration['main_database'], $dokeos_database_connection);
  362. }
  363. ?>
  364. </div> <!-- end of the whole #header section -->
  365. <div class="clear">&nbsp;</div>
  366. <?php
  367. //to mask the main div, set $header_hide_main_div to true in any script just before calling Display::display_header();
  368. global $header_hide_main_div;
  369. if(!empty($header_hide_main_div) && $header_hide_main_div===true)
  370. {
  371. //do nothing
  372. }
  373. else
  374. {
  375. ?>
  376. <div id="main"> <!-- start of #main wrapper for #content and #menu divs -->
  377. <?php
  378. }
  379. /*
  380. -----------------------------------------------------------------------------
  381. "call for chat" module section
  382. -----------------------------------------------------------------------------
  383. */
  384. $chat = strpos(api_get_self(), 'chat_banner.php');
  385. if (!$chat)
  386. {
  387. include_once (api_get_path(LIBRARY_PATH)."online.inc.php");
  388. echo $accept;
  389. $chatcall = chatcall();
  390. if ($chatcall)
  391. {
  392. Display :: display_normal_message($chatcall);
  393. }
  394. }
  395. /*
  396. -----------------------------------------------------------------------------
  397. Navigation menu section
  398. -----------------------------------------------------------------------------
  399. */
  400. if(api_get_setting('show_navigation_menu') != 'false' && api_get_setting('show_navigation_menu') != 'icons')
  401. {
  402. Display::show_course_navigation_menu($_GET['isHidden']);
  403. if (isset($_cid) )
  404. {
  405. echo '<div id="menuButton">';
  406. echo $output_string_menu;
  407. echo '</div>';
  408. if(isset($_SESSION['hideMenu']))
  409. {
  410. if($_SESSION['hideMenu'] =="shown")
  411. {
  412. if (isset($_cid) )
  413. {
  414. echo '<div id="centerwrap"> <!-- start of #centerwrap -->';
  415. echo '<div id="center"> <!-- start of #center -->';
  416. }
  417. }
  418. }
  419. else
  420. {
  421. if (isset($_cid) )
  422. {
  423. echo '<div id="centerwrap"> <!-- start of #centerwrap -->';
  424. echo '<div id="center"> <!-- start of #center -->';
  425. }
  426. }
  427. }
  428. }
  429. /**
  430. * Determines the possible tabs (=sections) that are available.
  431. * This function is used when creating the tabs in the third header line and all the sections
  432. * that do not appear there (as determined by the platform admin on the Dokeos configuration settings page)
  433. * will appear in the right hand menu that appears on several other pages
  434. *
  435. * @return array containing all the possible tabs
  436. *
  437. * @version Dokeos 1.8.4
  438. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  439. */
  440. function get_tabs()
  441. {
  442. global $_course, $rootAdminWeb, $_user;
  443. // Campus Homepage
  444. $navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
  445. $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
  446. // My Courses
  447. if(api_get_setting('use_session_mode')=='true')
  448. {
  449. if(api_is_allowed_to_create_course())
  450. {
  451. // Link to my courses for teachers
  452. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
  453. $navigation['mycourses']['title'] = get_lang('MyCourses');
  454. }
  455. else
  456. {
  457. // Link to my courses for students
  458. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  459. $navigation['mycourses']['title'] = get_lang('MyCourses');
  460. }
  461. // Link to active sessions
  462. //$navigation[SECTION_ACTIVESESSIONS]['url'] = api_get_path(WEB_PATH).'user_portal.php';
  463. //$navigation[SECTION_ACTIVESESSIONS]['title'] = get_lang('myActiveSessions');
  464. // Link to inactive sessions
  465. //$navigation[SECTION_INACTIVESESSIONS]['url'] = api_get_path(WEB_PATH).'user_portal.php?inactives';
  466. //$navigation[SECTION_INACTIVESESSIONS]['title'] = get_lang('myInActiveSessions');
  467. }
  468. else
  469. {
  470. // Link to my courses
  471. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  472. $navigation['mycourses']['title'] = get_lang('MyCourses');
  473. }
  474. // My Profile
  475. $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  476. $navigation['myprofile']['title'] = get_lang('ModifyProfile');
  477. // Link to my agenda
  478. $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/myagenda.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  479. $navigation['myagenda']['title'] = get_lang('MyAgenda');
  480. // Gradebook
  481. if (api_get_setting('gradebook_enable') == 'true')
  482. {
  483. $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  484. $navigation['mygradebook']['title'] = get_lang('MyGradebook');
  485. }
  486. // Reporting
  487. if(api_is_allowed_to_create_course() || $_user['status']==DRH)
  488. {
  489. // Link to my space
  490. $navigation['session_my_space']['url'] = api_get_path(WEB_PATH).'main/mySpace/';
  491. $navigation['session_my_space']['title'] = get_lang('MySpace');
  492. }
  493. else
  494. {
  495. // Link to my progress
  496. $navigation['session_my_progress']['url'] = api_get_path(WEB_PATH).'main/auth/my_progress.php';
  497. $navigation['session_my_progress']['title'] = get_lang('MyProgress');
  498. }
  499. // Platform administration
  500. if (api_is_platform_admin(true))
  501. {
  502. $navigation['platform_admin']['url'] = $rootAdminWeb;
  503. $navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
  504. }
  505. return $navigation;
  506. }
  507. ?>
  508. <!-- Begin Of script Output -->