configure_plugin.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. @author Julio Montoya <gugli100@gmail.com> BeezNest 2012
  5. * @package chamilo.admin
  6. */
  7. // name of the language file that needs to be included
  8. $language_file = array ('registration','admin');
  9. $cidReset = true;
  10. ////require_once '../inc/global.inc.php';
  11. // Access restrictions
  12. api_protect_admin_script();
  13. $plugin_name = $_GET['name'];
  14. $plugin_obj = new AppPlugin();
  15. $plugin_info = $plugin_obj->getPluginInfo($plugin_name, true);
  16. if (empty($plugin_info)) {
  17. api_not_allowed();
  18. }
  19. $installed_plugins = $plugin_obj->get_installed_plugins();
  20. if (!in_array($plugin_name, $installed_plugins)) {
  21. api_not_allowed();
  22. }
  23. global $_configuration;
  24. $message = null;
  25. $content = null;
  26. if (isset($plugin_info['settings_form'])) {
  27. $form = $plugin_info['settings_form'];
  28. if (isset($form)) {
  29. //We override the form attributes
  30. $attributes = array('action'=>api_get_self().'?name='.$plugin_name, 'method'=>'POST');
  31. $form->updateAttributes($attributes);
  32. $content = Display::page_header($plugin_info['title']);
  33. $content .= $form->toHtml();
  34. }
  35. } else {
  36. $message = Display::return_message(get_lang('NoConfigurationSettingsForThisPlugin'), 'warning');
  37. }
  38. if (isset($form)) {
  39. if ($form->validate()) {
  40. $values = $form->exportValues();
  41. //api_delete_category_settings_by_subkey($plugin_name);
  42. $access_url_id = api_get_current_access_url_id();
  43. api_delete_settings_params(array('category = ? AND access_url = ? AND subkey = ? AND type = ? and variable <> ?' =>
  44. array('Plugins', $access_url_id, $plugin_name, 'setting', "status")));
  45. foreach ($values as $key => $value) {
  46. $key = Database::escape_string($plugin_name.'_'.$key);
  47. api_add_setting(
  48. $value,
  49. $key,
  50. $plugin_name,
  51. 'setting',
  52. 'Plugins',
  53. $plugin_name,
  54. null,
  55. null,
  56. null,
  57. $_configuration['access_url'],
  58. 1
  59. );
  60. }
  61. $message = Display::return_message(get_lang('Updated'), 'success');
  62. }
  63. }
  64. $app['title'] = $tool_name;
  65. $tpl = $app['template'];
  66. $tpl->assign('actions', $actions);
  67. $tpl->assign('message', $message);
  68. $tpl->assign('content', $content);
  69. $tpl->display_one_col_template();