3column.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <?php
  2. /* For licensing terms, see /chamilo_license.txt */
  3. /**
  4. ==============================================================================
  5. * HOME PAGE FOR EACH COURSE (BASIC TOOLS FIXED)
  6. *
  7. * This page, included in every course's index.php is the home
  8. * page.To make administration simple, the professor edits his
  9. * course from it's home page. Only the login detects that the
  10. * visitor is allowed to activate, deactivate home page links,
  11. * access to Professor's tools (statistics, edit forums...).
  12. *
  13. * @package dokeos.course_home
  14. ==============================================================================
  15. */
  16. require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
  17. $hide = isset($_GET['hide']) && $_GET['hide'] == 'yes' ? 'yes' : null;
  18. $restore = isset($_GET['restore']) && $_GET['restore'] == 'yes' ? 'yes' : null;
  19. $id = isset($_GET['id']) ? intval($_GET['id']) : null;
  20. $TABLE_TOOLS = Database::get_main_table(TABLE_MAIN_COURSE_MODULE);
  21. $TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
  22. // WORK with data post askable by admin of course
  23. if (api_is_allowed_to_edit(null,true)) {
  24. /* Work 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. {
  55. $sql = "SELECT * FROM $TBL_ACCUEIL WHERE id=$id";
  56. $result = Database::query($sql);
  57. $toolsRow = Database::fetch_array($result);
  58. $tool_name = htmlspecialchars($toolsRow['name'] != "" ? $toolsRow['name'] : $toolsRow['link'],ENT_QUOTES,$charset);
  59. if($toolsRow['img'] != "external.gif")
  60. {
  61. $toolsRow['link']=api_get_path(WEB_CODE_PATH).$toolsRow['link'];
  62. }
  63. $toolsRow['image']=api_get_path(WEB_CODE_PATH)."img/".$toolsRow['image'];
  64. echo "<br><br><br>\n";
  65. echo "<table class=\"message\" width=\"70%\" align=\"center\">\n",
  66. "<tr><td width=\"7%\" align=\"center\">\n",
  67. "<a href=\"".$toolsRow['link']."\">".Display::return_icon($toolsRow['image'], get_lang('Delete')),"</a></td>\n",
  68. "<td width=\"28%\" height=\"45\"><small>\n",
  69. "<a href=\"".$toolsRow['link']."\">".$tool_name."</a></small></td>\n";
  70. echo "<td align=\"center\">\n",
  71. "<font color=\"#ff0000\">",
  72. "&nbsp;&nbsp;&nbsp;",
  73. "<strong>",get_lang('DelLk'),"</strong>",
  74. "<br>&nbsp;&nbsp;&nbsp;\n",
  75. "<a href=\"".api_get_self()."\">",get_lang('No'),"</a>\n",
  76. "&nbsp;|&nbsp;\n",
  77. "<a href=\"".api_get_self()."?destroy=yes&amp;id=$id\">",get_lang('Yes'),"</a>\n",
  78. "</font></td></tr>\n",
  79. "</table>\n";
  80. echo "<br><br><br>\n";
  81. } // if remove
  82. /*
  83. * Process hiding a tools from aivailable tools.
  84. * visibility=2 are only view by Dokeos Administrator (visibility 0,1->2)
  85. */
  86. elseif ($destroy)
  87. {
  88. Database::query("UPDATE $TBL_ACCUEIL SET visibility='2' WHERE id=$id");
  89. }
  90. /*--------------------------------------
  91. HIDE
  92. --------------------------------------*/
  93. elseif ($hide) // visibility 1 -> 0
  94. {
  95. Database::query("UPDATE $TBL_ACCUEIL SET visibility=0 WHERE id=$id");
  96. Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
  97. }
  98. /*--------------------------------------
  99. REACTIVATE
  100. --------------------------------------*/
  101. elseif ($restore) // visibility 0,2 -> 1
  102. {
  103. Database::query("UPDATE $TBL_ACCUEIL SET visibility=1 WHERE id=$id");
  104. Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
  105. }
  106. /*
  107. * editing "apparance" of a tools on the course Home Page.
  108. */
  109. elseif (isset ($update) && $update)
  110. {
  111. $result = Database::query("SELECT * FROM $TBL_ACCUEIL WHERE id=$id");
  112. $toolsRow = Database::fetch_array($result);
  113. $racine = $_configuration['root_sys']."/".$currentCourseID."/images/";
  114. $chemin = $racine;
  115. $name = $toolsRow[1];
  116. $image = $toolsRow[3];
  117. echo "<tr>\n",
  118. "<td colspan=\"4\">\n",
  119. "<table>\n",
  120. "<tr>\n",
  121. "<td>\n",
  122. "<form method=\"post\" action=\"".api_get_self()."\">\n",
  123. "<input type=\"hidden\" name=\"id\" value=\"$id\">\n",
  124. "Image : ".Display::return_icon($image)."\n",
  125. "</td>\n",
  126. "<td>\n",
  127. "<select name=\"image\">\n",
  128. "<option selected>",$image,"</option>\n";
  129. if ($dir = @opendir($chemin))
  130. {
  131. while($file = readdir($dir))
  132. {
  133. if($file==".." OR $file==".")
  134. {
  135. unset($file);
  136. }
  137. echo "<option>",$file,"</option>\n";
  138. }
  139. closedir($dir);
  140. }
  141. echo "</select>\n",
  142. "</td>\n",
  143. "</tr>\n",
  144. "<tr>\n",
  145. "<td>",get_lang('NameOfTheLink')," : </td>\n",
  146. "<td><input type=\"text\" name=\"name\" value=\"",$name,"\"></td>\n",
  147. "</tr>\n",
  148. "<tr>\n",
  149. "<td>Lien :</td>\n",
  150. "<td><input type=\"text\" name=\"link\" value=\"",$link,"\"></td>\n",
  151. "</tr>\n",
  152. "<tr>\n",
  153. "<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"",get_lang('Ok'),"\"></td>\n",
  154. "</tr>\n",
  155. "</form>\n",
  156. "</table>\n",
  157. "</td>\n",
  158. "</tr>\n";
  159. }
  160. }
  161. // work with data post askable by admin of course
  162. if ($is_platformAdmin && api_is_allowed_to_edit(null,true) && !api_is_coach())
  163. {
  164. // Show message to confirm that a tools must be hide from aivailable tools
  165. // visibility 0,1->2
  166. if($askDelete)
  167. {
  168. echo "<table align=\"center\"><tr>\n",
  169. "<td colspan=\"4\">\n",
  170. "<br><br>\n",
  171. "<font color=\"#ff0000\">",
  172. "&nbsp;&nbsp;&nbsp;",
  173. "<strong>",get_lang('DelLk'),"</strong>",
  174. "<br>&nbsp;&nbsp;&nbsp;\n",
  175. "<a href=\"".api_get_self()."\">",get_lang('No'),"</a>\n",
  176. "&nbsp;|&nbsp;\n",
  177. "<a href=\"".api_get_self()."?delete=yes&amp;id=$id\">",get_lang('Yes'),"</a>\n",
  178. "</font>\n",
  179. "<br><br><br>\n",
  180. "</td>\n",
  181. "</tr>",
  182. "</table>\n";
  183. } // if remove
  184. /*
  185. * Process hiding a tools from aivailable tools.
  186. * visibility=2 are only viewed by Dokeos Administrator visibility 0,1->2
  187. */
  188. elseif (isset($delete) && $delete)
  189. {
  190. Database::query("DELETE FROM $TBL_ACCUEIL WHERE id=$id AND added_tool=1");
  191. }
  192. }
  193. echo "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
  194. /*==========================
  195. TOOLS FOR EVERYBODY
  196. ==========================*/
  197. echo "<tr>\n<td colspan=\"6\">&nbsp;</td>\n</tr>\n";
  198. echo "<tr>\n<td colspan=\"6\">";
  199. CourseHome::show_tool_3column('Basic');
  200. CourseHome::show_tool_3column('External');
  201. echo "</td>\n</tr>\n";
  202. /*==========================
  203. PROF ONLY VIEW
  204. ==========================*/
  205. if (api_is_allowed_to_edit(null,true) && !api_is_coach()) {
  206. echo "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n",
  207. "<tr>\n","<td colspan=\"6\">\n",
  208. "<font color=\"#F66105\">\n",get_lang('CourseAdminOnly'),"</font>\n",
  209. "</td>\n","</tr>\n";
  210. echo "<tr>\n<td colspan=\"6\">";
  211. CourseHome::show_tool_3column('courseAdmin');
  212. echo "</td>\n</tr>\n";
  213. }
  214. /*--------------------------------------
  215. TOOLS FOR PLATFORM ADMIN ONLY
  216. --------------------------------------*/
  217. if ($is_platformAdmin && api_is_allowed_to_edit(null,true) && !api_is_coach())
  218. {
  219. echo "<tr>","<td colspan=\"6\">",
  220. "<hr noshade size=\"1\" />",
  221. "</td>","</tr>\n",
  222. "<tr>\n","<td colspan=\"6\">\n",
  223. "<font color=\"#F66105\" >",get_lang('PlatformAdminOnly'),"</font>\n",
  224. "</td>\n","</tr>\n";
  225. echo "<tr>\n<td colspan=\"6\">";
  226. CourseHome::show_tool_3column('platformAdmin');
  227. echo "</td>\n</tr>\n";
  228. }
  229. echo "</table>\n";
  230. ?>