summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/rcube_imap.php47
-rw-r--r--program/include/rcube_storage.php4
2 files changed, 40 insertions, 11 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
*/
diff --git a/program/include/rcube_storage.php b/program/include/rcube_storage.php
index f83e24041..933ebcc25 100644
--- a/program/include/rcube_storage.php
+++ b/program/include/rcube_storage.php
@@ -545,10 +545,12 @@ abstract class 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
*/
- abstract function save_message($folder, &$message, $headers = '', $is_file = false);
+ abstract function save_message($folder, &$message, $headers = '', $is_file = false, $flags = array(), $date = null);
/**