This repository has been archived by the owner on Jun 22, 2020. It is now read-only.
forked from phpmyadmin/phpmyadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs_forms.php
101 lines (91 loc) · 2.7 KB
/
prefs_forms.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* User preferences page
*
* @package PhpMyAdmin
*/
use PMA\libraries\config\ConfigFile;
use PMA\libraries\config\FormDisplay;
use PMA\libraries\Response;
use PMA\libraries\URL;
/**
* Gets some core libraries and displays a top message if required
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/user_preferences.lib.php';
require_once 'libraries/config/config_functions.lib.php';
require_once 'libraries/config/messages.inc.php';
require 'libraries/config/user_preferences.forms.php';
$cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
PMA_userprefsPageInit($cf);
// handle form processing
$form_param = isset($_GET['form']) ? $_GET['form'] : null;
if (! isset($forms[$form_param])) {
$forms_keys = array_keys($forms);
$form_param = array_shift($forms_keys);
}
$form_display = new FormDisplay($cf);
foreach ($forms[$form_param] as $form_name => $form) {
// skip Developer form if no setting is available
if ($form_name == 'Developer' && !$GLOBALS['cfg']['UserprefsDeveloperTab']) {
continue;
}
$form_display->registerForm($form_name, $form, 1);
}
if (isset($_POST['revert'])) {
// revert erroneous fields to their default values
$form_display->fixErrors();
// redirect
$url_params = array('form' => $form_param);
PMA_sendHeaderLocation(
'./prefs_forms.php'
. URL::getCommonRaw($url_params)
);
exit;
}
$error = null;
if ($form_display->process(false) && !$form_display->hasErrors()) {
// save settings
$result = PMA_saveUserprefs($cf->getConfigArray());
if ($result === true) {
// reload config
$GLOBALS['PMA_Config']->loadUserPreferences();
$tabHash = isset($_POST['tab_hash']) ? $_POST['tab_hash'] : null;
$hash = ltrim($tabHash, '#');
PMA_userprefsRedirect(
'prefs_forms.php',
array('form' => $form_param),
$hash
);
exit;
} else {
$error = $result;
}
}
// display forms
$response = Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('config.js');
require 'libraries/user_preferences.inc.php';
if ($error) {
$error->display();
}
if ($form_display->hasErrors()) {
// form has errors
?>
<div class="error config-form">
<b>
<?php echo __('Cannot save settings, submitted form contains errors!') ?>
</b>
<?php echo $form_display->displayErrors(); ?>
</div>
<?php
}
echo $form_display->getDisplay(true, true);
if ($response->isAjax()) {
$response->addJSON('_disableNaviSettings', true);
} else {
define('PMA_DISABLE_NAVI_SETTINGS', true);
}