course_home.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <?php
  2. /* For licensing terms, see /chamilo_license.txt */
  3. /**
  4. HOME PAGE FOR EACH COURSE
  5. *
  6. * This page, included in every course's index.php is the home
  7. * page. To make administration simple, the teacher edits his
  8. * course from the home page. Only the login detects that the
  9. * visitor is allowed to activate, deactivate home page links,
  10. * access to the teachers tools (statistics, edit forums...).
  11. *
  12. * Edit visibility of tools
  13. *
  14. * visibility = 1 - everybody
  15. * visibility = 0 - course admin (teacher) and platform admin
  16. *
  17. * Who can change visibility ?
  18. *
  19. * admin = 0 - course admin (teacher) and platform admin
  20. * admin = 1 - platform admin
  21. *
  22. * Show message to confirm that a tools must be hide from available tools
  23. *
  24. * visibility 0,1
  25. *
  26. *
  27. * @package dokeos.course_home
  28. */
  29. /* INIT SECTION */
  30. // Name of the language file that needs to be included.
  31. $language_file = 'course_home';
  32. $use_anonymous = true;
  33. // Inlcuding the global initialization file.
  34. require '../../main/inc/global.inc.php';
  35. //Delete LP sessions
  36. unset($_SESSION['oLP']);
  37. unset($_SESSION['lpobject']);
  38. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
  39. $htmlHeadXtra[] ='<script type="text/javascript">
  40. $(document).ready(function() {
  41. $(".make_visible_and_invisible").attr("href", "javascript:void(0);");
  42. $("td .make_visible_and_invisible > img").click(function () {
  43. make_visible = "visible.gif";
  44. make_invisible = "invisible.gif";
  45. path_name = $(this).attr("src");
  46. list_path_name = path_name.split("/");
  47. image_link = list_path_name[list_path_name.length - 1];
  48. tool_id = $(this).attr("id");
  49. tool_info = tool_id.split("_");
  50. my_tool_id = tool_info[1];
  51. $.ajax({
  52. contentType: "application/x-www-form-urlencoded",
  53. beforeSend: function(objeto) {
  54. $(".normal-message").show();
  55. $("#id_confirmation_message").hide();
  56. },
  57. type: "GET",
  58. url: "'.api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=set_visibility",
  59. data: "id=" + my_tool_id + "&sent_http_request=1",
  60. success: function(data) {
  61. eval("var info=" + data);
  62. new_current_tool_image = "'.api_get_path(WEB_IMG_PATH).'" + info.image;
  63. new_current_view = "'.api_get_path(WEB_IMG_PATH).'" + info.view;
  64. //eyes
  65. $("#" + tool_id).attr("src", new_current_view);
  66. //tool
  67. $("#toolimage_" + my_tool_id).attr("src", new_current_tool_image);
  68. //clase
  69. $("#tooldesc_" + my_tool_id).attr("class", info.tclass);
  70. $("#istooldesc_" + my_tool_id).attr("class", info.tclass);
  71. if (image_link == "visible.gif") {
  72. $("#" + tool_id).attr("alt", "'.get_lang('Activate', '').'");
  73. $("#" + tool_id).attr("title", "'.get_lang('Activate', '').'");
  74. } else {
  75. $("#" + tool_id).attr("alt", "'.get_lang('Deactivate', '').'");
  76. $("#" + tool_id).attr("title", "'.get_lang('Deactivate', '').'");
  77. }
  78. if (info.message == "is_active") {
  79. message = "'.get_lang('ToolIsNowVisible', '').'";
  80. } else {
  81. message = "'.get_lang('ToolIsNowHidden', '').'";
  82. }
  83. $(".normal-message").hide();
  84. $("#id_confirmation_message").html(message);
  85. $("#id_confirmation_message").show();
  86. }
  87. });
  88. });
  89. });
  90. /* toogle for post-it in course home */
  91. $(function() {
  92. $(".thematic-postit-head").click(function() {
  93. $(".thematic-postit-center").slideToggle("normal");
  94. }).$(".thematic-postit-center").hide();
  95. });
  96. </script>';
  97. if (!isset($cidReq)) {
  98. $cidReq = api_get_course_id(); // To provide compatibility with previous systems.
  99. global $error_msg,$error_no;
  100. $classError = "init";
  101. $error_no[$classError][] = "2";
  102. $error_level[$classError][] = "info";
  103. $error_msg[$classError][] = "[".__FILE__."][".__LINE__."] cidReq was Missing $cidReq take $dbname;";
  104. }
  105. if (isset($_SESSION['_gid'])) {
  106. unset($_SESSION['_gid']);
  107. }
  108. // The section for the tabs
  109. $this_section = SECTION_COURSES;
  110. // Libraries
  111. include_once api_get_path(LIBRARY_PATH).'course.lib.php';
  112. include_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
  113. /*
  114. -----------------------------------------------------------
  115. Constants
  116. -----------------------------------------------------------
  117. */
  118. define ('TOOL_PUBLIC', 'Public');
  119. define ('TOOL_PUBLIC_BUT_HIDDEN', 'PublicButHide');
  120. define ('TOOL_COURSE_ADMIN', 'courseAdmin');
  121. define ('TOOL_PLATFORM_ADMIN', 'platformAdmin');
  122. define ('TOOL_AUTHORING', 'toolauthoring');
  123. define ('TOOL_INTERACTION', 'toolinteraction');
  124. define ('TOOL_ADMIN', 'tooladmin');
  125. define ('TOOL_ADMIN_PLATEFORM', 'tooladminplatform');
  126. // ('TOOL_ADMIN_PLATFORM_VISIBLE', 'tooladminplatformvisible');
  127. //define ('TOOL_ADMIN_PLATFORM_INVISIBLE', 'tooladminplatforminvisible');
  128. //define ('TOOL_ADMIN_COURS_INVISIBLE', 'tooladmincoursinvisible');
  129. define ('TOOL_STUDENT_VIEW', 'toolstudentview');
  130. define ('TOOL_ADMIN_VISIBLE', 'tooladminvisible');
  131. /* Virtual course support code */
  132. $user_id = api_get_user_id();
  133. $course_code = $_course['sysCode'];
  134. $course_info = Database::get_course_info($course_code);
  135. $return_result = CourseManager::determine_course_title_from_course_info($_user['user_id'], $course_info);
  136. $course_title = $return_result['title'];
  137. $course_code = $return_result['code'];
  138. $_course['name'] = $course_title;
  139. $_course['official_code'] = $course_code;
  140. api_session_unregister('toolgroup');
  141. $is_speacialcourse = CourseManager::is_special_course($course_code);
  142. if ($is_speacialcourse==true){
  143. $autoreg=Security::remove_XSS($_GET['autoreg']);
  144. if ($autoreg==1){
  145. CourseManager::subscribe_user($user_id, $course_code, $status = STUDENT);
  146. }
  147. }
  148. /*
  149. -----------------------------------------------------------
  150. Is the user allowed here?
  151. -----------------------------------------------------------
  152. */
  153. if (!$is_allowed_in_course) {
  154. api_not_allowed(true);
  155. }
  156. /*
  157. -----------------------------------------------------------
  158. Header
  159. -----------------------------------------------------------
  160. */
  161. //Display::display_header($course_title, 'Home');
  162. Display::display_header('', 'Home');
  163. /*
  164. -----------------------------------------------------------
  165. STATISTICS
  166. -----------------------------------------------------------
  167. */
  168. if (!isset($coursesAlreadyVisited[$_cid])) {
  169. event_access_course();
  170. $coursesAlreadyVisited[$_cid] = 1;
  171. api_session_register('coursesAlreadyVisited');
  172. }
  173. $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  174. $temps = time();
  175. $reqdate = "&reqdate=$temps";
  176. /*
  177. ==============================================================================
  178. MAIN CODE
  179. ==============================================================================
  180. */
  181. //display course title for course home page (similar to toolname for tool pages)
  182. //echo '<h3>'.api_display_tool_title($nameTools) . '</h3>';
  183. /*
  184. -----------------------------------------------------------
  185. Introduction section
  186. (editable by course admins)
  187. -----------------------------------------------------------
  188. */
  189. Display::display_introduction_section(TOOL_COURSE_HOMEPAGE, array(
  190. 'CreateDocumentWebDir' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/document/',
  191. 'CreateDocumentDir' => 'document/',
  192. 'BaseHref' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/'
  193. )
  194. );
  195. /*
  196. -----------------------------------------------------------
  197. SWITCH TO A DIFFERENT HOMEPAGE VIEW
  198. the setting homepage_view is adjustable through
  199. the platform administration section
  200. -----------------------------------------------------------
  201. */
  202. if (api_get_setting('homepage_view') == 'activity') {
  203. require 'activity.php';
  204. }
  205. elseif(api_get_setting('homepage_view') == '2column') {
  206. require '2column.php';
  207. }
  208. elseif(api_get_setting('homepage_view') == '3column') {
  209. require '3column.php';
  210. }
  211. /*
  212. ==============================================================================
  213. FOOTER
  214. ==============================================================================
  215. */
  216. Display::display_footer();