| | |
| | | |
| | | $max = $this->_messagecount($mailbox); |
| | | $start_msg = ($this->list_page-1) * $this->page_size; |
| | | |
| | | |
| | | list($begin, $end) = $this->_get_message_range($max, $page); |
| | | |
| | | |
| | | // mailbox is empty |
| | | if ($begin >= $end) |
| | | return array(); |
| | | |
| | | //console("fetch headers $start_msg to ".($start_msg+$this->page_size)." (msg $begin to $end)"); |
| | | |
| | | $headers_sorted = FALSE; |
| | | $cache_key = $mailbox.'.msg'; |
| | | $cache_status = $this->check_cache_status($mailbox, $cache_key); |
| | | |
| | | //console("Cache status = $cache_status"); |
| | | |
| | | // cache is OK, we can get all messages from local cache |
| | | if ($cache_status>0) |
| | | { |
| | |
| | | // retrieve headers from IMAP |
| | | if ($this->get_capability('sort') && ($msg_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : ''))) |
| | | { |
| | | //console("$mailbox: ".join(',', $msg_index)); |
| | | |
| | | $msgs = $msg_index[$begin]; |
| | | for ($i=$begin+1; $i < $end; $i++) |
| | | $msgs = $msgs.','.$msg_index[$i]; |
| | | |
| | | $sorted = TRUE; |
| | | } |
| | | else |
| | | { |
| | | $msgs = sprintf("%d:%d", $begin+1, $end); |
| | | $sorted = FALSE; |
| | | } |
| | | |
| | | |
| | |
| | | return $this->_list_headers($mailbox, $page, $this->sort_field, $this->sort_order, TRUE); |
| | | } |
| | | |
| | | |
| | | |
| | | // fetch reuested headers from server |
| | | $a_msg_headers = array(); |
| | | $deleted_count = $this->_fetch_headers($mailbox, $msgs, $a_msg_headers, $cache_key); |
| | |
| | | // delete cached messages with a higher index than $max |
| | | $this->clear_message_cache($cache_key, $max); |
| | | |
| | | |
| | | |
| | | // kick child process to sync cache |
| | | // ... |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | // if not already sorted |
| | | // if (!$headers_sorted) |
| | | // $a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order); |
| | | if (!$headers_sorted) |
| | | $a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order); |
| | | |
| | | |
| | | if (!$headers_sorted && $this->sort_order == 'DESC') |
| | | $a_msg_headers = array_reverse($a_msg_headers); |
| | | |
| | | if (!$headers_sorted && $this->sort_order == 'DESC') |
| | | $a_msg_headers = array_reverse($a_msg_headers); |
| | | |
| | | |
| | | return array_values($a_msg_headers); |
| | | } |