Aleksander Machniak
2015-10-02 85f4209074aab255dacd766109af5092017606ae
program/lib/Roundcube/rcube_imap.php
@@ -62,7 +62,6 @@
    protected $sort_field = '';
    protected $sort_order = 'DESC';
    protected $struct_charset;
    protected $uid_id_map = array();
    protected $msg_headers = array();
    protected $search_set;
    protected $search_string = '';
@@ -984,7 +983,7 @@
        // gather messages from a multi-folder search
        if ($this->search_set->multi) {
            $page_size = $this->page_size;
            $page_size  = $this->page_size;
            $sort_field = $this->sort_field;
            $search_set = $this->search_set;
@@ -995,23 +994,26 @@
            $slice_length = min($page_size, $cnt - $from);
            // fetch resultset headers, sort and slice them
            if (!empty($sort_field)) {
            if (!empty($sort_field) && $search_set->get_parameters('SORT') != $sort_field) {
                $this->sort_field = null;
                $this->page_size = 1000;  // fetch up to 1000 matching messages per folder
                $this->threading = false;
                $this->page_size  = 1000;  // fetch up to 1000 matching messages per folder
                $this->threading  = false;
                $a_msg_headers = array();
                foreach ($search_set->sets as $resultset) {
                    if (!$resultset->is_empty()) {
                        $this->search_set = $resultset;
                        $this->search_set     = $resultset;
                        $this->search_threads = $resultset instanceof rcube_result_thread;
                        $a_msg_headers = array_merge($a_msg_headers, $this->list_search_messages($resultset->get_parameters('MAILBOX'), 1));
                        $a_headers     =  $this->list_search_messages($resultset->get_parameters('MAILBOX'), 1);
                        $a_msg_headers = array_merge($a_msg_headers, $a_headers);
                        unset($a_headers);
                    }
                }
                // sort headers
                if (!empty($a_msg_headers)) {
                    $a_msg_headers = $this->conn->sortHeaders($a_msg_headers, $sort_field, $this->sort_order);
                    $a_msg_headers = rcube_imap_generic::sortHeaders($a_msg_headers, $sort_field, $this->sort_order);
                }
                // store (sorted) message index
@@ -1045,7 +1047,7 @@
            // restore members
            $this->sort_field = $sort_field;
            $this->page_size = $page_size;
            $this->page_size  = $page_size;
            $this->search_set = $search_set;
            return $a_msg_headers;
@@ -1139,12 +1141,8 @@
                return array();
            }
            if (!$this->check_connection()) {
                return array();
            }
            // if not already sorted
            $a_msg_headers = $this->conn->sortHeaders(
            $a_msg_headers = rcube_imap_generic::sortHeaders(
                $a_msg_headers, $this->sort_field, $this->sort_order);
            // only return the requested part of the set
@@ -2683,7 +2681,6 @@
            // really deleted from the folder
            $this->expunge_message($uids, $folder, false);
            $this->clear_messagecount($folder);
            unset($this->uid_id_map[$folder]);
            // unset threads internal cache
            unset($this->icache['threads']);
@@ -3964,8 +3961,6 @@
            return $res;
        }
        return null;
    }
    /**
@@ -3986,7 +3981,6 @@
        }
        // @TODO: log error
        return null;
    }
@@ -4255,19 +4249,11 @@
            $folder = $this->folder;
        }
        if ($uid = array_search($id, (array)$this->uid_id_map[$folder])) {
            return $uid;
        }
        if (!$this->check_connection()) {
            return null;
        }
        $uid = $this->conn->ID2UID($folder, $id);
        $this->uid_id_map[$folder][$uid] = $id;
        return $uid;
        return $this->conn->ID2UID($folder, $id);
    }
    /**
@@ -4275,22 +4261,16 @@
     */
    protected function change_subscription($folders, $mode)
    {
        $updated = false;
        $updated = 0;
        $folders = (array) $folders;
        if (!empty($folders)) {
            if (!$this->check_connection()) {
                return false;
            }
            foreach ((array)$folders as $i => $folder) {
                $folders[$i] = $folder;
                if ($mode == 'subscribe') {
                    $updated = $this->conn->subscribe($folder);
                }
                else if ($mode == 'unsubscribe') {
                    $updated = $this->conn->unsubscribe($folder);
                }
            foreach ($folders as $folder) {
                $updated += (int) $this->conn->{$mode}($folder);
            }
        }
@@ -4299,7 +4279,7 @@
            $this->clear_cache('mailboxes', true);
        }
        return $updated;
        return $updated == count($folders) ? true : false;
    }
    /**