From 571d2d3ec0743d483cbe010cd92104c3eee395e9 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 20 Nov 2008 14:06:20 -0700 Subject: [PATCH] Another place where we do not need to cache MIME part. --- imp/lib/Crypt/pgp.php | 15 +++++---------- imp/lib/Mime/Viewer/pgp.php | 6 ++++-- imp/pgp.php | 12 +++++++----- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/imp/lib/Crypt/pgp.php b/imp/lib/Crypt/pgp.php index ef8eef414..067636153 100644 --- a/imp/lib/Crypt/pgp.php +++ b/imp/lib/Crypt/pgp.php @@ -448,20 +448,15 @@ class IMP_Horde_Crypt_pgp extends Horde_Crypt_pgp /** * Generates the javascript code for saving public keys. * - * @param Horde_Mime_Part &$mime_part The part containing the public key. - * @param string $cache The part identifier. + * @param string $mailbox The mailbox of the message. + * @param integer $uid The UID of the message. + * @param string $id The MIME ID of the message. * * @return string The URL for saving public keys. */ - public function savePublicKeyURL(&$mime_part, $cache = null) + public function savePublicKeyURL($mailbox, $uid, $id); { - if (empty($cache)) { - require_once 'Horde/SessionObjects.php'; - $cacheSess = &Horde_SessionObjects::singleton(); - $oid = $cacheSess->storeOid($mime_part); - } - - return $this->getJSOpenWinCode('save_attachment_public_key', false, array('mimecache' => $oid)); + return $this->getJSOpenWinCode('save_attachment_public_key', false, array('mailbox' => $mailbox, 'uid' => $uid, 'mime_id' => $id)); } /** diff --git a/imp/lib/Mime/Viewer/pgp.php b/imp/lib/Mime/Viewer/pgp.php index be00c90d2..2481cc594 100644 --- a/imp/lib/Mime/Viewer/pgp.php +++ b/imp/lib/Mime/Viewer/pgp.php @@ -222,15 +222,17 @@ class IMP_Horde_Mime_Viewer_pgp extends Horde_Mime_Viewer_Driver ) ); + $mime_id = $this->_mimepart->getMimeId(); + if ($GLOBALS['prefs']->getValue('use_pgp') && $GLOBALS['prefs']->getValue('add_source') && $GLOBALS['registry']->hasMethod('contacts/addField')) { - $status['text'][] = Horde::link('#', '', '', '', $this->_imppgp->savePublicKeyURL($mime) . 'return false;') . _("[Save the key to your Address book]") . ''; + $status['text'][] = Horde::link('#', '', '', '', $this->_imppgp->savePublicKeyURL($this->_params['contents']->getMailbox(), $this->_params['contents']->getIndex(), $mime_id) . 'return false;') . _("[Save the key to your Address book]") . ''; } $status['text'][] = $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', _("View the raw text of the Public Key."), array('params' => array('mode' => IMP_Contents::RENDER_INLINE, 'rawpgpkey' => 1))); return array( - $this->_mimepart->getMimeId() => array( + $mime_id => array( 'data' => '' . nl2br(str_replace(' ', ' ', $this->_imppgp->pgpPrettyKey($this->_mimepart->getContents()))) . '', 'status' => array($status), 'type' => 'text/html; charset=' . NLS::getCharset() diff --git a/imp/pgp.php b/imp/pgp.php index 740370353..c577828b9 100644 --- a/imp/pgp.php +++ b/imp/pgp.php @@ -263,13 +263,15 @@ case 'save_options': break; case 'save_attachment_public_key': - /* Retrieve the key from the cache. */ - $cache = &Horde_SessionObjects::singleton(); - $mime_part = $cache->query(Util::getFormData('mimecache')); + /* Retrieve the key from the message. */ + $contents = &IMP_Contents::singleton(Util::getFormData('uid') . IMP::IDX_SEP . Util::getFormData('mailbox')); + if (is_a($contents, 'PEAR_Error')) { + Horde::fatal($contents, __FILE__, __LINE__); + } + $mime_part = $contents->getMIMEPart(Util::getFormData('mime_id')); if (empty($mime_part)) { - Horde::fatal(_("Cannot retrieve public key from cache."), __FILE__, __LINE__); + Horde::fatal('Cannot retrieve public key from message.', __FILE__, __LINE__); } - $mime_part->transferDecodeContents(); /* Add the public key to the storage system. */ $key_info = $imp_pgp->addPublicKey($mime_part->getContents()); -- 2.11.0