configure_extensions.php 17 KB

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