Another place where we do not need to cache MIME part.
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 20 Nov 2008 21:06:20 +0000 (14:06 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 20 Nov 2008 21:06:20 +0000 (14:06 -0700)
imp/lib/Crypt/pgp.php
imp/lib/Mime/Viewer/pgp.php
imp/pgp.php

index ef8eef4..0676361 100644 (file)
@@ -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));
     }
 
     /**
index be00c90..2481cc5 100644 (file)
@@ -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]") . '</a>';
+            $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]") . '</a>';
         }
         $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' => '<span class="fixed">' . nl2br(str_replace(' ', '&nbsp;', $this->_imppgp->pgpPrettyKey($this->_mimepart->getContents()))) . '</span>',
                 'status' => array($status),
                 'type' => 'text/html; charset=' . NLS::getCharset()
index 7403703..c577828 100644 (file)
@@ -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());