Add option that allows users to have replies to their own messages sent to the recipi...
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 1 Jul 2012 20:06:18 +0000 (20:06 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 1 Jul 2012 20:06:18 +0000 (20:06 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14331 7612ce4b-ef26-0410-bec9-ea0150e637f0

doc/ChangeLog
include/load_prefs.php
include/options/compose.php
src/compose.php

index 65ea67d..9334842 100644 (file)
@@ -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.
     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)
 --------------------------------------
 
 Version 1.5.1 (branched on 2006-02-12)
 --------------------------------------
index ee32dca..5e66a9c 100644 (file)
@@ -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);
 
 /* 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);
 
 $include_self_reply_all =
     getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON);
 
index 44a1540..dfd6091 100644 (file)
@@ -119,6 +119,13 @@ function load_optpage_data_compose() {
     $optvals[SMOPT_GRP_COMPOSE_REPLY] = array();
 
     $optvals[SMOPT_GRP_COMPOSE_REPLY][] = array(
     $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"),
         'type'    => SMOPT_TYPE_BOOLEAN,
         'name'    => 'include_self_reply_all',
         'caption' => _("Include Me in CC when I Reply All"),
         'type'    => SMOPT_TYPE_BOOLEAN,
index 09cf6c3..23c47c0 100644 (file)
@@ -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,
         $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
 
     /*
      * 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);
                 }
                 $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);
                 $subject = decodeHeader($orig_header->subject,false,false,true);
                 $subject = str_replace('"', "'", $subject);
                 $subject = trim($subject);