From ace75dcb5845d993449daa54968499df519d0d77 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Sun, 1 Jul 2012 20:06:18 +0000 Subject: [PATCH] Add option that allows users to have replies to their own messages sent to the recipient of the previous message (#3520988) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14331 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- doc/ChangeLog | 2 + include/load_prefs.php | 3 ++ include/options/compose.php | 7 ++++ src/compose.php | 74 ++++++++++++++++++++++++++++++++++++- 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 65ea67de..93348422 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -374,6 +374,8 @@ Version 1.5.2 - SVN search in fields other than first/last name (nickname, email) - Made performance improvements in security token handling - Improvements for PHP 5.4 compatibility. + - Added option that allows users to have replies to their own + messages sent to the recipient of the previous message (#3520988). Version 1.5.1 (branched on 2006-02-12) -------------------------------------- diff --git a/include/load_prefs.php b/include/load_prefs.php index ee32dcab..5e66a9c8 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -275,6 +275,9 @@ $attachment_common_show_images = getPref($data_dir, $username, 'attachment_commo /* message disposition notification support setting */ $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', SMPREF_ON); +$do_not_reply_to_self = + getPref($data_dir, $username, 'do_not_reply_to_self', SMPREF_OFF); + $include_self_reply_all = getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON); diff --git a/include/options/compose.php b/include/options/compose.php index 44a15409..dfd6091d 100644 --- a/include/options/compose.php +++ b/include/options/compose.php @@ -118,6 +118,13 @@ function load_optpage_data_compose() { $optgrps[SMOPT_GRP_COMPOSE_REPLY] = _("Replying and Forwarding Messages"); $optvals[SMOPT_GRP_COMPOSE_REPLY] = array(); + $optvals[SMOPT_GRP_COMPOSE_REPLY][] = array( + 'name' => 'do_not_reply_to_self', + 'caption' => _("Send Replies To My Own Messages To Previous Recipient"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'refresh' => SMOPT_REFRESH_NONE + ); + $optvals[SMOPT_GRP_COMPOSE_REPLY][] = array( 'name' => 'include_self_reply_all', 'caption' => _("Include Me in CC when I Reply All"), diff --git a/src/compose.php b/src/compose.php index 09cf6c38..23c47c06 100644 --- a/src/compose.php +++ b/src/compose.php @@ -776,7 +776,7 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se $key, $imapServerAddress, $imapPort, $composeMessage, $body_quote, $request_mdn, $request_dr, $mdn_user_support, $languages, $squirrelmail_language, - $default_charset; + $default_charset, $do_not_reply_to_self; /* * Set $default_charset to correspond with the user's selection @@ -980,6 +980,78 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se } $send_to = decodeHeader($send_to,false,false,true); $send_to = str_replace('""', '"', $send_to); + + + // If user doesn't want replies to her own messages + // going back to herself (instead send again to the + // original recipient of the message being replied to), + // then iterate through identities, checking if the TO + // field is one of them (if the reply is to ourselves) + // + // Note we don't bother if the original message doesn't + // have anything in the TO field itself (because that's + // what we use if we change the recipient to be that of + // the previous message) + // + if ($do_not_reply_to_self && !empty($orig_header->to)) { + + $orig_to = ''; + + foreach($idents as $id) { + + if (!empty($id['email_address']) + && strpos($send_to, $id['email_address']) !== FALSE) { + + // if this is a reply-all, the original recipient + // is already in the CC field, so we can just blank + // the recipient (TO field) (as long as the CC field + // isn't empty that is) and we're done + // + if ($action == 'reply_all') { + if (!empty($send_to_cc)) $send_to = ''; + break; + } + + $orig_to = $orig_header->to; + if (is_array($orig_to) && count($orig_to)) { + $orig_to = $orig_header->getAddr_s('to', ',', FALSE, TRUE); + } else if (is_object($orig_to)) { /* unneccesarry, just for failsafe purpose */ + $orig_to = $orig_header->getAddr_s('to', ',', FALSE, TRUE); + } else { + $orig_to = ''; + } + $orig_to = decodeHeader($orig_to,false,false,true); + $orig_to = str_replace('""', '"', $orig_to); + + break; + } + } + + // if the reply was addressed back to ourselves, + // we will send it to the TO of the previous message, + // first making sure that that address wasn't also + // one of our identities + // + if (!empty($orig_to)) { + + foreach($idents as $id) { + if (!empty($id['email_address']) + && strpos($orig_to, $id['email_address']) !== FALSE) { + $orig_to = ''; + break; + } + } + + // if $orig_to still not empty, we can use it + // + if (!empty($orig_to)) { + $send_to = $orig_to; + } + } + + } + + $subject = decodeHeader($orig_header->subject,false,false,true); $subject = str_replace('"', "'", $subject); $subject = trim($subject); -- 2.25.1