3column.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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(
  58. $tool['name'] != '' ? $tool['name'] : $tool['link'],
  59. ENT_QUOTES,
  60. api_get_system_encoding()
  61. );
  62. if ($tool['img'] != 'external.gif') {
  63. $tool['link'] = api_get_path(WEB_CODE_PATH).$tool['link'];
  64. }
  65. $tool['image'] = Display::returnIconPath($tool['image']);
  66. echo "<br /><br /><br />\n";
  67. echo "<table class=\"message\" width=\"70%\" align=\"center\">\n",
  68. "<tr><td width=\"7%\" align=\"center\">\n",
  69. "<a href=\"".$tool['link']."\">".Display::return_icon($tool['image'], get_lang('Delete')), "</a></td>\n",
  70. "<td width=\"28%\" height=\"45\"><small>\n",
  71. "<a href=\"".$tool['link']."\">".$tool_name."</a></small></td>\n";
  72. echo "<td align=\"center\">\n",
  73. "<font color=\"#ff0000\">",
  74. "&nbsp;&nbsp;&nbsp;",
  75. "<strong>", get_lang('DelLk'), "</strong>",
  76. "<br />&nbsp;&nbsp;&nbsp;\n",
  77. "<a href=\"".api_get_self()."\">", get_lang('No'), "</a>\n",
  78. "&nbsp;|&nbsp;\n",
  79. "<a href=\"".api_get_self()."?destroy=yes&amp;id=$id\">", get_lang('Yes'), "</a>\n",
  80. "</font></td></tr>\n",
  81. "</table>\n";
  82. echo "<br /><br /><br />\n";
  83. } elseif ($destroy) {
  84. // if remove
  85. /*
  86. * Process hiding a tools from aivailable tools.
  87. * visibility=2 are only view by Dokeos Administrator (visibility 0,1->2)
  88. */
  89. Database::query("UPDATE $TBL_ACCUEIL SET visibility='2' WHERE c_id = $course_id AND id = $id");
  90. } elseif ($hide) {
  91. // visibility 1 -> 0
  92. /* HIDE */
  93. Database::query("UPDATE $TBL_ACCUEIL SET visibility=0 WHERE c_id = $course_id AND id=$id");
  94. $show_message .= Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
  95. } elseif ($restore) {
  96. /* REACTIVATE */
  97. // visibility 0,2 -> 1
  98. Database::query("UPDATE $TBL_ACCUEIL SET visibility=1 WHERE c_id = $course_id AND id=$id");
  99. $show_message .= Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
  100. } elseif (isset($update) && $update) {
  101. /*
  102. * Editing "apparance" of a tools on the course Home Page.
  103. */
  104. $result = Database::query("SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id");
  105. $tool = Database::fetch_array($result);
  106. $racine = api_get_path(SYS_PATH).'/'.$currentCourseID.'/images/';
  107. $chemin = $racine;
  108. $name = $tool[1];
  109. $image = $tool[3];
  110. $content .= "<tr>\n".
  111. "<td colspan=\"4\">\n".
  112. "<table>\n".
  113. "<tr>\n".
  114. "<td>\n".
  115. "<form method=\"post\" action=\"".api_get_self()."\">\n".
  116. "<input type=\"hidden\" name=\"id\" value=\"$id\">\n".
  117. "Image : ".Display::return_icon($image)."\n".
  118. "</td>\n".
  119. "<td>\n".
  120. "<select name=\"image\">\n".
  121. "<option selected>".$image."</option>\n";
  122. if ($dir = @opendir($chemin)) {
  123. while ($file = readdir($dir)) {
  124. if ($file == '..' || $file == '.') {
  125. unset($file);
  126. }
  127. $content .= "<option>".$file."</option>\n";
  128. }
  129. closedir($dir);
  130. }
  131. $content .= "</select>\n".
  132. "</td>\n".
  133. "</tr>\n".
  134. "<tr>\n".
  135. "<td>".get_lang('NameOfTheLink')." : </td>\n".
  136. "<td><input type=\"text\" name=\"name\" value=\"".$name."\"></td>\n".
  137. "</tr>\n".
  138. "<tr>\n".
  139. "<td>Lien :</td>\n".
  140. "<td><input type=\"text\" name=\"link\" value=\"".$link."\"></td>\n".
  141. "</tr>\n".
  142. "<tr>\n".
  143. "<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"".get_lang('Ok')."\"></td>\n".
  144. "</tr>\n".
  145. "</form>\n".
  146. "</table>\n".
  147. "</td>\n".
  148. "</tr>\n";
  149. }
  150. }
  151. // Work with data post askable by admin of course
  152. if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  153. // Show message to confirm that a tools must be hide from aivailable tools
  154. // visibility 0,1->2
  155. if ($askDelete) {
  156. $content .= "<table align=\"center\"><tr><td colspan=\"4\">
  157. <br /><br /><font color=\"#ff0000\">&nbsp;&nbsp;&nbsp;<strong>".get_lang('DelLk')."</strong>
  158. <br />&nbsp;&nbsp;&nbsp;
  159. <a href=\"".api_get_self()."\">".get_lang('No')."</a>
  160. &nbsp;|&nbsp;
  161. <a href=\"".api_get_self()."?delete=yes&amp;id=$id\">".get_lang('Yes')."</a>
  162. </font>
  163. <br /><br /><br />
  164. </td>
  165. </tr>
  166. </table>\n";
  167. } elseif (isset($delete) && $delete) {
  168. // if remove
  169. /*
  170. * Process hiding a tools from aivailable tools.
  171. * visibility=2 are only viewed by Dokeos Administrator visibility 0,1->2
  172. */
  173. Database::query("DELETE FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id = $id AND added_tool=1");
  174. }
  175. }
  176. $content .= "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
  177. /* TOOLS FOR EVERYBODY */
  178. $content .= "<tr>\n<td colspan=\"6\">&nbsp;</td>\n</tr>\n";
  179. $content .= "<tr>\n<td colspan=\"6\">";
  180. $content .= CourseHome::show_tool_3column('Basic');
  181. $content .= CourseHome::show_tool_3column('External');
  182. $content .= "</td>\n</tr>\n";
  183. /* PROF ONLY VIEW */
  184. if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  185. $content .= "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n".
  186. "<tr><td colspan=\"6\"><font color=\"#F66105\">\n".get_lang('CourseAdminOnly')."</font>
  187. </td></tr>\n";
  188. $content .= "<tr>\n<td colspan=\"6\">";
  189. $content .= CourseHome::show_tool_3column('courseAdmin');
  190. $content .= "</td>\n</tr>\n";
  191. }
  192. /* TOOLS FOR PLATFORM ADMIN ONLY */
  193. if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  194. $content .= "<tr>"."<td colspan=\"6\">".
  195. "<hr noshade size=\"1\" />".
  196. "</td>"."</tr>\n".
  197. "<tr>\n"."<td colspan=\"6\">\n".
  198. "<font color=\"#F66105\" >".get_lang('PlatformAdminOnly')."</font>\n".
  199. "</td>\n"."</tr>\n";
  200. $content .= "<tr>\n<td colspan=\"6\">";
  201. $content .= CourseHome::show_tool_3column('platformAdmin');
  202. $content .= "</td>\n</tr>\n";
  203. }
  204. $content .= "</table>\n";