From 583f1c8d80c42195d0ee41f30a885e13d777b79f Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 08 Nov 2005 15:18:56 -0500
Subject: [PATCH] Added reply-to-all function (submitted by Julien Brette)

---
 program/localization/fi/labels.inc            |    1 
 skins/default/images/buttons/replyall_pas.png |    0 
 program/steps/mail/compose.inc                |   47 ++++++++++++++++++-----
 skins/default/mail.css                        |    2 
 program/localization/nl/labels.inc            |    1 
 program/localization/ro/labels.inc            |    1 
 skins/default/templates/message.html          |    1 
 skins/default/images/buttons/replyall_act.png |    0 
 program/localization/en_GB/labels.inc         |    1 
 program/localization/se/labels.inc            |    1 
 skins/default/templates/mail.html             |    1 
 program/localization/it/labels.inc            |    1 
 program/localization/pt_BR/labels.inc         |    1 
 program/localization/de/labels.inc            |    1 
 CHANGELOG                                     |    5 ++
 program/localization/se/messages.inc          |    2 +
 program/localization/fr/labels.inc            |    1 
 program/localization/da/labels.inc            |    1 
 program/localization/en/labels.inc            |    1 
 program/steps/mail/sendmail.inc               |    2 
 program/localization/ca/labels.inc            |    1 
 program/localization/es/labels.inc            |    1 
 skins/default/templates/compose.html          |   10 +++++
 program/js/app.js                             |    9 ++--
 program/localization/pt/labels.inc            |    1 
 25 files changed, 76 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 4b0d6cf..618c51f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -62,7 +62,7 @@
 
 2005/11/06
 ----------
-- Added Finnish, Romanian, Polish, Czech, British and Chinese translation
+- Added Finnish, Romanian, Polish, Czech, British, Norwegian and Chinese translation
 - Get IMAP server capabilities in array
 - Check for NAMESPACE capability before sending command
 - Set default user language from config 'locale_string'
@@ -76,3 +76,6 @@
 - Added input check for contacts and identities (Patch #1346523)
 - Added messages/warning to compose step (Patch #1323895)
 - Added favicon to the default skin
+- Fixed Bug #1334337 as far as possible
+- Added Reply-To-All functionality
+
diff --git a/program/js/app.js b/program/js/app.js
index 7967f79..9825c18 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -6,7 +6,7 @@
  | Copyright (C) 2005, RoundCube Dev, - Switzerland                      |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
- | Modified: 2005/11/06 (roundcube)                                      |
+ | Modified: 2005/11/08 (roundcube)                                      |
  |                                                                       |
  +-----------------------------------------------------------------------+
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
@@ -118,7 +118,7 @@
         
         if (this.env.action=='show')
           {
-          this.enable_command('show', 'reply', 'forward', 'moveto', 'delete', 'viewsource', 'print', 'load-attachment', true);
+          this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'viewsource', 'print', 'load-attachment', true);
           if (this.env.next_uid)
             this.enable_command('nextmessage', true);
           if (this.env.prev_uid)
@@ -727,12 +727,13 @@
         this.upload_file(props)      
         break;
 
+      case 'reply-all':
       case 'reply':
         var uid;
         if (uid = this.get_single_uid())
           {
           this.set_busy(true);
-          location.href = this.env.comm_path+'&_action=compose&_reply_uid='+uid+'&_mbox='+escape(this.env.mailbox);
+          location.href = this.env.comm_path+'&_action=compose&_reply_uid='+uid+'&_mbox='+escape(this.env.mailbox)+(command=='reply-all' ? '&_all=1' : '');
           }
         break;      
 
@@ -1036,7 +1037,7 @@
     // enable/disable commands for message
     if (this.task=='mail')
       {
-      this.enable_command('show', 'reply', 'forward', 'print', selected);
+      this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', selected);
       this.enable_command('delete', 'moveto', this.selection.length>0 ? true : false);
       }
     else if (this.task=='addressbook')
diff --git a/program/localization/ca/labels.inc b/program/localization/ca/labels.inc
index f6b2877..b4e7aa0 100644
--- a/program/localization/ca/labels.inc
+++ b/program/localization/ca/labels.inc
@@ -91,6 +91,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Crear nou missatge';
 $labels['replytomessage']   = 'Respondre el missatge';
+$labels['replytoallmessage'] = 'Respondre a tots';
 $labels['forwardmessage']   = 'Reenviar el missatge';
 $labels['deletemessage']    = 'Moure el missatge a la paperera';
 $labels['printmessage']     = 'Imprimir aquest missatge';
diff --git a/program/localization/da/labels.inc b/program/localization/da/labels.inc
index bec439d..4df394c 100644
--- a/program/localization/da/labels.inc
+++ b/program/localization/da/labels.inc
@@ -93,6 +93,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Opret en ny besked';
 $labels['replytomessage']   = 'Svar p� denne besked';
+$labels['replytoallmessage'] = 'Svar alle';
 $labels['forwardmessage']   = 'Videresend denne besked';
 $labels['deletemessage']    = 'Flyt beskeden til skrald';
 $labels['printmessage']     = 'Udskriv denne besked';
diff --git a/program/localization/de/labels.inc b/program/localization/de/labels.inc
index fe5bd8e..4bbb14c 100644
--- a/program/localization/de/labels.inc
+++ b/program/localization/de/labels.inc
@@ -92,6 +92,7 @@
 // toolbar buttons // Symbolleisten-Tipps
 $labels['writenewmessage']  = 'Neue Nachricht schreiben';
 $labels['replytomessage']   = 'Antwort verfassen';
+$labels['replytoallmessage'] = 'Antwort an Absender und alle Empf�nger';
 $labels['forwardmessage']   = 'Nachricht weiterleiten';
 $labels['deletemessage']    = 'In den Papierkorb verschieben';
 $labels['printmessage']     = 'Diese Nachricht drucken';
diff --git a/program/localization/en/labels.inc b/program/localization/en/labels.inc
index 34d46a3..35813cd 100644
--- a/program/localization/en/labels.inc
+++ b/program/localization/en/labels.inc
@@ -91,6 +91,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Create a new message';
 $labels['replytomessage']   = 'Reply to the message';
+$labels['replytoallmessage'] = 'Reply to sender an all recipients';
 $labels['forwardmessage']   = 'Forward the message';
 $labels['deletemessage']    = 'Move message to trash';
 $labels['printmessage']     = 'Print this message';
diff --git a/program/localization/en_GB/labels.inc b/program/localization/en_GB/labels.inc
index 9efd1ff..d1a2749 100644
--- a/program/localization/en_GB/labels.inc
+++ b/program/localization/en_GB/labels.inc
@@ -91,6 +91,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Create a new message';
 $labels['replytomessage']   = 'Reply to the message';
+$labels['replytoallmessage'] = 'Reply to sender an all recipients';
 $labels['forwardmessage']   = 'Forward the message';
 $labels['deletemessage']    = 'Move message to trash';
 $labels['printmessage']     = 'Print this message';
diff --git a/program/localization/es/labels.inc b/program/localization/es/labels.inc
index bd80036..19bad21 100644
--- a/program/localization/es/labels.inc
+++ b/program/localization/es/labels.inc
@@ -90,6 +90,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Crear nuevo mensaje';
 $labels['replytomessage']   = 'Responder al mensaje';
+$labels['replytoallmessage'] = 'Responder a todos';
 $labels['forwardmessage']   = 'Reenviar mensaje';
 $labels['deletemessage']    = 'Move message to trash';
 $labels['printmessage']     = 'Imprimir este mensaje';
diff --git a/program/localization/fi/labels.inc b/program/localization/fi/labels.inc
index ba610a0..b92ef79 100644
--- a/program/localization/fi/labels.inc
+++ b/program/localization/fi/labels.inc
@@ -91,6 +91,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Kirjoita uusi viesti';
 $labels['replytomessage']   = 'Vastaa viestiin';
+$labels['replytoallmessage'] = 'Vastaa kaikille';
 $labels['forwardmessage']   = 'V�lit� viesti';
 $labels['deletemessage']    = 'Siirr� viesti roskakoriin';
 $labels['printmessage']     = 'Tulosta viesti';
diff --git a/program/localization/fr/labels.inc b/program/localization/fr/labels.inc
index 5b92518..c429d5b 100644
--- a/program/localization/fr/labels.inc
+++ b/program/localization/fr/labels.inc
@@ -90,6 +90,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Cr�er un nouveau message';
 $labels['replytomessage']   = 'R�pondre au message';
+$labels['replytoallmessage'] = 'R�pondre � tous';
 $labels['forwardmessage']   = 'Transmettre le message';
 $labels['deletemessage']    = 'D�placer le message dans la corbeille';
 $labels['printmessage']     = 'Imprimer ce message';
diff --git a/program/localization/it/labels.inc b/program/localization/it/labels.inc
index 3eba8b6..111a1ac 100644
--- a/program/localization/it/labels.inc
+++ b/program/localization/it/labels.inc
@@ -90,6 +90,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Crea un nuovo messaggio';
 $labels['replytomessage']   = 'Rispondi al messaggio';
+$labels['replytoallmessage'] = 'Rispondi a tutti';
 $labels['forwardmessage']   = 'Inoltra il messaggio';
 $labels['deletemessage']    = 'Sposta il messaggio nel cestino';
 $labels['printmessage']     = 'Stampa questo messaggio';
diff --git a/program/localization/nl/labels.inc b/program/localization/nl/labels.inc
index 464d939..b8158bd 100644
--- a/program/localization/nl/labels.inc
+++ b/program/localization/nl/labels.inc
@@ -91,6 +91,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Schrijf een nieuw bericht';
 $labels['replytomessage']   = 'Beantwoord het bericht';
+$labels['replytoallmessage'] = 'Beantwoord allen';
 $labels['forwardmessage']   = 'Stuur bericht door';
 $labels['deletemessage']    = 'Verplaats bericht naar prullenbak';
 $labels['printmessage']     = 'Print dit bericht';
diff --git a/program/localization/pt/labels.inc b/program/localization/pt/labels.inc
index 30710ba..6ca4dfa 100644
--- a/program/localization/pt/labels.inc
+++ b/program/localization/pt/labels.inc
@@ -91,6 +91,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Criar nova mensagem';
 $labels['replytomessage']   = 'Responder a mensagem';
+$labels['replytoallmessage'] = 'Responder a todos';
 $labels['forwardmessage']   = 'Reencaminhar a mensagem';
 $labels['deletemessage']    = 'Mover a mensagem para a reciclagem';
 $labels['printmessage']     = 'Imprimir esta mensagem';
diff --git a/program/localization/pt_BR/labels.inc b/program/localization/pt_BR/labels.inc
index 0086746..e0c3256 100644
--- a/program/localization/pt_BR/labels.inc
+++ b/program/localization/pt_BR/labels.inc
@@ -94,6 +94,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Criar nova mensagem';
 $labels['replytomessage']   = 'Responder';
+$labels['replytoallmessage'] = 'Responder a todos';
 $labels['forwardmessage']   = 'Encaminhar';
 $labels['deletemessage']    = 'Mover para a lixeira';
 $labels['printmessage']     = 'Imprimir';
diff --git a/program/localization/ro/labels.inc b/program/localization/ro/labels.inc
index 3d5f9dc..b7cab4d 100644
--- a/program/localization/ro/labels.inc
+++ b/program/localization/ro/labels.inc
@@ -90,6 +90,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Creaza mesaj nou';
 $labels['replytomessage']   = 'Raspunde la mesaj';
+$labels['replytoallmessage'] = 'Raspunde la toti';
 $labels['forwardmessage']   = 'Trimite mesaj mai departe';
 $labels['deletemessage']    = 'Muta mesaj la gunoi';
 $labels['printmessage']     = 'Printeaza mesaj';
diff --git a/program/localization/se/labels.inc b/program/localization/se/labels.inc
index 13930bb..7e06e45 100644
--- a/program/localization/se/labels.inc
+++ b/program/localization/se/labels.inc
@@ -91,6 +91,7 @@
 // toolbar buttons
 $labels['writenewmessage']  = 'Skapa nytt meddelande';
 $labels['replytomessage']   = 'Svar p� meddelande';
+$labels['replytoallmessage'] = 'Svara alla';
 $labels['forwardmessage']   = 'Skicka vidare meddelande';
 $labels['deletemessage']    = 'Flytta till papperskorgen';
 $labels['printmessage']     = 'Skriv ut';
diff --git a/program/localization/se/messages.inc b/program/localization/se/messages.inc
index 7ec1e98..a5f9f73 100644
--- a/program/localization/se/messages.inc
+++ b/program/localization/se/messages.inc
@@ -32,6 +32,8 @@
 
 $messages['mailboxempty'] = 'Mappen �r tom';
 
+$messages['loading'] = 'Laddar....';
+
 $messages['loadingdata'] = 'Laddar data...';
 
 $messages['messagesent'] = 'Meddelande skickades';
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index d01e399..93fae66 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -50,15 +50,18 @@
   $MESSAGE['structure'] = $mmd->decode(array('include_bodies' => TRUE,
                                              'decode_headers' => TRUE,
                                              'decode_bodies' => FALSE));
-                                             
+
   $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject);
   $MESSAGE['parts'] = $mmd->getMimeNumbers($MESSAGE['structure']);
   
   if ($_GET['_reply_uid'])
     {
-    $REPLY_MESSAGE = $MESSAGE;
+    $REPLY_MESSAGE = &$MESSAGE;
     $_SESSION['compose']['reply_uid'] = $_GET['_reply_uid'];
     $_SESSION['compose']['reply_msgid'] = $REPLY_MESSAGE['headers']->messageID;
+
+    if ($_GET['_all'])
+      $REPLY_MESSAGE['reply_all'] = 1;
     }
   else
     {
@@ -75,6 +78,7 @@
 function rcmail_compose_headers($attrib)
   {
   global $IMAP, $REPLY_MESSAGE, $DB;
+  static $sa_recipients = array();
 
   list($form_start, $form_end) = get_form_tags($attrib);
   
@@ -144,7 +148,7 @@
       if (!$fname)
         {
         $fname = '_cc';
-        //$header = 'cc';
+        $header = 'cc';
         }
     case 'bcc':
       if (!$fname)
@@ -162,7 +166,7 @@
       break;
     
     }
-    
+
     
   if ($fname && !empty($_POST[$fname]))
     $fvalue = $_POST[$fname];
@@ -173,14 +177,37 @@
       $fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->replyto);
     else if ($header=='to' && $REPLY_MESSAGE['headers']->from)
       $fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->from);
-    
+    // add recipent of original message if reply to all
+    else if ($header=='cc' && $REPLY_MESSAGE['reply_all'])
+      {
+      if ($IMAP->decode_header($REPLY_MESSAGE['headers']->to))
+        $fvalue .= $IMAP->decode_header($REPLY_MESSAGE['headers']->to);
+
+      if ($IMAP->decode_header($REPLY_MESSAGE['headers']->cc))
+        {
+        if($fvalue)
+          $fvalue .= ', ';
+
+        $fvalue .= $IMAP->decode_header($REPLY_MESSAGE['headers']->cc);
+        }
+      }
+
     // split recipients and put them back together in a unique way
-    $to_addresses = $IMAP->decode_address_list($fvalue);
-    $fvalue = '';
-    foreach ($to_addresses as $addr_part)
-      $fvalue .= (strlen($fvalue) ? ', ':'').$addr_part['string'];
+    if (!empty($fvalue))
+      {
+      $to_addresses = $IMAP->decode_address_list($fvalue);
+      $fvalue = '';
+      foreach ($to_addresses as $addr_part)
+        {
+        if (!in_array($addr_part['mailto'], $sa_recipients))
+          {
+          $fvalue .= (strlen($fvalue) ? ', ':'').$addr_part['string'];
+          $sa_recipients[] = $addr_part['mailto'];
+          }
+        }
+      }
     }
-    
+
         
   if ($fname && $field_type)
     {
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 2bafaeb..c5505c9 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -138,7 +138,7 @@
 
 
 // create PEAR::Mail_mime instance
-$MAIL_MIME = new Mail_mime();
+$MAIL_MIME = new Mail_mime("\n");
 $MAIL_MIME->setTXTBody(stripslashes($_POST['_message']), FALSE, TRUE);
 //$MAIL_MIME->setTXTBody(wordwrap(stripslashes($_POST['_message'])), FALSE, TRUE);
 
diff --git a/skins/default/images/buttons/replyall_act.png b/skins/default/images/buttons/replyall_act.png
new file mode 100644
index 0000000..b6ad3fb
--- /dev/null
+++ b/skins/default/images/buttons/replyall_act.png
Binary files differ
diff --git a/skins/default/images/buttons/replyall_pas.png b/skins/default/images/buttons/replyall_pas.png
new file mode 100644
index 0000000..948072d
--- /dev/null
+++ b/skins/default/images/buttons/replyall_pas.png
Binary files differ
diff --git a/skins/default/mail.css b/skins/default/mail.css
index 739bfed..5a362c1 100644
--- a/skins/default/mail.css
+++ b/skins/default/mail.css
@@ -26,7 +26,7 @@
 #messagetoolbar select.mboxlist
 {
   position: absolute;
-  left: 300px;
+  left: 335px;
   top: 10px;
 }
 
diff --git a/skins/default/templates/compose.html b/skins/default/templates/compose.html
index dd392bd..aa28098 100644
--- a/skins/default/templates/compose.html
+++ b/skins/default/templates/compose.html
@@ -105,6 +105,16 @@
 
 <roundcube:object name="composeAttachmentForm" id="attachment-form" />
 
+<script type="text/javascript">
+<!--
+
+var cc_field = document.form._cc;
+if (cc_field && cc_field.value!='')
+  rcmail_toggle_display('compose-cc');
+
+//-->
+</script>
+
 <!--
 <div id="attachment-form">
 <roundcube:object name="composeAttachment" size="20" /><br />
diff --git a/skins/default/templates/mail.html b/skins/default/templates/mail.html
index 3eafad5..61d0e6d 100644
--- a/skins/default/templates/mail.html
+++ b/skins/default/templates/mail.html
@@ -13,6 +13,7 @@
 <div id="messagetoolbar">
 <roundcube:button command="compose" imageAct="/images/buttons/compose_act.png" imagePas="/images/buttons/compose_pas.png" width="32" height="32" title="writenewmessage" />
 <roundcube:button command="reply" imageAct="/images/buttons/reply_act.png" imagePas="/images/buttons/reply_pas.png" width="32" height="32" title="replytomessage" />
+<roundcube:button command="reply-all" imageAct="/images/buttons/replyall_act.png" imagePas="/images/buttons/replyall_pas.png" width="32" height="32" title="replytoallmessage" />
 <roundcube:button command="forward" imageAct="/images/buttons/forward_act.png" imagePas="/images/buttons/forward_pas.png" width="32" height="32" title="forwardmessage" />
 <roundcube:button command="delete" imageAct="/images/buttons/delete_act.png" imagePas="/images/buttons/delete_pas.png" width="32" height="32" title="deletemessage" />
 <roundcube:button command="print" imageAct="/images/buttons/print_act.png" imagePas="/images/buttons/print_pas.png" width="32" height="32" title="printmessage" />
diff --git a/skins/default/templates/message.html b/skins/default/templates/message.html
index 4a4702a..0ef9ef0 100644
--- a/skins/default/templates/message.html
+++ b/skins/default/templates/message.html
@@ -19,6 +19,7 @@
 <div id="messagetoolbar">
 <roundcube:button command="list" image="/images/buttons/back_act.png" width="32" height="32" title="backtolist" />
 <roundcube:button command="reply" imageAct="/images/buttons/reply_act.png" imagePas="/images/buttons/reply_pas.png" width="32" height="32" title="replytomessage" />
+<roundcube:button command="reply-all" imageAct="/images/buttons/replyall_act.png" imagePas="/images/buttons/replyall_pas.png" width="32" height="32" title="replytoallmessage" />
 <roundcube:button command="forward" imageAct="/images/buttons/forward_act.png" imagePas="/images/buttons/forward_pas.png" width="32" height="32" title="forwardmessage" />
 <roundcube:button command="delete" imageAct="/images/buttons/delete_act.png" imagePas="/images/buttons/delete_pas.png" width="32" height="32" title="deletemessage" />
 <roundcube:button command="print" imageAct="/images/buttons/print_act.png" imagePas="/images/buttons/print_pas.png" width="32" height="32" title="printmessage" />

--
Gitblit v1.9.1