Fix display of some deeply embedded alternative and related parts
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 26 Feb 2010 06:46:23 +0000 (23:46 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 26 Feb 2010 06:46:23 +0000 (23:46 -0700)
imp/lib/Mime/Viewer/Alternative.php
imp/lib/Mime/Viewer/Related.php

index 7d17b45..fd7ccd2 100644 (file)
@@ -117,8 +117,14 @@ class IMP_Horde_Mime_Viewer_Alternative extends Horde_Mime_Viewer_Driver
             if (isset($display_ids[$val])) {
                 $render = $this->_params['contents']->renderMIMEPart($val, $inline ? IMP_Contents::RENDER_INLINE : IMP_Contents::RENDER_FULL, array('params' => $this->_params));
                 foreach (array_keys($render) as $id) {
-                    $ret[$id] = $render[$id];
                     unset($display_ids[$id]);
+                    if (!$inline) {
+                        if (!is_null($render[$id])) {
+                            return array($base_id => $render[$id]);
+                        }
+                    } else {
+                        $ret[$id] = $render[$id];
+                    }
                 }
             } elseif (($disp_id != $val) && !array_key_exists($val, $ret)) {
                 // Need array_key_exists() here since we are checking if the
@@ -134,6 +140,6 @@ class IMP_Horde_Mime_Viewer_Alternative extends Horde_Mime_Viewer_Driver
 
         return $inline
             ? $ret
-            : (isset($ret[$id]) ? array($base_id => $ret[$id]) : null);
+            : null;
     }
 }
index bd33737..d308460 100644 (file)
@@ -103,7 +103,12 @@ class IMP_Horde_Mime_Viewer_Related extends Horde_Mime_Viewer_Driver
         $render = $this->_params['contents']->renderMIMEPart($id, $inline ? IMP_Contents::RENDER_INLINE : IMP_Contents::RENDER_FULL, array('params' => array_merge($this->_params, array('related_id' => $related_id, 'related_cids' => $cids))));
 
         if (!$inline) {
-            return $render;
+            foreach (array_keys($render) as $key) {
+                if (!is_null($render[$key])) {
+                    return array($related_id => $render[$key]);
+                }
+            }
+            return null;
         }
 
         $data_id = null;
@@ -126,4 +131,5 @@ class IMP_Horde_Mime_Viewer_Related extends Horde_Mime_Viewer_Driver
 
         return $ret;
     }
+
 }