/**
* 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));
}
/**
)
);
+ $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(' ', ' ', $this->_imppgp->pgpPrettyKey($this->_mimepart->getContents()))) . '</span>',
'status' => array($status),
'type' => 'text/html; charset=' . NLS::getCharset()
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());