Auto-determine correct recipient when clicking on Base reply button
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 19 Nov 2009 21:03:41 +0000 (14:03 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 19 Nov 2009 21:03:41 +0000 (14:03 -0700)
imp/compose-dimp.php
imp/compose.php
imp/js/DimpBase.js
imp/lib/Compose.php
imp/message.php

index 84fa93e..fe0fdd6 100644 (file)
@@ -210,7 +210,7 @@ $folder = Horde_Util::getFormData('folder');
 $show_editor = false;
 $title = _("New Message");
 
-if (in_array($type, array('reply', 'reply_all', 'reply_list', 'forward', 'resume'))) {
+if (in_array($type, array('reply', 'reply_all', 'reply_auto', 'reply_list', 'forward', 'resume'))) {
     if (!$uid || !$folder) {
         $type = 'new';
     }
@@ -227,11 +227,13 @@ if (in_array($type, array('reply', 'reply_all', 'reply_list', 'forward', 'resume
 switch ($type) {
 case 'reply':
 case 'reply_all':
+case 'reply_auto':
 case 'reply_list':
     $reply_msg = $imp_compose->replyMessage($type, $imp_contents, Horde_Util::getFormData('to'));
     $msg = $reply_msg['body'];
     $header = $reply_msg['headers'];
     $header['replytype'] = 'reply';
+    $type = $reply_msg['type'];
 
     if ($type == 'reply') {
         $title = _("Reply:");
index 61d8fdc..8570ca1 100644 (file)
@@ -93,6 +93,7 @@ if ($actionID) {
     case 'draft':
     case 'reply':
     case 'reply_all':
+    case 'reply_auto':
     case 'reply_list':
     case 'forward':
     case 'redirect_compose':
@@ -305,6 +306,7 @@ case 'redirect_expand_addr':
 
 case 'reply':
 case 'reply_all':
+case 'reply_auto':
 case 'reply_list':
     if (!($imp_contents = _getIMPContents($uid, $thismailbox))) {
         break;
@@ -314,6 +316,7 @@ case 'reply_list':
     $msg = $reply_msg['body'];
     $header = $reply_msg['headers'];
     $format = $reply_msg['format'];
+    $actionID = $reply_msg['type'];
 
     if (!is_null($rtemode)) {
         $rtemode = $rtemode || $format == 'html';
index 5c78ea7..997ebbf 100644 (file)
@@ -1765,7 +1765,7 @@ var DimpBase = {
 
             case 'button_forward':
             case 'button_reply':
-                this.composeMailbox(id == 'button_reply' ? 'reply' : 'forward');
+                this.composeMailbox(id == 'button_reply' ? 'reply_auto' : 'forward');
                 break;
 
             case 'button_ham':
index 32a7a34..4c9caa4 100644 (file)
@@ -1230,8 +1230,8 @@ class IMP_Compose
     /**
      * Determines the reply text and headers for a message.
      *
-     * @param string $actionID        The reply action (reply, reply_all,
-     *                                reply_list or *).
+     * @param string $type            The reply type (reply, reply_all,
+     *                                reply_auto, reply_list, or *).
      * @param IMP_Contents $contents  An IMP_Contents object.
      * @param string $to              The recipient of the reply. Overrides
      *                                the automatically determined value.
@@ -1246,7 +1246,7 @@ class IMP_Compose
      *              message's addresses.
      * </pre>
      */
-    public function replyMessage($actionID, $contents, $to = null)
+    public function replyMessage($type, $contents, $to = null)
     {
         global $prefs;
 
@@ -1260,6 +1260,7 @@ class IMP_Compose
 
         $h = $contents->getHeaderOb();
         $match_identity = $this->_getMatchingIdentity($h);
+        $reply_type = 'reply';
 
         $this->_metadata['mailbox'] = $contents->getMailbox();
         $this->_metadata['reply_type'] = 'reply';
@@ -1283,16 +1284,16 @@ class IMP_Compose
             ? 'Re: '
             : 'Re: ' . $GLOBALS['imp_imap']->ob()->utils->getBaseSubject($subject, array('keepblob' => true));
 
-        if (in_array($actionID, array('reply', '*'))) {
+        if (in_array($type, array('reply', 'reply_auto', '*'))) {
             ($header['to'] = $to) ||
             ($header['to'] = Horde_Mime_Address::addrArray2String($h->getOb('reply-to'))) ||
             ($header['to'] = Horde_Mime_Address::addrArray2String($h->getOb('from')));
-            if ($actionID == '*') {
+            if ($type == '*') {
                 $all_headers['reply'] = $header;
             }
         }
 
-        if (in_array($actionID, array('reply_all', '*'))) {
+        if (in_array($type, array('reply_all', '*'))) {
             /* Filter out our own address from the addresses we reply to. */
             $identity = Identity::singleton(array('imp', 'imp'));
             $all_addrs = array_keys($identity->getAllFromAddresses(true));
@@ -1338,32 +1339,37 @@ class IMP_Compose
 
             /* Build the Bcc: header. */
             $header['bcc'] = Horde_Mime_Address::addrArray2String($h->getOb('bcc') + $identity->getBccAddresses(), array('filter' => $all_addrs));
-            if ($actionID == '*') {
+            if ($type == '*') {
                 $all_headers['reply_all'] = $header;
             }
+
+            $reply_type = 'reply_all';
         }
 
-        if (in_array($actionID, array('reply_list', '*'))) {
+        if (in_array($type, array('reply_auto', 'reply_list', '*'))) {
             $imp_ui = new IMP_UI_Message();
             $list_info = $imp_ui->getListInformation($h);
             if ($list_info['exists']) {
                 $header['to'] = $list_info['reply_list'];
-                if ($actionID == '*') {
+                if ($type == '*') {
                     $all_headers['reply_list'] = $header;
                 }
             }
+
+            $reply_type = 'reply_list';
         }
 
-        if ($actionID == '*') {
+        if ($type == '*') {
             $header = $all_headers;
         }
 
         if (!$prefs->getValue('reply_quote')) {
             return array(
                 'body' => '',
-                'headers' => $header,
                 'format' => 'text',
-                'identity' => $match_identity
+                'headers' => $header,
+                'identity' => $match_identity,
+                'type' => $reply_type
             );
         }
 
@@ -1410,9 +1416,10 @@ class IMP_Compose
         return array(
             'body' => $msg . "\n",
             'encoding' => $msg_text['encoding'],
-            'headers' => $header,
             'format' => $msg_text['mode'],
-            'identity' => $match_identity
+            'headers' => $header,
+            'identity' => $match_identity,
+            'type' => $reply_type
         );
     }
 
index e520a3e..9e3de7f 100644 (file)
@@ -474,7 +474,7 @@ if (!$readonly) {
 $disable_compose = !IMP::canCompose();
 
 if (!$disable_compose) {
-    $a_template->set('reply', Horde::widget(IMP::composeLink(array(), array('actionID' => 'reply') + $compose_params), _("Reply"), 'widget hasmenu', '', '', _("_Reply"), true));
+    $a_template->set('reply', Horde::widget(IMP::composeLink(array(), array('actionID' => 'reply_auto') + $compose_params), _("Reply"), 'widget hasmenu', '', '', _("_Reply"), true));
     $a_template->set('reply_sender', Horde::widget(IMP::composeLink(array(), array('actionID' => 'reply') + $compose_params), _("To Sender"), 'widget', '', '', _("To Sender"), true));
 
     if ($list_info['reply_list']) {