|
|
@ -5,7 +5,7 @@
|
|
|
|
| program/include/rcube_user.inc |
|
|
|
|
| program/include/rcube_user.inc |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| This file is part of the RoundCube Webmail client |
|
|
|
|
| This file is part of the RoundCube Webmail client |
|
|
|
|
| Copyright (C) 2005-2007, RoundCube Dev. - Switzerland |
|
|
|
|
| Copyright (C) 2005-2008, RoundCube Dev. - Switzerland |
|
|
|
|
| Licensed under the GNU GPL |
|
|
|
|
| Licensed under the GNU GPL |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| PURPOSE: |
|
|
|
|
| PURPOSE: |
|
|
|
@ -98,7 +98,7 @@ class rcube_user
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Write the given user prefs to the user's record
|
|
|
|
* Write the given user prefs to the user's record
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param mixed User prefs to save
|
|
|
|
* @param array User prefs to save
|
|
|
|
* @return boolean True on success, False on failure
|
|
|
|
* @return boolean True on success, False on failure
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function save_prefs($a_user_prefs)
|
|
|
|
function save_prefs($a_user_prefs)
|
|
|
@ -106,23 +106,31 @@ class rcube_user
|
|
|
|
if (!$this->ID)
|
|
|
|
if (!$this->ID)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$config = rcmail::get_instance()->config;
|
|
|
|
|
|
|
|
$old_prefs = (array)$this->get_prefs();
|
|
|
|
|
|
|
|
|
|
|
|
// merge (partial) prefs array with existing settings
|
|
|
|
// merge (partial) prefs array with existing settings
|
|
|
|
$a_user_prefs += (array)$this->get_prefs();
|
|
|
|
$save_prefs = $a_user_prefs + $old_prefs;
|
|
|
|
unset($a_user_prefs['language']);
|
|
|
|
unset($save_prefs['language']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// don't save prefs with default values if they haven't been changed yet
|
|
|
|
|
|
|
|
foreach ($a_user_prefs as $key => $value) {
|
|
|
|
|
|
|
|
if (!isset($old_prefs[$key]) && ($value == $config->get($key)))
|
|
|
|
|
|
|
|
unset($save_prefs[$key]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->db->query(
|
|
|
|
$this->db->query(
|
|
|
|
"UPDATE ".get_table_name('users')."
|
|
|
|
"UPDATE ".get_table_name('users')."
|
|
|
|
SET preferences=?,
|
|
|
|
SET preferences=?,
|
|
|
|
language=?
|
|
|
|
language=?
|
|
|
|
WHERE user_id=?",
|
|
|
|
WHERE user_id=?",
|
|
|
|
serialize($a_user_prefs),
|
|
|
|
serialize($save_prefs),
|
|
|
|
$_SESSION['language'],
|
|
|
|
$_SESSION['language'],
|
|
|
|
$this->ID);
|
|
|
|
$this->ID);
|
|
|
|
|
|
|
|
|
|
|
|
$this->language = $_SESSION['language'];
|
|
|
|
$this->language = $_SESSION['language'];
|
|
|
|
if ($this->db->affected_rows())
|
|
|
|
if ($this->db->affected_rows()) {
|
|
|
|
{
|
|
|
|
$config->merge($a_user_prefs);
|
|
|
|
rcmail::get_instance()->config->merge($a_user_prefs);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|