3column.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * HOME PAGE FOR EACH COURSE (BASIC TOOLS FIXED)
  5. *
  6. * This page, included in every course's index.php is the home
  7. * page.To make administration simple, the professor edits his
  8. * course from it's home page. Only the login detects that the
  9. * visitor is allowed to activate, deactivate home page links,
  10. * access to Professor's tools (statistics, edit forums...).
  11. *
  12. * @package chamilo.course_home
  13. */
  14. require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
  15. $hide = isset($_GET['hide']) && $_GET['hide'] == 'yes' ? 'yes' : null;
  16. $restore = isset($_GET['restore']) && $_GET['restore'] == 'yes' ? 'yes' : null;
  17. $id = isset($_GET['id']) ? intval($_GET['id']) : null;
  18. $TABLE_TOOLS = Database::get_main_table(TABLE_MAIN_COURSE_MODULE);
  19. $TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
  20. $course_id = api_get_course_int_id();
  21. // WORK with data post askable by admin of course
  22. if (api_is_allowed_to_edit(null, true)) {
  23. /* Processing request */
  24. /* MODIFY HOME PAGE */
  25. /*
  26. * Edit visibility of tools
  27. *
  28. * visibility = 1 - everybody
  29. * visibility = 0 - prof and admin
  30. * visibility = 2 - admin
  31. *
  32. * Who can change visibility ?
  33. *
  34. * admin = 0 - prof and admin
  35. * admin = 1 - admin
  36. *
  37. * Show message to confirm that a tools must be hide from aivailable tools
  38. *
  39. * visibility 0,1->2 - $remove
  40. *
  41. * Process hiding a tools from aivailable tools.
  42. *
  43. * visibility=2 are only view by Dokeos
  44. * Administrator visibility 0,1->2 - $destroy
  45. *
  46. * visibility 1 -> 0 - $hide / $restore
  47. */
  48. /*
  49. * Diplay message to confirm that a tools must be hide from aivailable tools
  50. * (visibility 0,1->2)
  51. */
  52. if ($remove) {
  53. $sql = "SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id";
  54. $result = Database::query($sql);
  55. $tool = Database::fetch_array($result);
  56. $tool_name = @htmlspecialchars($tool['name'] != '' ? $tool['name'] : $tool['link'], ENT_QUOTES, api_get_system_encoding());
  57. if ($tool['img'] != 'external.gif') {
  58. $tool['link'] = api_get_path(WEB_CODE_PATH).$tool['link'];
  59. }
  60. $tool['image'] = api_get_path(WEB_IMG_PATH).$tool['image'];
  61. echo "<br /><br /><br />\n";
  62. echo "<table class=\"message\" width=\"70%\" align=\"center\">\n",
  63. "<tr><td width=\"7%\" align=\"center\">\n",
  64. "<a href=\"".$tool['link']."\">".Display::return_icon($tool['image'], get_lang('Delete')), "</a></td>\n",
  65. "<td width=\"28%\" height=\"45\"><small>\n",
  66. "<a href=\"".$tool['link']."\">".$tool_name."</a></small></td>\n";
  67. echo "<td align=\"center\">\n",
  68. "<font color=\"#ff0000\">",
  69. "&nbsp;&nbsp;&nbsp;",
  70. "<strong>", get_lang('DelLk'), "</strong>",
  71. "<br />&nbsp;&nbsp;&nbsp;\n",
  72. "<a href=\"".api_get_self()."\">", get_lang('No'), "</a>\n",
  73. "&nbsp;|&nbsp;\n",
  74. "<a href=\"".api_get_self()."?destroy=yes&amp;id=$id\">", get_lang('Yes'), "</a>\n",
  75. "</font></td></tr>\n",
  76. "</table>\n";
  77. echo "<br /><br /><br />\n";
  78. } // if remove
  79. /*
  80. * Process hiding a tools from aivailable tools.
  81. * visibility=2 are only view by Dokeos Administrator (visibility 0,1->2)
  82. */
  83. elseif ($destroy) {
  84. Database::query("UPDATE $TBL_ACCUEIL SET visibility='2' WHERE c_id = $course_id AND id = $id");
  85. }
  86. /* HIDE */
  87. elseif ($hide) { // visibility 1 -> 0
  88. Database::query("UPDATE $TBL_ACCUEIL SET visibility=0 WHERE c_id = $course_id AND id=$id");
  89. Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
  90. }
  91. /* REACTIVATE */
  92. elseif ($restore) { // visibility 0,2 -> 1
  93. Database::query("UPDATE $TBL_ACCUEIL SET visibility=1 WHERE c_id = $course_id AND id=$id");
  94. Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
  95. }
  96. /*
  97. * Editing "apparance" of a tools on the course Home Page.
  98. */
  99. elseif (isset($update) && $update) {
  100. $result = Database::query("SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id");
  101. $tool = Database::fetch_array($result);
  102. $racine = $_configuration['root_sys'].'/'.$currentCourseID.'/images/';
  103. $chemin = $racine;
  104. $name = $tool[1];
  105. $image = $tool[3];
  106. echo "<tr>\n",
  107. "<td colspan=\"4\">\n",
  108. "<table>\n",
  109. "<tr>\n",
  110. "<td>\n",
  111. "<form method=\"post\" action=\"".api_get_self()."\">\n",
  112. "<input type=\"hidden\" name=\"id\" value=\"$id\">\n",
  113. "Image : ".Display::return_icon($image)."\n",
  114. "</td>\n",
  115. "<td>\n",
  116. "<select name=\"image\">\n",
  117. "<option selected>", $image, "</option>\n";
  118. if ($dir = @opendir($chemin)) {
  119. while ($file = readdir($dir)) {
  120. if ($file == '..' || $file == '.') {
  121. unset($file);
  122. }
  123. echo "<option>", $file, "</option>\n";
  124. }
  125. closedir($dir);
  126. }
  127. echo "</select>\n",
  128. "</td>\n",
  129. "</tr>\n",
  130. "<tr>\n",
  131. "<td>", get_lang('NameOfTheLink'), " : </td>\n",
  132. "<td><input type=\"text\" name=\"name\" value=\"", $name, "\"></td>\n",
  133. "</tr>\n",
  134. "<tr>\n",
  135. "<td>Lien :</td>\n",
  136. "<td><input type=\"text\" name=\"link\" value=\"", $link, "\"></td>\n",
  137. "</tr>\n",
  138. "<tr>\n",
  139. "<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"", get_lang('Ok'), "\"></td>\n",
  140. "</tr>\n",
  141. "</form>\n",
  142. "</table>\n",
  143. "</td>\n",
  144. "</tr>\n";
  145. }
  146. }
  147. // Work with data post askable by admin of course
  148. if ($is_platformAdmin && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  149. // Show message to confirm that a tools must be hide from aivailable tools
  150. // visibility 0,1->2
  151. if ($askDelete) {
  152. echo "<table align=\"center\"><tr>\n",
  153. "<td colspan=\"4\">\n",
  154. "<br /><br />\n",
  155. "<font color=\"#ff0000\">",
  156. "&nbsp;&nbsp;&nbsp;",
  157. "<strong>",get_lang('DelLk'),"</strong>",
  158. "<br />&nbsp;&nbsp;&nbsp;\n",
  159. "<a href=\"".api_get_self()."\">",get_lang('No'),"</a>\n",
  160. "&nbsp;|&nbsp;\n",
  161. "<a href=\"".api_get_self()."?delete=yes&amp;id=$id\">",get_lang('Yes'),"</a>\n",
  162. "</font>\n",
  163. "<br /><br /><br />\n",
  164. "</td>\n",
  165. "</tr>",
  166. "</table>\n";
  167. } // if remove
  168. /*
  169. * Process hiding a tools from aivailable tools.
  170. * visibility=2 are only viewed by Dokeos Administrator visibility 0,1->2
  171. */
  172. elseif (isset($delete) && $delete) {
  173. Database::query("DELETE FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id = $id AND added_tool=1");
  174. }
  175. }
  176. echo "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
  177. /* TOOLS FOR EVERYBODY */
  178. echo "<tr>\n<td colspan=\"6\">&nbsp;</td>\n</tr>\n";
  179. echo "<tr>\n<td colspan=\"6\">";
  180. CourseHome::show_tool_3column('Basic');
  181. CourseHome::show_tool_3column('External');
  182. echo "</td>\n</tr>\n";
  183. /* PROF ONLY VIEW */
  184. if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  185. echo "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n",
  186. "<tr>\n","<td colspan=\"6\">\n",
  187. "<font color=\"#F66105\">\n", get_lang('CourseAdminOnly'), "</font>\n",
  188. "</td>\n","</tr>\n";
  189. echo "<tr>\n<td colspan=\"6\">";
  190. CourseHome::show_tool_3column('courseAdmin');
  191. echo "</td>\n</tr>\n";
  192. }
  193. /* TOOLS FOR PLATFORM ADMIN ONLY */
  194. if ($is_platformAdmin && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  195. echo "<tr>","<td colspan=\"6\">",
  196. "<hr noshade size=\"1\" />",
  197. "</td>","</tr>\n",
  198. "<tr>\n","<td colspan=\"6\">\n",
  199. "<font color=\"#F66105\" >", get_lang('PlatformAdminOnly'), "</font>\n",
  200. "</td>\n","</tr>\n";
  201. echo "<tr>\n<td colspan=\"6\">";
  202. CourseHome::show_tool_3column('platformAdmin');
  203. echo "</td>\n</tr>\n";
  204. }
  205. echo "</table>\n";