3column.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <?php
  2. // $Id: 3column.php,v 1.2 2006/08/10 14:26:12 pcool Exp $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2004-2005 Dokeos S.A.
  7. Copyright (c) 2003 Ghent University
  8. Copyright (c) 2001 Universite Catholique de Louvain
  9. Copyright (c) various contributors
  10. Copyright (c) Bart Mollet, Hogeschool Gent
  11. For a full list of contributors, see "credits.txt".
  12. The full license can be read in "license.txt".
  13. This program is free software; you can redistribute it and/or
  14. modify it under the terms of the GNU General Public License
  15. as published by the Free Software Foundation; either version 2
  16. of the License, or (at your option) any later version.
  17. See the GNU General Public License for more details.
  18. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  19. Mail: info@dokeos.com
  20. ==============================================================================
  21. */
  22. /**
  23. ==============================================================================
  24. * HOME PAGE FOR EACH COURSE (BASIC TOOLS FIXED)
  25. *
  26. * This page, included in every course's index.php is the home
  27. * page.To make administration simple, the professor edits his
  28. * course from it's home page. Only the login detects that the
  29. * visitor is allowed to activate, deactivate home page links,
  30. * access to Professor's tools (statistics, edit forums...).
  31. *
  32. * @package dokeos.course_home
  33. ==============================================================================
  34. */
  35. $hide = isset($_GET['hide']) && $_GET['hide'] == 'yes' ? 'yes' : null;
  36. $restore = isset($_GET['restore']) && $_GET['restore'] == 'yes' ? 'yes' : null;
  37. $id = isset($_GET['id']) ? intval($_GET['id']) : null;
  38. include('../../main/course_home/btf_functions.php'); // RH: extra ../
  39. $is_AllowedToEdit = is_allowed_to_edit(); // RH: Allowed is not allowed...
  40. $TABLE_TOOLS = Database::get_main_table(TABLE_MAIN_COURSE_MODULE);
  41. $TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
  42. // WORK with data post askable by admin of course
  43. if (is_allowed_to_edit())
  44. {
  45. /* Work request */
  46. /*> > > > > > > > > > > > MODIFY HOME PAGE < < < < < < < < < < < <*/
  47. /*
  48. * Edit visibility of tools
  49. *
  50. * visibility = 1 - everybody
  51. * visibility = 0 - prof and admin
  52. * visibility = 2 - admin
  53. *
  54. * Who can change visibility ?
  55. *
  56. * admin = 0 - prof and admin
  57. * admin = 1 - admin
  58. *
  59. * Show message to confirm that a tools must be hide from aivailable tools
  60. *
  61. * visibility 0,1->2 - $remove
  62. *
  63. * Process hiding a tools from aivailable tools.
  64. *
  65. * visibility=2 are only view by Dokeos
  66. * Administrator visibility 0,1->2 - $destroy
  67. *
  68. * visibility 1 -> 0 - $hide / $restore
  69. */
  70. /*
  71. * diplay message to confirm that a tools must be hide from aivailable tools
  72. * (visibility 0,1->2)
  73. */
  74. if($remove)
  75. {
  76. $sql = "SELECT * FROM $TBL_ACCUEIL WHERE id=$id";
  77. $result = Database::query($sql,__FILE__,__LINE__);
  78. $toolsRow = Database::fetch_array($result);
  79. $tool_name = htmlspecialchars($toolsRow['name'] != "" ? $toolsRow['name'] : $toolsRow['link'],ENT_QUOTES,$charset);
  80. if($toolsRow['img'] != "external.gif")
  81. {
  82. $toolsRow['link']=api_get_path(WEB_CODE_PATH).$toolsRow['link'];
  83. }
  84. $toolsRow['image']=api_get_path(WEB_CODE_PATH)."img/".$toolsRow['image'];
  85. echo "<br><br><br>\n";
  86. echo "<table class=\"message\" width=\"70%\" align=\"center\">\n",
  87. "<tr><td width=\"7%\" align=\"center\">\n",
  88. "<a href=\"".$toolsRow['link']."\">".Display::return_icon($toolsRow['image'], get_lang('Delete')),"</a></td>\n",
  89. "<td width=\"28%\" height=\"45\"><small>\n",
  90. "<a href=\"".$toolsRow['link']."\">".$tool_name."</a></small></td>\n";
  91. echo "<td align=\"center\">\n",
  92. "<font color=\"#ff0000\">",
  93. "&nbsp;&nbsp;&nbsp;",
  94. "<strong>",get_lang('DelLk'),"</strong>",
  95. "<br>&nbsp;&nbsp;&nbsp;\n",
  96. "<a href=\"".api_get_self()."\">",get_lang('No'),"</a>\n",
  97. "&nbsp;|&nbsp;\n",
  98. "<a href=\"".api_get_self()."?destroy=yes&amp;id=$id\">",get_lang('Yes'),"</a>\n",
  99. "</font></td></tr>\n",
  100. "</table>\n";
  101. echo "<br><br><br>\n";
  102. } // if remove
  103. /*
  104. * Process hiding a tools from aivailable tools.
  105. * visibility=2 are only view by Dokeos Administrator (visibility 0,1->2)
  106. */
  107. elseif ($destroy)
  108. {
  109. Database::query("UPDATE $TBL_ACCUEIL SET visibility='2' WHERE id=$id");
  110. }
  111. /*--------------------------------------
  112. HIDE
  113. --------------------------------------*/
  114. elseif ($hide) // visibility 1 -> 0
  115. {
  116. Database::query("UPDATE $TBL_ACCUEIL SET visibility=0 WHERE id=$id");
  117. Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
  118. }
  119. /*--------------------------------------
  120. REACTIVATE
  121. --------------------------------------*/
  122. elseif ($restore) // visibility 0,2 -> 1
  123. {
  124. Database::query("UPDATE $TBL_ACCUEIL SET visibility=1 WHERE id=$id");
  125. Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
  126. }
  127. /*
  128. * editing "apparance" of a tools on the course Home Page.
  129. */
  130. elseif (isset ($update) && $update)
  131. {
  132. $result = Database::query("SELECT * FROM $TBL_ACCUEIL WHERE id=$id");
  133. $toolsRow = Database::fetch_array($result);
  134. $racine = $_configuration['root_sys']."/".$currentCourseID."/images/";
  135. $chemin = $racine;
  136. $name = $toolsRow[1];
  137. $image = $toolsRow[3];
  138. echo "<tr>\n",
  139. "<td colspan=\"4\">\n",
  140. "<table>\n",
  141. "<tr>\n",
  142. "<td>\n",
  143. "<form method=\"post\" action=\"".api_get_self()."\">\n",
  144. "<input type=\"hidden\" name=\"id\" value=\"$id\">\n",
  145. "Image : ".Display::return_icon($image)."\n",
  146. "</td>\n",
  147. "<td>\n",
  148. "<select name=\"image\">\n",
  149. "<option selected>",$image,"</option>\n";
  150. if ($dir = @opendir($chemin))
  151. {
  152. while($file = readdir($dir))
  153. {
  154. if($file==".." OR $file==".")
  155. {
  156. unset($file);
  157. }
  158. echo "<option>",$file,"</option>\n";
  159. }
  160. closedir($dir);
  161. }
  162. echo "</select>\n",
  163. "</td>\n",
  164. "</tr>\n",
  165. "<tr>\n",
  166. "<td>",get_lang('NameOfTheLink')," : </td>\n",
  167. "<td><input type=\"text\" name=\"name\" value=\"",$name,"\"></td>\n",
  168. "</tr>\n",
  169. "<tr>\n",
  170. "<td>Lien :</td>\n",
  171. "<td><input type=\"text\" name=\"link\" value=\"",$link,"\"></td>\n",
  172. "</tr>\n",
  173. "<tr>\n",
  174. "<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"",get_lang('Ok'),"\"></td>\n",
  175. "</tr>\n",
  176. "</form>\n",
  177. "</table>\n",
  178. "</td>\n",
  179. "</tr>\n";
  180. }
  181. }
  182. // work with data post askable by admin of course
  183. if ($is_platformAdmin and is_allowed_to_edit())
  184. {
  185. // Show message to confirm that a tools must be hide from aivailable tools
  186. // visibility 0,1->2
  187. if($askDelete)
  188. {
  189. echo "<table align=\"center\"><tr>\n",
  190. "<td colspan=\"4\">\n",
  191. "<br><br>\n",
  192. "<font color=\"#ff0000\">",
  193. "&nbsp;&nbsp;&nbsp;",
  194. "<strong>",get_lang('DelLk'),"</strong>",
  195. "<br>&nbsp;&nbsp;&nbsp;\n",
  196. "<a href=\"".api_get_self()."\">",get_lang('No'),"</a>\n",
  197. "&nbsp;|&nbsp;\n",
  198. "<a href=\"".api_get_self()."?delete=yes&amp;id=$id\">",get_lang('Yes'),"</a>\n",
  199. "</font>\n",
  200. "<br><br><br>\n",
  201. "</td>\n",
  202. "</tr>",
  203. "</table>\n";
  204. } // if remove
  205. /*
  206. * Process hiding a tools from aivailable tools.
  207. * visibility=2 are only viewed by Dokeos Administrator visibility 0,1->2
  208. */
  209. elseif (isset($delete) && $delete)
  210. {
  211. Database::query("DELETE FROM $TBL_ACCUEIL WHERE id=$id AND added_tool=1");
  212. }
  213. }
  214. echo "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
  215. /*==========================
  216. TOOLS FOR EVERYBODY
  217. ==========================*/
  218. echo "<tr>\n<td colspan=\"6\">&nbsp;</td>\n</tr>\n";
  219. echo "<tr>\n<td colspan=\"6\">";
  220. showtools2('Basic');
  221. showtools2('External');
  222. echo "</td>\n</tr>\n";
  223. /*==========================
  224. PROF ONLY VIEW
  225. ==========================*/
  226. if (is_allowed_to_edit())
  227. {
  228. echo "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n",
  229. "<tr>\n","<td colspan=\"6\">\n",
  230. "<font color=\"#F66105\">\n",get_lang('CourseAdminOnly'),"</font>\n",
  231. "</td>\n","</tr>\n";
  232. echo "<tr>\n<td colspan=\"6\">";
  233. showtools2('courseAdmin');
  234. echo "</td>\n</tr>\n";
  235. }
  236. /*--------------------------------------
  237. TOOLS FOR PLATFORM ADMIN ONLY
  238. --------------------------------------*/
  239. if ($is_platformAdmin and is_allowed_to_edit())
  240. {
  241. echo "<tr>","<td colspan=\"6\">",
  242. "<hr noshade size=\"1\" />",
  243. "</td>","</tr>\n",
  244. "<tr>\n","<td colspan=\"6\">\n",
  245. "<font color=\"#F66105\" >",get_lang('PlatformAdminOnly'),"</font>\n",
  246. "</td>\n","</tr>\n";
  247. echo "<tr>\n<td colspan=\"6\">";
  248. showtools2('platformAdmin');
  249. echo "</td>\n</tr>\n";
  250. }
  251. echo "</table>\n";
  252. ?>