if ($pgp_passphrase_dialog || $pgp_symmetric_passphrase_dialog) {
if ($pgp_passphrase_dialog) {
Horde::addInlineScript(array(
- IMP::passphraseDialogJS('PGPPersonal', 'ImpCompose.uniqSubmit(\'send_message\')')
+ IMP::passphraseDialogJS('PGPPersonal')
), 'dom');
} else {
Horde::addInlineScript(array(
- IMP::passphraseDialogJS('PGPSymmetric', 'ImpCompose.uniqSubmit(\'send_message\')', array('symmetricid' => 'imp_compose_' . $composeCacheID))
+ IMP::passphraseDialogJS('PGPSymmetric', array('symmetricid' => 'imp_compose_' . $composeCacheID))
), 'dom');
}
} elseif ($smime_passphrase_dialog) {
Horde::addInlineScript(array(
- IMP::passphraseDialogJS('SMIMEPersonal', 'ImpCompose.uniqSubmit(\'send_message\')')
+ IMP::passphraseDialogJS('SMIMEPersonal')
), 'dom');
}
/* Add click handler. */
document.observe('click', DimpCore.clickHandler.bindAsEventListener(DimpCore));
+ /* Catch dialog actions. */
+ document.observe('IMPDialog:success', function(e) {
+ switch (e.memo) {
+ case 'PGPPersonal':
+ case 'PGPSymmetric':
+ case 'SMIMEPersonal':
+ IMPDialog.noreload = true;
+ this.reloadMessage({});
+ break;
+ }
+ }.bindAsEventListener(this));
+
/* Determine base window. Need a try/catch block here since, if the
* page was loaded by an opener out of this current domain, this will
* throw an exception. */
/* Warn before closing the window. */
Event.observe(window, 'beforeunload', ImpCompose.onBeforeUnload.bind(ImpCompose));
+
+/* Catch dialog actions. */
+document.observe('IMPDialog:success', function(e) {
+ switch (e.memo) {
+ case 'PGPPersonal':
+ case 'PGPSymmetric':
+ case 'SMIMEPersonal':
+ IMPDialog.noreload = true;
+ ImpCompose.uniqSubmit('send_message');
+ break;
+ }
+});
display: function(data)
{
+ this.noreload = false;
+
if (Object.isString(data)) {
data = decodeURIComponent(data).evalJSON(true);
}
_display: function(data)
{
- this.action = data.action;
this.params = data.params;
+ this.type = data.type;
this.uri = data.uri;
var n = new Element('FORM', { action: '#', id: 'RB_confirm' }).insert(
if (r.response.success) {
this._close();
- if (this.action) {
- if (Object.isFunction(this.action)) {
- this.action();
- } else {
- eval(this.action)();
- }
- } else {
+ document.fire('IMPDialog:success', this.type);
+ if (!this.noreload) {
location.reload();
}
} else if (r.response.error) {
* Generate the JS code necessary to open a passphrase dialog. Adds the
* necessary JS files to open the dialog.
*
- * @param string $type The dialog type.
- * @param string $action The JS code to run after success. Defaults to
- * reloading the current window.
- * @param array $params Any additional parameters to pass.
+ * @param string $type The dialog type.
+ * @param array $params Any additional parameters to pass.
*
* @return string The generated JS code.
*/
- static public function passphraseDialogJS($type, $action = null,
- $params = array())
+ static public function passphraseDialogJS($type, $params = array())
{
Horde::addScriptFile('effects.js', 'horde');
Horde::addScriptFile('redbox.js', 'horde');
}
$js_params = array(
- 'action' => $action,
- 'uri' => Horde::applicationUrl('ajax.php', true, -1) . '/' . $type,
+ 'cancel_text' => _("Cancel"),
+ 'ok_text' => _("OK"),
'params' => $params,
- 'text' => $text,
'password' => true,
- 'ok_text' => _("OK"),
- 'cancel_text' => _("Cancel")
+ 'text' => $text,
+ 'type' => $type,
+ 'uri' => Horde::applicationUrl('ajax.php', true, -1) . '/' . $type
);
return 'IMPDialog.display(' . Horde::escapeJson($js_params, array('urlencode' => true)) . ')';
$symmetric_pass = $this->_imppgp->getPassphrase('symmetric', $symmetric_id);
if (is_null($symmetric_pass)) {
- $js_action = '';
$status[] = _("The data in this part has been encrypted via PGP.");
- switch ($_SESSION['imp']['view']) {
- case 'dimp':
- $js_action = 'DimpCore.reloadMessage({});';
- // Fall through
+ /* Ask for the correct passphrase if this is encrypted
+ * symmetrically. */
+ $status[] = Horde::link('#', '', '', '', IMP::passphraseDialogJS('PGPSymmetric', array('symmetricid' => $symmetric_id)) . ';return false;') . _("You must enter the passphrase used to encrypt this message to view it.") . '</a>';
- case 'imp':
- /* Ask for the correct passphrase if this is encrypted
- * symmetrically. */
- $status[] = Horde::link('#', '', '', '', IMP::passphraseDialogJS('PGPSymmetric', $js_action, array('symmetricid' => $symmetric_id)) . ';return false;') . _("You must enter the passphrase used to encrypt this message to view it.") . '</a>';
- break;
- }
return null;
}
}
if ($this->_imppgp->getPersonalPrivateKey()) {
$personal_pass = $this->_imppgp->getPassphrase('personal');
if (is_null($personal_pass)) {
- $js_action = '';
-
- switch ($_SESSION['imp']['view']) {
- case 'dimp':
- $js_action = 'DimpCore.reloadMessage({});';
- // Fall through
-
- case 'imp':
- /* Ask for the private key's passphrase if this is
- * encrypted asymmetrically. */
- $status[] = Horde::link('#', '', '', '', IMP::passphraseDialogJS('PGPPersonal', $js_action) . ';return false;') . _("You must enter the passphrase for your PGP private key to view this message.") . '</a>';
- break;
- }
+ /* Ask for the private key's passphrase if this is
+ * encrypted asymmetrically. */
+ $status[] = Horde::link('#', '', '', '', IMP::passphraseDialogJS('PGPPersonal') . ';return false;') . _("You must enter the passphrase for your PGP private key to view this message.") . '</a>';
return null;
}
} else {
/* Make sure we have a passphrase. */
$passphrase = $this->_impsmime->getPassphrase();
if (is_null($passphrase)) {
- $js_action = '';
-
- switch ($_SESSION['imp']['view']) {
- case 'dimp':
- $js_action = 'DimpCore.reloadMessage({});';
- // Fall through
-
- case 'imp':
- $status[] = Horde::link('#', '', '', '', IMP::passphraseDialogJS('SMIMEPersonal', $js_action) . ';return false;') . _("You must enter the passphrase for your S/MIME private key to view this data.") . '</a>';
- break;
- }
+ $status[] = Horde::link('#', '', '', '', IMP::passphraseDialogJS('SMIMEPersonal') . ';return false;') . _("You must enter the passphrase for your S/MIME private key to view this data.") . '</a>';
return null;
}