Aleksander Machniak
2015-05-21 0c08b0477864d4fa65a6fd9c8eb20f45e996f38d
Fix issues when using moduserprefs.sh without --user argument (#1490399)
3 files modified
30 ■■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/include/rcmail_utils.php 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_user.php 27 ●●●●● patch | view | raw | blame | history
CHANGELOG
@@ -30,6 +30,7 @@
- Fix bug where imap_conn_options were ignored in IMAP connection test (#1490392)
- Fix bug where some files could have "executable" extension when stored in temp folder (#1490377)
- Fix attached file path unsetting in database_attachments plugin (#1490393)
- Fix issues when using moduserprefs.sh without --user argument (#1490399)
RELEASE 1.1.1
-------------
program/include/rcmail_utils.php
@@ -351,7 +351,7 @@
            $prefs[$name] = $value;
            if ($prefs != $old_prefs) {
                $user->save_prefs($prefs);
                $user->save_prefs($prefs, true);
                echo "saved.\n";
            }
            else {
program/lib/Roundcube/rcube_user.php
@@ -169,9 +169,11 @@
     * Write the given user prefs to the user's record
     *
     * @param array $a_user_prefs User prefs to save
     * @param bool  $no_session   Simplified language/preferences handling
     *
     * @return boolean True on success, False on failure
     */
    function save_prefs($a_user_prefs)
    function save_prefs($a_user_prefs, $no_session = false)
    {
        if (!$this->ID)
            return false;
@@ -198,32 +200,39 @@
        }
        $save_prefs = serialize($save_prefs);
        if (!$no_session) {
            $this->language = $_SESSION['language'];
        }
        $this->db->query(
            "UPDATE ".$this->db->table_name('users', true).
            " SET `preferences` = ?, `language` = ?".
            " WHERE `user_id` = ?",
            $save_prefs,
            $_SESSION['language'],
            $this->language,
            $this->ID);
        $this->language = $_SESSION['language'];
        // Update success
        if ($this->db->affected_rows() !== false) {
            $config->set_user_prefs($a_user_prefs);
            $this->data['preferences'] = $save_prefs;
            if (isset($_SESSION['preferences'])) {
                $this->rc->session->remove('preferences');
                $this->rc->session->remove('preferences_time');
            if (!$no_session) {
                $config->set_user_prefs($a_user_prefs);
                if (isset($_SESSION['preferences'])) {
                    $this->rc->session->remove('preferences');
                    $this->rc->session->remove('preferences_time');
                }
            }
            return true;
        }
        // Update error, but we are using replication (we have read-only DB connection)
        // and we are storing session not in the SQL database
        // we can store preferences in session and try to write later (see get_prefs())
        else if ($this->db->is_replicated() && $config->get('session_storage', 'db') != 'db') {
        else if (!$no_session && $this->db->is_replicated()
            && $config->get('session_storage', 'db') != 'db'
        ) {
            $_SESSION['preferences'] = $save_prefs;
            $_SESSION['preferences_time'] = time();
            $config->set_user_prefs($a_user_prefs);