save lang and collation_connection to user preferences
This commit is contained in:
@@ -420,9 +420,11 @@ class PMA_Config
|
||||
* must be called after control connection has been estabilished
|
||||
*
|
||||
* @uses $GLOBALS['cfg']
|
||||
* @uses $_SESSION['cache']['config_mtime']
|
||||
* @uses $_SESSION['cache']['userprefs']
|
||||
* @uses $_SESSION['cache']['userprefs_mtime']
|
||||
* @uses $GLOBALS['collation_connection']
|
||||
* @uses $GLOBALS['lang']
|
||||
* @uses $_SESSION['cache']['server_$server']['config_mtime']
|
||||
* @uses $_SESSION['cache']['server_$server']['userprefs']
|
||||
* @uses $_SESSION['cache']['server_$server']['userprefs_mtime']
|
||||
* @uses $_SESSION['PMA_Theme_Manager']
|
||||
* @uses PMA_apply_userprefs()
|
||||
* @uses PMA_array_merge_recursive()
|
||||
@@ -472,14 +474,11 @@ class PMA_Config
|
||||
// changes are made only in index.php so everything is set when
|
||||
// in frames
|
||||
|
||||
// load/save theme
|
||||
// theme cookie exists only if we are using non-default theme
|
||||
// save theme
|
||||
$tmanager = $_SESSION['PMA_Theme_Manager'];
|
||||
|
||||
// save new theme
|
||||
if ($tmanager->getThemeCookie() || isset($_REQUEST['set_theme'])) {
|
||||
if (!isset($config_data['ThemeDefault'])
|
||||
|| $config_data['ThemeDefault'] != $tmanager->theme->getId()) {
|
||||
if ((!isset($config_data['ThemeDefault']) && $tmanager->theme->getId() != 'original')
|
||||
|| isset($config_data['ThemeDefault']) && $config_data['ThemeDefault'] != $tmanager->theme->getId()) {
|
||||
// new theme was set in common.inc.php
|
||||
$this->setUserValue(null, 'ThemeDefault', $tmanager->theme->getId(), 'original');
|
||||
}
|
||||
@@ -492,9 +491,37 @@ class PMA_Config
|
||||
}
|
||||
}
|
||||
|
||||
// save new font size
|
||||
if (!isset($config_data['fontsize']) || $org_fontsize != $config_data['fontsize']) {
|
||||
$this->setUserValue('pma_fontsize', 'fontsize', $org_fontsize, '82%');
|
||||
// save font size
|
||||
if ((!isset($config_data['fontsize']) && $org_fontsize != '82%')
|
||||
|| isset($config_data['fontsize']) && $org_fontsize != $config_data['fontsize']) {
|
||||
$this->setUserValue(null, 'fontsize', $org_fontsize, '82%');
|
||||
}
|
||||
|
||||
// save language
|
||||
if (isset($_COOKIE['pma_lang']) || isset($_POST['lang'])) {
|
||||
if ((!isset($config_data['lang']) && $GLOBALS['lang'] != 'en')
|
||||
|| isset($config_data['lang']) && $GLOBALS['lang'] != $config_data['lang']) {
|
||||
$this->setUserValue(null, 'lang', $GLOBALS['lang'], 'en');
|
||||
}
|
||||
} else {
|
||||
// read language from settings
|
||||
if (isset($config_data['lang']) && PMA_langSet($config_data['lang'])) {
|
||||
$this->setCookie('pma_lang', $GLOBALS['lang']);
|
||||
}
|
||||
}
|
||||
|
||||
// save connection collation
|
||||
if (isset($_COOKIE['pma_collation_connection']) || isset($_POST['collation_connection'])) {
|
||||
if ((!isset($config_data['collation_connection']) && $GLOBALS['collation_connection'] != 'utf8_general_ci')
|
||||
|| isset($config_data['collation_connection']) && $GLOBALS['collation_connection'] != $config_data['collation_connection']) {
|
||||
$this->setUserValue(null, 'collation_connection', $GLOBALS['collation_connection'], 'utf8_general_ci');
|
||||
}
|
||||
} else {
|
||||
// read collation from settings
|
||||
if (isset($config_data['collation_connection'])) {
|
||||
$GLOBALS['collation_connection'] = $config_data['collation_connection'];
|
||||
$this->setCookie('pma_collation_connection', $GLOBALS['collation_connection']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -135,8 +135,11 @@ function PMA_apply_userprefs(array $config_data)
|
||||
$cfg = array();
|
||||
$blacklist = array_flip($GLOBALS['cfg']['UserprefsDisallow']);
|
||||
$whitelist = array_flip(PMA_read_userprefs_fieldnames());
|
||||
// whitelist some additional fields which are custom handled
|
||||
$whitelist['ThemeDefault'] = true;
|
||||
$whitelist['fontsize'] = true;
|
||||
$whitelist['lang'] = true;
|
||||
$whitelist['collation_connection'] = true;
|
||||
foreach ($config_data as $path => $value) {
|
||||
if (!isset($whitelist[$path]) || isset($blacklist[$path])) {
|
||||
continue;
|
||||
@@ -210,19 +213,21 @@ function PMA_persist_option($path, $value, $default_value)
|
||||
*/
|
||||
function PMA_userprefs_redirect(array $forms, array $old_settings, $file_name, $params = null)
|
||||
{
|
||||
// compute differences and check whether left frame should be refreshed
|
||||
$old_settings = isset($old_settings['config_data'])
|
||||
? $old_settings['config_data']
|
||||
: array();
|
||||
$new_settings = ConfigFile::getInstance()->getConfigArray();
|
||||
$diff_keys = array_keys(array_diff_assoc($old_settings, $new_settings)
|
||||
+ array_diff_assoc($new_settings, $old_settings));
|
||||
$check_keys = array('NaturalOrder', 'MainPageIconic', 'DefaultTabDatabase');
|
||||
$check_keys = array_merge($check_keys, $forms['Left_frame']['Left_frame'],
|
||||
$forms['Left_frame']['Left_databases']);
|
||||
$diff = array_intersect($check_keys, $diff_keys);
|
||||
$reload_left_frame = !empty($diff)
|
||||
|| (isset($params['reload_left_frame']) && $params['reload_left_frame']);
|
||||
$reload_left_frame = isset($params['reload_left_frame']) && $params['reload_left_frame'];
|
||||
if (!$reload_left_frame) {
|
||||
// compute differences and check whether left frame should be refreshed
|
||||
$old_settings = isset($old_settings['config_data'])
|
||||
? $old_settings['config_data']
|
||||
: array();
|
||||
$new_settings = ConfigFile::getInstance()->getConfigArray();
|
||||
$diff_keys = array_keys(array_diff_assoc($old_settings, $new_settings)
|
||||
+ array_diff_assoc($new_settings, $old_settings));
|
||||
$check_keys = array('NaturalOrder', 'MainPageIconic', 'DefaultTabDatabase');
|
||||
$check_keys = array_merge($check_keys, $forms['Left_frame']['Left_frame'],
|
||||
$forms['Left_frame']['Left_databases']);
|
||||
$diff = array_intersect($check_keys, $diff_keys);
|
||||
$reload_left_frame = !empty($diff);
|
||||
}
|
||||
|
||||
// redirect
|
||||
$url_params = array(
|
||||
|
@@ -133,15 +133,27 @@ if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') ==
|
||||
// check for ThemeDefault and fontsize
|
||||
$params = array();
|
||||
if (isset($config['ThemeDefault'])
|
||||
&& $_SESSION['PMA_Theme_Manager']->theme->getId() != $config['ThemeDefault']
|
||||
&& $_SESSION['PMA_Theme_Manager']->checkTheme($config['ThemeDefault'])) {
|
||||
$_SESSION['PMA_Theme_Manager']->setActiveTheme($config['ThemeDefault']);
|
||||
$_SESSION['PMA_Theme_Manager']->setThemeCookie();
|
||||
$params['reload_left_frame'] = true;
|
||||
}
|
||||
if (isset($config['fontsize'])) {
|
||||
if (isset($config['fontsize'])
|
||||
&& $config['fontsize'] != $GLOBALS['PMA_Config']->get('fontsize')) {
|
||||
$params['set_fontsize'] = $config['fontsize'];
|
||||
$params['reload_left_frame'] = true;
|
||||
}
|
||||
if (isset($config['lang'])
|
||||
&& $config['lang'] != $GLOBALS['lang']) {
|
||||
$params['lang'] = $config['lang'];
|
||||
$params['reload_left_frame'] = true;
|
||||
}
|
||||
if (isset($config['collation_connection'])
|
||||
&& $config['collation_connection'] != $GLOBALS['collation_connection']) {
|
||||
$params['collation_connection'] = $config['collation_connection'];
|
||||
$params['reload_left_frame'] = true;
|
||||
}
|
||||
|
||||
// save settings
|
||||
$old_settings = PMA_load_userprefs();
|
||||
@@ -182,6 +194,8 @@ if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') ==
|
||||
$GLOBALS['PMA_Config']->removeCookie('pma_fontsize');
|
||||
$params['reload_left_frame'] = true;
|
||||
}
|
||||
$GLOBALS['PMA_Config']->removeCookie('pma_collaction_connection');
|
||||
$GLOBALS['PMA_Config']->removeCookie('pma_lang');
|
||||
PMA_userprefs_redirect($forms, $old_settings, 'prefs_manage.php', $params);
|
||||
exit;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user