banner.inc.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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) && $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=\"".$_SERVER['PHP_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'>Voir les utilisateurs connectés à mes sessions</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'])
  119. {
  120. if (api_is_course_admin() && is_student_view_enabled())
  121. {
  122. echo '<li>|';
  123. api_display_tool_view_option($_GET['isStudentView']);
  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/buoy.gif" 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. ?>
  160. <!-- start user section line with name, my course, my profile, scorm info, etc -->
  161. <form method="get" action="<?php echo api_get_path(WEB_PATH); ?>index.php" class="banner_links" target="_top">
  162. <input type="hidden" name="logout" value="true"/>
  163. <input type="hidden" name="uid" value="<?php echo $_user['user_id']; ?>"/>
  164. <ul id="logout">
  165. <li>
  166. <input type="submit" name="submit" value="<?php echo get_lang("Logout"); ?>"
  167. onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'"
  168. class="logout" style=" height:20px;" />
  169. </li>
  170. </ul>
  171. </form>
  172. <?php
  173. }
  174. echo "<ul>\n";
  175. $navigation = array();
  176. // Link to campus homepage
  177. $navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
  178. $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
  179. if ($_user['user_id'])
  180. {
  181. if(api_get_setting('use_session_mode')=='true')
  182. {
  183. if(api_is_allowed_to_create_course())
  184. {
  185. // Link to my courses for teachers
  186. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
  187. $navigation['mycourses']['title'] = get_lang('MyCourses');
  188. }
  189. else
  190. {
  191. // Link to my courses for students
  192. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  193. $navigation['mycourses']['title'] = get_lang('MyCourses');
  194. }
  195. // Link to active sessions
  196. //$navigation[SECTION_ACTIVESESSIONS]['url'] = api_get_path(WEB_PATH).'user_portal.php';
  197. //$navigation[SECTION_ACTIVESESSIONS]['title'] = get_lang('myActiveSessions');
  198. // Link to inactive sessions
  199. //$navigation[SECTION_INACTIVESESSIONS]['url'] = api_get_path(WEB_PATH).'user_portal.php?inactives';
  200. //$navigation[SECTION_INACTIVESESSIONS]['title'] = get_lang('myInActiveSessions');
  201. }
  202. else
  203. {
  204. // Link to my courses
  205. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  206. $navigation['mycourses']['title'] = get_lang('MyCourses');
  207. }
  208. //NOW IN THE RIGHT MENU IN "MY COURSES"
  209. /*
  210. // Link to my profile
  211. $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  212. $navigation['myprofile']['title'] = get_lang('ModifyProfile');
  213. // Link to my agenda
  214. $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/myagenda.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  215. $navigation['myagenda']['title'] = get_lang('MyAgenda');*/
  216. //if(api_get_setting('use_session_mode')=='true'){
  217. if(api_is_allowed_to_create_course())
  218. {
  219. // Link to my space
  220. $navigation['session_my_space']['url'] = api_get_path(WEB_PATH).'main/mySpace/';
  221. $navigation['session_my_space']['title'] = get_lang('MySpace');
  222. }
  223. if(!api_is_allowed_to_create_course())
  224. {
  225. // Link to my progress
  226. $navigation['session_my_progress']['url'] = api_get_path(WEB_PATH).'main/auth/my_progress.php';
  227. $navigation['session_my_progress']['title'] = get_lang('MyProgress');
  228. }
  229. //}
  230. if (api_is_platform_admin())
  231. {
  232. // Link to platform admin
  233. $navigation['platform_admin']['url'] = $rootAdminWeb;
  234. $navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
  235. }
  236. }
  237. foreach($navigation as $section => $navigation_info)
  238. {
  239. $current = ($section == $GLOBALS['this_section'] ? ' id="current"' : '');
  240. echo '<li'.$current.'>';
  241. echo '<a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a>';
  242. echo '</li>';
  243. echo "\n";
  244. }
  245. ?>
  246. </ul><!-- small hack to have it look good in opera -->&nbsp;
  247. </div> <!-- end of header3 (user) section -->
  248. <?php
  249. /*
  250. -----------------------------------------------------------------------------
  251. BREADCRUMBS
  252. -----------------------------------------------------------------------------
  253. */
  254. ?>
  255. <div id="header4">
  256. <?php
  257. /*
  258. * if the user is a coach he can see the users who are logged in its session
  259. */
  260. $navigation = array();
  261. // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage
  262. if (isset ($_cid))
  263. {
  264. $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php';
  265. switch(api_get_setting('breadcrumbs_course_homepage'))
  266. {
  267. case 'get_lang':
  268. $navigation_item['title'] = get_lang('CourseHomepageLink');
  269. break;
  270. case 'course_code':
  271. $navigation_item['title'] = $_course['official_code'];
  272. break;
  273. default:
  274. $navigation_item['title'] = $_course['name'];
  275. break;
  276. }
  277. $navigation[] = $navigation_item;
  278. }
  279. // part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself)
  280. if (is_array($interbreadcrumb))
  281. {
  282. foreach($interbreadcrumb as $breadcrumb_step)
  283. {
  284. $sep = (strrchr($breadcrumb_step['url'], '?') ? '&amp;' : '?');
  285. $navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq();
  286. $navigation_item['title'] = $breadcrumb_step['name'];
  287. $navigation[] = $navigation_item;
  288. }
  289. }
  290. // 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
  291. // is the same as the first part of the breadcrumbs (see part 1)
  292. if (isset ($nameTools) AND $language_file<>"course_home")
  293. {
  294. $navigation_item['url'] = '#';
  295. $navigation_item['title'] = $nameTools;
  296. $navigation[] = $navigation_item;
  297. }
  298. foreach($navigation as $index => $navigation_info)
  299. {
  300. $navigation[$index] = '<a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a>';
  301. }
  302. echo implode(' &gt; ',$navigation);
  303. ?>
  304. </div><!-- end of header4 -->
  305. <?php
  306. if(api_get_setting('show_toolshortcuts')=='true')
  307. {
  308. echo '<div id="toolshortcuts">';
  309. require_once('tool_navigation_menu.inc.php');
  310. show_navigation_tool_shortcuts();
  311. echo '</div>';
  312. }
  313. if (isset ($dokeos_database_connection))
  314. {
  315. // connect to the main database.
  316. // if single database, don't pefix table names with the main database name in SQL queries
  317. // (ex. SELECT * FROM `table`)
  318. // if multiple database, prefix table names with the course database name in SQL queries (or no prefix if the table is in
  319. // the main database)
  320. // (ex. SELECT * FROM `table_from_main_db` - SELECT * FROM `courseDB`.`table_from_course_db`)
  321. mysql_select_db($_configuration['main_database'], $dokeos_database_connection);
  322. }
  323. ?>
  324. </div> <!-- end of the whole #header section -->
  325. <div class="clear">&nbsp;</div>
  326. <?php
  327. //to mask the main div, set $header_hide_main_div to true in any script just before calling Display::display_header();
  328. global $header_hide_main_div;
  329. if(!empty($header_hide_main_div) && $header_hide_main_div===true)
  330. {
  331. //do nothing
  332. }
  333. else
  334. {
  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 -->