From ff0859ff475647ee54b4e174f93fdb779609026e Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 25 Nov 2008 17:03:23 -0700 Subject: [PATCH] Fix parsing of embedded parts. Add statuscache code - not currently used yet. --- imp/lib/Contents.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index b5b739b65..0d0ca7fd3 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -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; + } } -- 2.11.0