course_home.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
  36. $htmlHeadXtra[] ='<script type="text/javascript">
  37. $(document).ready(function() {
  38. $(".make_visible_and_invisible").attr("href", "javascript:void(0);");
  39. $("td .make_visible_and_invisible > img").click(function () {
  40. make_visible = "visible.gif";
  41. make_invisible = "invisible.gif";
  42. path_name = $(this).attr("src");
  43. list_path_name = path_name.split("/");
  44. image_link = list_path_name[list_path_name.length - 1];
  45. tool_id = $(this).attr("id");
  46. tool_info = tool_id.split("_");
  47. my_tool_id = tool_info[1];
  48. $.ajax({
  49. contentType: "application/x-www-form-urlencoded",
  50. beforeSend: function(objeto) {
  51. $(".normal-message").show();
  52. $("#id_confirmation_message").hide();
  53. },
  54. type: "GET",
  55. url: "'.api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=set_visibility",
  56. data: "id=" + my_tool_id + "&sent_http_request=1",
  57. success: function(data) {
  58. eval("var info=" + data);
  59. new_current_tool_image = "'.api_get_path(WEB_IMG_PATH).'" + info.image;
  60. new_current_view = "'.api_get_path(WEB_IMG_PATH).'" + info.view;
  61. //eyes
  62. $("#" + tool_id).attr("src", new_current_view);
  63. //tool
  64. $("#toolimage_" + my_tool_id).attr("src", new_current_tool_image);
  65. //clase
  66. $("#tooldesc_" + my_tool_id).attr("class", info.tclass);
  67. $("#istooldesc_" + my_tool_id).attr("class", info.tclass);
  68. if (image_link == "visible.gif") {
  69. $("#" + tool_id).attr("alt", "'.get_lang('Activate', '').'");
  70. $("#" + tool_id).attr("title", "'.get_lang('Activate', '').'");
  71. } else {
  72. $("#" + tool_id).attr("alt", "'.get_lang('Deactivate', '').'");
  73. $("#" + tool_id).attr("title", "'.get_lang('Deactivate', '').'");
  74. }
  75. if (info.message == "is_active") {
  76. message = "'.get_lang('ToolIsNowVisible', '').'";
  77. } else {
  78. message = "'.get_lang('ToolIsNowHidden', '').'";
  79. }
  80. $(".normal-message").hide();
  81. $("#id_confirmation_message").html(message);
  82. $("#id_confirmation_message").show();
  83. }
  84. });
  85. });
  86. });
  87. </script>';
  88. if (!isset($cidReq)) {
  89. $cidReq = api_get_course_id(); // To provide compatibility with previous systems.
  90. global $error_msg,$error_no;
  91. $classError = "init";
  92. $error_no[$classError][] = "2";
  93. $error_level[$classError][] = "info";
  94. $error_msg[$classError][] = "[".__FILE__."][".__LINE__."] cidReq was Missing $cidReq take $dbname;";
  95. }
  96. if (isset($_SESSION['_gid'])) {
  97. unset($_SESSION['_gid']);
  98. }
  99. // The section for the tabs
  100. $this_section = SECTION_COURSES;
  101. // Libraries
  102. include_once api_get_path(LIBRARY_PATH).'course.lib.php';
  103. include_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
  104. /*
  105. -----------------------------------------------------------
  106. Constants
  107. -----------------------------------------------------------
  108. */
  109. define ('TOOL_PUBLIC', 'Public');
  110. define ('TOOL_PUBLIC_BUT_HIDDEN', 'PublicButHide');
  111. define ('TOOL_COURSE_ADMIN', 'courseAdmin');
  112. define ('TOOL_PLATFORM_ADMIN', 'platformAdmin');
  113. define ('TOOL_AUTHORING', 'toolauthoring');
  114. define ('TOOL_INTERACTION', 'toolinteraction');
  115. define ('TOOL_ADMIN', 'tooladmin');
  116. define ('TOOL_ADMIN_PLATEFORM', 'tooladminplatform');
  117. // ('TOOL_ADMIN_PLATFORM_VISIBLE', 'tooladminplatformvisible');
  118. //define ('TOOL_ADMIN_PLATFORM_INVISIBLE', 'tooladminplatforminvisible');
  119. //define ('TOOL_ADMIN_COURS_INVISIBLE', 'tooladmincoursinvisible');
  120. define ('TOOL_STUDENT_VIEW', 'toolstudentview');
  121. define ('TOOL_ADMIN_VISIBLE', 'tooladminvisible');
  122. /* Virtual course support code */
  123. $user_id = api_get_user_id();
  124. $course_code = $_course['sysCode'];
  125. $course_info = Database::get_course_info($course_code);
  126. $return_result = CourseManager::determine_course_title_from_course_info($_user['user_id'], $course_info);
  127. $course_title = $return_result['title'];
  128. $course_code = $return_result['code'];
  129. $_course['name'] = $course_title;
  130. $_course['official_code'] = $course_code;
  131. api_session_unregister('toolgroup');
  132. /*
  133. -----------------------------------------------------------
  134. Is the user allowed here?
  135. -----------------------------------------------------------
  136. */
  137. if (!$is_allowed_in_course) {
  138. api_not_allowed(true);
  139. }
  140. /*
  141. -----------------------------------------------------------
  142. Header
  143. -----------------------------------------------------------
  144. */
  145. //Display::display_header($course_title, 'Home');
  146. Display::display_header('', 'Home');
  147. /*
  148. -----------------------------------------------------------
  149. STATISTICS
  150. -----------------------------------------------------------
  151. */
  152. if (!isset($coursesAlreadyVisited[$_cid])) {
  153. event_access_course();
  154. $coursesAlreadyVisited[$_cid] = 1;
  155. api_session_register('coursesAlreadyVisited');
  156. }
  157. $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  158. $temps = time();
  159. $reqdate = "&reqdate=$temps";
  160. /*
  161. ==============================================================================
  162. MAIN CODE
  163. ==============================================================================
  164. */
  165. //display course title for course home page (similar to toolname for tool pages)
  166. //echo '<h3>'.api_display_tool_title($nameTools) . '</h3>';
  167. /*
  168. -----------------------------------------------------------
  169. Introduction section
  170. (editable by course admins)
  171. -----------------------------------------------------------
  172. */
  173. Display::display_introduction_section(TOOL_COURSE_HOMEPAGE, array(
  174. 'CreateDocumentWebDir' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/document/',
  175. 'CreateDocumentDir' => 'document/',
  176. 'BaseHref' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/'
  177. )
  178. );
  179. /*
  180. -----------------------------------------------------------
  181. SWITCH TO A DIFFERENT HOMEPAGE VIEW
  182. the setting homepage_view is adjustable through
  183. the platform administration section
  184. -----------------------------------------------------------
  185. */
  186. if (api_get_setting('homepage_view') == 'activity') {
  187. require 'activity.php';
  188. }
  189. elseif(api_get_setting('homepage_view') == '2column') {
  190. require '2column.php';
  191. }
  192. elseif(api_get_setting('homepage_view') == '3column') {
  193. require '3column.php';
  194. }
  195. /*
  196. ==============================================================================
  197. FOOTER
  198. ==============================================================================
  199. */
  200. Display::display_footer();