From ea6ed1b79f6a250aaa4f0550646d87a0e4b3a3cc Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 5 Feb 2010 09:55:52 -0700 Subject: [PATCH] Allow switching to single recipient when auto replying to list --- horde/themes/screen.css | 2 +- imp/compose-dimp.php | 12 ++++++++++-- imp/js/compose-dimp.js | 23 ++++++++++++++++------- imp/lib/Ajax/Application.php | 21 ++++++++++++--------- imp/lib/Compose.php | 16 +++++++++++++++- imp/templates/chunks/compose.php | 3 ++- imp/themes/screen-dimp.css | 5 +++-- 7 files changed, 59 insertions(+), 23 deletions(-) diff --git a/horde/themes/screen.css b/horde/themes/screen.css index b276587bd..6f81951d8 100644 --- a/horde/themes/screen.css +++ b/horde/themes/screen.css @@ -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; diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index c369d776e..6c5fe2c5d 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -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']; diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index 0e9cf4b82..9f1182f2c 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -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; } diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index d09436128..e34ec3bd6 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -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) { diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 149d9d9cc..9222656de 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -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; + } + } diff --git a/imp/templates/chunks/compose.php b/imp/templates/chunks/compose.php index 27c12357c..6fe9dbbdc 100644 --- a/imp/templates/chunks/compose.php +++ b/imp/templates/chunks/compose.php @@ -125,7 +125,8 @@ $compose_disable = !IMP::canCompose(); diff --git a/imp/themes/screen-dimp.css b/imp/themes/screen-dimp.css index ed9d9f9ed..cfae6243d 100644 --- a/imp/themes/screen-dimp.css +++ b/imp/themes/screen-dimp.css @@ -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 { -- 2.11.0