Allow switching to single recipient when auto replying to list
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 5 Feb 2010 16:55:52 +0000 (09:55 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 5 Feb 2010 17:08:53 +0000 (10:08 -0700)
horde/themes/screen.css
imp/compose-dimp.php
imp/js/compose-dimp.js
imp/lib/Ajax/Application.php
imp/lib/Compose.php
imp/templates/chunks/compose.php
imp/themes/screen-dimp.css

index b276587..6f81951 100644 (file)
@@ -356,7 +356,7 @@ pre, code, .fixed, table.lineNumbered * {
     color: #000;
     background: #ffc;
     border: 1px solid #aaa;
-    padding: 1px 1px 1px 5px;
+    padding: 1px 3px;
 }
 .notices img, .notice img {
     margin-right: .5em;
index c369d77..6c5fe2c 100644 (file)
@@ -89,8 +89,16 @@ case 'reply_list':
     $header = $reply_msg['headers'];
     $header['replytype'] = 'reply';
 
-    if (($vars->type == 'reply_auto') && ($reply_msg['type'] == 'reply_all')) {
-        $fillform_opts['reply_auto_all'] = 1;
+    if ($vars->type == 'reply_auto') {
+        switch ($reply_msg['type']) {
+        case 'reply_all':
+            $fillform_opts['reply_auto'] = 'all';
+            break;
+
+        case 'reply_list':
+            $fillform_opts['reply_auto'] = 'list';
+            break;
+        }
     }
 
     $vars->type = $reply_msg['type'];
index 0e9cf4b..9f1182f 100644 (file)
@@ -459,7 +459,7 @@ var DimpCompose = {
         }
     },
 
-    // opts = focus, noupdate, reply_auto_all
+    // opts = focus, noupdate, reply_auto
     fillForm: function(msg, header, opts)
     {
         // On IE, this can get loaded before DOM:loaded. Check for an init
@@ -525,8 +525,14 @@ var DimpCompose = {
         Field.focus(opts.focus || 'to');
         this.resizeMsgArea();
 
-        if (opts.reply_auto_all) {
-            $('noticerow').show().down('.replyallnotice').show();
+        switch (opts.reply_auto) {
+        case 'all':
+            $('noticerow', 'replyallnotice').invoke('show');
+            break
+
+        case 'list':
+            $('noticerow', 'replylistnotice').invoke('show');
+            break;
         }
 
         if (DIMP.conf_compose.show_editor) {
@@ -539,12 +545,13 @@ var DimpCompose = {
         }
     },
 
-    replyAutoAllCallback: function(r)
+    swapToAddressCallback: function(r)
     {
         if (r.response.header) {
             $('to').setValue(r.response.header.to);
             this.resizeto.resizeNeeded();
         }
+        $('to_loading_img').hide();
     },
 
     focusEditor: function()
@@ -761,15 +768,17 @@ var DimpCompose = {
                 this.setSaveSentMail($F(elt));
                 break;
 
-            case 'replyallclick':
-                elt.up('LI').fade({
+            case 'replyallnotice':
+            case 'replylistnotice':
+                elt.fade({
                     afterFinish: function() {
                         elt.up('TR').hide();
                         this.resizeMsgArea();
                     }.bind(this),
                     duration: 0.4
                 });
-                DimpCore.doAction('GetReplyData', { headeronly: 1, imp_compose: $F('composeCache'), type: 'reply' }, { callback: this.replyAutoAllCallback.bind(this) });
+                $('to_loading_img').show();
+                DimpCore.doAction('GetReplyData', { headeronly: 1, imp_compose: $F('composeCache'), type: 'reply' }, { callback: this.swapToAddressCallback.bind(this) });
                 e.stop();
                 return;
             }
index d094361..e34ec3b 100644 (file)
@@ -1008,17 +1008,13 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
      */
     public function GetReplyData($vars)
     {
-
         try {
             $imp_compose = IMP_Compose::singleton($vars->imp_compose);
-            if ($imp_compose->getMetadata('reply_type')) {
-                $idx_string = $imp_compose->getMetadata('uid') . IMP::IDX_SEP . $imp_compose->getMetadata('mailbox');
-            } else {
+            if (!($imp_contents = $imp_compose->getContentsOb())) {
                 $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($vars->uid);
                 $i = each($indices);
-                $idx_string = reset($i['value']) . IMP::IDX_SEP . $i['key'];
+                $imp_contents = IMP_Contents::singleton(reset($i['value']) . IMP::IDX_SEP . $i['key']);
             }
-            $imp_contents = IMP_Contents::singleton($idx_string);
             $reply_msg = $imp_compose->replyMessage($vars->type, $imp_contents);
             $header = $reply_msg['headers'];
             $header['replytype'] = 'reply';
@@ -1030,9 +1026,16 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
                 $result->format = $reply_msg['format'];
                 $result->identity = $reply_msg['identity'];
                 $result->imp_compose = $imp_compose->getCacheId();
-                if (($vars->type == 'reply_auto') &&
-                    ($reply_msg['type'] == 'reply_all')) {
-                    $result->opts = array('reply_auto_all' => 1);
+                if ($vars->type == 'reply_auto') {
+                    switch ($reply_msg['type']) {
+                    case 'reply_all':
+                        $result->opts = array('reply_auto' => 'all');
+                        break;
+
+                    case 'reply_list':
+                        $result->opts = array('reply_auto' => 'list');
+                        break;
+                    }
                 }
             }
         } catch (Horde_Exception $e) {
index 149d9d9..9222656 100644 (file)
@@ -1285,7 +1285,7 @@ class IMP_Compose
         $match_identity = $this->_getMatchingIdentity($h);
         $reply_type = 'reply';
 
-        if (!isset($this->_metadata['reply_type'])) {
+        if (!$this->getMetadata('reply_type')) {
             $this->_metadata['mailbox'] = $contents->getMailbox();
             $this->_metadata['reply_type'] = 'reply';
             $this->_metadata['uid'] = $contents->getUid();
@@ -2713,4 +2713,18 @@ class IMP_Compose
 
         return array('sources' => $src, 'fields' => $fields);
     }
+
+    /**
+     * If this object contains sufficient metadata, return an IMP_Contents
+     * object reflecting that metadata.
+     *
+     * @return mixed  Either an IMP_Contents object or null.
+     */
+    public function getContentsOb()
+    {
+        return $this->getMetadata('reply_type')
+            ? IMP_Contents::singleton($this->getMetadata('uid') . IMP::IDX_SEP . $this->getMetadata('mailbox'))
+            : null;
+    }
+
 }
index 27c1235..6fe9dbb 100644 (file)
@@ -125,7 +125,8 @@ $compose_disable = !IMP::canCompose();
    <tr id="noticerow" style="display:none">
     <td colspan="2">
      <ul class="notices">
-      <li class="replyallnotice" style="display:none"><?php echo Horde::img('alerts/message.png', _("Message"), null, $GLOBALS['registry']->getImageDir('horde')) ?> <?php echo sprintf(_("You are currently replying to ALL recipients. To reply only to the original sender, click %s."), '<a href="#" id="replyallclick">' . _("HERE") . '</a>') ?></li>
+      <li id="replyallnotice" style="display:none"><?php echo _("You are currently replying to ALL recipients. Click here to reply to the original sender instead.") ?></li>
+      <li id="replylistnotice" style="display:none"><?php echo _("You are currently replying to the mailing list. Click here to reply to the original sender instead.") ?></li>
      </ul>
     </td>
    </tr>
index ed9d9f9..cfae624 100644 (file)
@@ -617,7 +617,7 @@ div.dimpActionsCompose, div.dimpActionsMsg {
 .msgwrite .dimpOptions div {
     padding-bottom: 0;
 }
-.msgwrite .dimpOptions label {
+.msgwrite .dimpOptions label, #replyallnotice, #replylistnotice {
     cursor: pointer;
 }
 .msgwrite tr {
@@ -633,7 +633,8 @@ div.dimpActionsCompose, div.dimpActionsMsg {
 }
 .msgwrite span.loadingImg {
     float: right;
-    padding: 0;
+    margin-left: 3px;
+    padding: 1px;
 }
 
 #composeMessageParent {