| | |
| | | // Seek in internal cache |
| | | if (array_key_exists('index', $this->icache[$mailbox])) { |
| | | // The index was fetched from database already, but not validated yet |
| | | if (!array_key_exists('object', $this->icache[$mailbox]['index'])) { |
| | | if (empty($this->icache[$mailbox]['index']['validated'])) { |
| | | $index = $this->icache[$mailbox]['index']; |
| | | } |
| | | // We've got a valid index |
| | |
| | | } |
| | | |
| | | $this->icache[$mailbox]['index'] = array( |
| | | 'validated' => true, |
| | | 'object' => $data, |
| | | 'sort_field' => $sort_field, |
| | | 'modseq' => !empty($index['modseq']) ? $index['modseq'] : $mbox_data['HIGHESTMODSEQ'] |
| | |
| | | return array(); |
| | | } |
| | | |
| | | $msgs = array_flip($msgs); |
| | | $result = array(); |
| | | |
| | | if ($this->mode & self::MODE_MESSAGE) { |
| | |
| | | ." AND uid IN (".$this->db->array2list($msgs, 'integer').")", |
| | | $this->userid, $mailbox); |
| | | |
| | | $msgs = array_flip($msgs); |
| | | |
| | | while ($sql_arr = $this->db->fetch_assoc($sql_result)) { |
| | | $uid = intval($sql_arr['uid']); |
| | | $result[$uid] = $this->build_message($sql_arr); |
| | |
| | | unset($msgs[$uid]); |
| | | } |
| | | } |
| | | |
| | | $msgs = array_flip($msgs); |
| | | } |
| | | |
| | | // Fetch not found messages from IMAP server |
| | | if (!empty($msgs)) { |
| | | $messages = $this->imap->fetch_headers($mailbox, array_keys($msgs), false, true); |
| | | $messages = $this->imap->fetch_headers($mailbox, $msgs, false, true); |
| | | |
| | | // Insert to DB and add to result list |
| | | if (!empty($messages)) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | $index['validated'] = true; |
| | | |
| | | // Get mailbox data (UIDVALIDITY, counters, etc.) for status check |
| | | $mbox_data = $this->imap->folder_data($mailbox); |
| | | |
| | |
| | | |
| | | unset($msg->replaces); |
| | | |
| | | if (is_array($msg->structure->parts)) { |
| | | foreach ($msg->structure->parts as $part) { |
| | | $this->message_object_prepare($part, $size); |
| | | } |
| | | if (is_object($msg->structure)) { |
| | | $this->message_object_prepare($msg->structure, $size); |
| | | } |
| | | |
| | | if (is_array($msg->parts)) { |