banner.inc.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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 $_course['titular'];
  46. }
  47. echo "</a></div>";
  48. }
  49. elseif (isset ($nameTools) && $langFile != 'course_home')
  50. {
  51. //Put the name of the user-tools in the header
  52. if (!isset ($_uid))
  53. echo " ";
  54. elseif(!$noPHP_SELF)
  55. {
  56. echo "<div id=\"my_courses\"><a href=\"".$_SERVER['PHP_SELF']."?".api_get_cidreq(), "\" target=\"_top\">", $nameTools, "</a></div>", "\n";
  57. }
  58. else
  59. {
  60. echo "<div id=\"my_courses\">$nameTools</div>\n";
  61. }
  62. }
  63. //not to let the header disappear if there's nothing on the left
  64. echo '<div class="clear">&nbsp;</div>';
  65. /*
  66. -----------------------------------------------------------------------------
  67. Plugins for banner section
  68. -----------------------------------------------------------------------------
  69. */
  70. api_plugin('banner');
  71. $web_course_path = api_get_path(WEB_COURSE_PATH);
  72. /*
  73. -----------------------------------------------------------------------------
  74. External link section
  75. -----------------------------------------------------------------------------
  76. */
  77. if ($_course['extLink']['name'] != "") /* --- --- */
  78. {
  79. echo " / ";
  80. if ($_course['extLink']['url'] != "")
  81. {
  82. echo "<a href=\"".$_course['extLink']['url']."\" target=\"_top\">";
  83. echo $_course['extLink']['name'];
  84. echo "</a>";
  85. }
  86. else
  87. echo $_course['extLink']['name'];
  88. }
  89. echo "</div> <!-- end of #header1 -->";
  90. echo '<div id="header2">';
  91. echo '<div id="Header2Right">';
  92. echo '<ul>';
  93. if ((api_get_setting('showonline','world') == "true" AND !$_uid) OR (api_get_setting('showonline','users') == "true" AND $_uid) OR (api_get_setting('showonline','course') == "true" AND $_uid AND $_cid))
  94. {
  95. if(api_get_setting("use_session_mode") == "true" && isset($_uid) && api_is_coach())
  96. {
  97. echo "<li><a href='".api_get_path(WEB_PATH)."whoisonlinesession.php?id_coach=".$_uid."&referer=".urlencode($_SERVER['REQUEST_URI'])."' target='_top'>Voir les utilisateurs connectés à mes sessions</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. $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. echo "<li>".get_lang('UsersOnline').": ";
  104. // Display the who's online of the platform
  105. if ((api_get_setting('showonline','world') == "true" AND !$_uid) OR (api_get_setting('showonline','users') == "true" AND $_uid))
  106. {
  107. echo "<a href='".api_get_path(WEB_PATH)."whoisonline.php' target='_top'>".$number."</a>";
  108. }
  109. // Display the who's online for the course
  110. if ($_course AND api_get_setting('showonline','course') == "true")
  111. {
  112. echo "(<a href='".api_get_path(WEB_PATH)."whoisonline.php?cidReq=".$_course['sysCode']."' target='_top'>$number_online_in_course ".get_lang('InThisCourse')."</a>)";
  113. }
  114. echo '</li>';
  115. }
  116. if ($_uid)
  117. {
  118. if (api_is_course_admin() && is_student_view_enabled())
  119. {
  120. echo '<li>|';
  121. api_display_tool_view_option($_GET['isStudentView']);
  122. echo '</li>';
  123. }
  124. }
  125. if ( api_is_allowed_to_edit() )
  126. {
  127. if( $help != null)
  128. {
  129. // Show help
  130. ?>
  131. <li>|
  132. <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;">
  133. <img src="<?php echo api_get_path(WEB_CODE_PATH); ?>img/buoy.gif" style="vertical-align: middle;" alt="<?php echo get_lang("Help") ?>"/>&nbsp;<?php echo get_lang("Help") ?></li></a>
  134. <?php
  135. }
  136. }
  137. ?>
  138. </ul>
  139. </div>
  140. <!-- link to campus home (not logged in)
  141. <a href="<?php echo api_get_path(WEB_PATH); ?>index.php" target="_top"><?php echo api_get_setting('siteName'); ?></a>
  142. -->
  143. <?php
  144. //not to let the empty header disappear and ensure help pic is inside the header
  145. echo "<div class=\"clear\">&nbsp;</div>";
  146. ?>
  147. </div> <!-- End of header 2-->
  148. <div id="header3">
  149. <?php
  150. /*
  151. -----------------------------------------------------------------------------
  152. User section
  153. -----------------------------------------------------------------------------
  154. */
  155. if ($_uid)
  156. {
  157. ?>
  158. <!-- start user section line with name, my course, my profile, scorm info, etc -->
  159. <form method="get" action="<?php echo api_get_path(WEB_PATH); ?>index.php" class="banner_links" target="_top">
  160. <input type="hidden" name="logout" value="true"/>
  161. <input type="hidden" name="uid" value="<?php echo $_uid; ?>"/>
  162. <ul id="logout">
  163. <li>
  164. <input type="submit" name="submit" value="<?php echo get_lang("Logout"); ?>"
  165. onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'"
  166. class="logout" style=" height:20px;" />
  167. </li>
  168. </ul>
  169. </form>
  170. <?php
  171. }
  172. echo "<ul>\n";
  173. $navigation = array();
  174. // Link to campus homepage
  175. $navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
  176. $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
  177. if ($_uid)
  178. {
  179. if(api_get_setting('use_session_mode')=='true')
  180. {
  181. if(api_is_allowed_to_create_course())
  182. {
  183. // Link to my courses for teachers
  184. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
  185. $navigation['mycourses']['title'] = get_lang('MyCourses');
  186. }
  187. else
  188. {
  189. // Link to my courses for students
  190. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  191. $navigation['mycourses']['title'] = get_lang('MyCourses');
  192. }
  193. // Link to active sessions
  194. //$navigation[SECTION_ACTIVESESSIONS]['url'] = api_get_path(WEB_PATH).'user_portal.php';
  195. //$navigation[SECTION_ACTIVESESSIONS]['title'] = get_lang('myActiveSessions');
  196. // Link to inactive sessions
  197. //$navigation[SECTION_INACTIVESESSIONS]['url'] = api_get_path(WEB_PATH).'user_portal.php?inactives';
  198. //$navigation[SECTION_INACTIVESESSIONS]['title'] = get_lang('myInActiveSessions');
  199. }
  200. else
  201. {
  202. // Link to my courses
  203. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  204. $navigation['mycourses']['title'] = get_lang('MyCourses');
  205. }
  206. // Link to my profile
  207. $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  208. $navigation['myprofile']['title'] = get_lang('ModifyProfile');
  209. // Link to my agenda
  210. $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/myagenda.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  211. $navigation['myagenda']['title'] = get_lang('MyAgenda');
  212. if(api_get_setting('use_session_mode')=='true')
  213. {
  214. if(api_is_coach())
  215. {
  216. // Link to my students
  217. $navigation['session_my_students']['url'] = api_get_path(WEB_PATH).'myStudents.php';
  218. $navigation['session_my_students']['title'] = get_lang('MyStudents');
  219. }
  220. if(api_is_allowed_to_create_course())
  221. {
  222. // Link to my space
  223. $navigation['session_my_space']['url'] = api_get_path(WEB_PATH).'main/mySpace/';
  224. $navigation['session_my_space']['title'] = get_lang('MySpace');
  225. }
  226. if(!api_is_allowed_to_create_course())
  227. {
  228. // Link to my progress
  229. $navigation['session_my_progress']['url'] = api_get_path(WEB_PATH).'main/auth/my_progress.php';
  230. $navigation['session_my_progress']['title'] = get_lang('MyProgress');
  231. }
  232. }
  233. if (api_is_platform_admin())
  234. {
  235. // Link to platform admin
  236. $navigation['platform_admin']['url'] = $rootAdminWeb;
  237. $navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
  238. }
  239. }
  240. foreach($navigation as $section => $navigation_info)
  241. {
  242. $current = ($section == $GLOBALS['this_section'] ? ' id="current"' : '');
  243. echo '<li'.$current.'>';
  244. echo '<a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a>';
  245. echo '</li>';
  246. echo "\n";
  247. }
  248. ?>
  249. </ul><!-- small hack to have it look good in opera -->&nbsp;
  250. </div> <!-- end of header3 (user) section -->
  251. <?php
  252. /*
  253. -----------------------------------------------------------------------------
  254. BREADCRUMBS
  255. -----------------------------------------------------------------------------
  256. */
  257. ?>
  258. <div id="header4">
  259. <?php
  260. /*
  261. * if the user is a coach he can see the users who are logged in its session
  262. */
  263. $navigation = array();
  264. // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage
  265. if (isset ($_cid))
  266. {
  267. $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php';
  268. switch(api_get_setting('breadcrumbs_course_homepage'))
  269. {
  270. case 'get_lang':
  271. $navigation_item['title'] = get_lang('CourseHomepageLink');
  272. break;
  273. case 'course_code':
  274. $navigation_item['title'] = $_course['official_code'];
  275. break;
  276. default:
  277. $navigation_item['title'] = $_course['name'];
  278. break;
  279. }
  280. $navigation[] = $navigation_item;
  281. }
  282. // part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself)
  283. if (is_array($interbreadcrumb))
  284. {
  285. foreach($interbreadcrumb as $breadcrumb_step)
  286. {
  287. $sep = (strrchr($breadcrumb_step['url'], '?') ? '&amp;' : '?');
  288. $navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq();
  289. $navigation_item['title'] = $breadcrumb_step['name'];
  290. $navigation[] = $navigation_item;
  291. }
  292. }
  293. // 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
  294. // is the same as the first part of the breadcrumbs (see part 1)
  295. if (isset ($nameTools) AND $langFile<>"course_home")
  296. {
  297. $navigation_item['url'] = '#';
  298. $navigation_item['title'] = $nameTools;
  299. $navigation[] = $navigation_item;
  300. }
  301. foreach($navigation as $index => $navigation_info)
  302. {
  303. $navigation[$index] = '<a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a>';
  304. }
  305. echo implode(' &gt; ',$navigation);
  306. ?>
  307. <div class="clear">&nbsp;</div>
  308. </div><!-- end of header4 -->
  309. <?php
  310. if(api_get_setting('show_toolshortcuts')=='true')
  311. {
  312. echo '<div id="toolshortcuts">';
  313. require_once('tool_navigation_menu.inc.php');
  314. show_navigation_tool_shortcuts();
  315. echo '</div>';
  316. }
  317. if (isset ($dokeos_database_connection))
  318. {
  319. // connect to the main database.
  320. // if single database, don't pefix table names with the main database name in SQL queries
  321. // (ex. SELECT * FROM `table`)
  322. // if multiple database, prefix table names with the course database name in SQL queries (or no prefix if the table is in
  323. // the main database)
  324. // (ex. SELECT * FROM `table_from_main_db` - SELECT * FROM `courseDB`.`table_from_course_db`)
  325. mysql_select_db($mainDbName, $dokeos_database_connection);
  326. }
  327. ?>
  328. </div> <!-- end of the whole #header section -->
  329. <?php
  330. //to mask the main div, set $header_hide_main_div to true in any script just before calling Display::display_header();
  331. global $header_hide_main_div;
  332. if(!empty($header_hide_main_div) && $header_hide_main_div===true){
  333. //do nothing
  334. }else{
  335. ?>
  336. <div id="main"> <!-- start of #main wrapper for #content and #menu divs -->
  337. <?php
  338. }
  339. /*
  340. -----------------------------------------------------------------------------
  341. "call for chat" module section
  342. -----------------------------------------------------------------------------
  343. */
  344. $chat = strpos($_SERVER['PHP_SELF'], 'chat_banner.php');
  345. if (!$chat)
  346. {
  347. include_once (api_get_path(LIBRARY_PATH)."online.inc.php");
  348. echo $accept;
  349. $chatcall = chatcall();
  350. if ($chatcall)
  351. {
  352. Display :: display_normal_message($chatcall);
  353. }
  354. }
  355. /*
  356. -----------------------------------------------------------------------------
  357. Navigation menu section
  358. -----------------------------------------------------------------------------
  359. */
  360. if(api_get_setting('show_navigation_menu') != 'false' && api_get_setting('show_navigation_menu') != 'icons')
  361. {
  362. Display::show_course_navigation_menu($_GET['isHidden']);
  363. if (isset($_cid) )
  364. {
  365. echo '<div id="menuButton">';
  366. echo $output_string_menu;
  367. echo '</div>';
  368. if(isset($_SESSION['hideMenu']))
  369. {
  370. if($_SESSION['hideMenu'] =="shown")
  371. {
  372. if (isset($_cid) )
  373. {
  374. echo '<div id="centerwrap"> <!-- start of #centerwrap -->';
  375. echo '<div id="center"> <!-- start of #center -->';
  376. }
  377. }
  378. }
  379. else
  380. {
  381. if (isset($_cid) )
  382. {
  383. echo '<div id="centerwrap"> <!-- start of #centerwrap -->';
  384. echo '<div id="center"> <!-- start of #center -->';
  385. }
  386. }
  387. }
  388. }
  389. ?>
  390. <!-- Begin Of script Output -->