From: Michael M Slusarz Date: Thu, 28 Oct 2010 22:51:31 +0000 (-0600) Subject: Bug #9334: Rework Cc/Bcc display in DIMP X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=008e81af5b4fe0e2ee95a63f3a6c1cca9da03b2a;p=horde.git Bug #9334: Rework Cc/Bcc display in DIMP ONLY show Cc/Bcc fields in dimp if compose_[b]cc pref is set. Locked value is irrelevant. This matches behavior in IMP. Improved location of Show Cc/Bcc button in dimp. --- diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 85770cfed..0c0cd0a84 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -200,7 +200,13 @@ case 'new': if ($vars->type == 'redirect') { $imp_ui->attachAutoCompleter(array('redirect_to')); } else { - $imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc', 'redirect_to')); + $acomplete = array('to', 'redirect_to'); + foreach (array('cc', 'bcc') as $val) { + if ($prefs->getValue('compose_' . $val)) { + $acomplete[] = $val; + } + } + $imp_ui->attachAutoCompleter($acomplete); $imp_ui->attachSpellChecker(); $sig = $identity->getSignature($show_editor ? 'html' : 'text'); if ($get_sig && !empty($sig)) { diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index edd404e5f..59dc8fc2f 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -68,8 +68,8 @@ var DimpCompose = { } $('composeCache').clear(); - $('qreply', 'sendcc', 'sendbcc').invoke('hide'); - [ $('msgData'), $('togglecc'), $('togglebcc') ].invoke('show'); + $('qreply', 'sendcc', 'sendbcc').compact().invoke('hide'); + $('msgData', 'togglecc', 'togglebcc').compact().invoke('show'); if (IMP_Compose_Base.editor_on) { this.toggleHtmlEditor(); } @@ -86,7 +86,9 @@ var DimpCompose = { var identity = IMP_Compose_Base.getIdentity($F('identity')); this.setPopdownLabel('sm', identity.id.smf_name, identity.id.smf_display); - $('bcc').setValue(identity.id.bcc); + if (DIMP.conf_compose.bcc) { + $('bcc').setValue(identity.id.bcc); + } this.setSaveSentMail(identity.id.smf_save); IMP_Compose_Base.replaceSignature($F('identity')); @@ -523,26 +525,26 @@ var DimpCompose = { opts = opts || {}; $('to').setValue(header.to); - if (header.cc) { + if (DIMP.conf_compose.cc && header.cc) { $('cc').setValue(header.cc); - } - if (DIMP.conf_compose.cc || header.cc) { - this.toggleCC('cc', true); + this.toggleCC('cc'); } this.setPopdownLabel('sm', identity.id.smf_name, identity.id.smf_display); this.setSaveSentMail(identity.id.smf_save); - if (header.bcc) { - $('bcc').setValue(header.bcc); - } - if (identity.id.bcc) { - bcc_add = $F('bcc'); - if (bcc_add) { - bcc_add += ', '; + if (DIMP.conf_compose.bcc) { + if (header.bcc) { + $('bcc').setValue(header.bcc); + } + if (identity.id.bcc) { + bcc_add = $F('bcc'); + if (bcc_add) { + bcc_add += ', '; + } + $('bcc').setValue(bcc_add + identity.id.bcc); + } + if ($F('bcc')) { + this.toggleCC('bcc'); } - $('bcc').setValue(bcc_add + identity.id.bcc); - } - if (DIMP.conf_compose.bcc || header.bcc) { - this.toggleCC('bcc', true); } $('subject').setValue(header.subject); @@ -600,7 +602,7 @@ var DimpCompose = { !this.auto_save_interval) { this.auto_save_interval = new PeriodicalExecuter(function() { if ($('compose').visible()) { - var hdrs = MD5.hash($('to', 'cc', 'bcc', 'subject').invoke('getValue').join('\0')), msg; + var hdrs = MD5.hash($('to', 'cc', 'bcc', 'subject').compact().invoke('getValue').join('\0')), msg; if (this.md5_hdrs) { msg = this.msgHash(); if (this.md5_hdrs != hdrs || this.md5_msg != msg) { @@ -831,20 +833,18 @@ var DimpCompose = { DimpCore.doActionComplete({ responseJSON: doc.body.innerHTML.evalJSON(true) }, this.uniqueSubmitCallback.bind(this)); }, - toggleCC: function(type, immediate) + toggleCC: function(type) { - var t = $('toggle' + type); + var t; $('send' + type).show(); - if (immediate) { - t.hide(); - this.resizeMsgArea(); + t = $('toggle' + type); + if (t.siblings().size()) { + t.remove(); } else { - t.fade({ - afterFinish: this.resizeMsgArea.bind(this), - duration: 0.4 - }); + t.up('TR').remove(); } + this.resizeMsgArea(); }, /* Open the addressbook window. */ @@ -1069,12 +1069,16 @@ var DimpCompose = { // Automatically resize compose address fields. new TextareaResize('to'); - new TextareaResize('cc'); - new TextareaResize('bcc'); + if (DIMP.conf_compose.cc) { + new TextareaResize('cc'); + } + if (DIMP.conf_compose.bcc) { + new TextareaResize('bcc'); + } /* Add addressbook link formatting. */ if (DIMP.conf_compose.URI_ABOOK) { - $('sendto', 'sendcc', 'sendbcc', 'redirect_sendto').each(function(a) { + $('sendto', 'sendcc', 'sendbcc', 'redirect_sendto').compact().each(function(a) { a.down('TD.label SPAN').addClassName('composeAddrbook'); }); } diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index b3a913203..cbba8a119 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -1797,12 +1797,10 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application $imp_ui = $injector->getInstance('IMP_Ui_Compose'); $headers['to'] = $imp_ui->getAddressList($this->_vars->to); - if ($prefs->getValue('compose_cc') || - !$prefs->isLocked('compose_cc')) { + if ($prefs->getValue('compose_cc')) { $headers['cc'] = $imp_ui->getAddressList($this->_vars->cc); } - if ($prefs->getValue('compose_bcc') || - !$prefs->isLocked('compose_bcc')) { + if ($prefs->getValue('compose_bcc')) { $headers['bcc'] = $imp_ui->getAddressList($this->_vars->bcc); } $headers['subject'] = $this->_vars->subject; diff --git a/imp/lib/Views/Compose.php b/imp/lib/Views/Compose.php index 098c4d0f5..fb8b1ca6f 100644 --- a/imp/lib/Views/Compose.php +++ b/imp/lib/Views/Compose.php @@ -173,6 +173,9 @@ class IMP_Views_Compose ), true)); } + $t->set('bcc', $prefs->getValue('compose_bcc')); + $t->set('cc', $prefs->getValue('compose_cc')); + $t->set('bcc_or_cc', $t->get('bcc') || $t->get('cc')); $t->set('compose_enable', IMP::canCompose()); $t->set('forminput', Horde_Util::formInput()); $t->set('redirect_button', IMP_Dimp::actionButton(array( @@ -180,6 +183,7 @@ class IMP_Views_Compose 'id' => 'send_button_redirect', 'title' => _("Redirect") ))); + $result['html'] = $t->fetch(IMP_TEMPLATES . '/dimp/compose/compose.html'); return $result; diff --git a/imp/message-dimp.php b/imp/message-dimp.php index 1c32a13d0..e9a0fea1b 100644 --- a/imp/message-dimp.php +++ b/imp/message-dimp.php @@ -84,7 +84,13 @@ if (!$disable_compose) { /* Attach spellchecker & auto completer. */ $imp_ui = new IMP_Ui_Compose(); - $imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc', 'redirect_to')); + $acomplete = array('to', 'redirect_to'); + foreach (array('cc', 'bcc') as $val) { + if ($prefs->getValue('compose_' . $val)) { + $acomplete[] = $val; + } + } + $imp_ui->attachAutoCompleter($acomplete); $imp_ui->attachSpellChecker(); $js_out = array_merge($js_out, $compose_result['js']); diff --git a/imp/templates/dimp/compose/compose.html b/imp/templates/dimp/compose/compose.html index e07a2920a..e58e89cb5 100644 --- a/imp/templates/dimp/compose/compose.html +++ b/imp/templates/dimp/compose/compose.html @@ -22,16 +22,6 @@
-
- -
-
- -