Felt like quadrupling the amount of work done in read_body.php
authorfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 11 Jan 2001 06:29:17 +0000 (06:29 +0000)
committerfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 11 Jan 2001 06:29:17 +0000 (06:29 +0000)
On a whim, removed the duplicate address problem with reply_all link
Accidentally just made Luke's change obsolete.  (sorry man)
This is what happens when my mind starts churning ...

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@931 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/read_body.php

index 0374904..d73fd0e 100644 (file)
    $url_replyto = urlencode($message->header->replyto);
 
    $url_replytoall   = urlencode($message->header->replyto);
-   $url_replytoallcc = $message->header->from . ", ";
-   $url_replytoallcc .= getLineOfAddrs($message->header->to);
-   $url_replytoallcc_cc = getLineOfAddrs($message->header->cc);
-   if ($url_replytoallcc) {
-      if ($url_replytoallcc_cc) {
-         $url_replytoallcc .= ", " . $url_replytoallcc_cc;
-      }
-   } else {
-      if ($url_replytoallcc_cc) {
-         $url_replytoallcc = $url_replytoallcc_cc;
-      } else {
-         $url_replytoallcc = "";
-      }
-   } 
+
+   // If we are replying to all, then find all other addresses and
+   // add them to the list.  Remove duplicates.
+   // This is somewhat messy, so I'll explain:
+   // 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
+   $url_replytoall_extra_addrs = array_merge(array($message->header->from),
+      $message->header->to, $message->header->cc);
+
+   // 2) Make one big string out of them
+   $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
+   
+   // 3) Parse that into an array of addresses
+   $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
+   
+   // 4) Make them unique -- weed out duplicates
+   $url_replytoall_extra_addrs = array_unique($url_replytoall_extra_addrs);
+   
+   // 5) Remove the addresses we'll be sending the message 'to'
+   $url_replytoall_avoid_addrs = parseAddrs($message->header->replyto);
+   foreach ($url_replytoall_avoid_addrs as $addr)
+   {
+       foreach (array_keys($url_replytoall_extra_addrs, $addr) as $key_to_delete)
+       {
+           unset($url_replytoall_extra_addrs[$key_to_delete]);
+       }
+   }
+   
+   // 6) Smoosh back into one nice line
+   $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
+   
+   // 7) urlencode() it
    $url_replytoallcc = urlencode($url_replytoallcc);
 
    $dateString = getLongDateString($message->header->date);