banner.inc.php 17 KB

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