3column.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. $hide = isset($_GET['hide']) && $_GET['hide'] === 'yes' ? 'yes' : null;
  15. $restore = isset($_GET['restore']) && $_GET['restore'] === 'yes' ? 'yes' : null;
  16. $id = isset($_GET['id']) ? intval($_GET['id']) : null;
  17. $TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
  18. $course_id = api_get_course_int_id();
  19. $remove = isset($remove) ? $remove : false;
  20. $destroy = isset($destroy) ? $destroy : false;
  21. $askDelete = isset($askDelete) ? $askDelete : false;
  22. // WORK with data post askable by admin of course
  23. if (api_is_allowed_to_edit(null, true)) {
  24. /* Processing request */
  25. /* MODIFY HOME PAGE */
  26. /*
  27. * Edit visibility of tools
  28. *
  29. * visibility = 1 - everybody
  30. * visibility = 0 - prof and admin
  31. * visibility = 2 - admin
  32. *
  33. * Who can change visibility ?
  34. *
  35. * admin = 0 - prof and admin
  36. * admin = 1 - admin
  37. *
  38. * Show message to confirm that a tools must be hide from aivailable tools
  39. *
  40. * visibility 0,1->2 - $remove
  41. *
  42. * Process hiding a tools from aivailable tools.
  43. *
  44. * visibility=2 are only view by Dokeos
  45. * Administrator visibility 0,1->2 - $destroy
  46. *
  47. * visibility 1 -> 0 - $hide / $restore
  48. */
  49. /*
  50. * Diplay message to confirm that a tools must be hide from aivailable tools
  51. * (visibility 0,1->2)
  52. */
  53. if ($remove) {
  54. $sql = "SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id";
  55. $result = Database::query($sql);
  56. $tool = Database::fetch_array($result);
  57. $tool_name = @htmlspecialchars($tool['name'] != '' ? $tool['name'] : $tool['link'], ENT_QUOTES, api_get_system_encoding());
  58. if ($tool['img'] != 'external.gif') {
  59. $tool['link'] = api_get_path(WEB_CODE_PATH).$tool['link'];
  60. }
  61. $tool['image'] = Display::returnIconPath($tool['image']);
  62. echo "<br /><br /><br />\n";
  63. echo "<table class=\"message\" width=\"70%\" align=\"center\">\n",
  64. "<tr><td width=\"7%\" align=\"center\">\n",
  65. "<a href=\"".$tool['link']."\">".Display::return_icon($tool['image'], get_lang('Delete')), "</a></td>\n",
  66. "<td width=\"28%\" height=\"45\"><small>\n",
  67. "<a href=\"".$tool['link']."\">".$tool_name."</a></small></td>\n";
  68. echo "<td align=\"center\">\n",
  69. "<font color=\"#ff0000\">",
  70. "&nbsp;&nbsp;&nbsp;",
  71. "<strong>", get_lang('DelLk'), "</strong>",
  72. "<br />&nbsp;&nbsp;&nbsp;\n",
  73. "<a href=\"".api_get_self()."\">", get_lang('No'), "</a>\n",
  74. "&nbsp;|&nbsp;\n",
  75. "<a href=\"".api_get_self()."?destroy=yes&amp;id=$id\">", get_lang('Yes'), "</a>\n",
  76. "</font></td></tr>\n",
  77. "</table>\n";
  78. echo "<br /><br /><br />\n";
  79. } elseif ($destroy) {
  80. // if remove
  81. /*
  82. * Process hiding a tools from aivailable tools.
  83. * visibility=2 are only view by Dokeos Administrator (visibility 0,1->2)
  84. */
  85. Database::query("UPDATE $TBL_ACCUEIL SET visibility='2' WHERE c_id = $course_id AND id = $id");
  86. } elseif ($hide) {
  87. // visibility 1 -> 0
  88. /* HIDE */
  89. Database::query("UPDATE $TBL_ACCUEIL SET visibility=0 WHERE c_id = $course_id AND id=$id");
  90. $show_message .= Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
  91. } elseif ($restore) {
  92. /* REACTIVATE */
  93. // visibility 0,2 -> 1
  94. Database::query("UPDATE $TBL_ACCUEIL SET visibility=1 WHERE c_id = $course_id AND id=$id");
  95. $show_message .= Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
  96. } elseif (isset($update) && $update) {
  97. /*
  98. * Editing "apparance" of a tools on the course Home Page.
  99. */
  100. $result = Database::query("SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id");
  101. $tool = Database::fetch_array($result);
  102. $racine = api_get_path(SYS_PATH).'/'.$currentCourseID.'/images/';
  103. $chemin = $racine;
  104. $name = $tool[1];
  105. $image = $tool[3];
  106. $content .= "<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. $content .= "<option>".$file."</option>\n";
  124. }
  125. closedir($dir);
  126. }
  127. $content .= "</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 (api_is_platform_admin() && 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. $content .= "<table align=\"center\"><tr><td colspan=\"4\">
  153. <br /><br /><font color=\"#ff0000\">&nbsp;&nbsp;&nbsp;<strong>".get_lang('DelLk')."</strong>
  154. <br />&nbsp;&nbsp;&nbsp;
  155. <a href=\"".api_get_self()."\">".get_lang('No')."</a>
  156. &nbsp;|&nbsp;
  157. <a href=\"".api_get_self()."?delete=yes&amp;id=$id\">".get_lang('Yes')."</a>
  158. </font>
  159. <br /><br /><br />
  160. </td>
  161. </tr>
  162. </table>\n";
  163. } elseif (isset($delete) && $delete) {
  164. // if remove
  165. /*
  166. * Process hiding a tools from aivailable tools.
  167. * visibility=2 are only viewed by Dokeos Administrator visibility 0,1->2
  168. */
  169. Database::query("DELETE FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id = $id AND added_tool=1");
  170. }
  171. }
  172. $content .= "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
  173. /* TOOLS FOR EVERYBODY */
  174. $content .= "<tr>\n<td colspan=\"6\">&nbsp;</td>\n</tr>\n";
  175. $content .= "<tr>\n<td colspan=\"6\">";
  176. $content .= CourseHome::show_tool_3column('Basic');
  177. $content .= CourseHome::show_tool_3column('External');
  178. $content .= "</td>\n</tr>\n";
  179. /* PROF ONLY VIEW */
  180. if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  181. $content .= "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n".
  182. "<tr><td colspan=\"6\"><font color=\"#F66105\">\n".get_lang('CourseAdminOnly')."</font>
  183. </td></tr>\n";
  184. $content .= "<tr>\n<td colspan=\"6\">";
  185. $content .= CourseHome::show_tool_3column('courseAdmin');
  186. $content .= "</td>\n</tr>\n";
  187. }
  188. /* TOOLS FOR PLATFORM ADMIN ONLY */
  189. if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  190. $content .= "<tr>"."<td colspan=\"6\">".
  191. "<hr noshade size=\"1\" />".
  192. "</td>"."</tr>\n".
  193. "<tr>\n"."<td colspan=\"6\">\n".
  194. "<font color=\"#F66105\" >".get_lang('PlatformAdminOnly')."</font>\n".
  195. "</td>\n"."</tr>\n";
  196. $content .= "<tr>\n<td colspan=\"6\">";
  197. $content .= CourseHome::show_tool_3column('platformAdmin');
  198. $content .= "</td>\n</tr>\n";
  199. }
  200. $content .= "</table>\n";