banner.inc.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <?php //$id: $
  2. require_once(api_get_path(SYS_CODE_PATH).'/inc/lib/banner.lib.php');
  3. /* For licensing terms, see /dokeos_license.txt */
  4. /**
  5. ==============================================================================
  6. * This script contains the actual html code to display the "header"
  7. * or "banner" on top of every Dokeos page.
  8. *
  9. * @package dokeos.include
  10. ==============================================================================
  11. */
  12. $session_id = api_get_session_id();
  13. $session_name = api_get_session_name($my_session_id);
  14. ?>
  15. <div id="wrapper">
  16. <div id="header">
  17. <div id="header1">
  18. <div id="top_corner"></div>
  19. <div id="institution">
  20. <a href="<?php echo api_get_path(WEB_PATH);?>index.php" target="_top"><?php echo api_get_setting('siteName') ?></a>
  21. <?php
  22. $iurl = api_get_setting('InstitutionUrl');
  23. $iname = api_get_setting('Institution');
  24. if (!empty($iname))
  25. {
  26. echo '-&nbsp;<a href="'.$iurl.'" target="_top">'.$iname.'</a>';
  27. }
  28. ?>
  29. </div>
  30. <?php
  31. /*
  32. -----------------------------------------------------------------------------
  33. Course title section
  34. -----------------------------------------------------------------------------
  35. */
  36. if (!empty($_cid) and $_cid != -1 and isset($_course)) {
  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. /*echo '
  43. <div id="my_courses">
  44. <a href="'.api_get_path(WEB_COURSE_PATH).$_course['path'].'/index.php" target="_top">'.$_course['name'].' ';*/
  45. if (api_get_setting("display_coursecode_in_courselist") == "true") {
  46. echo $_course['official_code'];
  47. }
  48. if(api_get_setting("use_session_mode") == "true" && isset($_SESSION['session_name'])) {
  49. echo ' ('.$_SESSION['session_name'].')';
  50. }
  51. if (api_get_setting("display_coursecode_in_courselist") == "true" AND api_get_setting("display_teacher_in_courselist") == "true") {
  52. echo " - ";
  53. }
  54. if (api_get_setting("display_teacher_in_courselist") == "true") {
  55. echo stripslashes($_course['titular']);
  56. }
  57. echo "</a></div>";
  58. } elseif (isset ($nameTools) && $language_file != 'course_home') {
  59. //Put the name of the user-tools in the header
  60. if (!isset ($_user['user_id'])) {
  61. echo " ";
  62. } elseif(!$noPHP_SELF) {
  63. echo "<div id=\"my_courses\"><a href=\"".api_get_self()."?".api_get_cidreq(), "\" target=\"_top\">", $nameTools, "</a></div>", "\n";
  64. } else {
  65. echo "<div id=\"my_courses\">$nameTools</div>\n";
  66. }
  67. }
  68. //not to let the header disappear if there's nothing on the left
  69. echo ' <div class="clear">&nbsp;</div>';
  70. /*
  71. -----------------------------------------------------------------------------
  72. Plugins for banner section
  73. -----------------------------------------------------------------------------
  74. */
  75. api_plugin('header');
  76. $web_course_path = api_get_path(WEB_COURSE_PATH);
  77. /*
  78. -----------------------------------------------------------------------------
  79. External link section
  80. -----------------------------------------------------------------------------
  81. */
  82. if (isset($_course['extLink']) && $_course['extLink']['name'] != "") {
  83. echo "<span class=\"extLinkSeparator\"> / </span>";
  84. if ($_course['extLink']['url'] != "") {
  85. echo "<a class=\"extLink\" href=\"".$_course['extLink']['url']."\" target=\"_top\">";
  86. echo $_course['extLink']['name'];
  87. echo "</a>";
  88. } else {
  89. echo $_course['extLink']['name'];
  90. }
  91. }
  92. ?>
  93. </div>
  94. <div id="header2">
  95. <div id="Header2Right">
  96. <ul>
  97. <?php
  98. 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)) {
  99. if (api_get_setting("use_session_mode") == "true" && isset($_user['user_id']) && api_is_coach()) {
  100. 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>';
  101. }
  102. $statistics_database = Database :: get_statistic_database();
  103. $number = count(WhoIsOnline(api_get_user_id(), $statistics_database, api_get_setting('time_limit_whosonline')));
  104. if(!empty($_course['id'])) {
  105. $online_in_course = who_is_online_in_this_course(api_get_user_id(), api_get_setting('time_limit_whosonline'), $_course['id']);
  106. $number_online_in_course= count( $online_in_course );
  107. } else {
  108. $number_online_in_course = 0;
  109. }
  110. echo "<li>";
  111. // Display the who's online of the platform
  112. if ((api_get_setting('showonline','world') == "true" AND !$_user['user_id']) OR (api_get_setting('showonline','users') == "true" AND $_user['user_id'])) {
  113. //echo '<a href="'.api_get_path(WEB_PATH).'whoisonline.php" target="_top">'.$number.'</a>';
  114. echo '<a href="'.api_get_path(WEB_PATH).'whoisonline.php" target="_top">'.get_lang('UsersOnline').': '.$number.'</a>';
  115. }
  116. // Display the who's online for the course
  117. if (is_array($_course) AND api_get_setting('showonline','course') == "true" AND isset($_course['sysCode'])) {
  118. echo "(<a href='".api_get_path(WEB_PATH)."whoisonline.php?cidReq=".$_course['sysCode']."' target='_top'>$number_online_in_course ".get_lang('InThisCourse')."</a>)";
  119. }
  120. echo '</li>';
  121. }
  122. if ($_user['user_id'] && isset($_cid)) {
  123. if ((api_is_course_admin() || api_is_platform_admin()) && api_get_setting('student_view_enabled') == 'true') {
  124. echo '<li>| ';
  125. api_display_tool_view_option();
  126. echo '</li>';
  127. }
  128. }
  129. if ( api_is_allowed_to_edit() ) {
  130. if(!empty($help)) {
  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=620,height=600,left=200,top=20'); return false;">
  135. <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>
  136. <?php
  137. }
  138. }
  139. ?>
  140. </ul>
  141. </div>
  142. <div class="clear">&nbsp;</div>
  143. </div>
  144. <div id="header3">
  145. <?php
  146. /*
  147. -----------------------------------------------------------------------------
  148. User section
  149. -----------------------------------------------------------------------------
  150. */
  151. if ($_user['user_id']) {
  152. $login = '';
  153. if(api_is_anonymous()) {
  154. $login = '('.get_lang('Anonymous').')';
  155. } else {
  156. $uinfo = api_get_user_info(api_get_user_id());
  157. $login = '('.$uinfo['username'].')';
  158. }
  159. ?>
  160. <!-- start user section line with name, my course, my profile, scorm info, etc -->
  161. <ul id="logout">
  162. <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>
  163. </ul>
  164. <?php
  165. }
  166. ?>
  167. <ul>
  168. <?php
  169. $navigation = array();
  170. $possible_tabs = get_tabs();
  171. // Campus Homepage
  172. if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
  173. $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  174. } else {
  175. $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  176. }
  177. if ($_user['user_id'] && !api_is_anonymous()) {
  178. // My Courses
  179. if (api_get_setting('show_tabs', 'my_courses') == 'true') {
  180. $navigation['mycourses'] = $possible_tabs['mycourses'];
  181. } else{
  182. $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
  183. }
  184. // My Profile
  185. if (api_get_setting('show_tabs', 'my_profile') == 'true') {
  186. $navigation['myprofile'] = $possible_tabs['myprofile'];
  187. } else {
  188. $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
  189. }
  190. // My Agenda
  191. if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
  192. $navigation['myagenda'] = $possible_tabs['myagenda'];
  193. } else {
  194. $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
  195. }
  196. // Gradebook
  197. if (api_get_setting('gradebook_enable') == 'true') {
  198. if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
  199. $navigation['mygradebook'] = $possible_tabs['mygradebook'];
  200. } else{
  201. $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
  202. }
  203. }
  204. // Reporting
  205. if (api_get_setting('show_tabs', 'reporting') == 'true') {
  206. if(api_is_allowed_to_create_course() || $_user['status'] == DRH) {
  207. $navigation['session_my_space'] = $possible_tabs['session_my_space'];
  208. } else {
  209. $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  210. }
  211. } else {
  212. if(api_is_allowed_to_create_course() || $_user['status'] == DRH) {
  213. $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
  214. } else {
  215. $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  216. }
  217. }
  218. // Social Networking
  219. //if (api_get_setting('show_tabs', 'social') == 'true') {
  220. if (1) {
  221. $navigation['social'] = $possible_tabs['social'];
  222. } else{
  223. $menu_navigation['social'] = $possible_tabs['social'];
  224. }
  225. if(api_is_platform_admin(true)) {
  226. if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
  227. $navigation['platform_admin'] = $possible_tabs['platform_admin'];
  228. } else {
  229. $menu_navigation['platform_admin'] = $possible_tabs['platform_admin'];
  230. }
  231. }
  232. }
  233. // Displaying the tabs
  234. foreach($navigation as $section => $navigation_info) {
  235. if(isset($GLOBALS['this_section'])) {
  236. $current = ($section == $GLOBALS['this_section'] ? ' id="current"' : '');
  237. } else {
  238. $current = '';
  239. }
  240. echo '<li'.$current.'><a href="'.$navigation_info['url'].'" target="_top"><span>'.$navigation_info['title'].'</span></a></li>'."\n";
  241. }
  242. /*********************/
  243. $lang = ''; //el for "Edit Language"
  244. if(!empty($_SESSION['user_language_choice'])) {
  245. $lang=$_SESSION['user_language_choice'];
  246. } elseif(!empty($_SESSION['_user']['language'])) {
  247. $lang=$_SESSION['_user']['language'];
  248. } else {
  249. $lang=get_setting('platformLanguage');
  250. }
  251. if ($_configuration['multiple_access_urls']==true) {
  252. $access_url_id = api_get_current_access_url_id();
  253. if ($access_url_id != -1){
  254. $url_info = api_get_access_url($access_url_id);
  255. $url = substr($url_info['url'],7,strlen($url_info['url'])-8);
  256. $clean_url = replace_dangerous_char($url);
  257. $clean_url = str_replace('/','-',$clean_url);
  258. $clean_url = $clean_url.'/';
  259. $homep = '../../home/'; //homep for Home Path
  260. $homep_new = '../../home/'.$clean_url; //homep for Home Path added the url
  261. $new_url_dir = api_get_path(SYS_PATH).'home/'.$clean_url;
  262. //we create the new dir for the new sites
  263. if (!is_dir($new_url_dir)){
  264. umask(0);
  265. $perm = api_get_setting('permissions_for_new_directories');
  266. $perm = octdec(!empty($perm)?$perm:'0755');
  267. mkdir($new_url_dir, $perm);
  268. }
  269. }
  270. } else {
  271. $homep_new ='';
  272. $vv = explode('/', api_get_self());
  273. if(count($vv) > 2) $homep = '../../home/';
  274. else $homep = 'home/';
  275. }
  276. $ext = '.html';
  277. $menutabs = 'home_tabs';
  278. if(is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
  279. $home_top=file_get_contents($homep.$menutabs.'_'.$lang.$ext);
  280. } elseif(is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
  281. $home_top=file_get_contents($homep.$menutabs.$lang.$ext);
  282. } else {
  283. $errorMsg=get_lang('HomePageFilesNotReadable');
  284. }
  285. if(api_get_self() != '/main/admin/configure_homepage.php') {
  286. if(file_exists($homep.$menutabs.'_'.$lang.$ext)) {
  287. $home_top_temp=file_get_contents($homep.$menutabs.'_'.$lang.$ext);
  288. } else if (file_exists($homep.$menutabs.$ext)) {
  289. $home_top_temp=file_get_contents($homep.$menutabs.$ext);
  290. }
  291. $open=str_replace('{rel_path}',api_get_path(REL_PATH),$home_top_temp);
  292. echo $open;
  293. } else {
  294. $home_menu = '';
  295. if(file_exists($homep.$menutabs.'_'.$lang.$ext)) {
  296. $home_menu = file($homep.$menutabs.'_'.$lang.$ext);
  297. } else {
  298. $home_menu = file ($homep.$menutabs.$ext);
  299. }
  300. foreach($home_menu as $key=>$enreg) {
  301. $enreg=trim($enreg);
  302. if(!empty($enreg)) {
  303. $edit_link='<a href="'.api_get_self().'?action=edit_tabs&amp;link_index='.$key.'" style="padding-right:0px; padding-left:0px;">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  304. $delete_link='<a href="'.api_get_self().'?action=delete_tabs&amp;link_index='.$key.'" style="padding-right:0px;" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
  305. echo str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=','</li>'),array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename(api_get_self()).'?action=open_link&link=',' '.$edit_link.' '.$delete_link.'</li>'),$enreg);
  306. }
  307. }
  308. echo '<li id="insert-link"> <a href="'.api_get_self().'?action=insert_tabs" style="padding-right:0px;">'. Display::return_icon('insert_row.png', get_lang('InsertLink')).'</a> <a href="'.api_get_self().'?action=insert_tabs">'.get_lang('InsertLink').'</a></li>';
  309. }
  310. /*********************/
  311. //Header about the tabs
  312. if ($_self == 'admin_intro_edition_page')
  313. ?>
  314. </ul>
  315. <div style="clear: both;" class="clear"> </div>
  316. </div>
  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. //hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
  324. $my_session_name= ($session_name==null) ? '' : '&nbsp;('.$session_name.')';
  325. if (isset ($_cid) and $_cid!=-1 and isset($_course) and !isset($_GET['hide_course_breadcrumb'])) {
  326. $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id)?'?id_session='.$session_id:'');
  327. switch(api_get_setting('breadcrumbs_course_homepage')) {
  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. case 'session_name_and_course_title':
  335. $navigation_item['title'] = $_course['name'].$my_session_name;
  336. break;
  337. default:
  338. $navigation_item['title'] = $_course['name'];
  339. break;
  340. }
  341. $navigation[] = $navigation_item;
  342. }
  343. // part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself)
  344. if (isset($interbreadcrumb) && is_array($interbreadcrumb)) {
  345. foreach($interbreadcrumb as $breadcrumb_step) {
  346. $sep = (strrchr($breadcrumb_step['url'], '?') ? '&amp;' : '?');
  347. $navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq();
  348. $navigation_item['title'] = $breadcrumb_step['name'];
  349. $navigation[] = $navigation_item;
  350. }
  351. }
  352. // 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
  353. // is the same as the first part of the breadcrumbs (see part 1)
  354. if (isset ($nameTools) AND $language_file<>"course_home") {
  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. if(!empty($navigation_info['title'])) {
  362. $final_navigation[$index] = '<a href="'.$navigation_info['url'].'" class="breadcrumb breadcrumb'.$index.'" target="_top">'.$navigation_info['title'].'</a>';
  363. }
  364. }
  365. if (!empty($final_navigation)) {
  366. echo '<div id="header4">';
  367. echo implode(' &gt; ',$final_navigation);
  368. echo '</div>';
  369. }
  370. if(api_get_setting('show_toolshortcuts')=='true') {
  371. echo '<div id="toolshortcuts">';
  372. require_once('tool_navigation_menu.inc.php');
  373. show_navigation_tool_shortcuts();
  374. echo '</div>';
  375. }
  376. if (isset ($dokeos_database_connection)) {
  377. // connect to the main database.
  378. // if single database, don't pefix table names with the main database name in SQL queries
  379. // (ex. SELECT * FROM `table`)
  380. // if multiple database, prefix table names with the course database name in SQL queries (or no prefix if the table is in
  381. // the main database)
  382. // (ex. SELECT * FROM `table_from_main_db` - SELECT * FROM `courseDB`.`table_from_course_db`)
  383. mysql_select_db($_configuration['main_database'], $dokeos_database_connection);
  384. }
  385. ?>
  386. </div> <!-- end of the whole #header section -->
  387. <div class="clear">&nbsp;</div>
  388. <?php
  389. //to mask the main div, set $header_hide_main_div to true in any script just before calling Display::display_header();
  390. global $header_hide_main_div;
  391. if (!empty($header_hide_main_div) && $header_hide_main_div===true) {
  392. //do nothing
  393. } else {
  394. ?>
  395. <div id="main"> <!-- start of #main wrapper for #content and #menu divs -->
  396. <?php
  397. }
  398. /*
  399. -----------------------------------------------------------------------------
  400. "call for chat" module section
  401. -----------------------------------------------------------------------------
  402. */
  403. $chat = strpos(api_get_self(), 'chat_banner.php');
  404. if (!$chat) {
  405. include_once (api_get_path(LIBRARY_PATH)."online.inc.php");
  406. //echo $accept;
  407. $chatcall = chatcall();
  408. if ($chatcall) {
  409. Display :: display_normal_message($chatcall);
  410. }
  411. }
  412. /*
  413. -----------------------------------------------------------------------------
  414. Navigation menu section
  415. -----------------------------------------------------------------------------
  416. */
  417. if(api_get_setting('show_navigation_menu') != 'false' && api_get_setting('show_navigation_menu') != 'icons') {
  418. Display::show_course_navigation_menu($_GET['isHidden']);
  419. $course_id = api_get_course_id();
  420. if (!empty($course_id) && ($course_id != -1)) {
  421. echo '<div id="menuButton">';
  422. echo $output_string_menu;
  423. echo '</div>';
  424. if(isset($_SESSION['hideMenu'])) {
  425. if($_SESSION['hideMenu'] =="shown") {
  426. if (isset($_cid) ) {
  427. echo '<div id="centerwrap"> <!-- start of #centerwrap -->';
  428. echo '<div id="center"> <!-- start of #center -->';
  429. }
  430. }
  431. } else {
  432. if (isset($_cid) ) {
  433. echo '<div id="centerwrap"> <!-- start of #centerwrap -->';
  434. echo '<div id="center"> <!-- start of #center -->';
  435. }
  436. }
  437. }
  438. }
  439. ?>
  440. <!-- Begin Of script Output -->