configure_extensions.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
  4. /**
  5. * Edition of extensions configuration
  6. * @package chamilo.admin
  7. */
  8. $cidReset = true;
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. $this_section = SECTION_PLATFORM_ADMIN;
  11. api_protect_admin_script();
  12. $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  13. // Database Table Definitions
  14. $tbl_settings_current = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  15. $message = '';
  16. if (isset($_POST['activeExtension'])) {
  17. switch ($_POST['extension_code']) {
  18. case 'ppt2lp':
  19. $sql = 'UPDATE '.$tbl_settings_current.' SET
  20. selected_value="true"
  21. WHERE variable="service_ppt2lp"
  22. AND subkey="active"';
  23. $rs = Database::query($sql);
  24. if (Database::affected_rows($rs) > 0) {
  25. $message = get_lang('ServiceActivated');
  26. }
  27. $sql = 'UPDATE '.$tbl_settings_current.' SET
  28. selected_value="'.addslashes($_POST['host']).'"
  29. WHERE variable="service_ppt2lp"
  30. AND subkey="host"';
  31. Database::query($sql);
  32. $sql = 'UPDATE '.$tbl_settings_current.' SET
  33. selected_value="'.addslashes($_POST['port']).'"
  34. WHERE variable="service_ppt2lp"
  35. AND subkey="port"';
  36. Database::query($sql);
  37. $sql = 'UPDATE '.$tbl_settings_current.' SET
  38. selected_value="'.addslashes($_POST['ftp_password']).'"
  39. WHERE variable="service_ppt2lp"
  40. AND subkey="ftp_password"';
  41. Database::query($sql);
  42. $sql = 'UPDATE '.$tbl_settings_current.' SET
  43. selected_value="'.addslashes($_POST['user']).'"
  44. WHERE variable="service_ppt2lp"
  45. AND subkey="user"';
  46. Database::query($sql);
  47. $sql = 'UPDATE '.$tbl_settings_current.' SET
  48. selected_value="'.addslashes($_POST['path_to_lzx']).'"
  49. WHERE variable="service_ppt2lp"
  50. AND subkey="path_to_lzx"';
  51. Database::query($sql);
  52. $sql = 'UPDATE '.$tbl_settings_current.' SET
  53. selected_value="'.addslashes($_POST['size']).'"
  54. WHERE variable="service_ppt2lp"
  55. AND subkey="size"';
  56. Database::query($sql);
  57. break;
  58. }
  59. }
  60. $listActiveServices = array();
  61. // get the list of active services
  62. $sql = 'SELECT variable FROM '.$tbl_settings_current.'
  63. WHERE variable LIKE "service_%" AND subkey="active" and selected_value="true"';
  64. $rs = Database::query($sql);
  65. while ($row = Database::fetch_array($rs)) {
  66. $listActiveServices[] = $row['variable'];
  67. }
  68. // javascript to handle accordion behaviour
  69. $javascript_message = '';
  70. if (!empty($message)) {
  71. $javascript_message = '
  72. document.getElementById("message").style.display = "block";
  73. var timer = setTimeout(hideMessage, 5000);';
  74. }
  75. $htmlHeadXtra[] = '<script>
  76. var listeDiv;
  77. var extensionsHeader = new Array();
  78. var extensionsContent = new Array();
  79. window.onload = loadTables;
  80. function loadTables(){
  81. '.$javascript_message.'
  82. var listeDiv = document.getElementsByTagName("div");
  83. // fill extensionsHeader and extensionsContent
  84. for(var i=0 ; i < listeDiv.length ; i++){
  85. if(listeDiv[i].id.indexOf(\'extension_header\')!=-1){
  86. listeDiv[i].onclick = afficheContent;
  87. extensionsHeader.push(listeDiv[i]);
  88. }
  89. if(listeDiv[i].id.indexOf("extension_content")!=-1){
  90. extensionsContent.push(listeDiv[i]);
  91. }
  92. }
  93. }
  94. function hideMessage(){
  95. document.getElementById("message").style.display = "none";
  96. }
  97. function afficheContent(event){
  98. var id = this.id.replace("header","content");
  99. switch(document.getElementById(id).style.display){
  100. case "block" :
  101. document.getElementById(id).style.display = "none";
  102. break;
  103. case "none" :
  104. document.getElementById(id).style.display = "block";
  105. for(var i=0 ; i < extensionsContent.length ; i++){
  106. if(extensionsContent[i].id != id)
  107. extensionsContent[i].style.display = "none";
  108. }
  109. break;
  110. }
  111. }
  112. </script>';
  113. $nameTool = get_lang('ConfigureExtensions');
  114. Display::display_header($nameTool);
  115. ?>
  116. <div id="message" style="display: none">
  117. <?php
  118. if (!empty($message)) {
  119. Display::addFlash(Display::return_message($message, 'normal'));
  120. }
  121. ?>
  122. </div>
  123. <div id="content" align="center">
  124. <!-- PPT2LP -->
  125. <div class="chamilo-rapid">
  126. <div class="row">
  127. <div class="col-md-12">
  128. <?php echo Display::panel(get_lang('Ppt2lpDescription').' '.get_lang('Ppt2lpVoiceRecordingNeedsRed5'), get_lang('Ppt2lp')) ?>
  129. </div>
  130. </div>
  131. <div class="row">
  132. <div class="col-md-5">
  133. <?php Display::display_icon('screenshot_ppt2lp.jpg', get_lang('Ppt2lp'), array('class'=>'img-responsive')); ?>
  134. </div>
  135. <div class="col-md-7">
  136. <form method="POST" class="form-horizontal" action="<?php echo api_get_self(); ?>">
  137. <?php
  138. $form = new FormValidator('ppt2lp');
  139. $form->addElement('text', 'host', get_lang('Host'));
  140. //$form -> addElement('html','<br /><br />');
  141. $form->addElement('text', 'port', get_lang('Port'));
  142. //$form -> addElement('html','<br /><br />');
  143. $form->addElement('text', 'user', get_lang('UserOnHost'));
  144. //$form -> addElement('html','<br /><br />');
  145. $form->addElement('text', 'ftp_password', get_lang('FtpPassword'));
  146. //$form -> addElement('html','<br /><br />');
  147. $form->addElement('text', 'path_to_lzx', get_lang('PathToLzx'));
  148. //$form -> addElement('html','<br /><br />');
  149. $options = ChamiloApi::getDocumentConversionSizes();
  150. $form->addElement('select', 'size', get_lang('SlideSize'), $options);
  151. $form->addElement('hidden', 'extension_code', 'ppt2lp');
  152. $defaults = array();
  153. $renderer = $form->defaultRenderer();
  154. $renderer->setElementTemplate(
  155. '<div style="text-align:left">{label}</div><div style="text-align:left">{element}</div>'
  156. );
  157. if (in_array('service_ppt2lp', $listActiveServices)) {
  158. $sql = 'SELECT subkey, selected_value FROM '.$tbl_settings_current.'
  159. WHERE variable = "service_ppt2lp"
  160. AND subkey <> "active"';
  161. $rs = Database::query($sql);
  162. while ($row = Database::fetch_array($rs, 'ASSOC')) {
  163. $defaults[$row['subkey']] = $row['selected_value'];
  164. }
  165. $form->addButtonSave(get_lang('ReconfigureExtension'), 'activeExtension');
  166. } else {
  167. $defaults['host'] = 'localhost';
  168. $defaults['port'] = '2002';
  169. $defaults['size'] = '720x540';
  170. $form->addButtonSave(get_lang('ActivateExtension'), 'activeExtension');
  171. }
  172. $form->setDefaults($defaults);
  173. $form->display();
  174. echo '<br />';
  175. ?>
  176. </form>
  177. </div>
  178. </div>
  179. </div>
  180. <?php
  181. /*
  182. <!-- EPHORUS -->
  183. <div id="main_ephorus">
  184. <div id="extension_header_ephorus" class="accordion_header">
  185. <a href="#"><?php echo get_lang('EphorusPlagiarismPrevention') ?></a>
  186. </div>
  187. <div id="extension_content_ephorus" style="display:none;padding:0;width:780px;" class="accordion_content">
  188. <table width="100%" cellpadding="0" cellspacing="0">
  189. <tr>
  190. <td align="center">
  191. <TABLE style="WIDTH: 750px" cellSpacing="0" cellPadding="0" align="middle" border="0">
  192. <TBODY>
  193. <TR>
  194. <TD>
  195. <TABLE style="WIDTH: 475px" cellSpacing="0" cellPadding="0" border="0">
  196. <TBODY>
  197. <TR>
  198. <TD>
  199. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  200. <a title="http://www.ephorus.com/dokeos_activate.html" href="http://www.ephorus.com/dokeos_activate.html" target="_blank">
  201. <?php Display::display_icon('ephorus.gif','Ephorus'); ?>
  202. </a>
  203. </TD>
  204. <TD>
  205. <P align=center>
  206. <FONT color="#669966" size="3"><?php echo get_lang('EphorusLeadersInAntiPlagiarism') ?></FONT>
  207. </P>
  208. </TD>
  209. </TR>
  210. </TBODY>
  211. </TABLE>
  212. </TD>
  213. </TR>
  214. <TR>
  215. <TD>
  216. <P>
  217. <TABLE style="WIDTH: 85%" cellSpacing="0" cellPadding="0" border="0">
  218. <TBODY>
  219. <TR>
  220. <TD width="50">&nbsp;
  221. </TD>
  222. <TD>
  223. <P>
  224. <?php echo get_lang('EphorusDescription') ?>
  225. </P>
  226. <P>
  227. <A title="http://www.ephorus.nl/demo_account_en.html" href="http://www.ephorus.nl/demo_account_en.html" target="_blank"><?php echo get_lang('EphorusClickHereForADemoAccount') ?></A>
  228. </P>
  229. <P>
  230. <A title="http://www.ephorus.nl:80/dokeos_activate.html" href="http://www.ephorus.nl/dokeos_activate.html" target="_blank"><?php echo get_lang('EphorusClickHereForInformationsAndPrices') ?></A>.
  231. </P>
  232. </TD>
  233. </TR>
  234. </TBODY>
  235. </TABLE>
  236. </P>
  237. </TD>
  238. </TR>
  239. </TBODY>
  240. </TABLE>
  241. </td>
  242. </tr>
  243. </table>
  244. </div>
  245. </div>
  246. */
  247. /*
  248. <!-- SEARCH -->
  249. <div id="main_search">
  250. <div id="extension_header_search" class="accordion_header">
  251. <a href="#"><?php echo get_lang('SearchEngine') ?></a>
  252. </div>
  253. <div id="extension_content_search" style="display:none" class="accordion_content">
  254. <?php echo get_lang('SearchEngineDescription') ?><br /><br />
  255. <table width="100%">
  256. <tr>
  257. <td width="50%">
  258. <?php Display::display_icon('screenshot_search.jpg', get_lang('SearchEngine')); ?>
  259. </td>
  260. <td align="center" width="50%">
  261. <form method="POST" action="<?php echo api_get_self(); ?>">
  262. <input type="hidden" name="extension_code" value="search" />
  263. <button type="submit" class="save" name="activeExtension" value="<?php echo get_lang('ActivateExtension') ?>" ><?php echo get_lang('ActivateExtension') ?></button>
  264. </form>
  265. </td>
  266. </tr>
  267. </table>
  268. </div>
  269. </div>
  270. <!-- SERVER STATS -->
  271. <div id="main_serverstats">
  272. <div id="extension_header_serverstats" class="accordion_header">
  273. <a href="#"><?php echo get_lang('ServerStatistics') ?></a>
  274. </div>
  275. <div id="extension_content_serverstats" style="display:none" class="accordion_content">
  276. <?php echo get_lang('ServerStatisticsDescription') ?><br /><br />
  277. <table width="100%">
  278. <tr>
  279. <td width="50%">
  280. <?php Display::display_icon('screenshot_serverstats.jpg', get_lang('ServerStatistics')); ?>
  281. </td>
  282. <td align="center" width="50%">
  283. <form method="POST" action="<?php echo api_get_self(); ?>">
  284. <input type="hidden" name="extension_code" value="serverstats" />
  285. <button type="submit" class="save" name="activeExtension" value="<?php echo get_lang('ActivateExtension') ?>" ><?php echo get_lang('ActivateExtension') ?></button>
  286. </form>
  287. </td>
  288. </tr>
  289. </table>
  290. </div>
  291. </div>
  292. <!-- BANDWIDTH STATS -->
  293. <div id="main_bandwidthstats">
  294. <div id="extension_header_bandwidthstats" class="accordion_header">
  295. <a href="#"><?php echo get_lang('BandWidthStatistics') ?></a>
  296. </div>
  297. <div id="extension_content_bandwidthstats" style="display:none" class="accordion_content">
  298. <?php echo get_lang('BandWidthStatisticsDescription') ?><br /><br />
  299. <table width="100%">
  300. <tr>
  301. <td width="50%">
  302. <?php Display::display_icon('screenshot_bandwidth.jpg', get_lang('BandWidthStatistics')); ?>
  303. </td>
  304. <td align="center" width="50%">
  305. <form method="POST" action="<?php echo api_get_self(); ?>">
  306. <input type="hidden" name="extension_code" value="bandwidthstats" />
  307. <button type="submit" class="save" name="activeExtension" value="<?php echo get_lang('ActivateExtension') ?>" ><?php echo get_lang('ActivateExtension') ?></button>
  308. </form>
  309. </td>
  310. </tr>
  311. </table>
  312. </div>
  313. </div>
  314. */ ?>
  315. </div><!-- /content -->
  316. <?php
  317. Display::display_footer();