}
$options = array(
+ 'identity' => $identity,
+ 'readreceipt' => ($conf['compose']['allow_receipts'] && ($prefs->getValue('disposition_request_read') == 'always')),
'save_sent' => $save_sent_mail,
- 'sent_folder' => $sent_mail_folder,
- 'readreceipt' => ($conf['compose']['allow_receipts'] && ($prefs->getValue('disposition_request_read') == 'always'))
+ 'sent_folder' => $sent_mail_folder
);
try {
}
} catch (IMP_Compose_Exception $e) {
$notification->push($e);
+
+ /* Switch to tied identity. */
+ if (!is_null($e->tied_identity)) {
+ $identity->setDefault($e->tied_identity);
+ $notification->push(_("Your identity has been switched to the identity associated with the current recipient address. The identity will not be checked again during this compose action."));
+ }
}
break;
}
}
$options = array(
+ 'encrypt' => $prefs->isLocked('default_encrypt') ? $prefs->getValue('default_encrypt') : $vars->encrypt_options,
+ 'identity' => $identity,
+ 'priority' => $vars->priority,
'save_sent' => $save_sent_mail,
'sent_folder' => $sent_mail_folder,
'save_attachments' => $vars->save_attachments_select,
- 'encrypt' => $prefs->isLocked('default_encrypt') ? $prefs->getValue('default_encrypt') : $vars->encrypt_options,
- 'priority' => $vars->priority,
'readreceipt' => $vars->request_read_receipt
);
$code = $e->getCode();
$notification->push($e->getMessage(), strpos($code, 'horde.') === 0 ? $code : 'horde.error');
+ /* Switch to tied identity. */
+ if (!is_null($e->tied_identity)) {
+ $identity->setDefault($e->tied_identity);
+ $notification->push(_("Your identity has been switched to the identity associated with the current recipient address. The identity will not be checked again during this compose action."));
+ }
+
// TODO
switch ($e->encrypt) {
case 'pgp_symmetric_passphrase_dialog':
$hidden = array(
'actionID' => '',
- 'user' => Horde_Auth::getAuth(),
- 'compose_requestToken' => Horde::getRequestToken('imp.compose'),
+ 'attachmentAction' => '',
'compose_formToken' => Horde_Token::generateId('compose'),
+ 'compose_requestToken' => Horde::getRequestToken('imp.compose'),
'composeCache' => $composeCacheID,
'mailbox' => htmlspecialchars(IMP::$mailbox),
- 'attachmentAction' => '',
'oldrtemode' => $rtemode,
- 'rtemode' => $rtemode
+ 'rtemode' => $rtemode,
+ 'user' => Horde_Auth::getAuth()
);
if ($_SESSION['imp']['file_upload']) {
v5.0-git
--------
+[mms] Check for incorrect identity on compose if a single recipient address
+ is tied to a different identity than the sending identity.
[mms] Use CATENATE (RFC 4469), if available, to strip MIME parts (Request
#8092).
[mms] Add preference to show flags created by other MUAs (Request #8882).
var DimpCompose = {
// Variables defaulting to empty/false:
// auto_save_interval, compose_cursor, disabled, drafts_mbox,
- // editor_wait, is_popup, knl_p, knl_sm, last_msg, loaded, rte,
- // skip_spellcheck, spellcheck, sc_submit, uploading
+ // editor_wait, is_popup, knl_p, knl_sm, last_msg, loaded, old_identity,
+ // rte, skip_spellcheck, spellcheck, sc_submit, uploading
confirmCancel: function()
{
this.resizeMsgArea();
break;
}
+ } else if (!Object.isUndefined(d.identity)) {
+ this.old_identity = $F('identity');
+ $('identity').setValue(d.identity);
+ this.changeIdentity();
+ $('noticerow', 'identitychecknotice').invoke('show');
}
this.setDisabled(false);
switch (opts.auto) {
case 'forward_attach':
$('noticerow', 'fwdattachnotice').invoke('show');
- $('composeMessage').stopObserving('keydown').observe('keydown', function() {
- $('fwdattachnotice').fade({
- afterFinish: function() {
- $('fwdattachnotice').up('TR').hide();
- this.resizeMsgArea();
- }.bind(this),
- duration: 0.4
- });
- }.bind(this));
+ $('composeMessage').stopObserving('keydown').observe('keydown', this.fadeNotice.bind(this, 'fwdattachnotice'));
break
case 'forward_body':
}
},
+ fadeNotice: function(elt)
+ {
+ elt = $(elt);
+
+ elt.fade({
+ afterFinish: function() {
+ if (!elt.siblings().any(Element.visible)) {
+ elt.up('TR').hide();
+ this.resizeMsgArea();
+ }
+ }.bind(this),
+ duration: 0.4
+ });
+ },
+
setBodyText: function(msg)
{
if (IMP_Compose_Base.editor_on) {
this.setSaveSentMail($F(elt));
break;
- case 'replyallnotice':
- case 'replylistnotice':
case 'fwdattachnotice':
case 'fwdbodynotice':
- elt.fade({
- afterFinish: function() {
- elt.up('TR').hide();
- this.resizeMsgArea();
- }.bind(this),
- duration: 0.4
- });
+ case 'identitychecknotice':
+ case 'replyallnotice':
+ case 'replylistnotice':
+ this.fadeNotice(elt);
if (!orig.match('SPAN.closeImg')) {
if (id.startsWith('reply')) {
$('to_loading_img').show();
DimpCore.doAction('getReplyData', { headeronly: 1, imp_compose: $F('composeCache'), type: 'reply' }, { callback: this.swapToAddressCallback.bind(this) });
- } else {
+ } else if (id.startsWith('fwd')) {
DimpCore.doAction('GetForwardData', { dataonly: 1, imp_compose: $F('composeCache'), type: (id == 'fwdattachnotice' ? 'forward_body' : 'forward_attach') }, { callback: this.forwardAddCallback.bind(this) });
$('composeMessage').stopObserving('keydown');
+ } else if (id == 'identitychecknotice') {
+ $('identity').setValue(this.old_identity);
+ this.changeIdentity();
}
}
e.stop();
* <pre>
* 'action' - (string) The AJAX action string
* 'draft_delete' - (integer) TODO
+ * 'identity' - (integer) If set, this is the identity that is tied to
+ * the current recipient address.
* 'log' - (array) TODO
* 'mailbox' - (array) TODO
* 'reply_folder' - (string) TODO
$imptree->eltDiffStart();
$options = array(
+ 'identity' => $identity,
'priority' => $this->_vars->priority,
'readreceipt' => $this->_vars->request_read_receipt,
'save_attachments' => $this->_vars->save_attachments_select,
} catch (IMP_Compose_Exception $e) {
$result->success = 0;
$GLOBALS['notification']->push($e);
+
+ if (!is_null($e->tied_identity)) {
+ $result->identity = $e->tied_identity;
+ }
+
return $result;
}
* @param boolean $html Whether this is an HTML message.
* @param array $opts An array of options w/the following keys:
* <pre>
- * 'save_sent' = (bool) Save sent mail?
- * 'sent_folder' = (string) The sent-mail folder (UTF7-IMAP).
- * 'save_attachments' = (bool) Save attachments with the message?
* 'encrypt' => (integer) A flag whether to encrypt or sign the message.
* One of IMP::PGP_ENCRYPT, IMP::PGP_SIGNENC,
* IMP::SMIME_ENCRYPT, or IMP::SMIME_SIGNENC.
+ * 'identity' => (IMP_Prefs_Identity) If set, checks for proper tie-to
+ * addresses.
* 'priority' => (string) The message priority ('high', 'normal', 'low').
+ * 'save_sent' = (bool) Save sent mail?
+ * 'sent_folder' = (string) The sent-mail folder (UTF7-IMAP).
+ * 'save_attachments' = (bool) Save attachments with the message?
* 'readreceipt' => (bool) Add return receipt headers?
* 'useragent' => (string) The User-Agent string to use.
* </pre>
$recip = $this->recipientList($header);
$header = array_merge($header, $recip['header']);
+ /* Check for correct identity usage. */
+ if (!$this->getMetadata('identity_check') &&
+ (count($recip['list']) === 1) &&
+ isset($opts['identity'])) {
+ $identity_search = $opts['identity']->getMatchingIdentity($recip['list']);
+ if (!is_null($identity_search) &&
+ ($opts['identity']->getDefault() != $identity_search)) {
+ $this->_metadata['identity_check'] = true;
+ $e = new IMP_Compose_Exception(_("Recipient address does not match the currently selected identity."));
+ $e->tied_identity = $identity_search;
+ throw $e;
+ }
+ }
+
$barefrom = Horde_Mime_Address::bareAddress($header['from'], $_SESSION['imp']['maildomain']);
$encrypt = empty($opts['encrypt']) ? 0 : $opts['encrypt'];
$recipients = implode(', ', $recip['list']);
* @author Michael Slusarz <slusarz@horde.org>
* @package IMP
*/
-class IMP_Compose_Exception extends Horde_Exception_Prior
+class IMP_Compose_Exception extends IMP_Exception
{
/**
* Stores information on whether an encryption dialog window needs
*/
public $encrypt = null;
+ /**
+ * If set, indicates that this identity matches the given to address.
+ *
+ * @var integer
+ */
+ public $tied_identity = null;
+
}
/* Search 'tieto' addresses first. */
/* Check for this address explicitly. */
- if ($search_ties && isset($this->_cached['tie_addresses'][$find_address])) {
+ if ($search_ties &&
+ isset($this->_cached['tie_addresses'][$find_address])) {
return $this->_cached['tie_addresses'][$find_address];
}
<li id="replylistnotice" style="display:none"><span class="iconImg closeImg"></span><?php echo _("You are currently replying to the mailing list. Click here to reply to the original sender instead.") ?></li>
<li id="fwdattachnotice" style="display:none"><span class="iconImg closeImg"></span><?php echo _("Click here to add the original message text to the body.") ?></li>
<li id="fwdbodynotice" style="display:none"><span class="iconImg closeImg"></span><?php echo _("Click here to add the original message as an attachment.") ?></li>
+ <li id="identitychecknotice" style="display:none"><span class="iconImg closeImg"></span><?php echo _("Your identity has been switched to the identity associated with the current recipient address. Click here to revert to the original identity. The identity will not be checked again during this compose action.") ?></li>
</ul>
</td>
</tr>