diff --git a/libraries/user_preferences.inc.php b/libraries/user_preferences.inc.php index 00bc89747..e11b5e1c6 100644 --- a/libraries/user_preferences.inc.php +++ b/libraries/user_preferences.inc.php @@ -47,17 +47,8 @@ if (!empty($_GET['saved'])) { $message->display(); } -$forms_all_keys = PMA_read_userprefs_fieldnames($forms); -$cf = ConfigFile::getInstance(); -$cf->resetConfigData(); // start with a clean instance -$cf->setAllowedKeys($forms_all_keys); -$cf->setCfgUpdateReadMapping(array( - 'Server/hide_db' => 'Servers/1/hide_db', - 'Server/only_db' => 'Servers/1/only_db')); -$cf->updateWithGlobalConfig($GLOBALS['cfg']); - // todo: debug - remove -$arr = $cf->getConfigArray(); +$arr = ConfigFile::getInstance()->getConfigArray(); $arr2 = array(); foreach ($arr as $k => $v) { $arr2[] = "$k " . var_export($v, true); diff --git a/libraries/user_preferences.lib.php b/libraries/user_preferences.lib.php index 6616963e8..dd26a3f95 100644 --- a/libraries/user_preferences.lib.php +++ b/libraries/user_preferences.lib.php @@ -6,6 +6,21 @@ * @package phpMyAdmin */ +/** + * Common initialization for user preferences modification pages + */ +function PMA_userprefs_pageinit() +{ + $forms_all_keys = PMA_read_userprefs_fieldnames($GLOBALS['forms']); + $cf = ConfigFile::getInstance(); + $cf->resetConfigData(); // start with a clean instance + $cf->setAllowedKeys($forms_all_keys); + $cf->setCfgUpdateReadMapping(array( + 'Server/hide_db' => 'Servers/1/hide_db', + 'Server/only_db' => 'Servers/1/only_db')); + $cf->updateWithGlobalConfig($GLOBALS['cfg']); +} + /** * Loads user preferences * diff --git a/prefs_forms.php b/prefs_forms.php index 280083237..63cdea502 100644 --- a/prefs_forms.php +++ b/prefs_forms.php @@ -18,11 +18,15 @@ require_once './libraries/config/Form.class.php'; require_once './libraries/config/FormDisplay.class.php'; require './libraries/config/user_preferences.forms.php'; -$GLOBALS['js_include'][] = 'config.js'; -require_once './libraries/header.inc.php'; -require_once './libraries/user_preferences.inc.php'; +PMA_userprefs_pageinit(); -// handle form display and processing +// handle form processing + +$form_param = filter_input(INPUT_GET, 'form'); +if (!isset($forms[$form_param])) { + $forms_keys = array_keys($forms); + $form_param = array_shift($forms_keys); +} $form_display = new FormDisplay(); foreach ($forms[$form_param] as $form_name => $form) { @@ -42,36 +46,36 @@ if (isset($_POST['revert'])) { . PMA_generate_common_url($url_params, '&')); exit; } -if (!$form_display->process(false)) { - // handle form view and failed POST - $form_display->display(true, true); -} else { - // check for form errors - if ($form_display->hasErrors()) { - // form has errors - ?> -