course_home.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. /* toogle for post-it in course home */
  88. $(function() {
  89. $(".thematic-postit-head").click(function() {
  90. $(".thematic-postit-center").slideToggle("normal");
  91. }).$(".thematic-postit-center").hide();
  92. });
  93. </script>';
  94. if (!isset($cidReq)) {
  95. $cidReq = api_get_course_id(); // To provide compatibility with previous systems.
  96. global $error_msg,$error_no;
  97. $classError = "init";
  98. $error_no[$classError][] = "2";
  99. $error_level[$classError][] = "info";
  100. $error_msg[$classError][] = "[".__FILE__."][".__LINE__."] cidReq was Missing $cidReq take $dbname;";
  101. }
  102. if (isset($_SESSION['_gid'])) {
  103. unset($_SESSION['_gid']);
  104. }
  105. // The section for the tabs
  106. $this_section = SECTION_COURSES;
  107. // Libraries
  108. include_once api_get_path(LIBRARY_PATH).'course.lib.php';
  109. include_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
  110. /*
  111. -----------------------------------------------------------
  112. Constants
  113. -----------------------------------------------------------
  114. */
  115. define ('TOOL_PUBLIC', 'Public');
  116. define ('TOOL_PUBLIC_BUT_HIDDEN', 'PublicButHide');
  117. define ('TOOL_COURSE_ADMIN', 'courseAdmin');
  118. define ('TOOL_PLATFORM_ADMIN', 'platformAdmin');
  119. define ('TOOL_AUTHORING', 'toolauthoring');
  120. define ('TOOL_INTERACTION', 'toolinteraction');
  121. define ('TOOL_ADMIN', 'tooladmin');
  122. define ('TOOL_ADMIN_PLATEFORM', 'tooladminplatform');
  123. // ('TOOL_ADMIN_PLATFORM_VISIBLE', 'tooladminplatformvisible');
  124. //define ('TOOL_ADMIN_PLATFORM_INVISIBLE', 'tooladminplatforminvisible');
  125. //define ('TOOL_ADMIN_COURS_INVISIBLE', 'tooladmincoursinvisible');
  126. define ('TOOL_STUDENT_VIEW', 'toolstudentview');
  127. define ('TOOL_ADMIN_VISIBLE', 'tooladminvisible');
  128. /* Virtual course support code */
  129. $user_id = api_get_user_id();
  130. $course_code = $_course['sysCode'];
  131. $course_info = Database::get_course_info($course_code);
  132. $return_result = CourseManager::determine_course_title_from_course_info($_user['user_id'], $course_info);
  133. $course_title = $return_result['title'];
  134. $course_code = $return_result['code'];
  135. $_course['name'] = $course_title;
  136. $_course['official_code'] = $course_code;
  137. api_session_unregister('toolgroup');
  138. /*
  139. -----------------------------------------------------------
  140. Is the user allowed here?
  141. -----------------------------------------------------------
  142. */
  143. if (!$is_allowed_in_course) {
  144. api_not_allowed(true);
  145. }
  146. /*
  147. -----------------------------------------------------------
  148. Header
  149. -----------------------------------------------------------
  150. */
  151. //Display::display_header($course_title, 'Home');
  152. Display::display_header('', 'Home');
  153. /*
  154. -----------------------------------------------------------
  155. STATISTICS
  156. -----------------------------------------------------------
  157. */
  158. if (!isset($coursesAlreadyVisited[$_cid])) {
  159. event_access_course();
  160. $coursesAlreadyVisited[$_cid] = 1;
  161. api_session_register('coursesAlreadyVisited');
  162. }
  163. $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  164. $temps = time();
  165. $reqdate = "&reqdate=$temps";
  166. /*
  167. ==============================================================================
  168. MAIN CODE
  169. ==============================================================================
  170. */
  171. //display course title for course home page (similar to toolname for tool pages)
  172. //echo '<h3>'.api_display_tool_title($nameTools) . '</h3>';
  173. /*
  174. -----------------------------------------------------------
  175. Introduction section
  176. (editable by course admins)
  177. -----------------------------------------------------------
  178. */
  179. Display::display_introduction_section(TOOL_COURSE_HOMEPAGE, array(
  180. 'CreateDocumentWebDir' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/document/',
  181. 'CreateDocumentDir' => 'document/',
  182. 'BaseHref' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/'
  183. )
  184. );
  185. /*
  186. -----------------------------------------------------------
  187. SWITCH TO A DIFFERENT HOMEPAGE VIEW
  188. the setting homepage_view is adjustable through
  189. the platform administration section
  190. -----------------------------------------------------------
  191. */
  192. if (api_get_setting('homepage_view') == 'activity') {
  193. require 'activity.php';
  194. }
  195. elseif(api_get_setting('homepage_view') == '2column') {
  196. require '2column.php';
  197. }
  198. elseif(api_get_setting('homepage_view') == '3column') {
  199. require '3column.php';
  200. }
  201. /*
  202. ==============================================================================
  203. FOOTER
  204. ==============================================================================
  205. */
  206. Display::display_footer();