banner.lib.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Code
  5. * @package chamilo.include
  6. */
  7. /**
  8. * Determines the possible tabs (=sections) that are available.
  9. * This function is used when creating the tabs in the third header line and
  10. * all the sections that do not appear there (as determined by the
  11. * platform admin on the Dokeos configuration settings page)
  12. * will appear in the right hand menu that appears on several other pages
  13. * @return array containing all the possible tabs
  14. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  15. */
  16. function get_tabs() {
  17. global $_course;
  18. // Campus Homepage
  19. $navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
  20. $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
  21. // My Courses
  22. if(api_get_setting('use_session_mode')=='true') {
  23. if(api_is_allowed_to_create_course()) {
  24. // Link to my courses for teachers
  25. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
  26. $navigation['mycourses']['title'] = get_lang('MyCourses');
  27. } else {
  28. // Link to my courses for students
  29. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  30. $navigation['mycourses']['title'] = get_lang('MyCourses');
  31. }
  32. } else {
  33. // Link to my courses
  34. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  35. $navigation['mycourses']['title'] = get_lang('MyCourses');
  36. }
  37. // My Profile
  38. $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  39. $navigation['myprofile']['title'] = get_lang('ModifyProfile');
  40. // Link to my agenda
  41. $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=personal';
  42. $navigation['myagenda']['title'] = get_lang('MyAgenda');
  43. // Gradebook
  44. if (api_get_setting('gradebook_enable') == 'true') {
  45. $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  46. $navigation['mygradebook']['title'] = get_lang('MyGradebook');
  47. }
  48. // Reporting
  49. if(api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
  50. // Link to my space
  51. $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/';
  52. $navigation['session_my_space']['title'] = get_lang('MySpace');
  53. } else {
  54. // Link to my progress
  55. $navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
  56. $navigation['session_my_progress']['title'] = get_lang('MyProgress');
  57. }
  58. // Social
  59. if (api_get_setting('allow_social_tool')=='true') {
  60. $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php';
  61. // get count unread message and total invitations
  62. $count_unread_message = MessageManager::get_number_of_messages(true);
  63. $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
  64. $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION,false);
  65. $group_pending_invitations = 0;
  66. if (!empty($group_pending_invitations )) {
  67. $group_pending_invitations = count($group_pending_invitations);
  68. }
  69. $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message);
  70. $total_invitations = (!empty($total_invitations)?' ('.$total_invitations.')':'');
  71. $navigation['social']['title'] = get_lang('SocialNetwork'). $total_invitations;
  72. }
  73. // Dashboard
  74. if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
  75. $navigation['dashboard']['url'] = api_get_path(WEB_CODE_PATH).'dashboard/index.php';
  76. $navigation['dashboard']['title'] = get_lang('Dashboard');
  77. }
  78. // Reports
  79. if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
  80. $navigation['reports']['url'] = api_get_path(WEB_CODE_PATH).'reports/index.php';
  81. $navigation['reports']['title'] = get_lang('Reports');
  82. }
  83. // Custom tabs
  84. for ($i = 1; $i<=3; $i++)
  85. if (api_get_setting('custom_tab_'.$i.'_name') && api_get_setting('custom_tab_'.$i.'_url')) {
  86. $navigation['custom_tab_'.$i]['url'] = api_get_setting('custom_tab_'.$i.'_url');
  87. $navigation['custom_tab_'.$i]['title'] = api_get_setting('custom_tab_'.$i.'_name');
  88. }
  89. // Platform administration
  90. if (api_is_platform_admin(true)) {
  91. $navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
  92. $navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
  93. }
  94. return $navigation;
  95. }
  96. function show_header_1($language_file, $nameTools) {
  97. global $noPHP_SELF;
  98. $_course = api_get_course_info();
  99. echo '<div id="header1">';
  100. $logo = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
  101. $site_name = api_get_setting('siteName');
  102. if (file_exists($logo)) {
  103. $site_name = api_get_setting('Institution').' - '.$site_name;
  104. echo '<div id="logo">';
  105. $image_url = api_get_path(WEB_CSS_PATH).api_get_visual_theme().'/images/header-logo.png';
  106. $logo = Display::img($image_url, $site_name, array('title'=>$site_name));
  107. echo Display::url($logo, api_get_path(WEB_PATH).'index.php');
  108. echo '</div>';
  109. } else {
  110. echo '<a href="'.api_get_path(WEB_PATH).'index.php" target="_top">'.$site_name.'</a>';
  111. $iurl = api_get_setting('InstitutionUrl');
  112. $iname = api_get_setting('Institution');
  113. if (!empty($iname)) {
  114. echo '-&nbsp;<a href="'.$iurl.'" target="_top">'.$iname.'</a>';
  115. }
  116. // External link section a.k.a Department - Department URL
  117. if (isset($_course['extLink']) && $_course['extLink']['name'] != '') {
  118. echo '<span class="extLinkSeparator"> - </span>';
  119. if ($_course['extLink']['url'] != '') {
  120. echo '<a class="extLink" href="'.$_course['extLink']['url'].'" target="_top">';
  121. echo $_course['extLink']['name'];
  122. echo '</a>';
  123. } else {
  124. echo $_course['extLink']['name'];
  125. }
  126. }
  127. }
  128. /* Course title section */
  129. if (!empty($_cid) and $_cid != -1 and isset($_course)) {
  130. //Put the name of the course in the header
  131. echo '<div id="my_courses">';
  132. /* <div id="my_courses"><a href="<?php echo api_get_path(WEB_COURSE_PATH).$_course['path']; ?>/index.php" target="_top">&nbsp;
  133. echo $_course['name'].' ';
  134. if (api_get_setting('display_coursecode_in_courselist') == 'true') {
  135. echo $_course['official_code'];
  136. }
  137. if (api_get_setting('use_session_mode') == 'true' && isset($_SESSION['session_name'])) {
  138. echo '&nbsp;('.$_SESSION['session_name'].')&nbsp;';
  139. }
  140. if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
  141. echo ' - ';
  142. }
  143. if (api_get_setting('display_teacher_in_courselist') == 'true') {
  144. //This is still necessary? There is the course teacher in the footer
  145. echo stripslashes($_course['titular']);
  146. }
  147. echo '</a>';*/
  148. echo '</div>';
  149. } elseif (isset($nameTools) && $language_file != 'course_home') {
  150. //Put the name of the user-tools in the header
  151. if (!isset($_user['user_id'])) {
  152. //echo '<div id="my_courses"></div>';
  153. } elseif (!$noPHP_SELF) {
  154. echo '<div id="my_courses"><a href="'.api_get_self().'?'.api_get_cidreq(), '" target="_top">'.$nameTools.'</a></div>';
  155. } else {
  156. echo '<div id="my_courses">'.$nameTools.'</div>';
  157. }
  158. } else {
  159. //echo '<div id="my_courses"></div>';
  160. }
  161. echo '<div id="plugin-header">';
  162. api_plugin('header');
  163. echo '</div>';
  164. //Don't let the header disappear if there's nothing on the left
  165. //echo '<div class="clear">&nbsp;</div>';
  166. echo '</div>';
  167. }
  168. function show_header_2() {
  169. $_course = api_get_course_info();
  170. $course_id = api_get_course_id();
  171. $user_id = api_get_user_id();
  172. echo '<div id="header2">';
  173. echo '<div id="Header2Right">';
  174. echo '<ul>';
  175. if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR (api_get_setting('showonline', 'users') == 'true' AND $user_id) OR (api_get_setting('showonline', 'course') == 'true' AND $user_id AND $course_id)) {
  176. $number = who_is_online_count(api_get_setting('time_limit_whosonline'));
  177. $number_online_in_course = 0;
  178. if(!empty($_course['id'])) {
  179. $number_online_in_course = who_is_online_in_this_course_count($user_id, api_get_setting('time_limit_whosonline'), $_course['id']);
  180. }
  181. echo '<li>';
  182. // Display the who's online of the platform
  183. if ($number) {
  184. if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR (api_get_setting('showonline', 'users') == 'true' AND $user_id)) {
  185. echo '<li><a href="'.api_get_path(WEB_PATH).'whoisonline.php" target="_top" title="'.get_lang('UsersOnline').'" ><img width="13px" src="'.api_get_path(WEB_IMG_PATH).'members.gif" title="'.get_lang('UsersOnline').'"> '.$number.'</a></li>';
  186. }
  187. }
  188. // Display the who's online for the course
  189. if ($number_online_in_course) {
  190. if (is_array($_course) AND api_get_setting('showonline', 'course') == 'true' AND isset($_course['sysCode'])) {
  191. echo '<li>| <a href="'.api_get_path(WEB_PATH).'whoisonline.php?cidReq='.$_course['sysCode'].'" target="_top">'.Display::return_icon('course.gif', get_lang('UsersOnline').' '.get_lang('InThisCourse'), array('width'=>'13px')).' '.$number_online_in_course.' </a></li>';
  192. }
  193. }
  194. // Display the who's online for the session
  195. if (api_get_setting('use_session_mode') == 'true' && isset($user_id) && api_get_session_id() != 0) {
  196. //echo '<li><a href="'.api_get_path(WEB_PATH).'whoisonlinesession.php?id_coach='.$user_id.'&amp;referer='.urlencode($_SERVER['REQUEST_URI']).'" target="_top">'.get_lang('UsersConnectedToMySessions').'</a></li>';
  197. echo '<li>| <a href="'.api_get_path(WEB_PATH).'whoisonlinesession.php?id_coach='.$user_id.'&amp;referer='.urlencode($_SERVER['REQUEST_URI']).'" target="_top">'.Display::return_icon('session.png', get_lang('UsersConnectedToMySessions'), array('width'=>'13px')).' </a></li>';
  198. }
  199. echo '</li>';
  200. }
  201. if ($user_id && isset($course_id)) {
  202. if ((api_is_course_admin() || api_is_platform_admin()) && api_get_setting('student_view_enabled') == 'true') {
  203. echo '<li>&nbsp;|&nbsp;';
  204. api_display_tool_view_option();
  205. echo '</li>';
  206. }
  207. }
  208. if (api_get_setting('accessibility_font_resize') == 'true') {
  209. echo '<li class="resize_font">';
  210. echo '<span class="decrease_font" title="'.get_lang('DecreaseFontSize').'">A</span> <span class="reset_font" title="'.get_lang('ResetFontSize').'">A</span> <span class="increase_font" title="'.get_lang('IncreaseFontSize').'">A</span>';
  211. echo '</li>';
  212. }
  213. echo '</ul>';
  214. echo '</div>';
  215. echo '</div>';
  216. }
  217. function show_header_3() {
  218. $navigation = $menu_navigation = array();
  219. $possible_tabs = get_tabs();
  220. // Campus Homepage
  221. if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
  222. $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  223. } else {
  224. $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  225. }
  226. if (api_get_user_id() && !api_is_anonymous()) {
  227. // My Courses
  228. if (api_get_setting('show_tabs', 'my_courses') == 'true') {
  229. $navigation['mycourses'] = $possible_tabs['mycourses'];
  230. } else {
  231. $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
  232. }
  233. // My Profile
  234. if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('allow_social_tool') != 'true') {
  235. $navigation['myprofile'] = $possible_tabs['myprofile'];
  236. } else {
  237. $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
  238. }
  239. // My Agenda
  240. if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
  241. $navigation['myagenda'] = $possible_tabs['myagenda'];
  242. } else {
  243. $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
  244. }
  245. // Gradebook
  246. if (api_get_setting('gradebook_enable') == 'true') {
  247. if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
  248. $navigation['mygradebook'] = $possible_tabs['mygradebook'];
  249. } else{
  250. $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
  251. }
  252. }
  253. // Reporting
  254. if (api_get_setting('show_tabs', 'reporting') == 'true') {
  255. if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
  256. $navigation['session_my_space'] = $possible_tabs['session_my_space'];
  257. } else {
  258. $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  259. }
  260. } else {
  261. if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
  262. $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
  263. } else {
  264. $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  265. }
  266. }
  267. // Social Networking
  268. if (api_get_setting('show_tabs', 'social') == 'true') {
  269. if (api_get_setting('allow_social_tool') == 'true') {
  270. $navigation['social'] = $possible_tabs['social'];
  271. }
  272. } else{
  273. $menu_navigation['social'] = $possible_tabs['social'];
  274. }
  275. // Dashboard
  276. if (api_get_setting('show_tabs', 'dashboard') == 'true') {
  277. if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
  278. $navigation['dashboard'] = $possible_tabs['dashboard'];
  279. }
  280. } else{
  281. $menu_navigation['dashboard'] = $possible_tabs['dashboard'];
  282. }
  283. // Administration
  284. if (api_is_platform_admin(true)) {
  285. if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
  286. $navigation['platform_admin'] = $possible_tabs['platform_admin'];
  287. } else {
  288. $menu_navigation['platform_admin'] = $possible_tabs['platform_admin'];
  289. }
  290. }
  291. // Reports
  292. if (api_get_setting('show_tabs', 'reports') == 'true') {
  293. if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) {
  294. $navigation['reports'] = $possible_tabs['reports'];
  295. }
  296. } else{
  297. $menu_navigation['reports'] = $possible_tabs['reports'];
  298. }
  299. // Custom tabs
  300. for ($i=1;$i<=3;$i++)
  301. if (api_get_setting('show_tabs', 'custom_tab_'.$i) == 'true') {
  302. $navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i];
  303. } else {
  304. if (isset($possible_tabs['custom_tab_'.$i])) {
  305. $menu_navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i];
  306. }
  307. }
  308. }
  309. // Displaying the tabs
  310. $lang = ''; //el for "Edit Language"
  311. if (!empty($_SESSION['user_language_choice'])) {
  312. $lang = $_SESSION['user_language_choice'];
  313. } elseif (!empty($_SESSION['_user']['language'])) {
  314. $lang = $_SESSION['_user']['language'];
  315. } else {
  316. $lang = get_setting('platformLanguage');
  317. }
  318. //Preparing home folder for multiple urls
  319. if (api_get_multiple_access_url()) {
  320. $access_url_id = api_get_current_access_url_id();
  321. if ($access_url_id != -1) {
  322. $url_info = api_get_access_url($access_url_id);
  323. $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
  324. $clean_url = replace_dangerous_char($url);
  325. $clean_url = str_replace('/', '-', $clean_url);
  326. $clean_url .= '/';
  327. $homep = api_get_path(SYS_PATH).'home/'.$clean_url; //homep for Home Path
  328. //we create the new dir for the new sites
  329. if (!is_dir($homep)) {
  330. mkdir($homep, api_get_permissions_for_new_directories());
  331. }
  332. }
  333. } else {
  334. $homep = api_get_path(SYS_PATH).'home/';
  335. }
  336. $ext = '.html';
  337. $menutabs = 'home_tabs';
  338. $home_top = '';
  339. if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
  340. $home_top = @(string)file_get_contents($homep.$menutabs.'_'.$lang.$ext);
  341. } elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
  342. $home_top = @(string)file_get_contents($homep.$menutabs.$lang.$ext);
  343. } else {
  344. $errorMsg = get_lang('HomePageFilesNotReadable');
  345. }
  346. $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
  347. //if (api_get_self() != '/main/admin/configure_homepage.php') {
  348. $open = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top);
  349. $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
  350. $lis = '';
  351. if (!empty($open)) {
  352. $lis .= Display::tag('li', $open);
  353. $show_bar = true;
  354. }
  355. //} else {
  356. //This code was moved in the admin/configure_homepage.php file
  357. /*
  358. $home_menu = '';
  359. if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
  360. $home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
  361. } else {
  362. $home_menu = @file($homep.$menutabs.$ext);
  363. }
  364. if (empty($home_menu)) {
  365. $home_menu = array();
  366. }
  367. if (!empty($home_menu)) {
  368. $home_menu = implode("\n", $home_menu);
  369. $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
  370. $home_menu = explode("\n", $home_menu);
  371. }
  372. $tab_counter = 0;
  373. if (!empty($home_menu)) {
  374. $show_bar = true;
  375. }
  376. foreach ($home_menu as $enreg) {
  377. $enreg = trim($enreg);
  378. if (!empty($enreg)) {
  379. $edit_link = '<a href="'.api_get_self().'?action=edit_tabs&amp;link_index='.$tab_counter.'" ><span>'.Display::return_icon('edit.gif', get_lang('Edit')).'</span></a>';
  380. $delete_link = '<a href="'.api_get_self().'?action=delete_tabs&amp;link_index='.$tab_counter.'" 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>';
  381. $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);
  382. $lis .= $tab_string;
  383. $tab_counter++;
  384. }
  385. }
  386. $lis .= '<li id="insert-link"><a href="'.api_get_self().'?action=insert_tabs" style="padding-right:0px;"><span>'. Display::return_icon('addd.gif', get_lang('InsertLink'), array('style' => 'vertical-align:middle')).' '.get_lang('InsertLink').'</span></a></li>';
  387. */
  388. //}
  389. if (count($navigation) > 1 || !empty($lis)) {
  390. $pre_lis = '';
  391. foreach ($navigation as $section => $navigation_info) {
  392. if (isset($GLOBALS['this_section'])) {
  393. $current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
  394. } else {
  395. $current = '';
  396. }
  397. $pre_lis .= '<li'.$current.'><a href="'.$navigation_info['url'].'" target="_top"><span id="tab_active">'.$navigation_info['title'].'</span></a></li>';
  398. }
  399. $lis = $pre_lis.$lis;
  400. $show_bar = true;
  401. }
  402. // Logout
  403. if ($show_bar) {
  404. echo '<div id="header3">';
  405. if (api_get_user_id()) {
  406. $login = '';
  407. if (api_is_anonymous()) {
  408. $login = get_lang('Anonymous');
  409. } else {
  410. $uinfo = api_get_user_info(api_get_user_id());
  411. $login = $uinfo['username'];
  412. }
  413. //start user section line with name, my course, my profile, scorm info, etc
  414. echo '<ul id="logout">';
  415. //echo '<li><span>'.get_lang('LoggedInAsX').' '.$login.'</span></li>';
  416. //echo '<li><a href="'.api_get_path(WEB_PATH).'main/auth/profile.php" target="_top"><span>'.get_lang('Profile').'</span></a></li>';
  417. echo '<li><a href="'.api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id().'" target="_top"><span>'.get_lang('Logout').' ('.$login.')</span></a></li>';
  418. echo '</ul>';
  419. }
  420. echo '<ul>';
  421. echo $lis;
  422. echo '</ul>';
  423. echo '</div>';
  424. }
  425. return $menu_navigation;
  426. }
  427. //Header 4
  428. function show_header_4($interbreadcrumb, $language_file, $nameTools) {
  429. $session_id = api_get_session_id();
  430. $session_name = api_get_session_name($session_id);
  431. $_course = api_get_course_info();
  432. /* Plugins for banner section */
  433. $web_course_path = api_get_path(WEB_COURSE_PATH);
  434. /*
  435. * if the user is a coach he can see the users who are logged in its session
  436. */
  437. $navigation = array();
  438. // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage
  439. // hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
  440. $my_session_name = is_null($session_name) ? '' : '&nbsp;('.$session_name.')';
  441. if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) {
  442. $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : '');
  443. switch (api_get_setting('breadcrumbs_course_homepage')) {
  444. case 'get_lang':
  445. $navigation_item['title'] = get_lang('CourseHomepageLink');
  446. break;
  447. case 'course_code':
  448. $navigation_item['title'] = $_course['official_code'];
  449. break;
  450. case 'session_name_and_course_title':
  451. $navigation_item['title'] = $_course['name'].$my_session_name;
  452. break;
  453. default:
  454. if (api_get_setting('use_session_mode') == 'true' && api_get_session_id() != -1 ) {
  455. $navigation_item['title'] = $_course['name'].$my_session_name;
  456. } else {
  457. $navigation_item['title'] = $_course['name'];
  458. }
  459. break;
  460. }
  461. /*
  462. * @todo could be useful adding the My courses in the breadcrumb
  463. $navigation_item_my_courses['title'] = get_lang('MyCourses');
  464. $navigation_item_my_courses['url'] = api_get_path(WEB_PATH).'user_portal.php';
  465. $navigation[] = $navigation_item_my_courses;
  466. */
  467. $navigation[] = $navigation_item;
  468. }
  469. // part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself)
  470. if (isset($interbreadcrumb) && is_array($interbreadcrumb)) {
  471. foreach ($interbreadcrumb as $breadcrumb_step) {
  472. if ($breadcrumb_step['url'] != '#') {
  473. $sep = (strrchr($breadcrumb_step['url'], '?') ? '&amp;' : '?');
  474. $navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq();
  475. } else {
  476. $navigation_item['url'] = '#';
  477. }
  478. $navigation_item['title'] = $breadcrumb_step['name'];
  479. // titles for shared folders
  480. if ($breadcrumb_step['name'] == 'shared_folder') {
  481. $navigation_item['title'] = get_lang('UserFolders');
  482. } elseif(strstr($breadcrumb_step['name'], 'shared_folder_session_')) {
  483. $navigation_item['title'] = get_lang('UserFolders');
  484. } elseif(strstr($breadcrumb_step['name'], 'sf_user_')) {
  485. $userinfo = Database::get_user_info_from_id(substr($breadcrumb_step['name'], 8));
  486. $navigation_item['title'] = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
  487. } elseif($breadcrumb_step['name'] == 'chat_files') {
  488. $navigation_item['title'] = get_lang('ChatFiles');
  489. } elseif($breadcrumb_step['name'] == 'images') {
  490. $navigation_item['title'] = get_lang('Images');
  491. } elseif($breadcrumb_step['name'] == 'video') {
  492. $navigation_item['title'] = get_lang('Video');
  493. } elseif($breadcrumb_step['name'] == 'audio') {
  494. $navigation_item['title'] = get_lang('Audio');
  495. } elseif($breadcrumb_step['name'] == 'flash') {
  496. $navigation_item['title'] = get_lang('Flash');
  497. } elseif($breadcrumb_step['name'] == 'gallery') {
  498. $navigation_item['title'] = get_lang('Gallery');
  499. }
  500. //Fixes breadcrumb title now we applied the Security::remove_XSS and we cut the string depending of the MAX_LENGTH_BREADCRUMB value
  501. if (api_strlen($navigation_item['title']) > MAX_LENGTH_BREADCRUMB) {
  502. $navigation_item['title'] = api_substr($navigation_item['title'], 0, MAX_LENGTH_BREADCRUMB).' ...';
  503. }
  504. $navigation_item['title'] = Security::remove_XSS($navigation_item['title']);
  505. $navigation[] = $navigation_item;
  506. }
  507. }
  508. // 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
  509. // is the same as the first part of the breadcrumbs (see part 1)
  510. if (isset($nameTools) && $language_file != 'course_home') { // TODO: This condition $language_file != 'course_home' might bring surprises.
  511. $navigation_item['url'] = '#';
  512. $navigation_item['title'] = $nameTools;
  513. $navigation[] = $navigation_item;
  514. }
  515. $final_navigation = array();
  516. $counter = 0;
  517. foreach ($navigation as $index => $navigation_info) {
  518. if (!empty($navigation_info['title'])) {
  519. if ($navigation_info['url'] == '#') {
  520. $final_navigation[$index] = '<span>'.$navigation_info['title'].'</span>';
  521. } else {
  522. $final_navigation[$index] = '<a href="'.$navigation_info['url'].'" class="" target="_top"><span>'.$navigation_info['title'].'</span></a>';
  523. }
  524. $counter++;
  525. }
  526. }
  527. $html = '';
  528. if (!empty($final_navigation)) {
  529. $html .= '<div id="header4">';
  530. $lis = '';
  531. $i = 0;
  532. $lis.= Display::tag('li', Display::url(Display::img(api_get_path(WEB_CSS_PATH).'home.png', get_lang('Homepage'), array('align'=>'middle')), api_get_path(WEB_PATH), array('class'=>'home')));
  533. foreach ($final_navigation as $bread) {
  534. $lis.= Display::tag('li', $bread);
  535. $i++;
  536. }
  537. $html .= Display::tag('ul',$lis, array('class'=>'bread'));
  538. $html .= '</div>';
  539. } else {
  540. //$html .= '<div id="header4"></div>';
  541. }
  542. return $html ;
  543. }