configure_extensions.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <?php // $Id: configure_homepage.php 9246 2006-09-25 13:24:53 +0000 (lun., 25 sept. 2006) bmol $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. $langFile='admin';
  20. $cidReset=true;
  21. include('../inc/global.inc.php');
  22. $this_section=SECTION_PLATFORM_ADMIN;
  23. api_protect_admin_script();
  24. $tbl_settings_current = Database::get_main_table(MAIN_SETTINGS_CURRENT_TABLE);
  25. $message = '';
  26. if(isset($_POST['activeExtension'])){
  27. switch ($_POST['extension_code']){
  28. case 'visio' :
  29. $sql = 'UPDATE '.$tbl_settings_current.' SET
  30. selected_value="true"
  31. WHERE variable="service_visio"
  32. AND subkey="active"';
  33. $rs = api_sql_query($sql, __FILE__, __LINE__);
  34. if(mysql_affected_rows()>0){
  35. $sql = 'UPDATE '.$tbl_settings_current.' SET
  36. selected_value="'.addslashes($_POST['visio_url']).'"
  37. WHERE variable="service_visio"
  38. AND subkey="url"';
  39. $rs = api_sql_query($sql, __FILE__, __LINE__);
  40. $message = get_lang('ServiceActivated');
  41. }
  42. // select all the courses and insert the tool inside
  43. $sql = 'SELECT db_name FROM '.Database::get_main_table(TABLE_MAIN_COURSE);
  44. $rs = api_sql_query($sql);
  45. while($row = mysql_fetch_array($rs)){
  46. $sql = 'INSERT INTO '.$row['db_name'].'.'.TOOL_LIST_TABLE.' SET
  47. name="visio",
  48. link="conf/",
  49. image="visio.gif",
  50. visibility="1",
  51. admin="0",
  52. address="squaregrey.gif",
  53. target="_self",
  54. category="authoring"';
  55. api_sql_query($sql);
  56. }
  57. break;
  58. case 'ppt2lp' :
  59. $sql = 'UPDATE '.$tbl_settings_current.' SET
  60. selected_value="true"
  61. WHERE variable="service_ppt2lp"
  62. AND subkey="active"';
  63. if(mysql_affected_rows()>0){
  64. $message = get_lang('ServiceActivated');
  65. }
  66. break;
  67. }
  68. }
  69. $listActiveServices = array();
  70. // get the list of active services
  71. $sql = 'SELECT variable FROM '.$tbl_settings_current.' WHERE variable LIKE "service_%" AND subkey="active" and selected_value="true"';
  72. $rs = api_sql_query($sql, __FILE__, __LINE__);
  73. while($row = mysql_fetch_array($rs)){
  74. $listActiveServices[] = $row['variable'];
  75. }
  76. $javascript_service_displayed = '';
  77. if(isset($_GET['display'])){
  78. $javascript_service_displayed = 'document.getElementById("extension_content_'.$_GET['display'].'").style.display = "block"';
  79. }
  80. // javascript to handle accordion behaviour
  81. $javascript_message = '';
  82. if(!empty($message)){
  83. $javascript_message =
  84. '
  85. document.getElementById("message").style.display = "block";
  86. var timer = setTimeout(hideMessage,5000);
  87. ';
  88. }
  89. $htmlHeadXtra[]= '
  90. <script type="text/javascript">
  91. var listeDiv;
  92. var extensionsHeader = new Array();
  93. var extensionsContent = new Array();
  94. window.onload = loadTables;
  95. function loadTables(){
  96. '.$javascript_message.'
  97. var listeDiv = document.getElementsByTagName("div");
  98. // fill extensionsHeader and extensionsContent
  99. for(var i=0 ; i < listeDiv.length ; i++){
  100. if(listeDiv[i].id.indexOf(\'extension_header\')!=-1){
  101. listeDiv[i].onclick = afficheContent;
  102. extensionsHeader.push(listeDiv[i]);
  103. }
  104. if(listeDiv[i].id.indexOf("extension_content")!=-1){
  105. extensionsContent.push(listeDiv[i]);
  106. }
  107. }
  108. '.$javascript_service_displayed.'
  109. }
  110. function hideMessage(){
  111. document.getElementById("message").style.display = "none";
  112. }
  113. function afficheContent(event){
  114. var id = this.id.replace("header","content");
  115. switch(document.getElementById(id).style.display){
  116. case "block" :
  117. document.getElementById(id).style.display = "none";
  118. break;
  119. case "none" :
  120. document.getElementById(id).style.display = "block";
  121. for(var i=0 ; i < extensionsContent.length ; i++){
  122. if(extensionsContent[i].id != id)
  123. extensionsContent[i].style.display = "none";
  124. }
  125. break;
  126. }
  127. }
  128. </script>';
  129. $nameTool = get_lang('ConfigureExtensions');
  130. Display::display_header($nameTool);
  131. ?>
  132. <div id="message" style="display: none">
  133. <?php
  134. if(!empty($message))
  135. Display::display_normal_message($message)
  136. ?>
  137. </div>
  138. <div id="content" align="center">
  139. <!-- INSTRUCTIONS TO ADD AN EXTENSION HERE
  140. - copy paste a "main_*" div
  141. - set the names of the subdiv to extension_header_yourextension and extension_content_yourextension
  142. - extension_content_yourextension is the hidden div where you have to put your form / activation process
  143. - extension_header_yourextension is the name of your extension
  144. - you do not need to add javascript to display / hide your divs
  145. - please fill free to improve the global display of the document
  146. -->
  147. <!-- VISIOCONFERENCE -->
  148. <div id="main_visio">
  149. <div id="extension_header_visio" class="accordion_header">
  150. <a href="#"><?php echo get_lang('Visioconf') ?></a>
  151. </div>
  152. <div id="extension_content_visio" style="display:none" class="accordion_content">
  153. <?php echo get_lang('VisioconfDescription') ?><br /><br />
  154. <table width="100%">
  155. <tr>
  156. <td>
  157. <img src="<?php echo api_get_path(WEB_IMG_PATH).'screenshot_conf.jpg' ?>" />
  158. </td>
  159. <td align="center" width="50%">
  160. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  161. <?php
  162. if(in_array('service_visio',$listActiveServices)){
  163. echo get_lang('ExtensionActivedButNotYetOperational');
  164. }
  165. else {
  166. echo get_lang('URL').' :
  167. <input type="text" size="30" name="visio_url" /><br /><br />
  168. <input type="hidden" name="extension_code" value="visio" />
  169. <input type="submit" name="activeExtension" value="'.get_lang('ActiveExtension').'" />';
  170. }
  171. ?>
  172. </form>
  173. </td>
  174. </tr>
  175. </table>
  176. </div>
  177. </div>
  178. <!-- PPT2LP -->
  179. <div id="main_ppt2lp">
  180. <div id="extension_header_ppt2lp" class="accordion_header">
  181. <a href="#"><?php echo get_lang('Ppt2lp') ?></a>
  182. </div>
  183. <div id="extension_content_ppt2lp" style="display:none" class="accordion_content">
  184. <?php echo get_lang('Ppt2lpDescription') ?><br /><br />
  185. <table width="100%">
  186. <tr>
  187. <td width="50%">
  188. <img src="<?php echo api_get_path(WEB_IMG_PATH).'screenshot_ppt2lp.jpg' ?>" />
  189. </td>
  190. <td align="center" width="50%">
  191. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  192. <?php
  193. if(in_array('ppt2lp',$listActiveServices)){
  194. echo get_lang('ExtensionActivedButNotYetOperational');
  195. }
  196. else {
  197. echo '
  198. <input type="hidden" name="extension_code" value="ppt2lp" />
  199. <input type="submit" name="activeExtension" value="'.get_lang('ActiveExtension').'" />';
  200. }
  201. ?>
  202. </form>
  203. </td>
  204. </tr>
  205. </table>
  206. </div>
  207. </div>
  208. <!-- SEARCH -->
  209. <div id="main_search">
  210. <div id="extension_header_search" class="accordion_header">
  211. <a href="#"><?php echo get_lang('SearchEngine') ?></a>
  212. </div>
  213. <div id="extension_content_search" style="display:none" class="accordion_content">
  214. <?php echo get_lang('SearchEngineDescription') ?><br /><br />
  215. <table width="100%">
  216. <tr>
  217. <td width="50%">
  218. <img src="<?php echo api_get_path(WEB_IMG_PATH).'screenshot_search.jpg' ?>" />
  219. </td>
  220. <td align="center" width="50%">
  221. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  222. <input type="hidden" name="extension_code" value="search" />
  223. <input type="submit" name="activeExtension" value="<?php echo get_lang('ActiveExtension') ?>" />
  224. </form>
  225. </td>
  226. </tr>
  227. </table>
  228. </div>
  229. </div>
  230. <!-- SERVER STATS -->
  231. <div id="main_serverstats">
  232. <div id="extension_header_serverstats" class="accordion_header">
  233. <a href="#"><?php echo get_lang('ServerStatistics') ?></a>
  234. </div>
  235. <div id="extension_content_serverstats" style="display:none" class="accordion_content">
  236. <?php echo get_lang('ServerStatisticsDescription') ?><br /><br />
  237. <table width="100%">
  238. <tr>
  239. <td width="50%">
  240. <img src="<?php echo api_get_path(WEB_IMG_PATH).'screenshot_serverstats.jpg' ?>" />
  241. </td>
  242. <td align="center" width="50%">
  243. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  244. <input type="hidden" name="extension_code" value="serverstats" />
  245. <input type="submit" name="activeExtension" value="<?php echo get_lang('ActiveExtension') ?>" />
  246. </form>
  247. </td>
  248. </tr>
  249. </table>
  250. </div>
  251. </div>
  252. <!-- BANDWIDTH STATS -->
  253. <div id="main_bandwidthstats">
  254. <div id="extension_header_bandwidthstats" class="accordion_header">
  255. <a href="#"><?php echo get_lang('BandWidthStatistics') ?></a>
  256. </div>
  257. <div id="extension_content_bandwidthstats" style="display:none" class="accordion_content">
  258. <?php echo get_lang('BandWidthStatisticsDescription') ?><br /><br />
  259. <table width="100%">
  260. <tr>
  261. <td width="50%">
  262. <img src="<?php echo api_get_path(WEB_IMG_PATH).'screenshot_bandwidth.jpg' ?>" />
  263. </td>
  264. <td align="center" width="50%">
  265. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  266. <input type="hidden" name="extension_code" value="bandwidthstats" />
  267. <input type="submit" name="activeExtension" value="<?php echo get_lang('ActiveExtension') ?>" />
  268. </form>
  269. </td>
  270. </tr>
  271. </table>
  272. </div>
  273. </div>
  274. </div><!-- /content -->
  275. <?php
  276. /*
  277. ==============================================================================
  278. FOOTER
  279. ==============================================================================
  280. */
  281. Display::display_footer();
  282. ?>