configure_extensions.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
  4. /**
  5. * Edition of extensions configuration.
  6. *
  7. * @package chamilo.admin
  8. */
  9. $cidReset = true;
  10. require_once __DIR__.'/../inc/global.inc.php';
  11. $this_section = SECTION_PLATFORM_ADMIN;
  12. api_protect_admin_script();
  13. $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')];
  14. // Database Table Definitions
  15. $tbl_settings_current = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  16. $message = '';
  17. if (isset($_POST['activeExtension'])) {
  18. switch ($_POST['extension_code']) {
  19. case 'ppt2lp':
  20. $sql = 'UPDATE '.$tbl_settings_current.' SET
  21. selected_value="true"
  22. WHERE variable="service_ppt2lp"
  23. AND subkey="active"';
  24. $rs = Database::query($sql);
  25. if (Database::affected_rows($rs) > 0) {
  26. $message = get_lang('Service activated');
  27. }
  28. $sql = 'UPDATE '.$tbl_settings_current.' SET
  29. selected_value="'.addslashes($_POST['host']).'"
  30. WHERE variable="service_ppt2lp"
  31. AND subkey="host"';
  32. Database::query($sql);
  33. $sql = 'UPDATE '.$tbl_settings_current.' SET
  34. selected_value="'.addslashes($_POST['port']).'"
  35. WHERE variable="service_ppt2lp"
  36. AND subkey="port"';
  37. Database::query($sql);
  38. $sql = 'UPDATE '.$tbl_settings_current.' SET
  39. selected_value="'.addslashes($_POST['ftp_password']).'"
  40. WHERE variable="service_ppt2lp"
  41. AND subkey="ftp_password"';
  42. Database::query($sql);
  43. $sql = 'UPDATE '.$tbl_settings_current.' SET
  44. selected_value="'.addslashes($_POST['user']).'"
  45. WHERE variable="service_ppt2lp"
  46. AND subkey="user"';
  47. Database::query($sql);
  48. $sql = 'UPDATE '.$tbl_settings_current.' SET
  49. selected_value="'.addslashes($_POST['path_to_lzx']).'"
  50. WHERE variable="service_ppt2lp"
  51. AND subkey="path_to_lzx"';
  52. Database::query($sql);
  53. $sql = 'UPDATE '.$tbl_settings_current.' SET
  54. selected_value="'.addslashes($_POST['size']).'"
  55. WHERE variable="service_ppt2lp"
  56. AND subkey="size"';
  57. Database::query($sql);
  58. break;
  59. }
  60. }
  61. $listActiveServices = [];
  62. // get the list of active services
  63. $sql = 'SELECT variable FROM '.$tbl_settings_current.'
  64. WHERE variable LIKE "service_%" AND subkey="active" and selected_value="true"';
  65. $rs = Database::query($sql);
  66. while ($row = Database::fetch_array($rs)) {
  67. $listActiveServices[] = $row['variable'];
  68. }
  69. // javascript to handle accordion behaviour
  70. $javascript_message = '';
  71. if (!empty($message)) {
  72. $javascript_message = '
  73. document.getElementById("message").style.display = "block";
  74. var timer = setTimeout(hideMessage, 5000);';
  75. }
  76. $htmlHeadXtra[] = '<script>
  77. var listeDiv;
  78. var extensionsHeader = new Array();
  79. var extensionsContent = new Array();
  80. window.onload = loadTables;
  81. function loadTables(){
  82. '.$javascript_message.'
  83. var listeDiv = document.getElementsByTagName("div");
  84. // fill extensionsHeader and extensionsContent
  85. for(var i=0 ; i < listeDiv.length ; i++){
  86. if(listeDiv[i].id.indexOf(\'extension_header\')!=-1){
  87. listeDiv[i].onclick = afficheContent;
  88. extensionsHeader.push(listeDiv[i]);
  89. }
  90. if(listeDiv[i].id.indexOf("extension_content")!=-1){
  91. extensionsContent.push(listeDiv[i]);
  92. }
  93. }
  94. }
  95. function hideMessage(){
  96. document.getElementById("message").style.display = "none";
  97. }
  98. function afficheContent(event){
  99. var id = this.id.replace("header","content");
  100. switch(document.getElementById(id).style.display){
  101. case "block" :
  102. document.getElementById(id).style.display = "none";
  103. break;
  104. case "none" :
  105. document.getElementById(id).style.display = "block";
  106. for(var i=0 ; i < extensionsContent.length ; i++){
  107. if(extensionsContent[i].id != id)
  108. extensionsContent[i].style.display = "none";
  109. }
  110. break;
  111. }
  112. }
  113. </script>';
  114. $nameTool = get_lang('Configure extensions');
  115. Display::display_header($nameTool);
  116. ?>
  117. <div id="message" style="display: none">
  118. <?php
  119. if (!empty($message)) {
  120. echo Display::return_message($message, 'normal');
  121. }
  122. ?>
  123. </div>
  124. <div id="content" align="center">
  125. <!-- PPT2LP -->
  126. <div class="chamilo-rapid">
  127. <div class="row">
  128. <div class="col-md-12">
  129. <?php echo Display::panel(get_lang('Chamilo RAPID is a Rapid Learning tool available in Chamilo Pro and Chamilo Medical. It allows you to convert Powerpoint or LibreOffice presentations to SCORM-compliant courses. After the conversion, you end up in the Courses authoring tool and are able to add audio comments on slides and pages, tests and activities between the slides or pages and interaction activities like forum discussions or assignment upload. Every step becomes an independent and removable learning object. And the whole course generates accurate SCORM reporting for further coaching.').' '.get_lang('The voice recording feature in the course editor relies on a Red5 streaming server. This server\'s parameters can be configured in the videoconference section on the current page.'), get_lang('Chamilo RAPID')); ?>
  130. </div>
  131. </div>
  132. <div class="row">
  133. <div class="col-md-5">
  134. <?php Display::display_icon('screenshot_ppt2lp.jpg', get_lang('Chamilo RAPID'), ['class' => 'img-responsive']); ?>
  135. </div>
  136. <div class="col-md-7">
  137. <form method="POST" class="form-horizontal" action="<?php echo api_get_self(); ?>">
  138. <?php
  139. $form = new FormValidator('ppt2lp');
  140. $form->addElement('text', 'host', get_lang('Host'));
  141. //$form -> addElement('html','<br /><br />');
  142. $form->addElement('text', 'port', get_lang('Port'));
  143. //$form -> addElement('html','<br /><br />');
  144. $form->addElement('text', 'user', get_lang('Login'));
  145. //$form -> addElement('html','<br /><br />');
  146. $form->addElement('text', 'ftp_password', get_lang('FTP password'));
  147. //$form -> addElement('html','<br /><br />');
  148. $form->addElement('text', 'path_to_lzx', get_lang('Path to LZX files'));
  149. //$form -> addElement('html','<br /><br />');
  150. $options = ChamiloApi::getDocumentConversionSizes();
  151. $form->addElement('select', 'size', get_lang('Size of the slides'), $options);
  152. $form->addElement('hidden', 'extension_code', 'ppt2lp');
  153. $defaults = [];
  154. $renderer = $form->defaultRenderer();
  155. $renderer->setElementTemplate(
  156. '<div style="text-align:left">{label}</div><div style="text-align:left">{element}</div>'
  157. );
  158. if (in_array('service_ppt2lp', $listActiveServices)) {
  159. $sql = 'SELECT subkey, selected_value FROM '.$tbl_settings_current.'
  160. WHERE variable = "service_ppt2lp"
  161. AND subkey <> "active"';
  162. $rs = Database::query($sql);
  163. while ($row = Database::fetch_array($rs, 'ASSOC')) {
  164. $defaults[$row['subkey']] = $row['selected_value'];
  165. }
  166. $form->addButtonSave(get_lang('Reconfigure extension'), 'activeExtension');
  167. } else {
  168. $defaults['host'] = 'localhost';
  169. $defaults['port'] = '2002';
  170. $defaults['size'] = '720x540';
  171. $form->addButtonSave(get_lang('Activate service'), 'activeExtension');
  172. }
  173. $form->setDefaults($defaults);
  174. $form->display();
  175. echo '<br />';
  176. ?>
  177. </form>
  178. </div>
  179. </div>
  180. </div>
  181. <?php
  182. /*
  183. <!-- SEARCH -->
  184. <div id="main_search">
  185. <div id="extension_header_search" class="accordion_header">
  186. <a href="#"><?php echo get_lang('Chamilo LIBRARY') ?></a>
  187. </div>
  188. <div id="extension_content_search" style="display:none" class="accordion_content">
  189. <?php echo get_lang('Chamilo LIBRARYDescription') ?><br /><br />
  190. <table width="100%">
  191. <tr>
  192. <td width="50%">
  193. <?php Display::display_icon('screenshot_search.jpg', get_lang('Chamilo LIBRARY')); ?>
  194. </td>
  195. <td align="center" width="50%">
  196. <form method="POST" action="<?php echo api_get_self(); ?>">
  197. <input type="hidden" name="extension_code" value="search" />
  198. <button type="submit" class="save" name="activeExtension" value="<?php echo get_lang('Activate service') ?>" ><?php echo get_lang('Activate service') ?></button>
  199. </form>
  200. </td>
  201. </tr>
  202. </table>
  203. </div>
  204. </div>
  205. */ ?>
  206. </div><!-- /content -->
  207. <?php
  208. Display::display_footer();