summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-10-11 10:17:12 +0200
committerAleksander Machniak <alec@alec.pl>2012-10-11 10:17:12 +0200
commit7ac533dedea5bae31baa2eb6450cc0eb8c1b0090 (patch)
tree7be771aae3a0e8c86226b506d1d47938adec5d64 /program
parent00891e687b97b6eac7317970aeb0d49826d05d42 (diff)
Add flags and date arguments to kolab_storage::save_message()
Diffstat (limited to 'program')
-rw-r--r--program/include/rcube_imap.php47
-rw-r--r--program/include/rcube_storage.php4
-rw-r--r--program/steps/mail/sendmail.inc3
3 files changed, 42 insertions, 12 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);
/**
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 5c2c6de20..ee6a3d3a7 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -739,7 +739,8 @@ if ($store_target) {
'message' => "Could not create message: ".$msg->getMessage()),
TRUE, FALSE);
else {
- $saved = $RCMAIL->storage->save_message($store_target, $msg, $headers, $mailbody_file ? true : false);
+ $saved = $RCMAIL->storage->save_message($store_target, $msg, $headers,
+ $mailbody_file ? true : false, array('SEEN'));
}
if ($mailbody_file) {