3column.php 8.2 KB

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