Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 92 lines (82 sloc) 2.611 kB
6b2f774 @Crack Add category tabs to preferences page
Crack authored
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * User preferences page
5 *
e56949f @nijel Use package name PhpMyAdmin
nijel authored
6 * @package PhpMyAdmin
6b2f774 @Crack Add category tabs to preferences page
Crack authored
7 */
8
9 /**
10 * Gets some core libraries and displays a top message if required
11 */
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
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';
6b2f774 @Crack Add category tabs to preferences page
Crack authored
20
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
21 PMA_userprefs_pageinit();
22
23 // handle form processing
e842432 @Crack User preferences:
Crack authored
24
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
25 $form_param = filter_input(INPUT_GET, 'form');
13b3195 @lem9 For easier reading, replace "!isset" with "! isset"
lem9 authored
26 if (! isset($forms[$form_param])) {
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
27 $forms_keys = array_keys($forms);
28 $form_param = array_shift($forms_keys);
29 }
9f44d86 @Crack user preferences saving and integration
Crack authored
30
3ed3539 @Crack Setup script refactoring: moved ConfigFile, Form, FormDisplay
Crack authored
31 $form_display = new FormDisplay();
03e66cd @Crack Display forms
Crack authored
32 foreach ($forms[$form_param] as $form_name => $form) {
7ac7e24 @Crack more styling for disabled options
Crack authored
33 // skip Developer form if no setting is available
2e55d85 @Crack Developers tab no longer depends on UserprefsDisallow, introduced Use…
Crack authored
34 if ($form_name == 'Developer' && !$GLOBALS['cfg']['UserprefsDeveloperTab']) {
35 continue;
7ac7e24 @Crack more styling for disabled options
Crack authored
36 }
9a73307 @Crack allow users to set only_db and hide_db
Crack authored
37 $form_display->registerForm($form_name, $form, 1);
3ed3539 @Crack Setup script refactoring: moved ConfigFile, Form, FormDisplay
Crack authored
38 }
6b2f774 @Crack Add category tabs to preferences page
Crack authored
39
b68ba42 @Crack Better error handling
Crack authored
40 if (isset($_POST['revert'])) {
03e66cd @Crack Display forms
Crack authored
41 // revert erroneous fields to their default values
42 $form_display->fixErrors();
43 // redirect
44 $url_params = array('form' => $form_param);
3332151 @madhuracj Fix Checkstyle Warnings - Type: CloseBracketLine (Closing parenthesis…
madhuracj authored
45 PMA_sendHeaderLocation(
46 $cfg['PmaAbsoluteUri'] . 'prefs_forms.php'
47 . PMA_generate_common_url($url_params, '&')
48 );
03e66cd @Crack Display forms
Crack authored
49 exit;
50 }
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
51
98cbab0 @Crack second part of error message display changes
Crack authored
52 $error = null;
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
53 if ($form_display->process(false) && !$form_display->hasErrors()) {
54 // save settings
55 $old_settings = PMA_load_userprefs();
56 $result = PMA_save_userprefs(ConfigFile::getInstance()->getConfigArray());
57 if ($result === true) {
a6b34a5 @Crack fix generation of theme unique value
Crack authored
58 // reload config
59 $GLOBALS['PMA_Config']->loadUserPreferences();
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
60 $hash = ltrim(filter_input(INPUT_POST, 'tab_hash'), '#');
3332151 @madhuracj Fix Checkstyle Warnings - Type: CloseBracketLine (Closing parenthesis…
madhuracj authored
61 PMA_userprefs_redirect(
62 $forms, $old_settings, 'prefs_forms.php',
63 array('form' => $form_param), $hash
64 );
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
65 exit;
03e66cd @Crack Display forms
Crack authored
66 } else {
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
67 $error = $result;
03e66cd @Crack Display forms
Crack authored
68 }
69 }
2e1fd26 @Crack Configuration forms styling
Crack authored
70
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
71 // display forms
a054562 @roccivic PMA_Footer and PMA_Header no longer need to be singletons
roccivic authored
72 $response = PMA_Response::getInstance();
73 $header = $response->getHeader();
74 $scripts = $header->getScripts();
4a74037 @roccivic Dropped header.inc.php in favor of the PMA_Header class
roccivic authored
75 $scripts->addFile('config.js');
a054562 @roccivic PMA_Footer and PMA_Header no longer need to be singletons
roccivic authored
76
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
77 require 'libraries/user_preferences.inc.php';
98cbab0 @Crack second part of error message display changes
Crack authored
78 if ($error) {
79 $error->display();
80 }
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
81 if ($form_display->hasErrors()) {
82 // form has errors
83 ?>
b2b1953 @lem9 Start to replace warning level with error level
lem9 authored
84 <div class="error config-form">
98cbab0 @Crack second part of error message display changes
Crack authored
85 <b><?php echo __('Cannot save settings, submitted form contains errors') ?></b>
279724d @Crack bugfix: user preferences don't work correctly without output buffering
Crack authored
86 <?php $form_display->displayErrors(); ?>
87 </div>
88 <?php
89 }
90 $form_display->display(true, true);
b2b1953 @lem9 Start to replace warning level with error level
lem9 authored
91 ?>
Something went wrong with that request. Please try again.