From bf9466fb3bffac2306c393d73ae094d59333979d Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 22 Apr 2010 23:38:31 -0600 Subject: [PATCH] Remove messageid parameter to append() --- .../Imap_Client/lib/Horde/Imap/Client/Base.php | 39 +++++++++++----------- imp/lib/Compose.php | 5 +-- imp/lib/Message.php | 3 +- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php index c8b7a6073..5530648c7 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php @@ -1169,15 +1169,6 @@ abstract class Horde_Imap_Client_Base * appended message. * DEFAULT: internaldate will be the same date as when * the message was appended. - * 'messageid' - (string) For servers/drivers that support the UIDPLUS - * IMAP extension, the UID of the appended message(s) can be - * determined automatically. If this extension is not - * available, the message-id of each message is needed to - * determine the UID. If UIDPLUS is not available, and this - * option is not defined, append() will return true only. - * DEFAULT: If UIDPLUS is supported, or this string is - * provided, appended ID is returned. Else, append() will - * return true. * * @param array $options Additonal options: *
@@ -1185,9 +1176,7 @@ abstract class Horde_Imap_Client_Base
      *             DEFAULT: No.
      * 
* - * @return mixed An array of the UIDs of the appended messages (if server - * supports UIDPLUS extension or 'messageid' is defined) - * or true. + * @return array The UIDs of the appended messages. * @throws Horde_Imap_Client_Exception */ public function append($mailbox, $data, $options = array()) @@ -1201,22 +1190,34 @@ abstract class Horde_Imap_Client_Base return $ret; } - $msgid = false; $uids = array(); while (list(,$val) = each($data)) { - if (empty($val['messageid'])) { - $uids[] = null; - } else { - $msgid = true; + if (is_string($data['data'])) { + $text = $data; + } elseif (is_resource($data['data'])) { + $text = ''; + rewind($data['data']); + while ($in = fread($data['data'], 1024)) { + $text .= $in; + if (preg_match("/\n\r*\n\r*/", $text)) { + break; + } + } + } + + $headers = Horde_Mime_Headers::parseHeaders($text); + $msgid = $headers->getValue('message-id'); + + if ($msgid) { $search_query = new Horde_Imap_Client_Search_Query(); - $search_query->headerText('Message-ID', $val['messageid']); + $search_query->headerText('Message-ID', $msgid); $uidsearch = $this->search($mailbox, $search_query); $uids[] = reset($uidsearch['match']); } } - return $msgid ? $uids : true; + return $uids; } /** diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index c9c7686f8..a926d814a 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -299,15 +299,12 @@ class IMP_Compose * set the $MDNSent keyword. However, IMP doesn't write MDN headers * until send time so no need to set the flag here. */ - /* Get the message ID. */ - $headers = Horde_Mime_Headers::parseHeaders($data); - $drafts_mbox = IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true); $old_uid = $this->getMetadata('draft_uid'); /* Add the message to the mailbox. */ try { - $ids = $GLOBALS['imp_imap']->ob()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags, 'messageid' => $headers->getValue('message-id')))); + $ids = $GLOBALS['imp_imap']->ob()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags))); if ($old_uid) { $GLOBALS['injector']->getInstance('IMP_Message')->delete(array($old_uid), array('nuke' => true)); diff --git a/imp/lib/Message.php b/imp/lib/Message.php index 777ea390d..eb748dd05 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -514,7 +514,6 @@ class IMP_Message try { $res = $GLOBALS['imp_imap']->ob()->fetch($mbox, array( Horde_Imap_Client::FETCH_HEADERTEXT => array(array('peek' => true)), - Horde_Imap_Client::FETCH_ENVELOPE => true, Horde_Imap_Client::FETCH_FLAGS => true ), array('ids' => array($index))); $res = reset($res); @@ -526,7 +525,7 @@ class IMP_Message unset($res['flags'][$pos]); } - $uid = $GLOBALS['imp_imap']->ob()->append($mbox, array(array('data' => $message->toString(array('headers' => $res['headertext'][0], 'stream' => true)), 'flags' => $res['flags'], 'messageid' => $res['envelope']['message-id']))); + $uid = $GLOBALS['imp_imap']->ob()->append($mbox, array(array('data' => $message->toString(array('headers' => $res['headertext'][0], 'stream' => true)), 'flags' => $res['flags']))); } catch (Horde_Imap_Client_Exception $e) { throw new Horde_Exception(_("An error occured while attempting to strip the attachment.")); } -- 2.11.0