diff --git a/libraries/Config.class.php b/libraries/Config.class.php index f1ad1871a..0cf0c3baf 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -416,7 +416,7 @@ class PMA_Config } /** - * loads user preferences and merges them with current config + * Loads user preferences and merges them with current config * must be called after control connection has been estabilished * * @uses $GLOBALS['cfg'] @@ -443,6 +443,7 @@ class PMA_Config $prefs = PMA_load_userprefs(); $_SESSION['cache']['userprefs'] = PMA_apply_userprefs($prefs['config_data']); $_SESSION['cache']['userprefs_mtime'] = $prefs['mtime']; + $_SESSION['cache']['userprefs_type'] = $prefs['type']; $_SESSION['cache']['config_mtime'] = $config_mtime; } } else if (!isset($_SESSION['cache']['userprefs'])) { @@ -450,12 +451,11 @@ class PMA_Config return; } $config_data = $_SESSION['cache']['userprefs']; - // todo: check for empty user data, user_preferences should then be true + // type id 'db' or 'session' + $this->set('user_preferences', $_SESSION['cache']['userprefs_type']); if (!$config_data) { - $this->set('user_preferences', false); return false; } - $this->set('user_preferences', true); // backup some settings $fontsize = $this->get('fontsize'); @@ -511,13 +511,15 @@ class PMA_Config function setUserValue($cookie_name, $cfg_path, $new_cfg_value, $default_value = null) { // use permanent user preferences if possible - if ($this->get('user_preferences')) { + $prefs_type = $this->get('user_preferences'); + if ($prefs_type) { require_once './libraries/user_preferences.lib.php'; if ($default_value === null) { $default_value = PMA_array_read($cfg_path, $this->default); } PMA_persist_option($cfg_path, $new_cfg_value, $default_value); - } else if ($cookie_name) { + } + if ($prefs_type != 'db' && $cookie_name) { // fall back to cookies if ($default_value === null) { $default_value = PMA_array_read($cfg_path, $this->settings); @@ -538,8 +540,9 @@ class PMA_Config function getUserValue($cookie_name, $cfg_value) { $cookie_exists = isset($_COOKIE) && !empty($_COOKIE[$cookie_name]); - if ($this->get('user_preferences')) { - // user preferences value exists, remove cookie + $prefs_type = $this->get('user_preferences'); + if ($prefs_type == 'db') { + // permanent user preferences value exists, remove cookie if ($cookie_exists) { $this->removeCookie($cookie_name); } diff --git a/libraries/user_preferences.inc.php b/libraries/user_preferences.inc.php index 2cdb01368..3b3ebe798 100644 --- a/libraries/user_preferences.inc.php +++ b/libraries/user_preferences.inc.php @@ -74,6 +74,11 @@ $arr2 .= '
Blacklist: ' . (empty($cfg['UserprefsDisallow']) $msg = PMA_Message::notice('Debug: ' . $arr2); $msg->display(); +// warn about using session storage for settings +$msg = __('Your preferences will be saved only for current session. Storing them permanently requires %s pmadb %s.'); +$msg = PMA_sanitize(sprintf($msg, '[a@http://wiki.phpmyadmin.net/pma/pmadb@_blank]', '[/a]')); +PMA_Message::notice($msg)->display(); + if (isset($error) && $error) { if (!$error instanceof PMA_Message) { $error = PMA_Message::error($error); diff --git a/libraries/user_preferences.lib.php b/libraries/user_preferences.lib.php index 3b52e9bbf..421ebebf1 100644 --- a/libraries/user_preferences.lib.php +++ b/libraries/user_preferences.lib.php @@ -12,7 +12,9 @@ * Returns false or an array: * * config_data - path => value pairs * * mtime - last modification time + * * type - 'db' (config read from pmadb) or 'session' (read from user session) * + * @uses $_SESSION['userconfig'] * @uses PMA_array_merge_recursive * @uses PMA_backquote() * @uses PMA_DBI_fetch_single_row() @@ -25,8 +27,18 @@ function PMA_load_userprefs() { $cfgRelation = PMA_getRelationsParam(); if (!$cfgRelation['userconfigwork']) { - return false; + // no pmadb table, use session storage + if (!isset($_SESSION['userconfig'])) { + $_SESSION['userconfig'] = array( + 'db' => array(), + 'ts' => time()); + } + return array( + 'config_data' => $_SESSION['userconfig']['db'], + 'mtime' => $_SESSION['userconfig']['ts'], + 'type' => 'session'); } + // load configuration from pmadb $query_table = PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['userconfig']); $query = ' SELECT `config_data`, UNIX_TIMESTAMP(`timevalue`) ts @@ -39,7 +51,8 @@ function PMA_load_userprefs() $config_data = unserialize($row['config_data']); return array( 'config_data' => $config_data, - 'mtime' => $row['ts']); + 'mtime' => $row['ts'], + 'type' => 'db'); } /** @@ -47,6 +60,7 @@ function PMA_load_userprefs() * * @uses $GLOBALS['controllink'] * @uses $_SESSION['cache']['userprefs'] + * @uses $_SESSION['userconfig'] * @uses ConfigFile::getConfigArray() * @uses ConfigFile::getInstance() * @uses PMA_backquote() @@ -64,8 +78,18 @@ function PMA_load_userprefs() function PMA_save_userprefs(array $config_array) { $cfgRelation = PMA_getRelationsParam(); - $config_data = serialize($config_array); + if (!$cfgRelation['userconfigwork']) { + // no pmadb table, use session storage + $_SESSION['userconfig'] = array( + 'db' => $config_array, + 'ts' => time()); + if (isset($_SESSION['cache']['userprefs'])) { + unset($_SESSION['cache']['userprefs']); + } + return true; + } + // save configuration to pmadb $query_table = PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['userconfig']); $query = ' SELECT `username` @@ -73,6 +97,7 @@ function PMA_save_userprefs(array $config_array) WHERE `username` = \'' . PMA_sqlAddslashes($cfgRelation['user']) . '\''; $has_config = PMA_DBI_fetch_value($query, 0, 0, $GLOBALS['controllink']); + $config_data = serialize($config_array); if ($has_config) { $query = ' UPDATE ' . $query_table . ' diff --git a/themes/original/css/theme_right.css.php b/themes/original/css/theme_right.css.php index 1fbc7652a..8cfb5d6e4 100644 --- a/themes/original/css/theme_right.css.php +++ b/themes/original/css/theme_right.css.php @@ -1217,7 +1217,7 @@ code.sql { .group-cnt { padding: 0 0 0 0.5em; display: inline-block; - width: 100%; + width: 98%; } /* for elements that should be revealed only via js */