user_portal.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is the index file displayed when a user is logged in on Chamilo.
  5. *
  6. * It displays:
  7. * - personal course list
  8. * - menu bar
  9. * Search for CONFIGURATION parameters to modify settings
  10. * @todo rewrite code to separate display, logic, database code
  11. * @package chamilo.main
  12. * @todo Shouldn't the SCRIPTVAL_ and CONFVAL_ constant be moved to the config page? Has anybody any idea what the are used for?
  13. * If these are really configuration settings then we can add those to the dokeos config settings.
  14. * @todo check for duplication of functions with index.php (user_portal.php is orginally a copy of index.php)
  15. * @todo display_digest, shouldn't this be removed and be made into an extension?
  16. */
  17. /**
  18. * INIT SECTION
  19. */
  20. // Language files that should be included.
  21. $language_file = array('courses', 'index','admin');
  22. $cidReset = true; /* Flag forcing the 'current course' reset,
  23. as we're not inside a course anymore */
  24. if (isset($_SESSION['this_section']))
  25. unset($_SESSION['this_section']); // For HTML editor repository.
  26. /* Included libraries */
  27. require_once './main/inc/global.inc.php';
  28. require_once api_get_path(LIBRARY_PATH).'userportal.lib.php';
  29. api_block_anonymous_users(); // Only users who are logged in can proceed.
  30. /* Constants and CONFIGURATION parameters */
  31. $load_dirs = api_get_setting('show_documents_preview');
  32. // Check if a user is enrolled only in one course for going directly to the course after the login.
  33. if (api_get_setting('go_to_course_after_login') == 'true') {
  34. // Get the courses list
  35. $personal_course_list = UserManager::get_personal_session_course_list(api_get_user_id());
  36. $my_session_list = array();
  37. $count_of_courses_no_sessions = 0;
  38. $count_of_courses_with_sessions = 0;
  39. foreach($personal_course_list as $course) {
  40. if (!empty($course['id_session'])) {
  41. $my_session_list[$course['id_session']] = true;
  42. $count_of_courses_with_sessions++;
  43. } else {
  44. $count_of_courses_no_sessions++;
  45. }
  46. }
  47. $count_of_sessions = count($my_session_list);
  48. if ($count_of_sessions == 1 && $count_of_courses_no_sessions == 0) {
  49. $key = array_keys($personal_course_list);
  50. $course_info = $personal_course_list[$key[0]];
  51. $course_directory = $course_info['d'];
  52. $id_session = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
  53. $url = api_get_path(WEB_CODE_PATH).'session/?session_id='.$id_session;
  54. header('location:'.$url);
  55. exit;
  56. }
  57. if (!isset($_SESSION['coursesAlreadyVisited']) && $count_of_sessions == 0 && $count_of_courses_no_sessions == 1) {
  58. $key = array_keys($personal_course_list);
  59. $course_info = $personal_course_list[$key[0]];
  60. $course_directory = $course_info['course_info']['path'];
  61. $id_session = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
  62. $url = api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$id_session;
  63. header('location:'.$url);
  64. exit;
  65. }
  66. }
  67. $nameTools = get_lang('MyCourses');
  68. $this_section = SECTION_COURSES;
  69. /*
  70. Header
  71. Include the HTTP, HTML headers plus the top banner.
  72. */
  73. if ($load_dirs) {
  74. $url = api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=document_preview';
  75. $folder_icon = api_get_path(WEB_IMG_PATH).'icons/22/folder.png';
  76. $close_icon = api_get_path(WEB_IMG_PATH).'loading1.gif';
  77. $htmlHeadXtra[] = '<script type="text/javascript">
  78. $(document).ready( function() {
  79. $(".document_preview_container").hide();
  80. $(".document_preview").click(function() {
  81. var my_id = this.id;
  82. var course_id = my_id.split("_")[2];
  83. var session_id = my_id.split("_")[3];
  84. //showing div
  85. $(".document_preview_container").hide();
  86. $("#document_result_" +course_id+"_" + session_id).show();
  87. //Loading
  88. var image = $("img", this);
  89. image.attr("src", "'.$close_icon.'");
  90. $.ajax({
  91. url: "'.$url.'",
  92. data: "course_id="+course_id+"&session_id="+session_id,
  93. success: function(return_value) {
  94. image.attr("src", "'.$folder_icon.'");
  95. $("#document_result_" +course_id+"_" + session_id).html(return_value);
  96. }
  97. });
  98. });
  99. });
  100. </script>';
  101. }
  102. /* Sniffing system */
  103. //store posts to sessions
  104. if($_SESSION['sniff_navigator']!="checked") {
  105. $_SESSION['sniff_navigator']=Security::remove_XSS($_POST['sniff_navigator']);
  106. $_SESSION['sniff_screen_size_w']=Security::remove_XSS($_POST['sniff_navigator_screen_size_w']);
  107. $_SESSION['sniff__screen_size_h']=Security::remove_XSS($_POST['sniff_navigator_screen_size_h']);
  108. $_SESSION['sniff_type_mimetypes']=Security::remove_XSS($_POST['sniff_navigator_type_mimetypes']);
  109. $_SESSION['sniff_suffixes_mimetypes']=Security::remove_XSS($_POST['sniff_navigator_suffixes_mimetypes']);
  110. $_SESSION['sniff_list_plugins']=Security::remove_XSS($_POST['sniff_navigator_list_plugins']);
  111. $_SESSION['sniff_check_some_activex']=Security::remove_XSS($_POST['sniff_navigator_check_some_activex']);
  112. $_SESSION['sniff_check_some_plugins']=Security::remove_XSS($_POST['sniff_navigator_check_some_plugins']);
  113. $_SESSION['sniff_java']=Security::remove_XSS($_POST['sniff_navigator_java']);
  114. $_SESSION['sniff_java_sun_ver']=Security::remove_XSS($_POST['sniff_navigator_java_sun_ver']);
  115. }
  116. /* MAIN CODE */
  117. $controller = new IndexManager(get_lang('MyCourses'));
  118. //@todo all this could be moved in the IndexManager
  119. // Main courses and session list
  120. $courses_and_sessions = $controller->return_courses_and_sessions();
  121. $controller->tpl->assign('content', $courses_and_sessions);
  122. if (api_get_setting('allow_browser_sniffer') == 'true') {
  123. if ($_SESSION['sniff_navigator']!="checked") {
  124. $controller->tpl->assign('show_sniff', 1);
  125. } else{
  126. $controller->tpl->assign('show_sniff', 0);
  127. }
  128. }
  129. //check for flash and message
  130. $sniff_notification = '';
  131. $some_activex=$_SESSION['sniff_check_some_activex'];
  132. $some_plugins=$_SESSION['sniff_check_some_plugins'];
  133. if(!empty($some_activex) || !empty($some_plugins)){
  134. if (! preg_match("/flash_yes/", $some_activex) && ! preg_match("/flash_yes/", $some_plugins)) {
  135. $sniff_notification = Display::return_message(get_lang('NoFlash'), 'warning', true);
  136. //js verification - To annoying of redirecting every time the page
  137. $controller->tpl->assign('sniff_notification', $sniff_notification);
  138. }
  139. }
  140. $controller->tpl->assign('profile_block', $controller->return_profile_block());
  141. $controller->tpl->assign('account_block', $controller->return_account_block());
  142. $controller->tpl->assign('navigation_course_links', $controller->return_navigation_course_links());
  143. $controller->tpl->assign('reservation_block', $controller->return_reservation_block());
  144. $controller->tpl->assign('search_block', $controller->return_search_block());
  145. $controller->tpl->assign('classes_block', $controller->return_classes_block());
  146. //if (api_is_platform_admin() || api_is_drh()) {
  147. $controller->tpl->assign('skills_block', $controller->return_skills_links());
  148. //}
  149. $controller->tpl->display_two_col_template();
  150. // Deleting the session_id.
  151. api_session_unregister('session_id');