Fix parsing of embedded parts.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 26 Nov 2008 00:03:23 +0000 (17:03 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 26 Nov 2008 00:04:57 +0000 (17:04 -0700)
Add statuscache code - not currently used yet.

imp/lib/Contents.php

index b5b739b..0d0ca7f 100644 (file)
@@ -60,6 +60,13 @@ class IMP_Contents
     protected $_build = false;
 
     /**
+     * The status cache.
+     *
+     * @var array
+     */
+    protected $_statuscache = array();
+
+    /**
      * Attempts to return a reference to a concrete IMP_Contents instance.
      * If an IMP_Contents object is currently stored in the local cache,
      * recreate that object.  Else, create a new instance.
@@ -363,6 +370,10 @@ class IMP_Contents
             $ret[$mime_id]['name'] = $mime_part->getName(true);
         }
 
+        if (isset($this->_statuscache[$mime_id])) {
+            $ret[$mime_id]['status'] = array_merge($this->_statuscache[$mime_id], $ret[$mime_id]['status']);
+        }
+
         /* If this is a text/* part, AND the browser does not support UTF-8,
          * give the user a link to open the part in a new window with the
          * correct character set. */
@@ -735,15 +746,15 @@ class IMP_Contents
                 $viewer->setParams(array('contents' => &$this));
                 $new_parts = $viewer->getEmbeddedMimeParts();
                 if (!is_null($new_parts)) {
-                    foreach ($new_parts as $key => $val) {
+                    foreach (array_keys($new_parts) as $key) {
                         if ($first_id === $key) {
                             $this->_message = $new_parts[$key];
                             $this->_build = false;
                             return $this->_buildMessage();
                         }
 
-                        $this->_message->alterPart($val, $new_parts[$val]);
-                        $to_process = array_merge($to_process, array_keys($new_parts[$val]->contentTypeMap()));
+                        $this->_message->alterPart($key, $new_parts[$key]);
+                        $to_process = array_merge($to_process, array_keys($new_parts[$key]->contentTypeMap()));
                     }
                     $last_id = $id;
                 }
@@ -827,4 +838,15 @@ class IMP_Contents
         $this->_buildMessage();
         return $this->_message->contentTypeMap();
     }
+
+    /**
+     * Sets additional status information for a part.
+     *
+     * @param string $id    The MIME ID
+     * @param array $entry  The status entry.
+     */
+    public function setStatusCache($id, $entry)
+    {
+        $this->_statuscache[$id][] = $entry;
+    }
 }