banner.inc.php 18 KB

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