3column.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. $TABLE_TOOLS = Database::get_main_table(TABLE_MAIN_COURSE_MODULE);
  40. $TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
  41. // WORK with data post askable by admin of course
  42. if (api_is_allowed_to_edit(null,true))
  43. {
  44. /* Work request */
  45. /*> > > > > > > > > > > > MODIFY HOME PAGE < < < < < < < < < < < <*/
  46. /*
  47. * Edit visibility of tools
  48. *
  49. * visibility = 1 - everybody
  50. * visibility = 0 - prof and admin
  51. * visibility = 2 - admin
  52. *
  53. * Who can change visibility ?
  54. *
  55. * admin = 0 - prof and admin
  56. * admin = 1 - admin
  57. *
  58. * Show message to confirm that a tools must be hide from aivailable tools
  59. *
  60. * visibility 0,1->2 - $remove
  61. *
  62. * Process hiding a tools from aivailable tools.
  63. *
  64. * visibility=2 are only view by Dokeos
  65. * Administrator visibility 0,1->2 - $destroy
  66. *
  67. * visibility 1 -> 0 - $hide / $restore
  68. */
  69. /*
  70. * diplay message to confirm that a tools must be hide from aivailable tools
  71. * (visibility 0,1->2)
  72. */
  73. if($remove)
  74. {
  75. $sql = "SELECT * FROM $TBL_ACCUEIL WHERE id=$id";
  76. $result = Database::query($sql,__FILE__,__LINE__);
  77. $toolsRow = Database::fetch_array($result);
  78. $tool_name = htmlspecialchars($toolsRow['name'] != "" ? $toolsRow['name'] : $toolsRow['link'],ENT_QUOTES,$charset);
  79. if($toolsRow['img'] != "external.gif")
  80. {
  81. $toolsRow['link']=api_get_path(WEB_CODE_PATH).$toolsRow['link'];
  82. }
  83. $toolsRow['image']=api_get_path(WEB_CODE_PATH)."img/".$toolsRow['image'];
  84. echo "<br><br><br>\n";
  85. echo "<table class=\"message\" width=\"70%\" align=\"center\">\n",
  86. "<tr><td width=\"7%\" align=\"center\">\n",
  87. "<a href=\"".$toolsRow['link']."\">".Display::return_icon($toolsRow['image'], get_lang('Delete')),"</a></td>\n",
  88. "<td width=\"28%\" height=\"45\"><small>\n",
  89. "<a href=\"".$toolsRow['link']."\">".$tool_name."</a></small></td>\n";
  90. echo "<td align=\"center\">\n",
  91. "<font color=\"#ff0000\">",
  92. "&nbsp;&nbsp;&nbsp;",
  93. "<strong>",get_lang('DelLk'),"</strong>",
  94. "<br>&nbsp;&nbsp;&nbsp;\n",
  95. "<a href=\"".api_get_self()."\">",get_lang('No'),"</a>\n",
  96. "&nbsp;|&nbsp;\n",
  97. "<a href=\"".api_get_self()."?destroy=yes&amp;id=$id\">",get_lang('Yes'),"</a>\n",
  98. "</font></td></tr>\n",
  99. "</table>\n";
  100. echo "<br><br><br>\n";
  101. } // if remove
  102. /*
  103. * Process hiding a tools from aivailable tools.
  104. * visibility=2 are only view by Dokeos Administrator (visibility 0,1->2)
  105. */
  106. elseif ($destroy)
  107. {
  108. Database::query("UPDATE $TBL_ACCUEIL SET visibility='2' WHERE id=$id");
  109. }
  110. /*--------------------------------------
  111. HIDE
  112. --------------------------------------*/
  113. elseif ($hide) // visibility 1 -> 0
  114. {
  115. Database::query("UPDATE $TBL_ACCUEIL SET visibility=0 WHERE id=$id");
  116. Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
  117. }
  118. /*--------------------------------------
  119. REACTIVATE
  120. --------------------------------------*/
  121. elseif ($restore) // visibility 0,2 -> 1
  122. {
  123. Database::query("UPDATE $TBL_ACCUEIL SET visibility=1 WHERE id=$id");
  124. Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
  125. }
  126. /*
  127. * editing "apparance" of a tools on the course Home Page.
  128. */
  129. elseif (isset ($update) && $update)
  130. {
  131. $result = Database::query("SELECT * FROM $TBL_ACCUEIL WHERE id=$id");
  132. $toolsRow = Database::fetch_array($result);
  133. $racine = $_configuration['root_sys']."/".$currentCourseID."/images/";
  134. $chemin = $racine;
  135. $name = $toolsRow[1];
  136. $image = $toolsRow[3];
  137. echo "<tr>\n",
  138. "<td colspan=\"4\">\n",
  139. "<table>\n",
  140. "<tr>\n",
  141. "<td>\n",
  142. "<form method=\"post\" action=\"".api_get_self()."\">\n",
  143. "<input type=\"hidden\" name=\"id\" value=\"$id\">\n",
  144. "Image : ".Display::return_icon($image)."\n",
  145. "</td>\n",
  146. "<td>\n",
  147. "<select name=\"image\">\n",
  148. "<option selected>",$image,"</option>\n";
  149. if ($dir = @opendir($chemin))
  150. {
  151. while($file = readdir($dir))
  152. {
  153. if($file==".." OR $file==".")
  154. {
  155. unset($file);
  156. }
  157. echo "<option>",$file,"</option>\n";
  158. }
  159. closedir($dir);
  160. }
  161. echo "</select>\n",
  162. "</td>\n",
  163. "</tr>\n",
  164. "<tr>\n",
  165. "<td>",get_lang('NameOfTheLink')," : </td>\n",
  166. "<td><input type=\"text\" name=\"name\" value=\"",$name,"\"></td>\n",
  167. "</tr>\n",
  168. "<tr>\n",
  169. "<td>Lien :</td>\n",
  170. "<td><input type=\"text\" name=\"link\" value=\"",$link,"\"></td>\n",
  171. "</tr>\n",
  172. "<tr>\n",
  173. "<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"",get_lang('Ok'),"\"></td>\n",
  174. "</tr>\n",
  175. "</form>\n",
  176. "</table>\n",
  177. "</td>\n",
  178. "</tr>\n";
  179. }
  180. }
  181. // work with data post askable by admin of course
  182. if ($is_platformAdmin && api_is_allowed_to_edit(null,true) && !api_is_coach())
  183. {
  184. // Show message to confirm that a tools must be hide from aivailable tools
  185. // visibility 0,1->2
  186. if($askDelete)
  187. {
  188. echo "<table align=\"center\"><tr>\n",
  189. "<td colspan=\"4\">\n",
  190. "<br><br>\n",
  191. "<font color=\"#ff0000\">",
  192. "&nbsp;&nbsp;&nbsp;",
  193. "<strong>",get_lang('DelLk'),"</strong>",
  194. "<br>&nbsp;&nbsp;&nbsp;\n",
  195. "<a href=\"".api_get_self()."\">",get_lang('No'),"</a>\n",
  196. "&nbsp;|&nbsp;\n",
  197. "<a href=\"".api_get_self()."?delete=yes&amp;id=$id\">",get_lang('Yes'),"</a>\n",
  198. "</font>\n",
  199. "<br><br><br>\n",
  200. "</td>\n",
  201. "</tr>",
  202. "</table>\n";
  203. } // if remove
  204. /*
  205. * Process hiding a tools from aivailable tools.
  206. * visibility=2 are only viewed by Dokeos Administrator visibility 0,1->2
  207. */
  208. elseif (isset($delete) && $delete)
  209. {
  210. Database::query("DELETE FROM $TBL_ACCUEIL WHERE id=$id AND added_tool=1");
  211. }
  212. }
  213. echo "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
  214. /*==========================
  215. TOOLS FOR EVERYBODY
  216. ==========================*/
  217. echo "<tr>\n<td colspan=\"6\">&nbsp;</td>\n</tr>\n";
  218. echo "<tr>\n<td colspan=\"6\">";
  219. showtools2('Basic');
  220. showtools2('External');
  221. echo "</td>\n</tr>\n";
  222. /*==========================
  223. PROF ONLY VIEW
  224. ==========================*/
  225. if (api_is_allowed_to_edit(null,true) && !api_is_coach())
  226. {
  227. echo "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n",
  228. "<tr>\n","<td colspan=\"6\">\n",
  229. "<font color=\"#F66105\">\n",get_lang('CourseAdminOnly'),"</font>\n",
  230. "</td>\n","</tr>\n";
  231. echo "<tr>\n<td colspan=\"6\">";
  232. showtools2('courseAdmin');
  233. echo "</td>\n</tr>\n";
  234. }
  235. /*--------------------------------------
  236. TOOLS FOR PLATFORM ADMIN ONLY
  237. --------------------------------------*/
  238. if ($is_platformAdmin && api_is_allowed_to_edit(null,true) && !api_is_coach())
  239. {
  240. echo "<tr>","<td colspan=\"6\">",
  241. "<hr noshade size=\"1\" />",
  242. "</td>","</tr>\n",
  243. "<tr>\n","<td colspan=\"6\">\n",
  244. "<font color=\"#F66105\" >",get_lang('PlatformAdminOnly'),"</font>\n",
  245. "</td>\n","</tr>\n";
  246. echo "<tr>\n<td colspan=\"6\">";
  247. showtools2('platformAdmin');
  248. echo "</td>\n</tr>\n";
  249. }
  250. echo "</table>\n";
  251. ?>