configure_extensions.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Edition of extensions configuration
  5. * @package chamilo.admin
  6. */
  7. $cidReset=true;
  8. require_once '../inc/global.inc.php';
  9. $this_section=SECTION_PLATFORM_ADMIN;
  10. api_protect_admin_script();
  11. $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  12. // Database Table Definitions
  13. $tbl_settings_current = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  14. $message = '';
  15. if (isset($_POST['activeExtension'])) {
  16. switch ($_POST['extension_code']) {
  17. case 'visio' :
  18. $sql = 'UPDATE '.$tbl_settings_current.' SET
  19. selected_value="true"
  20. WHERE variable="service_visio"
  21. AND subkey="active"';
  22. $rs = Database::query($sql);
  23. if (Database::affected_rows($rs)>0) {
  24. // select all the courses and insert the tool inside
  25. $sql = 'SELECT id FROM '.Database::get_main_table(TABLE_MAIN_COURSE);
  26. $rs = Database::query($sql);
  27. while($row = Database::fetch_array($rs)){
  28. if(!empty($_POST['visio_host'])) {
  29. $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  30. $select = "SELECT id FROM $tool_table WHERE c_id =".$row['id']." AND name='".TOOL_VISIO_CONFERENCE."'";
  31. $selectres = Database::query($select);
  32. if (Database::num_rows($selectres)<1) {
  33. $sql = 'INSERT INTO '.$tool_table.' SET
  34. c_id = '.$row['id'].',
  35. name="'.TOOL_VISIO_CONFERENCE.'",
  36. link="conference/index.php?type=conference",
  37. image="visio.gif",
  38. visibility="1",
  39. admin="0",
  40. address="squaregrey.gif",
  41. target="_self",
  42. category="interaction"';
  43. Database::query($sql);
  44. }
  45. $select = "SELECT id FROM $tool_table WHERE c_id =".$row['id']." AND name='".TOOL_VISIO_CLASSROOM."'";
  46. $selectres = Database::query($select);
  47. if(Database::num_rows($selectres)<1) {
  48. $sql = 'INSERT INTO '.$tool_table.' SET
  49. c_id = '.$row['id'].',
  50. name="'.TOOL_VISIO_CLASSROOM.'",
  51. link="conference/index.php?type=classroom",
  52. image="visio.gif",
  53. visibility="1",
  54. admin="0",
  55. address="squaregrey.gif",
  56. target="_self",
  57. category="authoring"';
  58. Database::query($sql);
  59. }
  60. }
  61. }
  62. $message = get_lang('ServiceActivated');
  63. }
  64. $sql = 'UPDATE '.$tbl_settings_current.' SET
  65. selected_value="'.Database::escape_string($_POST['visio_host']).'"
  66. WHERE variable="service_visio"
  67. AND subkey="visio_host"';
  68. $rs = Database::query($sql);
  69. $sql = 'UPDATE '.$tbl_settings_current.' SET
  70. selected_value="'.Database::escape_string($_POST['visio_port']).'"
  71. WHERE variable="service_visio"
  72. AND subkey="visio_port"';
  73. $rs = Database::query($sql);
  74. $sql = 'UPDATE '.$tbl_settings_current.' SET
  75. selected_value="'.Database::escape_string($_POST['visio_pass']).'"
  76. WHERE variable="service_visio"
  77. AND subkey="visio_pass"';
  78. $rs = Database::query($sql);
  79. $sql = 'UPDATE '.$tbl_settings_current.' SET
  80. selected_value="'.($_POST['visio_use_rtmpt']=='true'?'true':'false').'"
  81. WHERE variable="service_visio"
  82. AND subkey="visio_use_rtmpt"';
  83. $rs = Database::query($sql);
  84. if(empty($message)) {
  85. $message = get_lang('ServiceReconfigured');
  86. }
  87. break;
  88. case 'ppt2lp' :
  89. $sql = 'UPDATE '.$tbl_settings_current.' SET
  90. selected_value="true"
  91. WHERE variable="service_ppt2lp"
  92. AND subkey="active"';
  93. $rs = Database::query($sql);
  94. if (Database::affected_rows($rs)>0){
  95. $message = get_lang('ServiceActivated');
  96. }
  97. $sql = 'UPDATE '.$tbl_settings_current.' SET
  98. selected_value="'.addslashes($_POST['host']).'"
  99. WHERE variable="service_ppt2lp"
  100. AND subkey="host"';
  101. Database::query($sql);
  102. $sql = 'UPDATE '.$tbl_settings_current.' SET
  103. selected_value="'.addslashes($_POST['port']).'"
  104. WHERE variable="service_ppt2lp"
  105. AND subkey="port"';
  106. Database::query($sql);
  107. $sql = 'UPDATE '.$tbl_settings_current.' SET
  108. selected_value="'.addslashes($_POST['ftp_password']).'"
  109. WHERE variable="service_ppt2lp"
  110. AND subkey="ftp_password"';
  111. Database::query($sql);
  112. $sql = 'UPDATE '.$tbl_settings_current.' SET
  113. selected_value="'.addslashes($_POST['user']).'"
  114. WHERE variable="service_ppt2lp"
  115. AND subkey="user"';
  116. Database::query($sql);
  117. $sql = 'UPDATE '.$tbl_settings_current.' SET
  118. selected_value="'.addslashes($_POST['path_to_lzx']).'"
  119. WHERE variable="service_ppt2lp"
  120. AND subkey="path_to_lzx"';
  121. Database::query($sql);
  122. $sql = 'UPDATE '.$tbl_settings_current.' SET
  123. selected_value="'.addslashes($_POST['size']).'"
  124. WHERE variable="service_ppt2lp"
  125. AND subkey="size"';
  126. Database::query($sql);
  127. break;
  128. }
  129. }
  130. $listActiveServices = array();
  131. // get the list of active services
  132. $sql = 'SELECT variable FROM '.$tbl_settings_current.'
  133. WHERE variable LIKE "service_%" AND subkey="active" and selected_value="true"';
  134. $rs = Database::query($sql);
  135. while($row = Database::fetch_array($rs)){
  136. $listActiveServices[] = $row['variable'];
  137. }
  138. // javascript to handle accordion behaviour
  139. $javascript_message = '';
  140. if(!empty($message)){
  141. $javascript_message =
  142. '
  143. document.getElementById("message").style.display = "block";
  144. var timer = setTimeout(hideMessage,5000);
  145. ';
  146. }
  147. $htmlHeadXtra[]= '
  148. <script type="text/javascript">
  149. var listeDiv;
  150. var extensionsHeader = new Array();
  151. var extensionsContent = new Array();
  152. window.onload = loadTables;
  153. function loadTables(){
  154. '.$javascript_message.'
  155. var listeDiv = document.getElementsByTagName("div");
  156. // fill extensionsHeader and extensionsContent
  157. for(var i=0 ; i < listeDiv.length ; i++){
  158. if(listeDiv[i].id.indexOf(\'extension_header\')!=-1){
  159. listeDiv[i].onclick = afficheContent;
  160. extensionsHeader.push(listeDiv[i]);
  161. }
  162. if(listeDiv[i].id.indexOf("extension_content")!=-1){
  163. extensionsContent.push(listeDiv[i]);
  164. }
  165. }
  166. }
  167. function hideMessage(){
  168. document.getElementById("message").style.display = "none";
  169. }
  170. function afficheContent(event){
  171. var id = this.id.replace("header","content");
  172. switch(document.getElementById(id).style.display){
  173. case "block" :
  174. document.getElementById(id).style.display = "none";
  175. break;
  176. case "none" :
  177. document.getElementById(id).style.display = "block";
  178. for(var i=0 ; i < extensionsContent.length ; i++){
  179. if(extensionsContent[i].id != id)
  180. extensionsContent[i].style.display = "none";
  181. }
  182. break;
  183. }
  184. }
  185. </script>';
  186. $nameTool = get_lang('ConfigureExtensions');
  187. Display::display_header($nameTool);
  188. ?>
  189. <div id="message" style="display: none">
  190. <?php
  191. if(!empty($message))
  192. Display::display_normal_message($message)
  193. ?>
  194. </div>
  195. <div id="content" align="center">
  196. <!-- INSTRUCTIONS TO ADD AN EXTENSION HERE
  197. - copy paste a "main_*" div
  198. - set the names of the subdiv to extension_header_yourextension and extension_content_yourextension
  199. - extension_content_yourextension is the hidden div where you have to put your form / activation process
  200. - extension_header_yourextension is the name of your extension
  201. - you do not need to add javascript to display / hide your divs
  202. - please fill free to improve the global display of the document
  203. -->
  204. <!-- VISIOCONFERENCE -->
  205. <?php /*
  206. <div id="main_visio">
  207. <div id="extension_header_visio" class="accordion_header">
  208. <a href="#"><?php echo get_lang('Visioconf') ?></a>
  209. </div>
  210. <div id="extension_content_visio" style="display:none" class="accordion_content">
  211. <?php echo get_lang('VisioconfDescription') ?><br /><br />
  212. <table width="100%">
  213. <tr>
  214. <td align="center">
  215. <?php Display::display_icon('screenshot_conf.jpg', get_lang('Visioconf')); ?>
  216. </td>
  217. <td align="center" width="50%">
  218. <?php
  219. $form = new FormValidator('visio');
  220. $form -> addElement('text', 'visio_host', get_lang('VisioHost'));
  221. $form -> addElement('html','<br /><br />');
  222. $form -> addElement('text', 'visio_port', get_lang('VisioPort'));
  223. $form -> addElement('html','<br /><br />');
  224. $form -> addElement('text', 'visio_pass', get_lang('VisioPassword'));
  225. $form -> addElement('html','<br /><br />');
  226. $group = array();
  227. $group[] =& HTML_QuickForm::createElement('radio', 'visio_use_rtmpt',null,get_lang('Yes'),'true');
  228. $group[] =& HTML_QuickForm::createElement('radio', 'visio_use_rtmpt',null,get_lang('No'),'false');
  229. $form->addGroup($group, '', get_lang('VisioUseRtmptTitle').' ('.get_lang('VisioUseRtmptComment').')', '&nbsp;');
  230. //$form -> addElement('text', 'visio_is_web_rtmp', get_lang('VisioRTMPIsWeb'));
  231. //$form -> addElement('html','<br /><br />');
  232. $form -> addElement('hidden', 'extension_code', 'visio');
  233. $defaults = array();
  234. $renderer = $form -> defaultRenderer();
  235. $renderer -> setElementTemplate('<div style="text-align:left">{label}</div><div style="text-align:left">{element}</div>');
  236. $form -> addElement('html','<br /><br />');
  237. if(in_array('service_visio',$listActiveServices))
  238. {
  239. $sql = 'SELECT subkey, selected_value FROM '.$tbl_settings_current.'
  240. WHERE variable = "service_visio"';
  241. $rs = Database::query($sql);
  242. while($row = Database::fetch_array($rs,'ASSOC'))
  243. {
  244. $defaults[$row['subkey']] = $row['selected_value'];
  245. }
  246. $form -> addElement('style_submit_button', 'activeExtension', get_lang('ReconfigureExtension'),'class="save"');
  247. }
  248. else {
  249. $form -> addElement('style_submit_button', 'activeExtension', get_lang('ActivateExtension'),'class="save"');
  250. }
  251. $form -> setDefaults($defaults);
  252. $form -> display();
  253. ?>
  254. </td>
  255. </tr>
  256. </table>
  257. </div>
  258. </div>
  259. */ ?>
  260. <!-- PPT2LP -->
  261. <div class="chamilo-rapid">
  262. <div class="row">
  263. <div class="col-md-12">
  264. <?php echo Display::panel(get_lang('Ppt2lpDescription').' '.get_lang('Ppt2lpVoiceRecordingNeedsRed5'), get_lang('Ppt2lp')) ?>
  265. </div>
  266. </div>
  267. <div class="row">
  268. <div class="col-md-5">
  269. <?php Display::display_icon('screenshot_ppt2lp.jpg', get_lang('Ppt2lp'), array('class'=>'img-responsive')); ?>
  270. </div>
  271. <div class="col-md-7">
  272. <form method="POST" class="form-horizontal" action="<?php echo api_get_self(); ?>">
  273. <?php
  274. $form = new FormValidator('ppt2lp');
  275. $form -> addElement('text', 'host', get_lang('Host'));
  276. //$form -> addElement('html','<br /><br />');
  277. $form -> addElement('text', 'port', get_lang('Port'));
  278. //$form -> addElement('html','<br /><br />');
  279. $form -> addElement('text', 'user', get_lang('UserOnHost'));
  280. //$form -> addElement('html','<br /><br />');
  281. $form -> addElement('text', 'ftp_password', get_lang('FtpPassword'));
  282. //$form -> addElement('html','<br /><br />');
  283. $form -> addElement('text', 'path_to_lzx', get_lang('PathToLzx'));
  284. //$form -> addElement('html','<br /><br />');
  285. $options = array(
  286. '540x405'=>'540x405',
  287. '640x480'=>'640x480',
  288. '720x540'=>'720x540',
  289. '800x600'=>'800x600',
  290. '1000x750'=>'1000x750'
  291. );
  292. $form -> addElement('select', 'size', get_lang('SlideSize'), $options);
  293. $form -> addElement('hidden', 'extension_code', 'ppt2lp');
  294. $defaults = array();
  295. $renderer = $form -> defaultRenderer();
  296. $renderer -> setElementTemplate('<div style="text-align:left">{label}</div><div style="text-align:left">{element}</div>');
  297. //$form -> addElement('html','<br /><br />');
  298. if(in_array('service_ppt2lp',$listActiveServices))
  299. {
  300. $sql = 'SELECT subkey, selected_value FROM '.$tbl_settings_current.'
  301. WHERE variable = "service_ppt2lp"
  302. AND subkey <> "active"';
  303. $rs = Database::query($sql);
  304. while($row = Database::fetch_array($rs,'ASSOC'))
  305. {
  306. $defaults[$row['subkey']] = $row['selected_value'];
  307. }
  308. $form->addButtonSave(get_lang('ReconfigureExtension'), 'activeExtension');
  309. }
  310. else {
  311. $defaults['host'] = 'localhost';
  312. $defaults['port'] = '2002';
  313. $defaults['size'] = '720x540';
  314. $form->addButtonSave(get_lang('ActivateExtension'), 'activeExtension');
  315. }
  316. $form -> setDefaults($defaults);
  317. $form -> display();
  318. echo '<br />';
  319. ?>
  320. </form>
  321. </div>
  322. </div>
  323. </div>
  324. <?php
  325. /*
  326. <!-- EPHORUS -->
  327. <div id="main_ephorus">
  328. <div id="extension_header_ephorus" class="accordion_header">
  329. <a href="#"><?php echo get_lang('EphorusPlagiarismPrevention') ?></a>
  330. </div>
  331. <div id="extension_content_ephorus" style="display:none;padding:0;width:780px;" class="accordion_content">
  332. <table width="100%" cellpadding="0" cellspacing="0">
  333. <tr>
  334. <td align="center">
  335. <TABLE style="WIDTH: 750px" cellSpacing="0" cellPadding="0" align="middle" border="0">
  336. <TBODY>
  337. <TR>
  338. <TD>
  339. <TABLE style="WIDTH: 475px" cellSpacing="0" cellPadding="0" border="0">
  340. <TBODY>
  341. <TR>
  342. <TD>
  343. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  344. <a title="http://www.ephorus.com/dokeos_activate.html" href="http://www.ephorus.com/dokeos_activate.html" target="_blank">
  345. <?php Display::display_icon('ephorus.gif','Ephorus'); ?>
  346. </a>
  347. </TD>
  348. <TD>
  349. <P align=center>
  350. <FONT color="#669966" size="3"><?php echo get_lang('EphorusLeadersInAntiPlagiarism') ?></FONT>
  351. </P>
  352. </TD>
  353. </TR>
  354. </TBODY>
  355. </TABLE>
  356. </TD>
  357. </TR>
  358. <TR>
  359. <TD>
  360. <P>
  361. <TABLE style="WIDTH: 85%" cellSpacing="0" cellPadding="0" border="0">
  362. <TBODY>
  363. <TR>
  364. <TD width="50">&nbsp;
  365. </TD>
  366. <TD>
  367. <P>
  368. <?php echo get_lang('EphorusDescription') ?>
  369. </P>
  370. <P>
  371. <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>
  372. </P>
  373. <P>
  374. <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>.
  375. </P>
  376. </TD>
  377. </TR>
  378. </TBODY>
  379. </TABLE>
  380. </P>
  381. </TD>
  382. </TR>
  383. </TBODY>
  384. </TABLE>
  385. </td>
  386. </tr>
  387. </table>
  388. </div>
  389. </div>
  390. */
  391. /*
  392. <!-- SEARCH -->
  393. <div id="main_search">
  394. <div id="extension_header_search" class="accordion_header">
  395. <a href="#"><?php echo get_lang('SearchEngine') ?></a>
  396. </div>
  397. <div id="extension_content_search" style="display:none" class="accordion_content">
  398. <?php echo get_lang('SearchEngineDescription') ?><br /><br />
  399. <table width="100%">
  400. <tr>
  401. <td width="50%">
  402. <?php Display::display_icon('screenshot_search.jpg', get_lang('SearchEngine')); ?>
  403. </td>
  404. <td align="center" width="50%">
  405. <form method="POST" action="<?php echo api_get_self(); ?>">
  406. <input type="hidden" name="extension_code" value="search" />
  407. <button type="submit" class="save" name="activeExtension" value="<?php echo get_lang('ActivateExtension') ?>" ><?php echo get_lang('ActivateExtension') ?></button>
  408. </form>
  409. </td>
  410. </tr>
  411. </table>
  412. </div>
  413. </div>
  414. <!-- SERVER STATS -->
  415. <div id="main_serverstats">
  416. <div id="extension_header_serverstats" class="accordion_header">
  417. <a href="#"><?php echo get_lang('ServerStatistics') ?></a>
  418. </div>
  419. <div id="extension_content_serverstats" style="display:none" class="accordion_content">
  420. <?php echo get_lang('ServerStatisticsDescription') ?><br /><br />
  421. <table width="100%">
  422. <tr>
  423. <td width="50%">
  424. <?php Display::display_icon('screenshot_serverstats.jpg', get_lang('ServerStatistics')); ?>
  425. </td>
  426. <td align="center" width="50%">
  427. <form method="POST" action="<?php echo api_get_self(); ?>">
  428. <input type="hidden" name="extension_code" value="serverstats" />
  429. <button type="submit" class="save" name="activeExtension" value="<?php echo get_lang('ActivateExtension') ?>" ><?php echo get_lang('ActivateExtension') ?></button>
  430. </form>
  431. </td>
  432. </tr>
  433. </table>
  434. </div>
  435. </div>
  436. <!-- BANDWIDTH STATS -->
  437. <div id="main_bandwidthstats">
  438. <div id="extension_header_bandwidthstats" class="accordion_header">
  439. <a href="#"><?php echo get_lang('BandWidthStatistics') ?></a>
  440. </div>
  441. <div id="extension_content_bandwidthstats" style="display:none" class="accordion_content">
  442. <?php echo get_lang('BandWidthStatisticsDescription') ?><br /><br />
  443. <table width="100%">
  444. <tr>
  445. <td width="50%">
  446. <?php Display::display_icon('screenshot_bandwidth.jpg', get_lang('BandWidthStatistics')); ?>
  447. </td>
  448. <td align="center" width="50%">
  449. <form method="POST" action="<?php echo api_get_self(); ?>">
  450. <input type="hidden" name="extension_code" value="bandwidthstats" />
  451. <button type="submit" class="save" name="activeExtension" value="<?php echo get_lang('ActivateExtension') ?>" ><?php echo get_lang('ActivateExtension') ?></button>
  452. </form>
  453. </td>
  454. </tr>
  455. </table>
  456. </div>
  457. </div>
  458. */ ?>
  459. </div><!-- /content -->
  460. <?php
  461. Display::display_footer();