| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | // 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') |