From 3ee5a7200afc62d8eda2c0ce77743af4951147a3 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 09 Dec 2010 14:10:44 -0500
Subject: [PATCH] - Improved Mail-Reply-To and Mail-Followup-To headers handling

---
 CHANGELOG                                |    1 
 program/steps/mail/compose.inc           |   20 +++-------
 skins/default/mail.css                   |    3 -
 program/steps/mail/func.inc              |    8 +++-
 program/localization/en_US/labels.inc    |   11 +----
 program/localization/pl_PL/labels.inc    |   11 +----
 skins/default/functions.js               |    2 
 skins/default/templates/compose.html     |   18 ++------
 program/steps/mail/sendmail.inc          |   13 +++---
 program/js/app.js                        |    2 
 program/localization/en_GB/labels.inc    |    9 +---
 program/steps/settings/edit_identity.inc |    3 +
 12 files changed, 37 insertions(+), 64 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 85b65ef..c99e6eb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@
 - Add confirmation message on purge/expunge command response
 - Fix handling of untagged responses for AUTHENTICATE command (#1487450)
 - Add username and IP address to log message on unsuccessful login (#1487626)
+- Improved Mail-Followup-To and Mail-Reply-To headers handling
 
 RELEASE 0.5-BETA
 ----------------
diff --git a/program/js/app.js b/program/js/app.js
index e88e19f..90c18b6 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -2819,7 +2819,7 @@
       input_subject = $("input[name='_subject']"),
       input_message = $("[name='_message']").get(0),
       html_mode = $("input[name='_is_html']").val() == '1',
-      ac_fields = ['cc', 'bcc', 'replyto', 'mailreplyto', 'mailfollowupto'];
+      ac_fields = ['cc', 'bcc', 'replyto', 'followupto'];
 
     // init live search events
     this.init_address_input_events(input_to);
diff --git a/program/localization/en_GB/labels.inc b/program/localization/en_GB/labels.inc
index cd61ed6..7a36f00 100644
--- a/program/localization/en_GB/labels.inc
+++ b/program/localization/en_GB/labels.inc
@@ -38,16 +38,12 @@
 $labels['cc'] = 'Copy';
 $labels['bcc'] = 'Bcc';
 $labels['replyto'] = 'Reply-To';
-$labels['mailreplyto'] = 'Mail-Reply-To';
-$labels['mailfollowupto'] = 'Mail-Followup-To';
+$labels['followupto'] = 'Followup-To';
 $labels['date'] = 'Date';
 $labels['size'] = 'Size';
 $labels['priority'] = 'Priority';
 $labels['organization'] = 'Organisation';
 $labels['readstatus'] = 'Read status';
-$labels['reply-to'] = $labels['replyto'];
-$labels['mail-reply-to'] = $labels['mailreplyto'];
-$labels['mail-followup-to'] = $labels['mailfollowupto'];
 $labels['mailboxlist'] = 'Folders';
 $labels['messagesfromto'] = 'Messages $from to $to of $count';
 $labels['threadsfromto'] = 'Threads $from to $to of $count';
@@ -201,8 +197,7 @@
 $labels['addcc'] = 'Add Cc';
 $labels['addbcc'] = 'Add Bcc';
 $labels['addreplyto'] = 'Add Reply-To';
-$labels['addmailreplyto'] = 'Add Mail-Reply-To';
-$labels['addmailfollowupto'] = 'Add Mail-Followup-To';
+$labels['addfollowupto'] = 'Add Followup-To';
 $labels['mdnrequest'] = 'The sender of this message has asked to be notified when you read this message. Do you wish to notify the sender?';
 $labels['receiptread'] = 'Return Receipt (read)';
 $labels['yourmessage'] = 'This is a Return Receipt for your message';
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 6b759bb..22be28e 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -46,18 +46,12 @@
 $labels['cc']      = 'Copy';
 $labels['bcc']     = 'Bcc';
 $labels['replyto'] = 'Reply-To';
-$labels['mailreplyto'] = 'Mail-Reply-To';
-$labels['mailfollowupto'] = 'Mail-Followup-To';
+$labels['followupto'] = 'Followup-To';
 $labels['date']    = 'Date';
 $labels['size']    = 'Size';
 $labels['priority'] = 'Priority';
 $labels['organization'] = 'Organization';
 $labels['readstatus'] = 'Read status';
-
-// aliases
-$labels['reply-to'] = $labels['replyto'];
-$labels['mail-reply-to'] = $labels['mailreplyto'];
-$labels['mail-followup-to'] = $labels['mailfollowupto'];
 
 $labels['mailboxlist'] = 'Folders';
 $labels['messagesfromto'] = 'Messages $from to $to of $count';
@@ -241,8 +235,7 @@
 $labels['addcc'] = 'Add Cc';
 $labels['addbcc'] = 'Add Bcc';
 $labels['addreplyto'] = 'Add Reply-To';
-$labels['addmailreplyto'] = 'Add Mail-Reply-To';
-$labels['addmailfollowupto'] = 'Add Mail-Followup-To';
+$labels['addfollowupto'] = 'Add Followup-To';
 
 // mdn
 $labels['mdnrequest'] = 'The sender of this message has asked to be notified when you read this message. Do you wish to notify the sender?';
diff --git a/program/localization/pl_PL/labels.inc b/program/localization/pl_PL/labels.inc
index 8c52cdf..6cde046 100644
--- a/program/localization/pl_PL/labels.inc
+++ b/program/localization/pl_PL/labels.inc
@@ -42,13 +42,12 @@
 $labels['to'] = 'Odbiorca';
 $labels['cc'] = 'Kopia';
 $labels['bcc'] = 'Ukryta kopia';
-$labels['replyto'] = 'Odp. do';
+$labels['replyto'] = 'Odpowiedź do';
 $labels['date'] = 'Data';
 $labels['size'] = 'Rozmiar';
 $labels['readstatus'] = 'Przeczytano';
 $labels['priority'] = 'Priorytet';
 $labels['organization'] = 'Organizacja';
-$labels['reply-to'] = 'Odpowiedz do';
 $labels['mailboxlist'] = 'Foldery';
 $labels['messagesfromto'] = 'Wiadomości od $from do $to z $count';
 $labels['threadsfromto'] = 'Wątki od $from do $to z $count';
@@ -348,15 +347,11 @@
 $labels['folderactions'] = 'Działania na folderach...';
 $labels['contacts'] = 'Kontakty';
 $labels['messageoptions'] = 'Opcje wiadomości...';
-$labels['mailreplyto'] = 'Mail-Reply-To';
-$labels['mailfollowupto'] = 'Mail-Followup-To';
-$labels['mail-reply-to'] = 'Mail-Reply-To';
-$labels['mail-followup-to'] = 'Mail-Followup-To';
+$labels['followupto'] = 'Kontynuacja do';
 $labels['replyall'] = 'Odpowiedz wszystkim';
 $labels['replylist'] = 'Odpowiedz na listę';
 $labels['editidents'] = 'Edytuj tożsamości';
-$labels['addmailreplyto'] = 'Dodaj Mail-Reply-To';
-$labels['addmailfollowupto'] = 'Dodaj Mail-Followup-To';
+$labels['addfollowupto'] = 'Dodaj Followup-To';
 $labels['dsn'] = 'Status dostarczenia (DSN)';
 $labels['reqdsn'] = 'Zawsze żądaj statusu dostarczenia (DSN)';
 $labels['replysamefolder'] = 'Umieszczaj odpowiedzi w folderze wiadomości, na którą odpowiadam';
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 8358559..45b95c9 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -267,19 +267,11 @@
       $param = 'replyto';
       $header = 'reply-to';
 
-    case 'mailreplyto':
-    case 'mail-reply-to':
+    case 'followupto':
+    case 'followup-to':
       if (!$fname) {
-        $fname = '_mailreplyto';
-        $param = 'mailreplyto';
-        $header = 'mail-reply-to';
-      }
-
-    case 'mailfollowupto':
-    case 'mail-followup-to':
-      if (!$fname) {
-        $fname = '_mailfollowupto';
-        $param = 'mailfollowupto';
+        $fname = '_followupto';
+        $param = 'followupto';
         $header = 'mail-followup-to';
       }
 
@@ -354,10 +346,10 @@
       $fvalue = $MESSAGE->get_header('cc');
     else if ($header=='bcc' && !empty($MESSAGE->headers->bcc))
       $fvalue = $MESSAGE->get_header('bcc');
+    else if ($header=='reply-to' && !empty($MESSAGE->headers->others['mail-reply-to']))
+      $fvalue = $MESSAGE->get_header('mail-reply-to');
     else if ($header=='reply-to' && !empty($MESSAGE->headers->replyto))
       $fvalue = $MESSAGE->get_header('reply-to');
-    else if ($header=='mail-reply-to' && !empty($MESSAGE->headers->others['mail-reply-to']))
-      $fvalue = $MESSAGE->get_header('followup-to');
     else if ($header=='mail-followup-to' && !empty($MESSAGE->headers->others['mail-followup-to']))
       $fvalue = $MESSAGE->get_header('mail-followup-to');
 
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 9e485eb..750cf6f 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -927,10 +927,14 @@
     else
       $header_value = trim($IMAP->decode_header($value));
 
-    $output_headers[$hkey] = array('title' => rcube_label($hkey), 'value' => $header_value, 'raw' => $value);
+    $output_headers[$hkey] = array(
+        'title' => rcube_label(preg_replace('/(^mail-|-)/', '', $hkey)),
+        'value' => $header_value, 'raw' => $value
+    );
   }
 
-  $plugin = $RCMAIL->plugins->exec_hook('message_headers_output', array('output' => $output_headers, 'headers' => $MESSAGE->headers));
+  $plugin = $RCMAIL->plugins->exec_hook('message_headers_output',
+    array('output' => $output_headers, 'headers' => $MESSAGE->headers));
 
   // compose html table
   $table = new html_table(array('cols' => 2));
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index a796c7b..07f32b8 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -322,15 +322,16 @@
 if (!empty($identity_arr['organization']))
   $headers['Organization'] = $identity_arr['organization'];
 
-if (!empty($_POST['_replyto']))
-  $headers['Reply-To'] = rcmail_email_input_format(get_input_value('_replyto', RCUBE_INPUT_POST, TRUE, $message_charset));
+if (!empty($_POST['_replyto'])) {
+  $reply_to = rcmail_email_input_format(get_input_value('_replyto', RCUBE_INPUT_POST, TRUE, $message_charset));
+  $headers['Reply-To'] = $reply_to;
+  $headers['Mail-Reply-To'] = $reply_to;
+}
 else if (!empty($identity_arr['reply-to']))
   $headers['Reply-To'] = rcmail_email_input_format($identity_arr['reply-to'], false, true);
 
-if (!empty($_POST['_mailfollowupto']))
-  $headers['Mail-Followup-To'] = rcmail_email_input_format(get_input_value('_mailfollowupto', RCUBE_INPUT_POST, TRUE, $message_charset));
-if (!empty($_POST['_mailreplyto']))
-  $headers['Mail-Reply-To'] = rcmail_email_input_format(get_input_value('_mailreplyto', RCUBE_INPUT_POST, TRUE, $message_charset));
+if (!empty($_POST['_followupto']))
+  $headers['Mail-Followup-To'] = rcmail_email_input_format(get_input_value('_followupto', RCUBE_INPUT_POST, TRUE, $message_charset));
 
 if (!empty($_SESSION['compose']['reply_msgid']))
   $headers['In-Reply-To'] = $_SESSION['compose']['reply_msgid'];
diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc
index ef2be65..f458cbf 100644
--- a/program/steps/settings/edit_identity.inc
+++ b/program/steps/settings/edit_identity.inc
@@ -126,7 +126,8 @@
       foreach ($fieldset['content'] as $col => $colprop) {
         $colprop['id'] = 'rcmfd_'.$col;
 
-        $label = !empty($colprop['label']) ? $colprop['label'] : rcube_label($col);
+        $label = !empty($colprop['label']) ? $colprop['label'] :
+            rcube_label(str_replace('-', '', $col));
         $value = !empty($colprop['value']) ? $colprop['value'] :
             rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $colprop, $colprop['type']);
 
diff --git a/skins/default/functions.js b/skins/default/functions.js
index 3197c98..77cdeb8 100644
--- a/skins/default/functions.js
+++ b/skins/default/functions.js
@@ -353,7 +353,7 @@
 /* Message composing */
 init_compose_form: function()
 {
-  var f, field, fields = ['cc', 'bcc', 'replyto', 'mailreplyto', 'mailfollowupto'],
+  var f, field, fields = ['cc', 'bcc', 'replyto', 'followupto'],
     div = document.getElementById('compose-div'),
     headers_div = document.getElementById('compose-headers-div');
 
diff --git a/skins/default/mail.css b/skins/default/mail.css
index 2cd51e5..7bb308c 100644
--- a/skins/default/mail.css
+++ b/skins/default/mail.css
@@ -1337,8 +1337,7 @@
 #compose-cc,
 #compose-bcc,
 #compose-replyto,
-#compose-mailreplyto,
-#compose-mailfollowupto
+#compose-followupto
 {
   display: none;
 }
diff --git a/skins/default/templates/compose.html b/skins/default/templates/compose.html
index 99015ab..2dcf8b0 100644
--- a/skins/default/templates/compose.html
+++ b/skins/default/templates/compose.html
@@ -78,18 +78,12 @@
                 <label for="_replyto"><roundcube:label name="replyto" /></label>
             </td>
             <td class="editfield"><roundcube:object name="composeHeaders" part="replyto" form="form" id="_replyto" size="70" tabindex="5" /></td>
-        </tr><tr id="compose-mailreplyto">
+        </tr><tr id="compose-followupto">
             <td class="title top">
-                <a href="#mailreplyto" onclick="return rcmail_ui.hide_header_form('mailreplyto');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
-                <label for="_mailreplyto"><roundcube:label name="mailreplyto" /></label>
+                <a href="#followupto" onclick="return rcmail_ui.hide_header_form('followupto');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
+                <label for="_followupto"><roundcube:label name="followupto" /></label>
             </td>
-            <td class="editfield"><roundcube:object name="composeHeaders" part="mailreplyto" form="form" id="_mailreplyto" size="70" tabindex="6" /></td>
-        </tr><tr id="compose-mailfollowupto">
-            <td class="title top">
-                <a href="#mailfollowupto" onclick="return rcmail_ui.hide_header_form('mailfollowupto');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
-                <label for="_mailfollowupto"><roundcube:label name="mailfollowupto" /></label>
-            </td>
-            <td class="editfield"><roundcube:object name="composeHeaders" part="mailfollowupto" form="form" id="_mailfollowupto" size="70" tabindex="7" /></td>
+            <td class="editfield"><roundcube:object name="composeHeaders" part="followupto" form="form" id="_followupto" size="70" tabindex="7" /></td>
         </tr><tr>
             <td></td>
             <td class="formlinks">
@@ -99,9 +93,7 @@
                 <span class="separator">|</span>
                 <a href="#reply-to" onclick="return rcmail_ui.show_header_form('replyto')" id="replyto-link"><roundcube:label name="addreplyto" /></a>
                 <span class="separator">|</span>
-                <a href="#mailreply-to" onclick="return rcmail_ui.show_header_form('mailreplyto')" id="mailreplyto-link"><roundcube:label name="addmailreplyto" /></a>
-                <span class="separator">|</span>
-                <a href="#mailfollowup-to" onclick="return rcmail_ui.show_header_form('mailfollowupto')" id="mailfollowupto-link"><roundcube:label name="addmailfollowupto" /></a>
+                <a href="#followup-to" onclick="return rcmail_ui.show_header_form('followupto')" id="followupto-link"><roundcube:label name="addfollowupto" /></a>
             </td>
         </tr><tr>
             <td class="title"><label for="compose-subject"><roundcube:label name="subject" /></label></td>

--
Gitblit v1.9.1