| | |
| | | * |
| | | * @package RoundCube Webmail |
| | | * @author Thomas Bruederli <roundcube@gmail.com> |
| | | * @version 1.22 |
| | | * @version 1.26 |
| | | * @link http://ilohamail.org |
| | | */ |
| | | class rcube_imap |
| | |
| | | var $page_size = 10; |
| | | var $sort_field = 'date'; |
| | | var $sort_order = 'DESC'; |
| | | var $default_charset = 'ISO-8859-1'; |
| | | var $delimiter = NULL; |
| | | var $caching_enabled = FALSE; |
| | | var $default_folders = array('inbox', 'drafts', 'sent', 'junk', 'trash'); |
| | |
| | | if (!is_array($a_folders) || !sizeof($a_folders)) |
| | | $a_folders = array(); |
| | | |
| | | // create INBOX if it does not exist |
| | | if (!in_array_nocase('INBOX', $a_folders)) |
| | | // create Default folders if they do not exist |
| | | global $CONFIG; |
| | | foreach ($CONFIG['default_imap_folders'] as $folder) |
| | | { |
| | | $this->create_mailbox('INBOX', TRUE); |
| | | array_unshift($a_folders, 'INBOX'); |
| | | if (!in_array_nocase($folder, $a_folders)) |
| | | { |
| | | $this->create_mailbox($folder, TRUE); |
| | | $this->subscribe($folder); |
| | | } |
| | | } |
| | | |
| | | $a_folders = iil_C_ListSubscribed($this->conn, $this->_mod_mailbox($root), $filter); |
| | | $a_mailbox_cache = array(); |
| | | |
| | | // write mailboxlist to cache |
| | |
| | | // append a mail message (source) to a specific mailbox |
| | | function save_message($mbox_name, &$message) |
| | | { |
| | | $mbox_name = stripslashes($mbox_name); |
| | | $mailbox = $this->_mod_mailbox($mbox_name); |
| | | |
| | | // make sure mailbox exists |
| | |
| | | // move a message from one mailbox to another |
| | | function move_message($uids, $to_mbox, $from_mbox='') |
| | | { |
| | | $to_mbox = stripslashes($to_mbox); |
| | | $from_mbox = stripslashes($from_mbox); |
| | | $to_mbox = $this->_mod_mailbox($to_mbox); |
| | | $from_mbox = $from_mbox ? $this->_mod_mailbox($from_mbox) : $this->mailbox; |
| | | |
| | |
| | | // mark messages as deleted and expunge mailbox |
| | | function delete_message($uids, $mbox_name='') |
| | | { |
| | | $mbox_name = stripslashes($mbox_name); |
| | | $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; |
| | | |
| | | // convert the list of uids to array |
| | |
| | | // clear all messages in a specific mailbox |
| | | function clear_mailbox($mbox_name=NULL) |
| | | { |
| | | $mbox_name = stripslashes($mbox_name); |
| | | $mailbox = !empty($mbox_name) ? $this->_mod_mailbox($mbox_name) : $this->mailbox; |
| | | $msg_count = $this->_messagecount($mailbox, 'ALL'); |
| | | |
| | |
| | | // send IMAP expunge command and clear cache |
| | | function expunge($mbox_name='', $clear_cache=TRUE) |
| | | { |
| | | $mbox_name = stripslashes($mbox_name); |
| | | $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; |
| | | return $this->_expunge($mailbox, $clear_cache); |
| | | } |
| | |
| | | |
| | | |
| | | // set a new name to an existing mailbox |
| | | function rename_mailbox($mbox_name, $new_name) |
| | | function rename_mailbox($mbox_name, $new_name, $subscribe=TRUE) |
| | | { |
| | | // not implemented yet |
| | | $result = FALSE; |
| | | |
| | | // replace backslashes |
| | | $name = preg_replace('/[\\\]+/', '-', $new_name); |
| | | |
| | | $name_enc = UTF7EncodeString($new_name); |
| | | |
| | | // reduce mailbox name to 100 chars |
| | | $name_enc = substr($name_enc, 0, 100); |
| | | |
| | | $abs_name = $this->_mod_mailbox($name_enc); |
| | | $a_mailbox_cache = $this->get_cache('mailboxes'); |
| | | |
| | | if (strlen($abs_name) && (!is_array($a_mailbox_cache) || !in_array($abs_name, $a_mailbox_cache))) |
| | | $result = iil_C_RenameFolder($this->conn, $mbox_name, $abs_name); |
| | | |
| | | // update mailboxlist cache |
| | | if ($result && $subscribe) |
| | | $this->unsubscribe($mbox_name); |
| | | $this->subscribe($name_enc); |
| | | |
| | | return $result ? $name : FALSE; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | return $str; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Decode a mime-encoded string to internal charset |
| | | * |
| | | * @access static |
| | | */ |
| | | function decode_mime_string($input) |
| | | { |
| | | $out = ''; |
| | |
| | | } |
| | | |
| | | // no encoding information, defaults to what is specified in the class header |
| | | return rcube_charset_convert($input, $this->default_charset); |
| | | return rcube_charset_convert($input, 'ISO-8859-1'); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Decode a part of a mime-encoded string |
| | | * |
| | | * @access static |
| | | */ |
| | | function _decode_mime_string_part($str) |
| | | { |
| | | $a = explode('?', $str); |
| | |
| | | return rcube_charset_convert($body, $ctype_param['charset']); |
| | | |
| | | // defaults to what is specified in the class header |
| | | return rcube_charset_convert($body, $this->default_charset); |
| | | return rcube_charset_convert($body, 'ISO-8859-1'); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /* -------------------------------- |
| | | * private methods |
| | | * --------------------------------*/ |