Some fixes in phpgacl to work with php 5.4
[openemr.git] / phpmyadmin / prefs_forms.php
blob68b7274ab0826efafe36c580dbb77cc7e3f29509
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 $cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
22 PMA_userprefsPageInit($cf);
24 // handle form processing
26 $form_param = isset($_GET['form']) ? $_GET['form'] : null;
27 if (! isset($forms[$form_param])) {
28 $forms_keys = array_keys($forms);
29 $form_param = array_shift($forms_keys);
32 $form_display = new FormDisplay($cf);
33 foreach ($forms[$form_param] as $form_name => $form) {
34 // skip Developer form if no setting is available
35 if ($form_name == 'Developer' && !$GLOBALS['cfg']['UserprefsDeveloperTab']) {
36 continue;
38 $form_display->registerForm($form_name, $form, 1);
41 if (isset($_POST['revert'])) {
42 // revert erroneous fields to their default values
43 $form_display->fixErrors();
44 // redirect
45 $url_params = array('form' => $form_param);
46 PMA_sendHeaderLocation(
47 $cfg['PmaAbsoluteUri'] . 'prefs_forms.php'
48 . PMA_URL_getCommon($url_params, 'text')
50 exit;
53 $error = null;
54 if ($form_display->process(false) && !$form_display->hasErrors()) {
55 // save settings
56 $result = PMA_saveUserprefs($cf->getConfigArray());
57 if ($result === true) {
58 // reload config
59 $GLOBALS['PMA_Config']->loadUserPreferences();
60 $tabHash = isset($_POST['tab_hash']) ? $_POST['tab_hash'] : null;
61 $hash = ltrim($tabHash, '#');
62 PMA_userprefsRedirect(
63 'prefs_forms.php',
64 array('form' => $form_param),
65 $hash
67 exit;
68 } else {
69 $error = $result;
73 // display forms
74 $response = PMA_Response::getInstance();
75 $header = $response->getHeader();
76 $scripts = $header->getScripts();
77 $scripts->addFile('config.js');
79 require 'libraries/user_preferences.inc.php';
80 if ($error) {
81 $error->display();
83 if ($form_display->hasErrors()) {
84 // form has errors
86 <div class="error config-form">
87 <b>
88 <?php echo __('Cannot save settings, submitted form contains errors!') ?>
89 </b>
90 <?php echo $form_display->displayErrors(); ?>
91 </div>
92 <?php
94 echo $form_display->getDisplay(true, true);
96 if ($response->isAjax()) {
97 $response->addJSON('_disableNaviSettings', true);
98 } else {
99 define('PMA_DISABLE_NAVI_SETTINGS', true);