| | |
| | | |
| | | require_once('lib/imap.inc'); |
| | | require_once('lib/mime.inc'); |
| | | require_once('lib/utf7.inc'); |
| | | |
| | | |
| | | class rcube_imap |
| | |
| | | } |
| | | |
| | | |
| | | // old function; replaced 2005/10/18 |
| | | // original function; replaced 2005/10/18 |
| | | // private method for listing message header |
| | | function _list_headers($mailbox='', $page=NULL, $sort_field='date', $sort_order='DESC') |
| | | { |
| | |
| | | |
| | | // sort headers by a specific col |
| | | $a_headers = iil_SortHeaders($a_msg_headers, $sort_field, $sort_order); |
| | | $headers_count = count($a_headers); |
| | | |
| | | // free memory |
| | | unset($a_msg_headers); |
| | |
| | | // write headers list to cache |
| | | if (!$headers_cached) |
| | | $this->update_cache($mailbox.'.msg', $a_headers); |
| | | |
| | | // update message count cache |
| | | $a_mailbox_cache = $this->get_cache('messagecount'); |
| | | if (isset($a_mailbox_cache[$mailbox]['ALL']) && $a_mailbox_cache[$mailbox]['ALL'] != $headers_count) |
| | | { |
| | | $a_mailbox_cache[$mailbox]['ALL'] = (int)$headers_count; |
| | | $this->update_cache('messagecount', $a_mailbox_cache); |
| | | } |
| | | |
| | | if (empty($a_headers)) |
| | | return array(); |
| | |
| | | // return complete list of messages |
| | | if (strtolower($page)=='all') |
| | | return $a_headers; |
| | | |
| | | |
| | | $start_msg = ($this->list_page-1) * $this->page_size; |
| | | return array_slice($a_headers, $start_msg, $this->page_size); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | // clear all messages in a specific mailbox |
| | | function clear_mailbox($mbox) |
| | | { |
| | | $mailbox = $mbox ? $this->_mod_mailbox($mbox) : $this->mailbox; |
| | | $msg_count = $this->_messagecount($mailbox, 'ALL'); |
| | | |
| | | if ($msg_count>0) |
| | | return iil_C_ClearFolder($this->conn, $mailbox); |
| | | else |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | // send IMAP expunge command and clear cache |
| | | function expunge($mbox='', $clear_cache=TRUE) |
| | | { |
| | |
| | | function create_mailbox($name, $subscribe=FALSE) |
| | | { |
| | | $result = FALSE; |
| | | $abs_name = $this->_mod_mailbox($name); |
| | | $name_enc = UTF7EncodeString($name); |
| | | $abs_name = $this->_mod_mailbox($name_enc); |
| | | $a_mailbox_cache = $this->get_cache('mailboxes'); |
| | | |
| | | //if (strlen($this->root_ns)) |
| | | // $abs_name = $this->root_ns.$abs_name; |
| | | |
| | | if (strlen($abs_name) && (!is_array($a_mailbox_cache) || !in_array($abs_name, $a_mailbox_cache))) |
| | | $result = iil_C_CreateFolder($this->conn, iil_utf7_encode($abs_name)); |
| | | $result = iil_C_CreateFolder($this->conn, $abs_name); |
| | | |
| | | // update mailboxlist cache |
| | | if ($result && $subscribe) |
| | | $this->subscribe($name); |
| | | $this->subscribe($name_enc); |
| | | |
| | | return $result ? $name : FALSE; |
| | | } |
| | |
| | | |
| | | function decode_header($input) |
| | | { |
| | | return $this->decode_mime_string($input); |
| | | } |
| | | |
| | | |
| | | function decode_mime_string($input) |
| | | { |
| | | $out = ''; |
| | | |
| | | $pos = strpos($input, '=?'); |
| | |
| | | $encstr = substr($input, $pos+2, ($end_pos-$pos-2)); |
| | | $rest = substr($input, $end_pos+2); |
| | | |
| | | $out .= $this->decode_mime_string($encstr); |
| | | $out .= $this->decode_header($rest); |
| | | $out .= rcube_imap::_decode_mime_string_part($encstr); |
| | | $out .= rcube_imap::decode_mime_string($rest); |
| | | |
| | | return $out; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | function decode_mime_string($str) |
| | | function _decode_mime_string_part($str) |
| | | { |
| | | $a = explode('?', $str); |
| | | $count = count($a); |
| | |
| | | // convert body chars according to the ctype_parameters |
| | | function charset_decode($body, $ctype_param) |
| | | { |
| | | if (is_array($ctype_param) && strlen($ctype_param['charset'])) |
| | | if (is_array($ctype_param) && !empty($ctype_param['charset'])) |
| | | return decode_specialchars($body, $ctype_param['charset']); |
| | | |
| | | return $body; |
| | |
| | | |
| | | function _mod_mailbox($mbox, $mode='in') |
| | | { |
| | | if (!empty($this->root_ns) && $this->root_ns == $mbox) |
| | | if ((!empty($this->root_ns) && $this->root_ns == $mbox) || ($mbox == 'INBOX' && $mode == 'in')) |
| | | return $mbox; |
| | | |
| | | if (!empty($this->root_dir) && $mode=='in') |
| | | if (!empty($this->root_dir) && $mode=='in') |
| | | $mbox = $this->root_dir.$this->delimiter.$mbox; |
| | | else if (strlen($this->root_dir) && $mode=='out') |
| | | $mbox = substr($mbox, strlen($this->root_dir)+1); |