configure_extensions.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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_services = Database::get_main_table(MAIN_SETTINGS_SERVICE_TABLE);
  25. $message = '';
  26. if(isset($_POST['activeExtension'])){
  27. switch ($_POST['extension_code']){
  28. case 'visio' :
  29. $sql = 'UPDATE '.$tbl_settings_services.' SET
  30. value="true"
  31. WHERE variable="active"
  32. AND code_service="visio"';
  33. $rs = api_sql_query($sql, __FILE__, __LINE__);
  34. if(mysql_affected_rows()>0){
  35. $message = get_lang('ServiceActivated');
  36. }
  37. // select all the courses and insert the tool inside
  38. $sql = 'SELECT db_name FROM '.Database::get_main_table(MAIN_COURSE_TABLE);
  39. echo $sql;
  40. $rs = api_sql_query($sql);
  41. while($row = mysql_fetch_array($rs)){
  42. $sql = 'INSERT INTO '.$row['db_name'].'.'.TOOL_LIST_TABLE.' SET
  43. name="visio",
  44. link="conf/",
  45. image="",
  46. visibility="1",
  47. admin="0",
  48. address="squaregrey.gif",
  49. target="_self",
  50. category="authoring"';
  51. api_sql_query($sql);
  52. }
  53. break;
  54. case 'ppt2lp' :
  55. $sql = 'UPDATE '.$tbl_settings_services.' SET
  56. value="true"
  57. WHERE variable="active"
  58. AND code_service="ppt2lp"';
  59. $rs = api_sql_query($sql, __FILE__, __LINE__);
  60. if(mysql_affected_rows()>0){
  61. $message = get_lang('ServiceActivated');
  62. }
  63. break;
  64. }
  65. }
  66. $listActiveServices = array();
  67. // get the list of active services
  68. $sql = 'SELECT code_service FROM '.$tbl_settings_services.' WHERE variable="active" and value="true"';
  69. $rs = api_sql_query($sql, __FILE__, __LINE__);
  70. while($row = mysql_fetch_array($rs)){
  71. $listActiveServices[] = $row['code_service'];
  72. }
  73. $javascript_service_displayed = '';
  74. if(isset($_GET['display'])){
  75. $javascript_service_displayed = 'document.getElementById("extension_content_'.$_GET['display'].'").style.display = "block"';
  76. }
  77. // javascript to handle accordion behaviour
  78. $javascript_message = '';
  79. if(!empty($message)){
  80. $javascript_message =
  81. '
  82. document.getElementById("message").style.display = "block";
  83. var timer = setTimeout(hideMessage,5000);
  84. ';
  85. }
  86. $htmlHeadXtra[]= '
  87. <script type="text/javascript">
  88. var listeDiv;
  89. var extensionsHeader = new Array();
  90. var extensionsContent = new Array();
  91. window.onload = loadTables;
  92. function loadTables(){
  93. '.$javascript_message.'
  94. var listeDiv = document.getElementsByTagName("div");
  95. // fill extensionsHeader and extensionsContent
  96. for(var i=0 ; i < listeDiv.length ; i++){
  97. if(listeDiv[i].id.indexOf(\'extension_header\')!=-1){
  98. listeDiv[i].onclick = afficheContent;
  99. extensionsHeader.push(listeDiv[i]);
  100. }
  101. if(listeDiv[i].id.indexOf("extension_content")!=-1){
  102. extensionsContent.push(listeDiv[i]);
  103. }
  104. }
  105. '.$javascript_service_displayed.'
  106. }
  107. function hideMessage(){
  108. document.getElementById("message").style.display = "none";
  109. }
  110. function afficheContent(event){
  111. var id = this.id.replace("header","content");
  112. switch(document.getElementById(id).style.display){
  113. case "block" :
  114. document.getElementById(id).style.display = "none";
  115. break;
  116. case "none" :
  117. document.getElementById(id).style.display = "block";
  118. for(var i=0 ; i < extensionsContent.length ; i++){
  119. if(extensionsContent[i].id != id)
  120. extensionsContent[i].style.display = "none";
  121. }
  122. break;
  123. }
  124. }
  125. </script>';
  126. $nameTool = get_lang('ConfigureExtensions');
  127. Display::display_header($nameTool);
  128. ?>
  129. <div id="message" style="display: none">
  130. <?php
  131. if(!empty($message))
  132. Display::display_normal_message($message)
  133. ?>
  134. </div>
  135. <div id="content" align="center">
  136. <!-- INSTRUCTIONS TO ADD AN EXTENSION HERE
  137. - copy paste a "main_*" div
  138. - set the names of the subdiv to extension_header_yourextension and extension_content_yourextension
  139. - extension_content_yourextension is the hidden div where you have to put your form / activation process
  140. - extension_header_yourextension is the name of your extension
  141. - you do not need to add javascript to display / hide your divs
  142. - please fill free to improve the global display of the document
  143. -->
  144. <!-- VISIOCONFERENCE -->
  145. <div id="main_visio">
  146. <div id="extension_header_visio" class="accordion_header">
  147. <a href="#"><?php echo get_lang('Visioconf') ?></a>
  148. </div>
  149. <div id="extension_content_visio" style="display:none" class="accordion_content">
  150. <?php echo get_lang('VisioconfDescription') ?><br /><br />
  151. <table width="100%">
  152. <tr>
  153. <td>
  154. <img src="<?php echo api_get_path(WEB_IMG_PATH).'screenshot_conf.jpg' ?>" />
  155. </td>
  156. <td align="center" width="50%">
  157. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  158. <?php
  159. if(in_array('visio',$listActiveServices)){
  160. echo get_lang('ExtensionActivedButNotYetOperational');
  161. }
  162. else {
  163. echo '
  164. <input type="hidden" name="extension_code" value="visio" />
  165. <input type="submit" name="activeExtension" value="'.get_lang('ActiveExtension').'" />';
  166. }
  167. ?>
  168. </form>
  169. </td>
  170. </tr>
  171. </table>
  172. </div>
  173. </div>
  174. <!-- PPT2LP -->
  175. <div id="main_ppt2lp">
  176. <div id="extension_header_ppt2lp" class="accordion_header">
  177. <a href="#"><?php echo get_lang('Ppt2lp') ?></a>
  178. </div>
  179. <div id="extension_content_ppt2lp" style="display:none" class="accordion_content">
  180. <?php echo get_lang('Ppt2lpDescription') ?><br /><br />
  181. <table width="100%">
  182. <tr>
  183. <td width="50%">
  184. <img src="<?php echo api_get_path(WEB_IMG_PATH).'screenshot_ppt2lp.jpg' ?>" />
  185. </td>
  186. <td align="center" width="50%">
  187. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  188. <?php
  189. if(in_array('ppt2lp',$listActiveServices)){
  190. echo get_lang('ExtensionActivedButNotYetOperational');
  191. }
  192. else {
  193. echo '
  194. <input type="hidden" name="extension_code" value="ppt2lp" />
  195. <input type="submit" name="activeExtension" value="'.get_lang('ActiveExtension').'" />';
  196. }
  197. ?>
  198. </form>
  199. </td>
  200. </tr>
  201. </table>
  202. </div>
  203. </div>
  204. <!-- SEARCH -->
  205. <div id="main_search">
  206. <div id="extension_header_search" class="accordion_header">
  207. <a href="#"><?php echo get_lang('SearchEngine') ?></a>
  208. </div>
  209. <div id="extension_content_search" style="display:none" class="accordion_content">
  210. <?php echo get_lang('SearchEngineDescription') ?><br /><br />
  211. <table width="100%">
  212. <tr>
  213. <td width="50%">
  214. <img src="<?php echo api_get_path(WEB_IMG_PATH).'screenshot_search.jpg' ?>" />
  215. </td>
  216. <td align="center" width="50%">
  217. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  218. <input type="hidden" name="extension_code" value="search" />
  219. <input type="submit" name="activeExtension" value="<?php echo get_lang('ActiveExtension') ?>" />
  220. </form>
  221. </td>
  222. </tr>
  223. </table>
  224. </div>
  225. </div>
  226. <!-- SERVER STATS -->
  227. <div id="main_serverstats">
  228. <div id="extension_header_serverstats" class="accordion_header">
  229. <a href="#"><?php echo get_lang('ServerStatistics') ?></a>
  230. </div>
  231. <div id="extension_content_serverstats" style="display:none" class="accordion_content">
  232. <?php echo get_lang('ServerStatisticsDescription') ?><br /><br />
  233. <table width="100%">
  234. <tr>
  235. <td width="50%">
  236. <img src="<?php echo api_get_path(WEB_IMG_PATH).'screenshot_serverstats.jpg' ?>" />
  237. </td>
  238. <td align="center" width="50%">
  239. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  240. <input type="hidden" name="extension_code" value="serverstats" />
  241. <input type="submit" name="activeExtension" value="<?php echo get_lang('ActiveExtension') ?>" />
  242. </form>
  243. </td>
  244. </tr>
  245. </table>
  246. </div>
  247. </div>
  248. <!-- BANDWIDTH STATS -->
  249. <div id="main_bandwidthstats">
  250. <div id="extension_header_bandwidthstats" class="accordion_header">
  251. <a href="#"><?php echo get_lang('BandWidthStatistics') ?></a>
  252. </div>
  253. <div id="extension_content_bandwidthstats" style="display:none" class="accordion_content">
  254. <?php echo get_lang('BandWidthStatisticsDescription') ?><br /><br />
  255. <table width="100%">
  256. <tr>
  257. <td width="50%">
  258. <img src="<?php echo api_get_path(WEB_IMG_PATH).'screenshot_bandwidth.jpg' ?>" />
  259. </td>
  260. <td align="center" width="50%">
  261. <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  262. <input type="hidden" name="extension_code" value="bandwidthstats" />
  263. <input type="submit" name="activeExtension" value="<?php echo get_lang('ActiveExtension') ?>" />
  264. </form>
  265. </td>
  266. </tr>
  267. </table>
  268. </div>
  269. </div>
  270. </div><!-- /content -->
  271. <?php
  272. /*
  273. ==============================================================================
  274. FOOTER
  275. ==============================================================================
  276. */
  277. Display::display_footer();
  278. ?>