Permalink
Browse files

Add flags and date arguments to kolab_storage::save_message()

  • Loading branch information...
1 parent 00891e6 commit 7ac533dedea5bae31baa2eb6450cc0eb8c1b0090 @alecpl alecpl committed Oct 11, 2012
Showing with 42 additions and 12 deletions.
  1. +37 −10 program/include/rcube_imap.php
  2. +3 −1 program/include/rcube_storage.php
  3. +2 −1 program/steps/mail/sendmail.inc
@@ -2219,10 +2219,12 @@ public function set_flag($uids, $flag, $folder=null, $skip_cache=false)
* @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 @@ public function save_message($folder, &$message, $headers='', $is_file=false)
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 @@ protected function clear_messagecount($folder, $mode=null)
/**
+ * 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
*/
@@ -545,10 +545,12 @@ public function unset_flag($uids, $flag, $folder = null)
* @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);
/**
@@ -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) {

0 comments on commit 7ac533d

Please sign in to comment.