3column.php 7.1 KB

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