| | |
| | | |
| | | // use saved message set |
| | | if ($this->search_string && $mailbox == $this->mailbox) |
| | | return $this->_list_header_set($mailbox, $page, $sort_field, $sort_order); |
| | | return $this->_list_header_set($mailbox, $page, $sort_field, $sort_order, $slice); |
| | | |
| | | $this->_set_sort_order($sort_field, $sort_order); |
| | | |
| | |
| | | { |
| | | $start_msg = ($page-1) * $this->page_size; |
| | | $a_msg_headers = $this->get_message_cache($cache_key, $start_msg, $start_msg+$this->page_size, $this->sort_field, $this->sort_order); |
| | | return array_values($a_msg_headers); |
| | | $result = array_values($a_msg_headers); |
| | | if ($slice) |
| | | $result = array_slice($result, -$slice, $slice); |
| | | return $result; |
| | | } |
| | | // cache is dirty, sync it |
| | | else if ($this->caching_enabled && $cache_status==-1 && !$recursive) |
| | | { |
| | | $this->sync_header_index($mailbox); |
| | | return $this->_list_headers($mailbox, $page, $this->sort_field, $this->sort_order, TRUE); |
| | | return $this->_list_headers($mailbox, $page, $this->sort_field, $this->sort_order, TRUE, $slice); |
| | | } |
| | | |
| | | // retrieve headers from IMAP |
| | |
| | | * @param int Current page to list |
| | | * @param string Header field to sort by |
| | | * @param string Sort order [ASC|DESC] |
| | | * @param boolean Number of slice items to extract from result array |
| | | * @return array Indexed array with message header objects |
| | | * @access private |
| | | * @see rcube_imap::list_header_set() |
| | | */ |
| | | private function _list_header_set($mailbox, $page=NULL, $sort_field=NULL, $sort_order=NULL) |
| | | private function _list_header_set($mailbox, $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0) |
| | | { |
| | | if (!strlen($mailbox) || empty($this->search_set)) |
| | | return array(); |
| | |
| | | // get messages uids for one page |
| | | $msgs = array_slice(array_values($msgs), $start_msg, min(count($msgs)-$start_msg, $this->page_size)); |
| | | |
| | | if ($slice) |
| | | $msgs = array_slice($msgs, -$slice, $slice); |
| | | |
| | | // fetch headers |
| | | $this->_fetch_headers($mailbox, join(',',$msgs), $a_msg_headers, NULL); |
| | | |
| | |
| | | $a_index = $this->message_index('', $this->sort_field, $this->sort_order); |
| | | // get messages uids for one page... |
| | | $msgs = array_slice($a_index, $start_msg, min($cnt-$start_msg, $this->page_size)); |
| | | if ($slice) |
| | | $msgs = array_slice($msgs, -$slice, $slice); |
| | | // ...and fetch headers |
| | | $this->_fetch_headers($mailbox, join(',', $msgs), $a_msg_headers, NULL); |
| | | |
| | |
| | | $a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order); |
| | | |
| | | // only return the requested part of the set |
| | | return array_slice(array_values($a_msg_headers), $start_msg, min($cnt-$start_msg, $this->page_size)); |
| | | $a_msg_headers = array_slice(array_values($a_msg_headers), $start_msg, min($cnt-$start_msg, $this->page_size)); |
| | | if ($slice) |
| | | $a_msg_headers = array_slice($a_msg_headers, -$slice, $slice); |
| | | |
| | | return $a_msg_headers; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // write structure to cache |
| | | if ($this->caching_enabled) |
| | | $this->add_message_cache($cache_key, $msg_id, $headers, $struct); |
| | | $this->add_message_cache($cache_key, $this->_msg_id, $headers, $struct); |
| | | } |
| | | |
| | | return $struct; |
| | |
| | | { |
| | | $structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $uid, true); |
| | | $structure = iml_GetRawStructureArray($structure_str); |
| | | // error or message not found |
| | | if (empty($structure)) |
| | | return false; |
| | | |
| | | $part_type = iml_GetPartTypeCode($structure, $part); |
| | | $o_part = new rcube_message_part; |
| | | $o_part->ctype_primary = $part_type==0 ? 'text' : ($part_type==2 ? 'message' : 'other'); |
| | |
| | | |
| | | $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $uid, true, $part, |
| | | $o_part->encoding, $print, $fp); |
| | | |
| | | |
| | | if ($fp || $print) |
| | | return true; |
| | | |