2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * User preferences page
10 * Gets some core libraries and displays a top message if required
12 require_once './libraries/common.inc.php';
13 require_once './libraries/user_preferences.lib.php';
14 require_once './libraries/config/config_functions.lib.php';
15 require_once './libraries/config/messages.inc.php';
16 require_once './libraries/config/ConfigFile.class.php';
17 require_once './libraries/config/Form.class.php';
18 require_once './libraries/config/FormDisplay.class.php';
19 require './libraries/config/user_preferences.forms.php';
21 $GLOBALS['js_include'][] = 'config.js';
23 require_once './libraries/header.inc.php';
27 $form_param = filter_input(INPUT_GET
, 'form');
28 if (!isset($forms[$form_param])) {
29 $forms_keys = array_keys($forms);
30 $form_param = array_shift($forms_keys);
33 'Features' => 'b_tblops.png',
34 'Sql_queries' => 'b_sql.png',
35 'Left_frame' => 'b_select.png',
36 'Main_frame' => 'b_props.png',
37 'Import' => 'b_import.png',
38 'Export' => 'b_export.png');
39 foreach (array_keys($forms) as $formset) {
41 'link' => 'user_preferences.php',
42 'text' => PMA_ifSetOr($GLOBALS['strSetupForm_' . $formset], $formset), // TODO: remove ifSetOr
43 'icon' => $tabs_icons[$formset],
44 'active' => $formset == $form_param,
45 'url_params' => array('form' => $formset));
48 echo PMA_generate_html_tabs($tabs, array());
50 // show "configuration saved" message and reload navigation frame if needed
51 if (!empty($_GET['saved'])) {
52 $message = PMA_Message
::rawSuccess(__('Configuration has been saved'));
54 if (isset($_GET['refresh_left_frame']) && $_GET['refresh_left_frame'] == '1') {
56 <script type
="text/javascript">
57 if (window
.parent
&& window
.parent
.frame_navigation
) {
58 window
.parent
.frame_navigation
.location
.reload();
65 // handle form display and processing
67 $forms_all_keys = PMA_read_userprefs_fieldnames($forms);
68 $cf = ConfigFile
::getInstance();
69 $cf->setAllowedKeys($forms_all_keys);
70 $cf->updateWithGlobalConfig($GLOBALS['PMA_Config']);
72 // todo: debug - remove
73 $arr = $cf->getConfigArray();
75 foreach ($arr as $k => $v) {
76 $arr2[] = "<b>$k</b> " . var_export($v, true);
78 $arr2 = implode(', ', $arr2);
79 $arr2 .= '<br />Blacklist: ' . (empty($cfg['UserprefsDisallow'])
81 : implode(', ', $cfg['UserprefsDisallow']));
82 $msg = PMA_Message
::notice('Debug: ' . $arr2);
85 $form_display = new FormDisplay();
86 foreach ($forms[$form_param] as $form_name => $form) {
87 $form_display->registerForm($form_name, $form);
90 if (isset($_POST['revert'])) {
91 // revert erroneous fields to their default values
92 $form_display->fixErrors();
94 $url_params = array('form' => $form_param);
95 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'user_preferences.php'
96 . PMA_generate_common_url($url_params, '&'));
99 if (!$form_display->process(false)) {
100 // handle form view and failed POST
101 $form_display->display(true, true);
103 // check for form errors
104 if ($form_display->hasErrors()) {
108 <b
><?php
echo __('Submitted form contains errors') ?
></b
>
109 <?php
$form_display->displayErrors(); ?
>
112 $form_display->display(true, true);
115 $old_settings = PMA_load_userprefs();
116 $result = PMA_save_userprefs();
117 if ($result === true) {
118 // compute differences and check whether left frame should be refreshed
119 $old_settings = isset($old_settings['config_data'])
120 ?
$old_settings['config_data']
122 $new_settings = ConfigFile
::getInstance()->getConfigArray();
123 $diff_keys = array_keys(array_diff_assoc($old_settings, $new_settings)
124 +
array_diff_assoc($new_settings, $old_settings));
125 $check_keys = array('NaturalOrder', 'MainPageIconic', 'DefaultTabDatabase');
126 $check_keys = array_merge($check_keys, $forms['Left_frame']['Left_frame'],
127 $forms['Left_frame']['Left_servers'], $forms['Left_frame']['Left_databases']);
128 $diff = array_intersect($check_keys, $diff_keys);
129 $refresh_left_frame = !empty($diff);
133 'form' => $form_param,
135 'refresh_left_frame' => $refresh_left_frame);
136 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'user_preferences.php'
137 . PMA_generate_common_url($url_params, '&'));
142 $form_display->display(true, true);
145 $GLOBALS['error_handler']->dispAllErrors();
148 * Displays the footer
150 require_once './libraries/footer.inc.php';