Make message pagenav (prev/next) work with sorted multi-folder search results
| | |
| | | break; |
| | | |
| | | case 'list': |
| | | // TODO: don't reset search but re-send for the new folder |
| | | if (props && props != '') |
| | | this.reset_qsearch(); |
| | | if (this.env.action == 'compose' && this.env.extwin) |
| | |
| | | |
| | | var uid = list.get_single_selection(); |
| | | |
| | | if (uid && this.env.mailbox == this.env.drafts_mailbox) |
| | | if (uid && (this.env.messages[uid].mbox || this.env.mailbox) == this.env.drafts_mailbox) |
| | | this.open_compose_step({ _draft_uid: uid, _mbox: this.env.mailbox }); |
| | | else if (uid) |
| | | this.show_message(uid, false, false); |
| | |
| | | $a_msg_headers = $this->conn->sortHeaders($a_msg_headers, $sort_field, $this->sort_order); |
| | | } |
| | | |
| | | // store (sorted) message index |
| | | $search_set->set_message_index($a_msg_headers, $sort_field, $this->sort_order); |
| | | |
| | | // only return the requested part of the set |
| | | $slice_length = min($page_size, $cnt - ($to > $cnt ? $from : $to)); |
| | | $a_msg_headers = array_slice(array_values($a_msg_headers), $from, $slice_length); |
| | |
| | | return new rcube_result_index($folder, '* SORT'); |
| | | } |
| | | |
| | | if ($this->search_set instanceof rcube_result_multifolder) { |
| | | $index = $this->search_set; |
| | | $index->folder = $folder; |
| | | // TODO: handle changed sorting |
| | | } |
| | | // search result is an index with the same sorting? |
| | | if (($this->search_set instanceof rcube_result_index) |
| | | else if (($this->search_set instanceof rcube_result_index) |
| | | && ((!$this->sort_field && !$this->search_sorted) || |
| | | ($this->search_sorted && $this->search_sort_field == $this->sort_field)) |
| | | ) { |
| | |
| | | { |
| | | public $multi = true; |
| | | public $sets = array(); |
| | | public $folder; |
| | | |
| | | protected $meta = array(); |
| | | protected $index = array(); |
| | | protected $sorting; |
| | | protected $order = 'ASC'; |
| | | |
| | | |
| | |
| | | $this->meta['count'] += $result->count(); |
| | | } |
| | | |
| | | /** |
| | | * Store a global index of (sorted) message UIDs |
| | | */ |
| | | public function set_message_index($headers, $sort_field, $sort_order) |
| | | { |
| | | $this->index = array(); |
| | | foreach ($headers as $header) { |
| | | $this->index[] = $header->uid . '-' . $header->folder; |
| | | } |
| | | |
| | | $this->sorting = $sort_field; |
| | | $this->order = $sort_order; |
| | | } |
| | | |
| | | /** |
| | | * Checks the result from IMAP command |
| | |
| | | */ |
| | | public function exists($msgid, $get_index = false) |
| | | { |
| | | return false; |
| | | if (!empty($this->folder)) { |
| | | $msgid .= '-' . $this->folder; |
| | | } |
| | | return array_search($msgid, $this->index); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public function get() |
| | | { |
| | | return array(); |
| | | return $this->index; |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @return int Element value |
| | | */ |
| | | public function get_element($index) |
| | | public function get_element($idx) |
| | | { |
| | | return null; |
| | | switch ($idx) { |
| | | case 'FIRST': return $this->index[0]; |
| | | case 'LAST': return end($this->index); |
| | | default: return $this->index[$idx]; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public function get_parameters($param=null) |
| | | { |
| | | $params = array( |
| | | 'SORT' => $this->sorting, |
| | | 'ORDER' => $this->order, |
| | | ); |
| | | |
| | | if ($param !== null) { |
| | | return $params[$param]; |
| | | } |
| | | |
| | | return $params; |
| | | } |
| | | |
| | |
| | | $_REQUEST['_uid'] = $_uid; |
| | | unset($_uid); |
| | | |
| | | if (empty($_REQUEST['_mbox']) && !empty($mbox)) { |
| | | // override mbox |
| | | if (!empty($mbox)) { |
| | | $_GET['_mbox'] = $mbox; |
| | | $_POST['_mbox'] = $mbox; |
| | | $RCMAIL->storage->set_folder(($_SESSION['mbox'] = $mbox)); |
| | | } |
| | | } |
| | | |
| | |
| | | if ($header->parent_uid) |
| | | $header->parent_uid .= '-'.$header->folder; |
| | | } |
| | | |
| | | $OUTPUT->command('select_folder', ''); |
| | | } |
| | | } |
| | | // remove old search data |
| | |
| | | $RCMAIL->storage->search($mboxes, $search_str, $imap_charset, $sort_column); |
| | | } |
| | | |
| | | // Get the headers |
| | | $result_h = $RCMAIL->storage->list_messages($mbox, 1, $sort_column, rcmail_sort_order()); |
| | | $count = $RCMAIL->storage->count($mbox, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL'); |
| | | |
| | | // save search results in session |
| | | if (!is_array($_SESSION['search'])) { |
| | | $_SESSION['search'] = array(); |
| | |
| | | $_SESSION['last_text_search'] = $str; |
| | | } |
| | | $_SESSION['search_request'] = $search_request; |
| | | |
| | | // Get the headers |
| | | $result_h = $RCMAIL->storage->list_messages($mbox, 1, $sort_column, rcmail_sort_order()); |
| | | $count = $RCMAIL->storage->count($mbox, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL'); |
| | | |
| | | // Add 'folder' column to list |
| | | if ($_SESSION['search'][1]->multi) { |