From: Michael M Slusarz Date: Fri, 14 Nov 2008 23:24:25 +0000 (-0700) Subject: IMP_Contents improvements. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4796ded7b7abd55f33d7df25011354ffb927cf88;p=horde.git IMP_Contents improvements. Allow MIME Part to be specified to render(). Make sure message is built before calling render(). Catch if embedded part replaces base message. getMessageIndex() -> getIndex(). getMessageMailbox() -> getMailbox(). --- diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index a9f9c4213..52e81ee60 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -122,7 +122,7 @@ class IMP_Contents * * @return integer The message index. */ - public function getMessageIndex() + public function getIndex() { return $this->_index; } @@ -132,7 +132,7 @@ class IMP_Contents * * @return string The message mailbox. */ - public function getMessageMailbox() + public function getMailbox() { return $this->_mailbox; } @@ -288,6 +288,7 @@ class IMP_Contents * @param integer $mode One of the RENDER_ constants. * @param array $options Additional options: *
+     * 'mime_part' - (Horde_Mime_Part) The MIME part to render.
      * 'params' - (array) Additional params to set.
      * 'type' - (string) Use this MIME type instead of the MIME type
      *          identified in the MIME part.
@@ -299,7 +300,11 @@ class IMP_Contents
      */
     public function renderMIMEPart($mime_id, $mode, $options = array())
     {
-        $mime_part = $this->getMIMEPart($mime_id);
+        $this->_buildMessage();
+
+        $mime_part = empty($options['mime_part'])
+            ? $this->getMIMEPart($mime_id)
+            : $options['mime_part'];
         $viewer = Horde_Mime_Viewer::factory($mime_part, empty($options['type']) ? null : $options['type']);
         $viewer->setParams(array('contents' => &$this));
         if (!empty($options['params'])) {
@@ -705,10 +710,15 @@ class IMP_Contents
             $mime_part = $this->getMIMEPart($id, array('nocontents' => true));
             $viewer = Horde_Mime_Viewer::factory($mime_part);
             if ($viewer->embeddedMimeParts()) {
-                $mime_part = $this->getMIMEPart($mime_id);
+                $mime_part = $this->getMIMEPart($id);
                 $viewer->setMIMEPart($mime_part);
+                $viewer->setParams(array('contents' => &$this));
                 $new_part = $viewer->getEmbeddedMimeParts();
                 if (!is_null($new_part)) {
+                    if (is_a($new_part, 'Horde_Mime_Message')) {
+                        $this->_message = $new_part;
+                        break;
+                    }
                     $this->_message->alterPart($id, $new_part);
                     $to_process = array_merge($to_process, array_slice($new_part->contentTypeMap(), 1));
                     if ($id == 0) {
diff --git a/imp/lib/Mime/Viewer/html.php b/imp/lib/Mime/Viewer/html.php
index 655a811ea..b13fe3828 100644
--- a/imp/lib/Mime/Viewer/html.php
+++ b/imp/lib/Mime/Viewer/html.php
@@ -203,7 +203,7 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html
             if ($inline) {
                 $url = Util::removeParameter($url, array('actionID'));
             }
-            $url = Util::addParameter($url, 'index', $this->_params['contents']->getMessageIndex());
+            $url = Util::addParameter($url, 'index', $this->_params['contents']->getIndex());
 
             $view_img = Util::getFormData('view_html_images');
             $addr_check = ($GLOBALS['prefs']->getValue('html_image_addrbook') && $this->_inAddressBook());
diff --git a/imp/lib/UI/Compose.php b/imp/lib/UI/Compose.php
index b4f92f7c7..c8fadfbfb 100644
--- a/imp/lib/UI/Compose.php
+++ b/imp/lib/UI/Compose.php
@@ -59,7 +59,7 @@ class IMP_UI_Compose {
          * decoding stays as-is. */
         require_once IMP_BASE . '/lib/MIME/Headers.php';
         $imp_imap = &IMP_IMAP::singleton();
-        $imp_imap->changeMbox($contents->getMessageMailbox(), IMP_IMAP_AUTO);
+        $imp_imap->changeMbox($contents->getMailbox(), IMP_IMAP_AUTO);
 
         $headers = $contents->getHeaderOb();
         $headers->addResentHeaders($from_addr, $recip['header']['to']);