activity.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. /* For licensing terms, see /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. * @package chamilo.course_home
  13. */
  14. require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
  15. $id = isset($_GET['id']) ? intval($_GET['id']) : null;
  16. // MAIN CODE
  17. if (api_is_allowed_to_edit(null, true)) {
  18. // HIDE
  19. if (!empty($_GET['hide'])) {
  20. $sql = "UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id=".$id;
  21. Database::query($sql);
  22. Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
  23. } elseif (!empty($_GET['restore'])) {
  24. // visibility 0,2 -> 1
  25. // REACTIVATE
  26. $sql = "UPDATE $tool_table SET visibility=1 WHERE c_id = $course_id AND id=".$id;
  27. Database::query($sql);
  28. Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
  29. }
  30. }
  31. // Work with data post askable by admin of course
  32. if (api_is_platform_admin()) {
  33. // Show message to confirm that a tool it to be hidden from available tools
  34. // visibility 0,1->2
  35. if (!empty($_GET['askDelete'])) {
  36. ?>
  37. <div id="toolhide"><?php echo get_lang('DelLk'); ?><br />&nbsp;&nbsp;&nbsp;
  38. <a href="<?php echo api_get_self(); ?>"><?php echo get_lang('No'); ?></a>&nbsp;|&nbsp;
  39. <a href="<?php echo api_get_self(); ?>?delete=yes&id=<?php echo Security::remove_XSS($_GET['id']); ?>"><?php echo get_lang('Yes'); ?></a>
  40. </div>
  41. <?php
  42. }
  43. /*
  44. * Process hiding a tools from available tools.
  45. */
  46. elseif (isset($_GET['delete']) && $_GET['delete']) {
  47. //where $id is set?
  48. $id = intval($id);
  49. Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
  50. }
  51. }
  52. // COURSE ADMIN ONLY VIEW
  53. // Start of tools for CourseAdmins (teachers/tutors)
  54. if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  55. $current_protocol = $_SERVER['SERVER_PROTOCOL'];
  56. $current_host = $_SERVER['HTTP_HOST'];
  57. $server_protocol = substr($current_protocol, 0, strrpos($current_protocol, '/'));
  58. $server_protocol = $server_protocol.'://';
  59. if ($current_host == 'localhost') {
  60. // Get information of path
  61. $info = explode('courses', api_get_self());
  62. $path_work = substr($info[0], 1);
  63. } else {
  64. $path_work = '';
  65. }
  66. ?>
  67. <div class="courseadminview" style="border:0px; margin-top: 0px;padding:0px;">
  68. <div class="normal-message" id="id_normal_message" style="display:none">
  69. <?php
  70. echo '<img src="'.$server_protocol.$current_host.'/'.$path_work.'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
  71. echo get_lang('PleaseStandBy');
  72. ?>
  73. </div>
  74. <div class="confirmation-message" id="id_confirmation_message" style="display:none"></div>
  75. </div>
  76. <?php
  77. if (api_get_setting('show_session_data') == 'true' && $id_session > 0) {
  78. ?>
  79. <div class="courseadminview">
  80. <span class="viewcaption"><?php echo get_lang('SessionData'); ?></span>
  81. <table class="course_activity_home">
  82. <?php
  83. echo show_session_data($id_session);
  84. ?>
  85. </table>
  86. </div>
  87. <?php
  88. }
  89. ?>
  90. <div class="courseadminview">
  91. <span class="viewcaption"><?php echo get_lang('Authoring'); ?></span>
  92. <?php
  93. $my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
  94. CourseHome::show_tools_category($my_list);
  95. ?>
  96. </div>
  97. <div class="courseadminview">
  98. <span class="viewcaption"><?php echo get_lang('Interaction'); ?></span>
  99. <?php
  100. $my_list = CourseHome::get_tools_category(TOOL_INTERACTION);
  101. $list2 = CourseHome::get_tools_category(TOOL_COURSE_PLUGIN);
  102. $my_list = array_merge($my_list,$list2);
  103. CourseHome::show_tools_category($my_list);
  104. ?>
  105. </div>
  106. <div class="courseadminview">
  107. <span class="viewcaption"><?php echo get_lang('Administration'); ?></span>
  108. <?php
  109. $theme = api_get_setting('homepage_view');
  110. $rows = false;
  111. if ($theme == 'activity_big') {
  112. $rows = 4;
  113. }
  114. $my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
  115. CourseHome::show_tools_category($my_list, $rows);
  116. ?>
  117. </div>
  118. <?php
  119. } elseif (api_is_coach()) {
  120. if (api_get_setting('show_session_data') == 'true' && $id_session > 0) {
  121. ?>
  122. <div class="courseadminview">
  123. <span class="viewcaption"><?php echo get_lang('SessionData'); ?></span>
  124. <table class="course_activity_home">
  125. <?php
  126. echo CourseHome::show_session_data($id_session);
  127. ?>
  128. </table>
  129. </div>
  130. <?php
  131. }
  132. ?>
  133. <div class="Authoringview">
  134. <?php
  135. $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  136. CourseHome::show_tools_category($my_list);
  137. ?>
  138. </div>
  139. <?php
  140. // TOOLS AUTHORING
  141. } else {
  142. $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  143. if (count($my_list) > 0) {
  144. echo '<div class="Authoringview">';
  145. CourseHome::show_tools_category($my_list);
  146. echo '</div>';
  147. }
  148. }