bugfix: use true/false for boolean values read from <select>s instead of 1/0
[phpmyadmin.git] / prefs_forms.php
blob63cdea50271465c3fb0eeafbd9a97b52a0f64658
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * User preferences page
6 * @package phpMyAdmin
7 */
9 /**
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 PMA_userprefs_pageinit();
23 // handle form processing
25 $form_param = filter_input(INPUT_GET, 'form');
26 if (!isset($forms[$form_param])) {
27 $forms_keys = array_keys($forms);
28 $form_param = array_shift($forms_keys);
31 $form_display = new FormDisplay();
32 foreach ($forms[$form_param] as $form_name => $form) {
33 // skip Developer form if no setting is available
34 if ($form_name == 'Developer' && !$GLOBALS['cfg']['UserprefsDeveloperTab']) {
35 continue;
37 $form_display->registerForm($form_name, $form, 1);
40 if (isset($_POST['revert'])) {
41 // revert erroneous fields to their default values
42 $form_display->fixErrors();
43 // redirect
44 $url_params = array('form' => $form_param);
45 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'prefs_forms.php'
46 . PMA_generate_common_url($url_params, '&'));
47 exit;
50 if ($form_display->process(false) && !$form_display->hasErrors()) {
51 // save settings
52 $old_settings = PMA_load_userprefs();
53 $result = PMA_save_userprefs(ConfigFile::getInstance()->getConfigArray());
54 if ($result === true) {
55 $hash = ltrim(filter_input(INPUT_POST, 'tab_hash'), '#');
56 PMA_userprefs_redirect($forms, $old_settings, 'prefs_forms.php', array(
57 'form' => $form_param), $hash);
58 exit;
59 } else {
60 $error = $result;
64 // display forms
65 $GLOBALS['js_include'][] = 'config.js';
66 require './libraries/header.inc.php';
67 require './libraries/user_preferences.inc.php';
68 if ($form_display->hasErrors()) {
69 // form has errors
71 <div class="warning config-form">
72 <b><?php echo __('Submitted form contains errors') ?></b>
73 <?php $form_display->displayErrors(); ?>
74 </div>
75 <?php
77 $form_display->display(true, true);
79 /**
80 * Displays the footer
82 require './libraries/footer.inc.php';