Update to new Horde_Mime_Part API
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 1 Jul 2009 05:55:07 +0000 (23:55 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 1 Jul 2009 06:49:20 +0000 (00:49 -0600)
imp/lib/Compose.php
imp/lib/Contents.php
imp/lib/Message.php
imp/view.php

index d0fb5bf..570ca29 100644 (file)
@@ -230,9 +230,9 @@ class IMP_Compose
 
         /* Need to add Message-ID so we can use it in the index search. */
         $draft_headers->addMessageIdHeader();
-        $draft_headers = $base->addMimeHeaders($draft_headers);
+        $draft_headers = $base->addMimeHeaders(array('headers' => $draft_headers));
 
-        return $draft_headers->toString(array('charset' => $charset, 'defserver' => $session ? $_SESSION['imp']['maildomain'] : null)) . $base->toString(false);
+        return $draft_headers->toString(array('charset' => $charset, 'defserver' => $session ? $_SESSION['imp']['maildomain'] : null)) . $base->toString(array('headers' => false));
     }
 
     /**
@@ -592,7 +592,7 @@ class IMP_Compose
 
             /* Generate the message string. */
             $fcc = $headers->toString(array('charset' => $charset, 'defserver' => $_SESSION['imp']['maildomain'])) .
-                $mime_message->toString(false);
+                $mime_message->toString(array('headers' => false));
 
             $imp_folder = IMP_Folder::singleton();
 
@@ -1618,9 +1618,6 @@ class IMP_Compose
         $type = $part->getType();
         $vfs = $conf['compose']['use_vfs'];
 
-        /* Decode the contents. */
-        $part->transferDecodeContents();
-
         /* Try to determine the MIME type from 1) the extension and
          * then 2) analysis of the file (if available). */
         if ($type == 'application/octet-stream') {
index b17420d..5b5d51b 100644 (file)
@@ -163,7 +163,7 @@ class IMP_Contents
     public function getBody($options = array())
     {
         if (is_null($this->_mailbox)) {
-            return $this->_message->toString(true, !empty($options['stream']));
+            return $this->_message->toString(array('headers' => true, 'stream' => !empty($options['stream'])));
         }
 
         try {
@@ -305,9 +305,6 @@ class IMP_Contents
      *            DEFAULT: All data is retrieved.
      * 'nocontents' - (boolean) If true, don't add the contents to the part
      *              DEFAULT: Contents are added to the part
-     * 'nodecode' - (boolean) If 'nocontents' is false, and this setting is
-     *              true, does not transfer decode the contents.
-     *            DEFAULT: Contents are transfer decoded.
      * </pre>
      *
      * @return Horde_Mime_Part  The raw MIME part asked for (reference).
@@ -325,12 +322,8 @@ class IMP_Contents
             !is_null($part) &&
             empty($options['nocontents']) &&
             !is_null($this->_mailbox) &&
-            !$part->getContentsAsStream()) {
-            $part->setContents($this->getBodyPart($id, array('length' => empty($options['length']) ? null : $options['length'], 'stream' => true)));
-
-            if (empty($options['nodecode'])) {
-                $part->transferDecodeContents();
-            }
+            !$part->getContents(array('stream' => true))) {
+            $part->setContents($this->getBodyPart($id, array('length' => empty($options['length']) ? null : $options['length'], 'stream' => true)), array('usestream' => true));
         }
 
         return $part;
@@ -942,7 +935,7 @@ class IMP_Contents
                 if (($key != 0) &&
                     ($val != 'message/rfc822') &&
                     (strpos($val, 'multipart/') === false)) {
-                    $part = $this->getMIMEPart($key, array('nodecode' => true));
+                    $part = $this->getMIMEPart($key);
                     $message->alterPart($key, $part);
                 }
             }
index 4885810..38d7957 100644 (file)
@@ -536,7 +536,7 @@ class IMP_Message
                 unset($res['flags'][$pos]);
             }
 
-            $uid = $GLOBALS['imp_imap']->ob->append($mbox, array(array('data' => $res['headertext'][0] . $message->toString(false), 'flags' => $res['flags'], 'messageid' => $res['envelope']['message-id'])));
+            $uid = $GLOBALS['imp_imap']->ob->append($mbox, array(array('data' => $res['headertext'][0] . $message->toString(array('headers' => false)), 'flags' => $res['flags'], 'messageid' => $res['envelope']['message-id'])));
         } catch (Horde_Imap_Client_Exception $e) {
             throw new Horde_Exception(_("An error occured while attempting to strip the attachment."));
         }
index 9f2db61..0f1f8af 100644 (file)
@@ -39,8 +39,8 @@ function _sanitizeName($name)
 
 function _fullMessageTextLength($ob)
 {
-    $stat = fstat($ob[1]);
-    $len = strlen($ob[0]) + $stat['size']);
+    $stat = fseek($ob[1], 0, SEEK_END);
+    $len = strlen($ob[0]) + ftell($ob[1]);
     rewind($ob[1]);
     return $len;
 }
@@ -134,7 +134,7 @@ case 'download_render':
             $name .= '.zip';
             $type = 'application/zip';
         } else {
-            $body = $mime->getContentsAsStream();
+            $body = $mime->getContents(array('stream' => true));
             $type = $mime->getType(true);
         }
         break;