configure_extensions.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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_service_displayed = '';
  139. if (isset($_GET['display'])) {
  140. $javascript_service_displayed = 'document.getElementById("extension_content_'.$_GET['display'].'").style.display = "block"';
  141. }*/
  142. // javascript to handle accordion behaviour
  143. $javascript_message = '';
  144. if(!empty($message)){
  145. $javascript_message =
  146. '
  147. document.getElementById("message").style.display = "block";
  148. var timer = setTimeout(hideMessage,5000);
  149. ';
  150. }
  151. $htmlHeadXtra[]= '
  152. <script type="text/javascript">
  153. var listeDiv;
  154. var extensionsHeader = new Array();
  155. var extensionsContent = new Array();
  156. window.onload = loadTables;
  157. function loadTables(){
  158. '.$javascript_message.'
  159. var listeDiv = document.getElementsByTagName("div");
  160. // fill extensionsHeader and extensionsContent
  161. for(var i=0 ; i < listeDiv.length ; i++){
  162. if(listeDiv[i].id.indexOf(\'extension_header\')!=-1){
  163. listeDiv[i].onclick = afficheContent;
  164. extensionsHeader.push(listeDiv[i]);
  165. }
  166. if(listeDiv[i].id.indexOf("extension_content")!=-1){
  167. extensionsContent.push(listeDiv[i]);
  168. }
  169. }
  170. '.$javascript_service_displayed.'
  171. }
  172. function hideMessage(){
  173. document.getElementById("message").style.display = "none";
  174. }
  175. function afficheContent(event){
  176. var id = this.id.replace("header","content");
  177. switch(document.getElementById(id).style.display){
  178. case "block" :
  179. document.getElementById(id).style.display = "none";
  180. break;
  181. case "none" :
  182. document.getElementById(id).style.display = "block";
  183. for(var i=0 ; i < extensionsContent.length ; i++){
  184. if(extensionsContent[i].id != id)
  185. extensionsContent[i].style.display = "none";
  186. }
  187. break;
  188. }
  189. }
  190. </script>';
  191. $nameTool = get_lang('ConfigureExtensions');
  192. Display::display_header($nameTool);
  193. ?>
  194. <div id="message" style="display: none">
  195. <?php
  196. if(!empty($message))
  197. Display::display_normal_message($message)
  198. ?>
  199. </div>
  200. <div id="content" align="center">
  201. <!-- INSTRUCTIONS TO ADD AN EXTENSION HERE
  202. - copy paste a "main_*" div
  203. - set the names of the subdiv to extension_header_yourextension and extension_content_yourextension
  204. - extension_content_yourextension is the hidden div where you have to put your form / activation process
  205. - extension_header_yourextension is the name of your extension
  206. - you do not need to add javascript to display / hide your divs
  207. - please fill free to improve the global display of the document
  208. -->
  209. <!-- VISIOCONFERENCE -->
  210. <?php /*
  211. <div id="main_visio">
  212. <div id="extension_header_visio" class="accordion_header">
  213. <a href="#"><?php echo get_lang('Visioconf') ?></a>
  214. </div>
  215. <div id="extension_content_visio" style="display:none" class="accordion_content">
  216. <?php echo get_lang('VisioconfDescription') ?><br /><br />
  217. <table width="100%">
  218. <tr>
  219. <td align="center">
  220. <?php Display::display_icon('screenshot_conf.jpg', get_lang('Visioconf')); ?>
  221. </td>
  222. <td align="center" width="50%">
  223. <?php
  224. $form = new FormValidator('visio');
  225. $form -> addElement('text', 'visio_host', get_lang('VisioHost'));
  226. $form -> addElement('html','<br /><br />');
  227. $form -> addElement('text', 'visio_port', get_lang('VisioPort'));
  228. $form -> addElement('html','<br /><br />');
  229. $form -> addElement('text', 'visio_pass', get_lang('VisioPassword'));
  230. $form -> addElement('html','<br /><br />');
  231. $group = array();
  232. $group[] =& HTML_QuickForm::createElement('radio', 'visio_use_rtmpt',null,get_lang('Yes'),'true');
  233. $group[] =& HTML_QuickForm::createElement('radio', 'visio_use_rtmpt',null,get_lang('No'),'false');
  234. $form->addGroup($group, '', get_lang('VisioUseRtmptTitle').' ('.get_lang('VisioUseRtmptComment').')', '&nbsp;');
  235. //$form -> addElement('text', 'visio_is_web_rtmp', get_lang('VisioRTMPIsWeb'));
  236. //$form -> addElement('html','<br /><br />');
  237. $form -> addElement('hidden', 'extension_code', 'visio');
  238. $defaults = array();
  239. $renderer = $form -> defaultRenderer();
  240. $renderer -> setElementTemplate('<div style="text-align:left">{label}</div><div style="text-align:left">{element}</div>');
  241. $form -> addElement('html','<br /><br />');
  242. if(in_array('service_visio',$listActiveServices))
  243. {
  244. $sql = 'SELECT subkey, selected_value FROM '.$tbl_settings_current.'
  245. WHERE variable = "service_visio"';
  246. $rs = Database::query($sql);
  247. while($row = Database::fetch_array($rs,'ASSOC'))
  248. {
  249. $defaults[$row['subkey']] = $row['selected_value'];
  250. }
  251. $form -> addElement('style_submit_button', 'activeExtension', get_lang('ReconfigureExtension'),'class="save"');
  252. }
  253. else {
  254. $form -> addElement('style_submit_button', 'activeExtension', get_lang('ActivateExtension'),'class="save"');
  255. }
  256. $form -> setDefaults($defaults);
  257. $form -> display();
  258. ?>
  259. </td>
  260. </tr>
  261. </table>
  262. </div>
  263. </div>
  264. */ ?>
  265. <!-- PPT2LP -->
  266. <div id="main_ppt2lp">
  267. <div id="extension_header_ppt2lp" class="accordion_header">
  268. <a href="#"><?php echo get_lang('Ppt2lp') ?></a>
  269. </div>
  270. <div id="extension_content_ppt2lp" style="display:none" class="accordion_content">
  271. <?php echo get_lang('Ppt2lpDescription').' '.get_lang('Ppt2lpVoiceRecordingNeedsRed5') ?><br /><br />
  272. <table width="100%">
  273. <tr>
  274. <td valign="top" align="center">
  275. <?php Display::display_icon('screenshot_ppt2lp.jpg', get_lang('Ppt2lp')); ?>
  276. </td>
  277. <td align="center" width="50%">
  278. <form method="POST" action="<?php echo api_get_self(); ?>">
  279. <?php
  280. $form = new FormValidator('ppt2lp');
  281. $form -> addElement('text', 'host', get_lang('Host'));
  282. $form -> addElement('html','<br /><br />');
  283. $form -> addElement('text', 'port', get_lang('Port'));
  284. $form -> addElement('html','<br /><br />');
  285. $form -> addElement('text', 'user', get_lang('UserOnHost'));
  286. $form -> addElement('html','<br /><br />');
  287. $form -> addElement('text', 'ftp_password', get_lang('FtpPassword'));
  288. $form -> addElement('html','<br /><br />');
  289. $form -> addElement('text', 'path_to_lzx', get_lang('PathToLzx'));
  290. $form -> addElement('html','<br /><br />');
  291. $options = array(
  292. '540x405'=>'540x405',
  293. '640x480'=>'640x480',
  294. '720x540'=>'720x540',
  295. '800x600'=>'800x600',
  296. '1000x750'=>'1000x750'
  297. );
  298. $form -> addElement('select', 'size', get_lang('SlideSize'), $options);
  299. $form -> addElement('hidden', 'extension_code', 'ppt2lp');
  300. $defaults = array();
  301. $renderer = $form -> defaultRenderer();
  302. $renderer -> setElementTemplate('<div style="text-align:left">{label}</div><div style="text-align:left">{element}</div>');
  303. $form -> addElement('html','<br /><br />');
  304. if(in_array('service_ppt2lp',$listActiveServices))
  305. {
  306. $sql = 'SELECT subkey, selected_value FROM '.$tbl_settings_current.'
  307. WHERE variable = "service_ppt2lp"
  308. AND subkey <> "active"';
  309. $rs = Database::query($sql);
  310. while($row = Database::fetch_array($rs,'ASSOC'))
  311. {
  312. $defaults[$row['subkey']] = $row['selected_value'];
  313. }
  314. $form->addButtonSave(get_lang('ReconfigureExtension'), 'activeExtension');
  315. }
  316. else {
  317. $defaults['host'] = 'localhost';
  318. $defaults['port'] = '2002';
  319. $defaults['size'] = '720x540';
  320. $form->addButtonSave(get_lang('ActivateExtension'), 'activeExtension');
  321. }
  322. $form -> setDefaults($defaults);
  323. $form -> display();
  324. echo '<br />';
  325. ?>
  326. </form>
  327. </td>
  328. </tr>
  329. </table>
  330. </div>
  331. </div>
  332. <?php
  333. /*
  334. <!-- EPHORUS -->
  335. <div id="main_ephorus">
  336. <div id="extension_header_ephorus" class="accordion_header">
  337. <a href="#"><?php echo get_lang('EphorusPlagiarismPrevention') ?></a>
  338. </div>
  339. <div id="extension_content_ephorus" style="display:none;padding:0;width:780px;" class="accordion_content">
  340. <table width="100%" cellpadding="0" cellspacing="0">
  341. <tr>
  342. <td align="center">
  343. <TABLE style="WIDTH: 750px" cellSpacing="0" cellPadding="0" align="middle" border="0">
  344. <TBODY>
  345. <TR>
  346. <TD>
  347. <TABLE style="WIDTH: 475px" cellSpacing="0" cellPadding="0" border="0">
  348. <TBODY>
  349. <TR>
  350. <TD>
  351. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  352. <a title="http://www.ephorus.com/dokeos_activate.html" href="http://www.ephorus.com/dokeos_activate.html" target="_blank">
  353. <?php Display::display_icon('ephorus.gif','Ephorus'); ?>
  354. </a>
  355. </TD>
  356. <TD>
  357. <P align=center>
  358. <FONT color="#669966" size="3"><?php echo get_lang('EphorusLeadersInAntiPlagiarism') ?></FONT>
  359. </P>
  360. </TD>
  361. </TR>
  362. </TBODY>
  363. </TABLE>
  364. </TD>
  365. </TR>
  366. <TR>
  367. <TD>
  368. <P>
  369. <TABLE style="WIDTH: 85%" cellSpacing="0" cellPadding="0" border="0">
  370. <TBODY>
  371. <TR>
  372. <TD width="50">&nbsp;
  373. </TD>
  374. <TD>
  375. <P>
  376. <?php echo get_lang('EphorusDescription') ?>
  377. </P>
  378. <P>
  379. <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>
  380. </P>
  381. <P>
  382. <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>.
  383. </P>
  384. </TD>
  385. </TR>
  386. </TBODY>
  387. </TABLE>
  388. </P>
  389. </TD>
  390. </TR>
  391. </TBODY>
  392. </TABLE>
  393. </td>
  394. </tr>
  395. </table>
  396. </div>
  397. </div>
  398. */
  399. /*
  400. <!-- SEARCH -->
  401. <div id="main_search">
  402. <div id="extension_header_search" class="accordion_header">
  403. <a href="#"><?php echo get_lang('SearchEngine') ?></a>
  404. </div>
  405. <div id="extension_content_search" style="display:none" class="accordion_content">
  406. <?php echo get_lang('SearchEngineDescription') ?><br /><br />
  407. <table width="100%">
  408. <tr>
  409. <td width="50%">
  410. <?php Display::display_icon('screenshot_search.jpg', get_lang('SearchEngine')); ?>
  411. </td>
  412. <td align="center" width="50%">
  413. <form method="POST" action="<?php echo api_get_self(); ?>">
  414. <input type="hidden" name="extension_code" value="search" />
  415. <button type="submit" class="save" name="activeExtension" value="<?php echo get_lang('ActivateExtension') ?>" ><?php echo get_lang('ActivateExtension') ?></button>
  416. </form>
  417. </td>
  418. </tr>
  419. </table>
  420. </div>
  421. </div>
  422. <!-- SERVER STATS -->
  423. <div id="main_serverstats">
  424. <div id="extension_header_serverstats" class="accordion_header">
  425. <a href="#"><?php echo get_lang('ServerStatistics') ?></a>
  426. </div>
  427. <div id="extension_content_serverstats" style="display:none" class="accordion_content">
  428. <?php echo get_lang('ServerStatisticsDescription') ?><br /><br />
  429. <table width="100%">
  430. <tr>
  431. <td width="50%">
  432. <?php Display::display_icon('screenshot_serverstats.jpg', get_lang('ServerStatistics')); ?>
  433. </td>
  434. <td align="center" width="50%">
  435. <form method="POST" action="<?php echo api_get_self(); ?>">
  436. <input type="hidden" name="extension_code" value="serverstats" />
  437. <button type="submit" class="save" name="activeExtension" value="<?php echo get_lang('ActivateExtension') ?>" ><?php echo get_lang('ActivateExtension') ?></button>
  438. </form>
  439. </td>
  440. </tr>
  441. </table>
  442. </div>
  443. </div>
  444. <!-- BANDWIDTH STATS -->
  445. <div id="main_bandwidthstats">
  446. <div id="extension_header_bandwidthstats" class="accordion_header">
  447. <a href="#"><?php echo get_lang('BandWidthStatistics') ?></a>
  448. </div>
  449. <div id="extension_content_bandwidthstats" style="display:none" class="accordion_content">
  450. <?php echo get_lang('BandWidthStatisticsDescription') ?><br /><br />
  451. <table width="100%">
  452. <tr>
  453. <td width="50%">
  454. <?php Display::display_icon('screenshot_bandwidth.jpg', get_lang('BandWidthStatistics')); ?>
  455. </td>
  456. <td align="center" width="50%">
  457. <form method="POST" action="<?php echo api_get_self(); ?>">
  458. <input type="hidden" name="extension_code" value="bandwidthstats" />
  459. <button type="submit" class="save" name="activeExtension" value="<?php echo get_lang('ActivateExtension') ?>" ><?php echo get_lang('ActivateExtension') ?></button>
  460. </form>
  461. </td>
  462. </tr>
  463. </table>
  464. </div>
  465. </div>
  466. */ ?>
  467. </div><!-- /content -->
  468. <?php
  469. Display::display_footer();