From: Michael M Slusarz Date: Fri, 5 Feb 2010 18:31:41 +0000 (-0700) Subject: Add ability to swap between forward options if using auto forward X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7eba9311ccd488faabe102efee17cca2be7f4f72;p=horde.git Add ability to swap between forward options if using auto forward --- diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 6c5fe2c5d..ae8a325d2 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -88,19 +88,9 @@ case 'reply_list': $msg = $reply_msg['body']; $header = $reply_msg['headers']; $header['replytype'] = 'reply'; - 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; - } + $fillform_opts['auto'] = $reply_msg['type']; } - $vars->type = $reply_msg['type']; if ($vars->type == 'reply') { @@ -133,6 +123,9 @@ case 'forward_both': if ($fwd_msg['format'] == 'html') { $show_editor = true; } + if ($vars->type == 'forward_auto') { + $fillform_opts['auto'] = $fwd_msg['type']; + } $vars->type = 'forward'; if (!$prefs->isLocked('default_identity') && diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 386dac6ce..c8a009bc4 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,8 @@ v5.0-git -------- +[mms] Add chance to switch between forward options on compose page when using + auto-forward (DIMP). [mms] Add chance to switch reply type to single recipient on compose page when using auto-reply (DIMP). [mms] Fix printing multipage HTML messages in Mozilla browsers (Bug #8708). diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index bd57eff59..497e32892 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -306,7 +306,7 @@ var DimpCompose = { case 'AddAttachment': this.uploading = false; if (d.success) { - this.addAttach(d.info.number, d.info.name, d.info.type, d.info.size); + this.addAttach(d.atc.num, d.atc.name, d.atc.type, d.atc.size); } else { this.setDisabled(false); } @@ -459,7 +459,7 @@ var DimpCompose = { } }, - // opts = focus, noupdate, reply_auto + // opts = auto, focus, fwd_list, noupdate fillForm: function(msg, header, opts) { // On IE, this can get loaded before DOM:loaded. Check for an init @@ -470,15 +470,14 @@ var DimpCompose = { } var bcc_add, - identity = this.getIdentity($F('last_identity')), - msgval = $('composeMessage'); + identity = this.getIdentity($F('last_identity')); opts = opts || {}; // Set auto-save-drafts now if not already active. if (DIMP.conf_compose.auto_save_interval_val && !this.auto_save_interval) { this.auto_save_interval = new PeriodicalExecuter(function() { - var curr_hash = MD5.hash($('to', 'cc', 'bcc', 'subject').invoke('getValue').join('\0') + (this.editor_on ? this.rte.getData() : $F(msgval))); + var curr_hash = MD5.hash($('to', 'cc', 'bcc', 'subject').invoke('getValue').join('\0') + (this.editor_on ? this.rte.getData() : $F('composeMessage'))); if (this.last_msg && curr_hash != this.last_msg) { this.uniqueSubmit('AutoSaveDraft'); } @@ -488,12 +487,7 @@ var DimpCompose = { this.auto_save_interval.execute(); } - if (this.editor_on) { - this.rte.setData(msg); - } else { - msgval.setValue(msg); - this.setCursorPosition(msgval); - } + this.setBodyText(msg, true); $('to').setValue(header.to); this.resizeto.resizeNeeded(); @@ -522,15 +516,25 @@ var DimpCompose = { } $('subject').setValue(header.subject); + this.processFwdList(opts.fwd_list); + Field.focus(opts.focus || 'to'); this.resizeMsgArea(); - switch (opts.reply_auto) { - case 'all': + switch (opts.auto) { + case 'forward_attach': + $('noticerow', 'fwdattachnotice').invoke('show'); + break + + case 'forward_body': + $('noticerow', 'fwdbodynotice').invoke('show'); + break + + case 'reply_all': $('noticerow', 'replyallnotice').invoke('show'); break - case 'list': + case 'reply_list': $('noticerow', 'replylistnotice').invoke('show'); break; } @@ -545,6 +549,28 @@ var DimpCompose = { } }, + setBodyText: function(msg) + { + var msgval; + + if (this.editor_on) { + this.rte.setData(msg); + } else { + msgval = $('composeMessage'); + msgval.setValue(msg); + this.setCursorPosition(msgval); + } + }, + + processFwdList: function(f) + { + if (f && f.size()) { + f.each(function(ptr) { + this.addAttach(ptr.num, ptr.name, ptr.type, ptr.size); + }, this); + } + }, + swapToAddressCallback: function(r) { if (r.response.header) { @@ -554,6 +580,21 @@ var DimpCompose = { $('to_loading_img').hide(); }, + forwardAddCallback: function(r) + { + if (r.response.type) { + switch (r.response.type) { + case 'forward_attach': + this.processFwdList(r.response.opts.fwd_list); + break; + + case 'forward_body': + this.setBodyText(r.response.body); + break; + } + } + }, + focusEditor: function() { try { @@ -770,6 +811,8 @@ var DimpCompose = { case 'replyallnotice': case 'replylistnotice': + case 'fwdattachnotice': + case 'fwdbodynotice': elt.fade({ afterFinish: function() { elt.up('TR').hide(); @@ -777,8 +820,12 @@ var DimpCompose = { }.bind(this), duration: 0.4 }); - $('to_loading_img').show(); - DimpCore.doAction('GetReplyData', { headeronly: 1, imp_compose: $F('composeCache'), type: 'reply' }, { callback: this.swapToAddressCallback.bind(this) }); + if (id.startsWith('reply')) { + $('to_loading_img').show(); + DimpCore.doAction('GetReplyData', { headeronly: 1, imp_compose: $F('composeCache'), type: 'reply' }, { callback: this.swapToAddressCallback.bind(this) }); + } else { + DimpCore.doAction('GetForwardData', { dataonly: 1, imp_compose: $F('composeCache'), type: (id == 'fwdattachnotice' ? 'forward_body' : 'forward_attach') }, { callback: this.forwardAddCallback.bind(this) }); + } e.stop(); return; } diff --git a/imp/js/fullmessage-dimp.js b/imp/js/fullmessage-dimp.js index 63b1614d4..a230f6a08 100644 --- a/imp/js/fullmessage-dimp.js +++ b/imp/js/fullmessage-dimp.js @@ -54,12 +54,6 @@ var DimpFullmessage = { DimpCompose.fillForm((i.id[2]) ? ("\n" + i.sig + r.body) : (r.body + "\n" + i.sig), r.header, r.opts); - if (r.fwd_list && r.fwd_list.length) { - r.fwd_list.each(function(ptr) { - DimpCompose.addAttach(ptr.number, ptr.name, ptr.type, ptr.size); - }); - } - if (editor_on) { DimpCompose.toggleHtmlEditor(true); } diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index e34ec3bd6..a4a24ebb9 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -929,6 +929,8 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base * _checkUidvalidity(). Additional variables * used: *
+     * 'dataonly' - (boolean) Only return data information (DEFAULT:
+     *              false).
      * 'imp_compose' - (string) The IMP_Compose cache identifier.
      * 'type' - (string) See IMP_Compose::forwardMessage().
      * 'uid' - (string) Indices of the messages to forward (IMAP sequence
@@ -944,33 +946,40 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
      * 'header' - (array) The headers of the message.
      * 'identity' - (integer) The identity ID to use for this message.
      * 'imp_compose'- (string) The IMP_Compose cache identifier.
+     * 'opts' - (array) Additional options needed for DimpCompose.fillForm().
+     * 'type' - (string) The input 'type' value.
      * 'ViewPort' - (object) See _viewPortData().
      * 
*/ public function GetForwardData($vars) { - $header = array(); - $msg = $header = null; - $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($vars->uid); - - $i = each($indices); - try { - $imp_contents = IMP_Contents::singleton(reset($i['value']) . IMP::IDX_SEP . $i['key']); $imp_compose = IMP_Compose::singleton($vars->imp_compose); + if (!($imp_contents = $imp_compose->getContentsOb())) { + $indices = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($vars->uid); + $i = each($indices); + $imp_contents = IMP_Contents::singleton(reset($i['value']) . IMP::IDX_SEP . $i['key']); + } + $fwd_msg = $imp_compose->forwardMessage($vars->type, $imp_contents); - $header = $fwd_msg['headers']; - $header['replytype'] = 'forward'; - $result = new stdClass; /* Can't open session read-only since we need to store the message * cache id. */ - $result->imp_compose = $imp_compose->getCacheId(); - $result->fwd_list = IMP_Dimp::getAttachmentInfo($imp_compose); + $result = new stdClass; + $result->opts = new stdClass; + $result->opts->fwd_list = IMP_Dimp::getAttachmentInfo($imp_compose); $result->body = $fwd_msg['body']; - $result->header = $header; - $result->format = $fwd_msg['format']; - $result->identity = $fwd_msg['identity']; + $result->type = $vars->type; + if (!$vars->dataonly) { + $result->format = $fwd_msg['format']; + $fwd_msg['headers']['replytype'] = 'forward'; + $result->header = $fwd_msg['headers']; + $result->identity = $fwd_msg['identity']; + $result->imp_compose = $imp_compose->getCacheId(); + if ($vars->type == 'forward_auto') { + $result->opts->auto = $fwd_msg['type']; + } + } } catch (Horde_Exception $e) { $GLOBALS['notification']->push($e, 'horde.error'); $result = $this->_checkUidvalidity($vars); @@ -1015,27 +1024,21 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base $i = each($indices); $imp_contents = IMP_Contents::singleton(reset($i['value']) . IMP::IDX_SEP . $i['key']); } + $reply_msg = $imp_compose->replyMessage($vars->type, $imp_contents); - $header = $reply_msg['headers']; - $header['replytype'] = 'reply'; + $reply_msg['headers']['replytype'] = 'reply'; + /* Can't open session read-only since we need to store the message + * cache id. */ $result = new stdClass; - $result->header = $header; + $result->header = $reply_msg['headers']; if (!$vars->headeronly) { $result->body = $reply_msg['body']; $result->format = $reply_msg['format']; $result->identity = $reply_msg['identity']; $result->imp_compose = $imp_compose->getCacheId(); 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; - } + $result->opts = array('auto' => $reply_msg['type']); } } } catch (Horde_Exception $e) { @@ -1397,7 +1400,9 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base * * @return object An object with the following entries: *
+     * 'atc' - TODO
      * 'error' - (string) An error message.
+     * 'imp_compose' - TODO
      * 'success' - (integer) 1 on success, 0 on failure.
      * 
*/ @@ -1411,9 +1416,8 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base if ($_SESSION['imp']['file_upload'] && $imp_compose->addFilesFromUpload('file_')) { - $info = IMP_Dimp::getAttachmentInfo($imp_compose); + $result->atc = end(IMP_Dimp::getAttachmentInfo($imp_compose)); $result->success = 1; - $result->info = end($info); $result->imp_compose = $imp_compose->getCacheId(); } diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index e42976b45..dfe8809ba 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -1506,10 +1506,12 @@ class IMP_Compose *
      * 'body'     - The text of the body part
      * 'encoding' - The guessed charset to use for the reply
-     * 'headers'  - The headers of the message to use for the reply
      * 'format'   - The format of the body message
+     * 'headers'  - The headers of the message to use for the reply
      * 'identity' - The identity to use for the reply based on the original
      *              message's addresses.
+     * 'type'     - The forward type used (either 'forward_attach',
+     *              'forward_body', or 'forward_both').
      * 
*/ public function forwardMessage($type, $contents, $attach = true) @@ -1589,7 +1591,8 @@ class IMP_Compose 'encoding' => isset($msg_text) ? $msg_text['encoding'] : Horde_Nls::getCharset(), 'format' => $format, 'headers' => $header, - 'identity' => $this->_getMatchingIdentity($h) + 'identity' => $this->_getMatchingIdentity($h), + 'type' => $type ); } diff --git a/imp/lib/Dimp.php b/imp/lib/Dimp.php index bd79708de..0e975569b 100644 --- a/imp/lib/Dimp.php +++ b/imp/lib/Dimp.php @@ -104,7 +104,7 @@ class IMP_Dimp * * @return array An array of arrays with the following keys: *
-     * 'number' - The current attachment number
+     * 'num' - The current attachment number
      * 'name' - The HTML encoded attachment name
      * 'type' - The MIME type of the attachment
      * 'size' - The size of the attachment in KB (string)
@@ -119,8 +119,8 @@ class IMP_Dimp
                 $mime = $data['part'];
 
                 $fwd_list[] = array(
-                    'number' => $atc_num,
                     'name' => htmlspecialchars($mime->getName(true)),
+                    'num' => $atc_num,
                     'type' => $mime->getType(),
                     'size' => $mime->getSize()
                 );
diff --git a/imp/templates/chunks/compose.php b/imp/templates/chunks/compose.php
index 6fe9dbbdc..8b8563099 100644
--- a/imp/templates/chunks/compose.php
+++ b/imp/templates/chunks/compose.php
@@ -127,6 +127,8 @@ $compose_disable = !IMP::canCompose();
      
     
    
diff --git a/imp/themes/ie6_or_less-dimp.css b/imp/themes/ie6_or_less-dimp.css
index 81294c68a..c1d062390 100644
--- a/imp/themes/ie6_or_less-dimp.css
+++ b/imp/themes/ie6_or_less-dimp.css
@@ -54,7 +54,7 @@ div.vpRow {
 }
 
 /* Fixes broken inline-block. */
-div.msgStatus div, #msgHeadersContent .subject span, span.iconImg, span.contextImg, span.spellcheckPopdownImg, span.popdownImg, #qsearch_icon, #qsearch_close, #upload_wait {
+div.msgStatus div, #msgHeadersContent .subject span, span.iconImg, span.contextImg, span.spellcheckPopdownImg, span.popdownImg, #qsearch_icon, #qsearch_close, #upload_wait, #noticerow .notices li {
     zoom: 1;
     *display: inline;
 }
diff --git a/imp/themes/ie7-dimp.css b/imp/themes/ie7-dimp.css
index c98fbbe22..2ef2a70b5 100644
--- a/imp/themes/ie7-dimp.css
+++ b/imp/themes/ie7-dimp.css
@@ -35,7 +35,7 @@
 }
 
 /* Fixes broken inline-block. */
-div.msgStatus div, #msgHeadersContent .subject span, span.iconImg, span.contextImg, span.spellcheckPopdownImg, span.popdownImg, #qsearch_icon, #qsearch_close, #upload_wait {
+div.msgStatus div, #msgHeadersContent .subject span, span.iconImg, span.contextImg, span.spellcheckPopdownImg, span.popdownImg, #qsearch_icon, #qsearch_close, #upload_wait, #noticerow .notices li {
     zoom: 1;
     *display: inline;
 }
diff --git a/imp/themes/screen-dimp.css b/imp/themes/screen-dimp.css
index cfae6243d..b38254167 100644
--- a/imp/themes/screen-dimp.css
+++ b/imp/themes/screen-dimp.css
@@ -637,6 +637,11 @@ div.dimpActionsCompose, div.dimpActionsMsg {
     padding: 1px;
 }
 
+#noticerow .notices li {
+    display: -moz-inline-stack;
+    display: inline-block;
+}
+
 #composeMessageParent {
     background: #fff url("graphics/backhead_shadow.png") top repeat-x;
     border-left: 1px silver solid;