syncparams.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. $cidReset = true;
  3. require_once '../../../main/inc/global.inc.php';
  4. api_protect_admin_script();
  5. require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib.php';
  6. require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib/vchamilo_plugin.class.php';
  7. $action = isset($_GET['what']) ? $_GET['what'] : '';
  8. define('CHAMILO_INTERNAL', true);
  9. $plugininstance = VChamiloPlugin::create();
  10. $thisurl = api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php';
  11. if ($action){
  12. require_once(api_get_path(SYS_PLUGIN_PATH).'vchamilo/views/syncparams.controller.php');
  13. }
  14. $settings = api_get_settings();
  15. $table = new HTML_Table(array('class' => 'data_table', 'width' => '100%'));
  16. $column = 0;
  17. $row = 0;
  18. // $table->set_additional_parameters($parameters);
  19. $headers = array(
  20. '',
  21. $plugininstance->get_lang('variable').' ['.$plugininstance->get_lang('subkey').']',
  22. $plugininstance->get_lang('category'),
  23. $plugininstance->get_lang('accessurl'),
  24. $plugininstance->get_lang('value'),
  25. '',
  26. );
  27. $attrs = array('center' => 'left');
  28. $table->addRow($headers, $attrs, 'th');
  29. foreach ($settings as $param) {
  30. if ($param['subkey'] == 'vchamilo') {
  31. continue;
  32. }
  33. // $check = '<input type="checkbox" name="sync_'.$param->id.'" value="'.$param->selected_value.'" />';
  34. //<input type="checkbox" name="del_'.$param['id'].'" value="1" title="'.$plugininstance->get_lang('deleteifempty').'" />
  35. $check = '';
  36. $attrs = array('center' => 'left');
  37. $syncthisbutton = '<input type="button" name="syncthis" value="'.$plugininstance->get_lang('syncthis').'" onclick="ajax_sync_setting(\''.$_configuration['root_web'].'\', \''.$param['id'].'\')" />
  38. <span id="res_'.$param['id'].'"></span>';
  39. $data = array(
  40. $check,
  41. isset($param['subkey']) && !empty($param['subkey']) ? $param['variable'].' ['.$param['subkey'].']' : $param['variable'],
  42. $param['category'],
  43. $param['access_url'],
  44. '<input type="text" name="value_'.$param['id'].'" value="'.htmlspecialchars($param['selected_value'], ENT_COMPAT, 'UTF-8' ).'" />'.
  45. '<br />Master value: '.$param['selected_value'],
  46. $syncthisbutton,
  47. );
  48. $row = $table->addRow($data, $attrs, 'td');
  49. $table->setRowAttributes($row, array('id' => 'row_'.$param['id']), true);
  50. }
  51. $content = '<form name="settingsform" action="'.$thisurl.'">';
  52. $content .= '<input type="hidden" name="what" value="" />';
  53. $content .= $table->toHtml();
  54. // $content .= '<div class"vchamilo-right"><div></div><div><input type="button" name="syncall" value="'.$plugininstance->get_lang('syncall').'" onclick="this.form.what.value=\'syncall\';this.form.submit();">';
  55. $content .= '</form>';
  56. $actions = '';
  57. Display::addFlash(Display::return_message($plugininstance->get_lang('Sync your master settings to all instances.')));
  58. $message = require_js('ajax.js', 'vchamilo', true);
  59. $interbreadcrumb[] = array('url' => 'manage.php', 'name' => get_lang('VChamilo'));
  60. $tpl = new Template($plugininstance->get_lang('sync_settings'), true, true, false, true, false);
  61. $tpl->assign('actions', $actions);
  62. $tpl->assign('message', $message);
  63. $tpl->assign('content', $content);
  64. $tpl->display_one_col_template();