| | |
| | | public $mdn_to; |
| | | public $others = array(); |
| | | public $flags = array(); |
| | | |
| | | // map header to rcube_mail_header object property |
| | | private $obj_headers = array( |
| | | 'date' => 'date', |
| | | 'from' => 'from', |
| | | 'to' => 'to', |
| | | 'subject' => 'subject', |
| | | 'reply-to' => 'replyto', |
| | | 'cc' => 'cc', |
| | | 'bcc' => 'bcc', |
| | | 'content-transfer-encoding' => 'encoding', |
| | | 'in-reply-to' => 'in_reply_to', |
| | | 'content-type' => 'ctype', |
| | | 'references' => 'references', |
| | | 'return-receipt-to' => 'mdn_to', |
| | | 'disposition-notification-to' => 'mdn_to', |
| | | 'x-confirm-reading-to' => 'mdn_to', |
| | | 'message-id' => 'messageID', |
| | | 'x-priority' => 'priority', |
| | | ); |
| | | |
| | | /** |
| | | * Returns header value |
| | | */ |
| | | public function get($name, $decode = true) |
| | | { |
| | | $name = strtolower($name); |
| | | |
| | | if (isset($this->obj_headers[$name])) { |
| | | $value = $this->{$this->obj_headers[$name]}; |
| | | } |
| | | else { |
| | | $value = $this->others[$name]; |
| | | } |
| | | |
| | | return $decode ? rcube_mime::decode_header($value, $this->charset) : $value; |
| | | } |
| | | |
| | | /** |
| | | * Sets header value |
| | | */ |
| | | public function set($name, $value) |
| | | { |
| | | $name = strtolower($name); |
| | | |
| | | if (isset($this->obj_headers[$name])) { |
| | | $this->{$this->obj_headers[$name]} = $value; |
| | | } |
| | | else { |
| | | $this->others[$name] = $value; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // For backward compatibility with cached messages (#1486602) |
| | | class iilBasicHeader extends rcube_mail_header |
| | | { |
| | | } |
| | | |
| | | // Support objects created in git-master (0.9) |
| | | class rcube_message_header extends rcube_mail_header |
| | | { |
| | | } |
| | | |
| | |
| | | $folders[$mailbox] = array(); |
| | | } |
| | | |
| | | // Add to options array |
| | | if (empty($this->data['LIST'][$mailbox])) |
| | | $this->data['LIST'][$mailbox] = $opts; |
| | | else if (!empty($opts)) |
| | | $this->data['LIST'][$mailbox] = array_unique(array_merge( |
| | | $this->data['LIST'][$mailbox], $opts)); |
| | | // store LSUB options only if not empty, this way |
| | | // we can detect a situation when LIST doesn't return specified folder |
| | | if (!empty($opts) || $cmd == 'LIST') { |
| | | // Add to options array |
| | | if (empty($this->data['LIST'][$mailbox])) |
| | | $this->data['LIST'][$mailbox] = $opts; |
| | | else if (!empty($opts)) |
| | | $this->data['LIST'][$mailbox] = array_unique(array_merge( |
| | | $this->data['LIST'][$mailbox], $opts)); |
| | | } |
| | | } |
| | | // * STATUS <mailbox> (<result>) |
| | | else if ($cmd == 'STATUS') { |
| | |
| | | |
| | | // Invoke SEARCH as a fallback |
| | | $index = $this->search($mailbox, 'ALL UNSEEN', false, array('COUNT')); |
| | | if (!$index->isError()) { |
| | | if (!$index->is_error()) { |
| | | return $index->count(); |
| | | } |
| | | |
| | |
| | | return new rcube_result_index($mailbox); |
| | | } |
| | | |
| | | // RFC 5957: SORT=DISPLAY |
| | | if (($field == 'FROM' || $field == 'TO') && $this->getCapability('SORT=DISPLAY')) { |
| | | $field = 'DISPLAY' . $field; |
| | | } |
| | | |
| | | // message IDs |
| | | if (!empty($add)) |
| | | $add = $this->compressMessageSet($add); |
| | |
| | | |
| | | // If ESEARCH is supported always use ALL |
| | | // but not when items are specified or using simple id2uid search |
| | | if (empty($items) && ((int) $criteria != $criteria)) { |
| | | if (empty($items) && preg_match('/[^0-9]/', $criteria)) { |
| | | $items = array('ALL'); |
| | | } |
| | | |
| | |
| | | $result[$id]->subject = ''; |
| | | $result[$id]->messageID = 'mid:' . $id; |
| | | |
| | | $lines = array(); |
| | | $line = substr($line, strlen($m[0]) + 2); |
| | | $ln = 0; |
| | | $headers = null; |
| | | $lines = array(); |
| | | $line = substr($line, strlen($m[0]) + 2); |
| | | $ln = 0; |
| | | |
| | | // get complete entry |
| | | while (preg_match('/\{([0-9]+)\}\r\n$/', $line, $m)) { |
| | |
| | | return $this->handlePartBody($mailbox, $id, $is_uid, $part); |
| | | } |
| | | |
| | | function handlePartBody($mailbox, $id, $is_uid=false, $part='', $encoding=NULL, $print=NULL, $file=NULL) |
| | | function handlePartBody($mailbox, $id, $is_uid=false, $part='', $encoding=NULL, $print=NULL, $file=NULL, $formatted=true) |
| | | { |
| | | if (!$this->select($mailbox)) { |
| | | return false; |
| | |
| | | continue; |
| | | $line = convert_uudecode($line); |
| | | // default |
| | | } else { |
| | | } else if ($formatted) { |
| | | $line = rtrim($line, "\t\r\n\0\x0B") . "\n"; |
| | | } |
| | | |
| | |
| | | if ($string === null) { |
| | | return 'NIL'; |
| | | } |
| | | |
| | | if ($string === '') { |
| | | return '""'; |
| | | } |
| | | |
| | | // atom-string (only safe characters) |
| | | if (!$force_quotes && !preg_match('/[\x00-\x20\x22\x28-\x2A\x5B-\x5D\x7B\x7D\x80-\xFF]/', $string)) { |
| | | if (!$force_quotes && !preg_match('/[\x00-\x20\x22\x25\x28-\x2A\x5B-\x5D\x7B\x7D\x80-\xFF]/', $string)) { |
| | | return $string; |
| | | } |
| | | |
| | | // quoted-string |
| | | if (!preg_match('/[\r\n\x00\x80-\xFF]/', $string)) { |
| | | return '"' . addcslashes($string, '\\"') . '"'; |