From f60f3752e98769c12a9d09620c328cada20157d5 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 14 Apr 2010 01:38:15 -0600 Subject: [PATCH] Use injector to get IMP_Contents singleton instance --- imp/compose-dimp.php | 4 +- imp/compose-mimp.php | 2 +- imp/compose.php | 2 +- imp/lib/Ajax/Application.php | 2 +- imp/lib/Application.php | 1 + imp/lib/Compose.php | 20 +++++----- imp/lib/Contents.php | 51 +++---------------------- imp/lib/Filter.php | 2 +- imp/lib/Injector/Binder/Contents.php | 29 ++++++++++++++ imp/lib/Injector/Factory/Contents.php | 72 +++++++++++++++++++++++++++++++++++ imp/lib/Mailbox.php | 4 +- imp/lib/Message.php | 4 +- imp/lib/Mime/Viewer/Partial.php | 2 +- imp/lib/Spam.php | 6 +-- imp/lib/Ui/Compose.php | 4 +- imp/lib/Views/ShowMessage.php | 4 +- imp/message-mimp.php | 4 +- imp/message.php | 4 +- imp/pgp.php | 2 +- imp/saveimage.php | 15 ++++---- imp/smime.php | 2 +- imp/thread.php | 2 +- imp/view.php | 4 +- 23 files changed, 151 insertions(+), 91 deletions(-) create mode 100644 imp/lib/Injector/Binder/Contents.php create mode 100644 imp/lib/Injector/Factory/Contents.php diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 7f44336c6..2c02791c0 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -71,7 +71,7 @@ if (in_array($vars->type, array('reply', 'reply_all', 'reply_auto', 'reply_list' } try { - $imp_contents = IMP_Contents::singleton($vars->uid . IMP::IDX_SEP . $vars->folder); + $imp_contents = $injector->getInstance('IMP_Contents')->getOb($vars->folder, $vars->uid); } catch (Horde_Exception $e) { $notification->push(_("Requested message not found."), 'horde.error'); $vars->uid = $vars->folder = null; @@ -143,7 +143,7 @@ case 'forward_redirect': case 'resume': try { - $result = $imp_compose->resumeDraft($vars->uid . IMP::IDX_SEP . $vars->folder); + $result = $imp_compose->resumeDraft($vars->folder, $vars->uid); if ($result['mode'] == 'html') { $show_editor = true; diff --git a/imp/compose-mimp.php b/imp/compose-mimp.php index 2c9f54b5c..74304d28d 100644 --- a/imp/compose-mimp.php +++ b/imp/compose-mimp.php @@ -104,7 +104,7 @@ switch ($vars->a) { // 'd' = draft case 'd': try { - $result = $imp_compose->resumeDraft($imp_mbox['uid'] . IMP::IDX_SEP . $imp_mbox['thismailbox']); + $result = $imp_compose->resumeDraft($imp_mbox['thismailbox'], $imp_mbox['uid']); $msg = $result['msg']; $header = array_merge($header, $result['header']); diff --git a/imp/compose.php b/imp/compose.php index 5eb816043..5999fba13 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -234,7 +234,7 @@ case 'mailto_link': case 'draft': try { - $result = $imp_compose->resumeDraft($uid . IMP::IDX_SEP . $thismailbox); + $result = $imp_compose->resumeDraft($thismailbox, $uid); if (!is_null($rtemode)) { $rtemode = ($result['mode'] == 'html'); diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index d1211b048..abfa4a8a5 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -1537,7 +1537,7 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base if (!($imp_contents = $imp_compose->getContentsOb())) { $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($this->_vars->uid); $i = each($indices); - $imp_contents = IMP_Contents::singleton(reset($i['value']) . IMP::IDX_SEP . $i['key']); + $imp_contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($i['key'], reset($i['value'])); } return array($imp_compose, $imp_contents); diff --git a/imp/lib/Application.php b/imp/lib/Application.php index 77608d3cd..ba8e50261 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -93,6 +93,7 @@ class IMP_Application extends Horde_Registry_Application { /* Add IMP-specific binders. */ $binders = array( + 'IMP_Contents' => new IMP_Injector_Binder_Contents(), 'IMP_Crypt_Pgp' => new IMP_Injector_Binder_Pgp(), 'IMP_Crypt_Smime' => new IMP_Injector_Binder_Smime(), 'IMP_Folder' => new IMP_Injector_Binder_Folder(), diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 097aec154..e302089de 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -356,8 +356,8 @@ class IMP_Compose /** * Resumes a previously saved draft message. * - * @param string $uid The IMAP message mailbox/index. The uid should - * be in IMP::parseIndicesList() format #1. + * @param string $mailbox Draft mailbox. + * @param integer $uid Message UID. * * @return mixed An array with the following keys: *
@@ -368,11 +368,11 @@ class IMP_Compose
      * 
* @throws IMP_Compose_Exception */ - public function resumeDraft($uid) + public function resumeDraft($mailbox, $uid) { try { - $contents = IMP_Contents::singleton($uid); - } catch (Horde_Exception $e) { + $contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mailbox, $uid); + } catch (IMP_Exception $e) { throw new IMP_Compose_Exception($e); } @@ -436,15 +436,15 @@ class IMP_Compose // even though the server is the same. UIDVALIDITY should // catch any true server/backend changes. ($GLOBALS['imp_imap']->checkUidvalidity($imap_url['mailbox']) == $imap_url['uidvalidity']) && - IMP_Contents::singleton($imap_url['uid'] . IMP::IDX_SEP . $imap_url['mailbox'])) { + $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($imap_url['uid'] . IMP::IDX_SEP . $imap_url['mailbox'])) { $this->_metadata['mailbox'] = $imap_url['mailbox']; $this->_metadata['reply_type'] = $reply_type; $this->_metadata['uid'] = $imap_url['uid']; } - } catch (Horde_Exception $e) {} + } catch (Exception $e) {} } - $this->_metadata['draft_uid_resume'] = $uid; + $this->_metadata['draft_uid_resume'] = $uid . IMP::IDX_SEP . $mailbox; $this->_modified = true; return array( @@ -1702,7 +1702,7 @@ class IMP_Compose foreach ($msgList as $mbox => $indicesList) { foreach ($indicesList as $idx) { ++$attached; - $contents = IMP_Contents::singleton($idx . IMP::IDX_SEP . $mbox); + $contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mbox, $idx); $headerob = $contents->getHeaderOb(); $part = new Horde_Mime_Part(); @@ -2713,7 +2713,7 @@ class IMP_Compose public function getContentsOb() { return $this->getMetadata('reply_type') - ? IMP_Contents::singleton($this->getMetadata('uid') . IMP::IDX_SEP . $this->getMetadata('mailbox')) + ? $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($this->getMetadata('mailbox'), $this->getMetadata('uid')) : null; } diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index bb47e04c8..b48064555 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -44,21 +44,6 @@ class IMP_Contents public $lastBodyPartDecode = null; /** - * Singleton instances - * - * @var array - */ - static protected $_instances = array(); - - /** - * Internal counter for ensuring Horde_Mime_Part objects passed to - * singleton() are given unique objects. - * - * @var integer - */ - static protected $_mimepartid = 1; - - /** * The IMAP UID of the message. * * @var integer @@ -94,39 +79,13 @@ class IMP_Contents protected $_embedded = 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. - * Ensures that only one IMP_Contents instance for any given message is - * available at any one time. - * - * @param mixed $in Either a UID string (UID . IMP::IDX_SEP . Mailbox) or - * a Horde_Mime_Part object. - * - * @return IMP_Contents The IMP_Contents object. - * @throws Horde_Exception - */ - static public function singleton($in) - { - $sig = ($in instanceof Horde_Mime_Part) - ? 'horde_mime_part_' . self::$_mimepartid++ - : $in; - - if (empty(self::$_instances[$sig])) { - self::$_instances[$sig] = new self($in); - } - - return self::$_instances[$sig]; - } - - /** * Constructor. * * @param mixed $in Either a UID string (UID . IMP::IDX_SEP . Mailbox) or * a Horde_Mime_Part object. - * @throws Horde_Exception + * @throws IMP_Exception */ - protected function __construct($in) + public function __construct($in) { if ($in instanceof Horde_Mime_Part) { $this->_message = $in; @@ -139,11 +98,11 @@ class IMP_Contents Horde_Imap_Client::FETCH_STRUCTURE => array('parse' => true) ), array('ids' => array($this->_uid))); } catch (Horde_Imap_Client_Exception $e) { - throw new Horde_Exception('Error displaying message.'); + throw new IMP_Exception('Error displaying message.'); } if (!isset($ret[$this->_uid]['structure'])) { - throw new Horde_Exception('Error displaying message.'); + throw new IMP_Exception('Error displaying message.'); } $this->_message = $ret[$this->_uid]['structure']; @@ -704,7 +663,7 @@ class IMP_Contents if (($mask && self::SUMMARY_IMAGE_SAVE) && $GLOBALS['registry']->hasMethod('images/selectGalleries') && ($mime_part->getPrimaryType() == 'image')) { - $part['img_save'] = Horde::link('#', _("Save Image in Gallery"), 'saveImgAtc', null, Horde::popupJs(Horde::applicationUrl('saveimage.php'), array('params' => array('uid' => ($this->_uid . IMP::IDX_SEP . $this->_mailbox), 'id' => $id), 'height' => 200, 'width' => 450)) . 'return false;') . ''; + $part['img_save'] = Horde::link('#', _("Save Image in Gallery"), 'saveImgAtc', null, Horde::popupJs(Horde::applicationUrl('saveimage.php'), array('params' => array('mbox' => $this->_mailbox, 'uid' => $this->_uid, 'id' => $id), 'height' => 200, 'width' => 450)) . 'return false;') . ''; } /* Add print link? */ diff --git a/imp/lib/Filter.php b/imp/lib/Filter.php index 6eab2e350..11fdaad44 100644 --- a/imp/lib/Filter.php +++ b/imp/lib/Filter.php @@ -113,7 +113,7 @@ class IMP_Filter $GLOBALS['imp_imap']->checkUidvalidity($mbox); foreach ($msgIndices as $idx) { - $contents = IMP_Contents::singleton($idx . IMP::IDX_SEP . $mbox); + $contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mbox, $idx); $hdr = $contents->getHeaderOb(); $addr[] = Horde_Mime_Address::bareAddress($hdr->getValue('from')); } diff --git a/imp/lib/Injector/Binder/Contents.php b/imp/lib/Injector/Binder/Contents.php new file mode 100644 index 000000000..e81aec823 --- /dev/null +++ b/imp/lib/Injector/Binder/Contents.php @@ -0,0 +1,29 @@ + + * @package IMP + */ +class IMP_Injector_Binder_Contents implements Horde_Injector_Binder +{ + /** + */ + public function create(Horde_Injector $injector) + { + return new IMP_Injector_Factory_Contents($injector); + } + + /** + */ + public function equals(Horde_Injector_Binder $binder) + { + return false; + } + +} diff --git a/imp/lib/Injector/Factory/Contents.php b/imp/lib/Injector/Factory/Contents.php new file mode 100644 index 000000000..e606e8c46 --- /dev/null +++ b/imp/lib/Injector/Factory/Contents.php @@ -0,0 +1,72 @@ + + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @link http://pear.horde.org/index.php?package=IMP + */ + +/** + * A Horde_Injector:: based IMP_Contents:: factory. + * + * Copyright 2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + * + * @category Horde + * @package IMP + * @author Michael Slusarz + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @link http://pear.horde.org/index.php?package=IMP + */ +class IMP_Injector_Factory_Contents +{ + /** + * Instances. + * + * @var array + */ + private $_instances = array(); + + /** + * The injector. + * + * @var Horde_Injector + */ + private $_injector; + + /** + * Constructor. + * + * @param Horde_Injector $injector The injector to use. + */ + public function __construct(Horde_Injector $injector) + { + $this->_injector = $injector; + } + + /** + * Return the Horde_Editor:: instance. + * + * @param string $mailbox The mailbox name. + * @param integer $uid The message UID. + * + * @return IMP_Contents The singleton contents instance. + * @throws IMP_Exception + */ + public function getOb($mailbox, $uid) + { + $uid = $uid . IMP::IDX_SEP . $mailbox; + if (!isset($this->_instances[$uid])) { + $this->_instances[$uid] = new IMP_Contents($uid); + } + return $this->_instances[$uid]; + } + +} diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index 8413e8f46..19b472b25 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -264,13 +264,13 @@ class IMP_Mailbox !in_array('\\seen', $v['flags'])))) { if (empty($preview_info[$k])) { try { - $imp_contents = IMP_Contents::singleton($k . IMP::IDX_SEP . $mbox); + $imp_contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mbox, $k); $prev = $imp_contents->generatePreview(); $preview_info[$k] = array('IMPpreview' => $prev['text'], 'IMPpreviewc' => $prev['cut']); if (!is_null($cache)) { $tostore[$k] = $preview_info[$k]; } - } catch (Horde_Exception $e) { + } catch (Exception $e) { $preview_info[$k] = array('IMPpreview' => '', 'IMPpreviewc' => false); } } diff --git a/imp/lib/Message.php b/imp/lib/Message.php index 6f54f6385..c25ad27f4 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -312,7 +312,7 @@ class IMP_Message foreach ($msgList as $folder => $msgIndices) { foreach ($msgIndices as $index) { /* Fetch the message contents. */ - $imp_contents = IMP_Contents::singleton($index . IMP::IDX_SEP . $folder); + $imp_contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($folder, $index); /* Fetch the message headers. */ $imp_headers = $imp_contents->getHeaderOb(); @@ -475,7 +475,7 @@ class IMP_Message $GLOBALS['imp_imap']->checkUidvalidity($mbox); /* Get a local copy of the message. */ - $contents = IMP_Contents::singleton($index . IMP::IDX_SEP . $mbox); + $contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mbox, $index); /* Loop through all to-be-stripped mime parts. */ if (is_null($partid)) { diff --git a/imp/lib/Mime/Viewer/Partial.php b/imp/lib/Mime/Viewer/Partial.php index 2805fc8bd..67b992670 100644 --- a/imp/lib/Mime/Viewer/Partial.php +++ b/imp/lib/Mime/Viewer/Partial.php @@ -108,7 +108,7 @@ class IMP_Horde_Mime_Viewer_Partial extends Horde_Mime_Viewer_Driver if ($val == $number) { $parts[$number] = $this->_mimepart->getContents(); } else { - $ic = IMP_Contents::singleton($val . IMP::IDX_SEP . $mbox); + $ic = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mbox, $val); $parts[$ic->getMIMEMessage()->getContentTypeParameter('number')] = $ic->getBody(); } } diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index fa948f186..2378e7310 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -39,7 +39,7 @@ class IMP_Spam foreach ($msgList as $mbox => $msgIndices) { try { $GLOBALS['imp_imap']->checkUidvalidity($mbox); - } catch (Horde_Exception $e) { + } catch (IMP_Exception $e) { continue; } @@ -47,8 +47,8 @@ class IMP_Spam /* Fetch the raw message contents (headers and complete * body). */ try { - $imp_contents = IMP_Contents::singleton($idx . IMP::IDX_SEP . $mbox); - } catch (Horde_Exception $e) { + $imp_contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mbox, $idx); + } catch (IMP_Exception $e) { continue; } diff --git a/imp/lib/Ui/Compose.php b/imp/lib/Ui/Compose.php index d9ae6e1cb..c6c6f57b8 100644 --- a/imp/lib/Ui/Compose.php +++ b/imp/lib/Ui/Compose.php @@ -191,8 +191,8 @@ class IMP_Ui_Compose { if (!empty($uid)) { try { - return IMP_Contents::singleton($uid . IMP::IDX_SEP . $mailbox); - } catch (Horde_Exception $e) { + return $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mailbox, $uid); + } catch (IMP_Exception $e) { $GLOBALS['notification']->push(_("Could not retrieve the message from the mail server."), 'horde.error'); } } diff --git a/imp/lib/Views/ShowMessage.php b/imp/lib/Views/ShowMessage.php index 74b5e42b1..edf008e91 100644 --- a/imp/lib/Views/ShowMessage.php +++ b/imp/lib/Views/ShowMessage.php @@ -118,8 +118,8 @@ class IMP_Views_ShowMessage /* Parse MIME info and create the body of the message. */ try { - $imp_contents = IMP_Contents::singleton($uid . IMP::IDX_SEP . $mailbox); - } catch (Horde_Exception $e) { + $imp_contents = $GLOBALS['injector']->getInstance('IMP_Contents')->getOb($mailbox, $uid); + } catch (IMP_Exception $e) { $result['error'] = $error_msg; $result['errortype'] = 'horde.error'; return $result; diff --git a/imp/message-mimp.php b/imp/message-mimp.php index 944ded436..fa231c713 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -120,8 +120,8 @@ $use_pop = ($_SESSION['imp']['protocol'] == 'pop'); /* Parse the message. */ try { - $imp_contents = IMP_Contents::singleton($uid . IMP::IDX_SEP . $mailbox_name); -} catch (Horde_Exception $e) { + $imp_contents = $injector->getInstance('IMP_Contents')->getOb($mailbox_name, $uid); +} catch (IMP_Exception $e) { header('Location: ' . IMP::generateIMPUrl('mailbox-mimp.php', $mailbox_name)->setRaw(true)->add('a', 'm')); exit; } diff --git a/imp/message.php b/imp/message.php index f31d05441..6da7b52da 100644 --- a/imp/message.php +++ b/imp/message.php @@ -188,8 +188,8 @@ $uid = $index_array['uid']; /* Parse the message. */ try { - $imp_contents = IMP_Contents::singleton($uid . IMP::IDX_SEP . $mailbox_name); -} catch (Horde_Exception $e) { + $imp_contents = $injector->getInstance('IMP_Contents')->getOb($mailbox_name, $uid); +} catch (IMP_Exception $e) { $imp_mailbox->removeMsgs(true); _returnToMailbox(null, 'message_missing'); require IMP_BASE . '/mailbox.php'; diff --git a/imp/pgp.php b/imp/pgp.php index 1402b5ef1..a45334b70 100644 --- a/imp/pgp.php +++ b/imp/pgp.php @@ -141,7 +141,7 @@ case 'info_personal_private_key': case 'save_attachment_public_key': /* Retrieve the key from the message. */ - $contents = IMP_Contents::singleton($vars->uid . IMP::IDX_SEP . $vars->mailbox); + $contents = $injector->getInstance('IMP_Contents')->getOb($vars->mailbox, $vars->uid); $mime_part = $contents->getMIMEPart($vars->mime_id); if (empty($mime_part)) { throw new IMP_Exception('Cannot retrieve public key from message.'); diff --git a/imp/saveimage.php b/imp/saveimage.php index 311427fdd..6364dd4f6 100644 --- a/imp/saveimage.php +++ b/imp/saveimage.php @@ -14,14 +14,13 @@ require_once dirname(__FILE__) . '/lib/Application.php'; Horde_Registry::appInit('imp'); -$id = Horde_Util::getFormData('id'); -$uid = Horde_Util::getFormData('uid'); +$vars = Horde_Variables::getDefaultVariables(); /* Run through the action handlers. */ -switch (Horde_Util::getFormData('actionID')) { +switch ($vars->actionID) { case 'save_image': - $contents = IMP_Contents::singleton($uid); - $mime_part = $contents->getMIMEPart($id); + $contents = $injector->getInstance('IMP_Contents')->getOb($vars->mbox, $vars->uid); + $mime_part = $contents->getMIMEPart($vars->id); $image_data = array( 'data' => $mime_part->getContents(), 'description' => $mime_part->getDescription(true), @@ -29,7 +28,7 @@ case 'save_image': 'type' => $mime_part->getType() ); try { - $registry->call('images/saveImage', array(null, Horde_Util::getFormData('gallery'), $image_data)); + $registry->call('images/saveImage', array(null, $vars->gallery, $image_data)); } catch (Horde_Exception $e) { $notification->push($e); break; @@ -47,8 +46,8 @@ if (!$registry->hasMethod('images/selectGalleries') || $t = $injector->createInstance('Horde_Template'); $t->setOption('gettext', true); $t->set('action', Horde::applicationUrl('saveimage.php')); -$t->set('id', htmlspecialchars($id)); -$t->set('uid', htmlspecialchars($uid)); +$t->set('id', htmlspecialchars($vars->id)); +$t->set('uid', htmlspecialchars($vars->uid)); $t->set('image_img', Horde::img('mime/image.png', _("Image"))); /* Build the list of galleries. */ diff --git a/imp/smime.php b/imp/smime.php index 4be7867b5..b54cd6e9c 100644 --- a/imp/smime.php +++ b/imp/smime.php @@ -89,7 +89,7 @@ case 'process_import_personal_certs': case 'save_attachment_public_key': /* Retrieve the key from the message. */ - $contents = IMP_Contents::singleton($vars->uid . IMP::IDX_SEP . $vars->mailbox); + $contents = $injector->getInstance('IMP_Contents')->getOb($vars->mailbox, $vars->uid); $mime_part = $contents->getMIMEPart($vars->mime_id); if (empty($mime_part)) { throw new IMP_Exception('Cannot retrieve public key from message.'); diff --git a/imp/thread.php b/imp/thread.php index de4be45dd..2d818e1d3 100644 --- a/imp/thread.php +++ b/imp/thread.php @@ -88,7 +88,7 @@ foreach ($loop_array as $mbox => $idxlist) { /* Get the body of the message. */ $curr_msg = $curr_tree = array(); - $contents = IMP_Contents::singleton($idx . IMP::IDX_SEP . $mbox); + $contents = $injector->getInstance('IMP_Contents')->getOb($mbox, $idx); $mime_id = $contents->findBody(); if ($contents->canDisplay($mime_id, IMP_Contents::RENDER_INLINE)) { $ret = $contents->renderMIMEPart($mime_id, IMP_Contents::RENDER_INLINE); diff --git a/imp/view.php b/imp/view.php index 5c9fd5c3f..7f0d6517c 100644 --- a/imp/view.php +++ b/imp/view.php @@ -61,12 +61,12 @@ if ($vars->actionID == 'compose_attach_preview') { /* Create a dummy IMP_Contents() object so we can use the view code below. * Then use the 'view_attach' handler to output. */ - $contents = IMP_Contents::singleton($mime); + $contents = new IMP_Contents($mime); } else { if (!$vars->uid || !$vars->mailbox) { exit; } - $contents = IMP_Contents::singleton($vars->uid . IMP::IDX_SEP . $vars->mailbox); + $contents = $injector->getInstance('IMP_Contents')->getOb($vars->mailbox, $vars->uid); } /* Run through action handlers */ -- 2.11.0