summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-06-01 15:19:14 +0200
committerAleksander Machniak <alec@alec.pl>2013-06-01 15:19:14 +0200
commit15482bcadef86676864f7d498dc54f7c6a85c524 (patch)
tree3acb7b236384fca1439e0438c12cb767acb1e27f
parentcb3e2fe0c2e36e0f41d93015fb1b604d195f9047 (diff)
Improved handling of Reply-To/Bcc addresses of identity in compose form (#1489016)
-rw-r--r--CHANGELOG1
-rw-r--r--program/js/app.js37
-rw-r--r--program/steps/mail/compose.inc10
-rw-r--r--program/steps/mail/sendmail.inc7
-rw-r--r--skins/classic/functions.js10
-rw-r--r--skins/larry/ui.js12
6 files changed, 61 insertions, 16 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 1fdd3718e..0af5ff1b9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Improved handling of Reply-To/Bcc addresses of identity in compose form (#1489016)
- Fix displaying messages with invalid self-closing HTML tags (#1489137)
- Fix PHP warning when responding to a message with many Return-Path headers (#1489136)
- Added user preference to open all popups as standard windows
diff --git a/program/js/app.js b/program/js/app.js
index 25f7fe98e..dbd171d30 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3355,12 +3355,45 @@ function rcube_webmail()
if (!show_sig)
show_sig = this.env.show_sig;
- var cursor_pos, p = -1,
+ var i, rx, cursor_pos, p = -1,
id = obj.options[obj.selectedIndex].value,
input_message = $("[name='_message']"),
message = input_message.val(),
is_html = ($("input[name='_is_html']").val() == '1'),
- sig = this.env.identity;
+ sig = this.env.identity,
+ delim = this.env.recipients_delimiter,
+ headers = ['replyto', 'bcc'];
+
+ // update reply-to/bcc fields with addresses defined in identities
+ for (i in headers) {
+ var key = headers[i],
+ old_val = sig && this.env.identities[sig] ? this.env.identities[sig][key] : '',
+ new_val = id && this.env.identities[id] ? this.env.identities[id][key] : '',
+ input = $('[name="_'+key+'"]'), input_val = input.val();
+
+ // remove old address(es)
+ if (old_val && input_val) {
+ rx = new RegExp('\\s*' + RegExp.escape(old_val) + '\\s*');
+ input_val = input_val.replace(rx, '');
+ }
+
+ // cleanup
+ rx = new RegExp(RegExp.escape(delim) + '\\s*' + RegExp(delim), 'g');
+ input_val = input_val.replace(rx, delim)
+ rx = new RegExp('^\\s*' + RegExp.escape(delim) + '\\s*$');
+ input_val = input_val.replace(rx, '')
+
+ // add new address(es)
+ if (new_val) {
+ rx = new RegExp(RegExp.escape(delim) + '\\s*$');
+ if (input_val && !rx.test(input_val))
+ input_val += delim + ' ';
+ input_val += new_val + delim + ' ';
+ }
+
+ if (old_val || new_val)
+ input.val(input_val).change();
+ }
// enable manual signature insert
if (this.env.signatures && this.env.signatures[id]) {
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 9ee57d31e..140554514 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -474,6 +474,7 @@ function rcmail_compose_header_from($attrib)
if (count($MESSAGE->identities))
{
$a_signatures = array();
+ $identities = array();
$separator = intval($RCMAIL->config->get('reply_mode')) > 0
&& ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD) ? '---' : '-- ';
@@ -511,12 +512,21 @@ function rcmail_compose_header_from($attrib)
$a_signatures[$identity_id]['text'] = $text;
$a_signatures[$identity_id]['html'] = $html;
}
+
+ // add bcc and reply-to
+ if (!empty($sql_arr['reply-to'])) {
+ $identities[$identity_id]['replyto'] = $sql_arr['reply-to'];
+ }
+ if (!empty($sql_arr['bcc'])) {
+ $identities[$identity_id]['bcc'] = $sql_arr['bcc'];
+ }
}
$out = $select_from->show($MESSAGE->compose['from']);
// add signatures to client
$OUTPUT->set_env('signatures', $a_signatures);
+ $OUTPUT->set_env('identities', $identities);
}
// no identities, display text input field
else {
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index cb3a40524..cf22a2af9 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -391,10 +391,6 @@ if (!empty($mailcc)) {
if (!empty($mailbcc)) {
$headers['Bcc'] = $mailbcc;
}
-if (!empty($identity_arr['bcc']) && stripos($headers['Bcc'], $identity_arr['bcc']) === false) {
- $headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc'];
- $RECIPIENT_COUNT ++;
-}
if (($max_recipients = (int) $RCMAIL->config->get('max_recipients')) > 0) {
if ($RECIPIENT_COUNT > $max_recipients) {
@@ -412,9 +408,6 @@ if (!empty($identity_arr['organization'])) {
if (!empty($_POST['_replyto'])) {
$headers['Reply-To'] = rcmail_email_input_format(get_input_value('_replyto', RCUBE_INPUT_POST, TRUE, $message_charset));
}
-else if (!empty($identity_arr['reply-to'])) {
- $headers['Reply-To'] = rcmail_email_input_format($identity_arr['reply-to'], false, true);
-}
if (!empty($headers['Reply-To'])) {
$headers['Mail-Reply-To'] = $headers['Reply-To'];
}
diff --git a/skins/classic/functions.js b/skins/classic/functions.js
index d980627aa..1dcaa1586 100644
--- a/skins/classic/functions.js
+++ b/skins/classic/functions.js
@@ -492,14 +492,18 @@ switch_preview_pane: function(elem)
/* Message composing */
init_compose_form: function()
{
- var f, field, fields = ['cc', 'bcc', 'replyto', 'followupto'],
+ var f, v, field, fields = ['cc', 'bcc', 'replyto', 'followupto'],
div = document.getElementById('compose-div'),
headers_div = document.getElementById('compose-headers-div');
// Show input elements with non-empty value
for (f=0; f<fields.length; f++) {
- if ((field = $('#_'+fields[f])) && field.length && field.val() != '')
- rcmail_ui.show_header_form(fields[f]);
+ v = fields[f]; field = $('#_'+v);
+ if (field.length) {
+ field.on('change', {v:v}, function(e) { if (this.value) rcmail_ui.show_header_form(e.data.v); });
+ if (field.val() != '')
+ rcmail_ui.show_header_form(v);
+ }
}
// prevent from form data loss when pressing ESC key in IE
diff --git a/skins/larry/ui.js b/skins/larry/ui.js
index 693448097..096369a88 100644
--- a/skins/larry/ui.js
+++ b/skins/larry/ui.js
@@ -111,10 +111,14 @@ function rcube_mail_ui()
layout_composeview();
// Show input elements with non-empty value
- var field, fields = ['cc', 'bcc', 'replyto', 'followupto'];
- for (var f=0; f < fields.length; f++) {
- if ((field = $('#_'+fields[f])) && field.length && field.val() != '')
- show_header_row(fields[f], true);
+ var f, v, field, fields = ['cc', 'bcc', 'replyto', 'followupto'];
+ for (f=0; f < fields.length; f++) {
+ v = fields[f]; field = $('#_'+v);
+ if (field.length) {
+ field.on('change', {v: v}, function(e) { if (this.value) show_header_row(e.data.v, true); });
+ if (field.val() != '')
+ show_header_row(v, true);
+ }
}
$('#composeoptionstoggle').click(function(){