diff options
author | Aleksander Machniak <alec@alec.pl> | 2012-10-11 10:17:12 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2012-10-11 10:17:12 +0200 |
commit | 7ac533dedea5bae31baa2eb6450cc0eb8c1b0090 (patch) | |
tree | 7be771aae3a0e8c86226b506d1d47938adec5d64 /program/include/rcube_imap.php | |
parent | 00891e687b97b6eac7317970aeb0d49826d05d42 (diff) |
Add flags and date arguments to kolab_storage::save_message()
Diffstat (limited to 'program/include/rcube_imap.php')
-rw-r--r-- | program/include/rcube_imap.php | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 8a1c65bbe..1e6cf360b 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -2219,10 +2219,12 @@ class rcube_imap extends rcube_storage * @param string $message The message source string or filename * @param string $headers Headers string if $message contains only the body * @param boolean $is_file True if $message is a filename + * @param array $flags Message flags + * @param mixed $date Message internal date * * @return int|bool Appended message UID or True on success, False on error */ - public function save_message($folder, &$message, $headers='', $is_file=false) + public function save_message($folder, &$message, $headers='', $is_file=false, $flags = array(), $date = null) { if (!strlen($folder)) { $folder = $this->folder; @@ -2232,16 +2234,18 @@ class rcube_imap extends rcube_storage return false; } - $flags = array('SEEN'); - // make sure folder exists - if ($this->folder_exists($folder)) { - if ($is_file) { - $saved = $this->conn->appendFromFile($folder, $message, $headers, $flags); - } - else { - $saved = $this->conn->append($folder, $message, $flags); - } + if (!$this->folder_exists($folder)) { + return false; + } + + $date = $this->date_format($date); + + if ($is_file) { + $saved = $this->conn->appendFromFile($folder, $message, $headers, $flags, $date); + } + else { + $saved = $this->conn->append($folder, $message, $flags, $date); } if ($saved) { @@ -3984,6 +3988,29 @@ class rcube_imap extends rcube_storage /** + * Converts date string/object into IMAP date/time format + */ + protected function date_format($date) + { + if (empty($date)) { + return null; + } + + if (!is_object($date) || !is_a($date, 'DateTime')) { + try { + $timestamp = rcube_utils::strtotime($date); + $date = new DateTime("@".$timestamp); + } + catch (Exception $e) { + return null; + } + } + + return $date->format('d-M-Y H:i:s O'); + } + + + /** * This is our own debug handler for the IMAP connection * @access public */ |