banner.inc.php 17 KB

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