| | |
| | | var $delimiter = NULL; |
| | | var $caching_enabled = FALSE; |
| | | var $default_charset = 'ISO-8859-1'; |
| | | var $struct_charset = NULL; |
| | | var $default_folders = array('INBOX'); |
| | | var $default_folders_lc = array('inbox'); |
| | | var $fetch_add_headers = ''; |
| | | var $cache = array(); |
| | | var $cache_keys = array(); |
| | | var $cache_changes = array(); |
| | |
| | | global $ICL_SSL, $ICL_PORT, $IMAP_USE_INTERNAL_DATE; |
| | | |
| | | // check for Open-SSL support in PHP build |
| | | if ($use_ssl && in_array('openssl', get_loaded_extensions())) |
| | | if ($use_ssl && extension_loaded('openssl')) |
| | | $ICL_SSL = $use_ssl == 'imaps' ? 'ssl' : $use_ssl; |
| | | else if ($use_ssl) |
| | | { |
| | |
| | | if (is_array($a_mboxes)) |
| | | return $a_mboxes; |
| | | |
| | | // retrieve list of folders from IMAP server |
| | | $a_folders = iil_C_ListSubscribed($this->conn, $this->_mod_mailbox($root), $filter); |
| | | // Give plugins a chance to provide a list of mailboxes |
| | | $data = rcmail::get_instance()->plugins->exec_hook('list_mailboxes',array('root'=>$root,'filter'=>$filter)); |
| | | if (isset($data['folders'])) { |
| | | $a_folders = $data['folders']; |
| | | } |
| | | else{ |
| | | // retrieve list of folders from IMAP server |
| | | $a_folders = iil_C_ListSubscribed($this->conn, $this->_mod_mailbox($root), $filter); |
| | | } |
| | | |
| | | |
| | | if (!is_array($a_folders) || !sizeof($a_folders)) |
| | | $a_folders = array(); |
| | |
| | | $cache_index = $this->get_message_cache_index($cache_key); |
| | | |
| | | // fetch reuested headers from server |
| | | $a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, $msgs); |
| | | $a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, $msgs, false, $this->fetch_add_headers); |
| | | $deleted_count = 0; |
| | | |
| | | if (!empty($a_header_index)) |
| | |
| | | if ($this->sort_field && $this->search_sort_field != $this->sort_field) |
| | | $this->search('', $this->search_string, $this->search_charset, $this->sort_field); |
| | | |
| | | if ($this->sort_order == 'DESC') |
| | | if ($this->sort_order == 'DESC') |
| | | $this->cache[$key] = array_reverse($this->search_set); |
| | | else |
| | | $this->cache[$key] = $this->search_set; |
| | | else |
| | | $this->cache[$key] = $this->search_set; |
| | | } |
| | | else |
| | | { |
| | | $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, join(',', $this->search_set), $this->sort_field); |
| | | $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, join(',', $this->search_set), $this->sort_field, false); |
| | | |
| | | if ($this->sort_order=="ASC") |
| | | asort($a_index); |
| | |
| | | |
| | | |
| | | // fetch complete headers and add to cache |
| | | $headers = iil_C_FetchHeader($this->conn, $mailbox, $id); |
| | | $headers = iil_C_FetchHeader($this->conn, $mailbox, $id, false, $this->fetch_add_headers); |
| | | $this->add_message_cache($cache_key, $headers->id, $headers); |
| | | } |
| | | |
| | |
| | | if ($uid && ($headers = &$this->get_cached_message($mailbox.'.msg', $uid))) |
| | | return $headers; |
| | | |
| | | $headers = iil_C_FetchHeader($this->conn, $mailbox, $id, $is_uid, $bodystr); |
| | | $headers = iil_C_FetchHeader($this->conn, $mailbox, $id, $is_uid, $bodystr, $this->fetch_add_headers); |
| | | |
| | | // write headers cache |
| | | if ($headers) |
| | |
| | | { |
| | | $this->_msg_id = $msg_id; |
| | | $headers = $this->get_headers($uid); |
| | | |
| | | |
| | | // set message charset from message headers |
| | | if ($headers->charset) |
| | | $this->struct_charset = $headers->charset; |
| | | // ... or from first part headers |
| | | else if (is_array($structure[2]) && $structure[2][0] == 'charset') |
| | | $this->struct_charset = $structure[2][1]; |
| | | else if (is_array($structure[0][2]) && $structure[0][2][0] == 'charset') |
| | | $this->struct_charset = $structure[0][2][1]; |
| | | else if (is_array($structure[0][0][2]) && $structure[0][0][2][0] == 'charset') |
| | | $this->struct_charset = $structure[0][0][2][1]; |
| | | else |
| | | $this->struct_charset = null; |
| | | |
| | | $struct = &$this->_structure_part($structure); |
| | | $struct->headers = get_object_vars($headers); |
| | | |
| | |
| | | // decode filename |
| | | if (!empty($filename_mime)) { |
| | | $part->filename = rcube_imap::decode_mime_string($filename_mime, |
| | | $part->charset ? $part->charset : rc_detect_encoding($filename_mime, $this->default_charset)); |
| | | $part->charset ? $part->charset : $this->struct_charset ? $this->struct_charset : |
| | | rc_detect_encoding($filename_mime, $this->default_charset)); |
| | | } |
| | | else if (!empty($filename_encoded)) { |
| | | // decode filename according to RFC 2231, Section 4 |
| | |
| | | if ($cache_count==$msg_count) |
| | | { |
| | | // get highest index |
| | | $header = iil_C_FetchHeader($this->conn, $mailbox, "$msg_count"); |
| | | $header = iil_C_FetchHeader($this->conn, $mailbox, "$msg_count", false, $this->fetch_add_headers); |
| | | $cache_uid = array_pop($cache_index); |
| | | |
| | | // uids of highest message matches -> cache seems OK |
| | |
| | | |
| | | // featch headers if unserialize failed |
| | | if (empty($this->cache[$cache_key][$uid])) |
| | | $this->cache[$cache_key][$uid] = iil_C_FetchHeader($this->conn, preg_replace('/.msg$/', '', $key), $uid, true); |
| | | $this->cache[$cache_key][$uid] = iil_C_FetchHeader($this->conn, preg_replace('/.msg$/', '', $key), $uid, true, $this->fetch_add_headers); |
| | | } |
| | | } |
| | | |