From: Michael M Slusarz Date: Mon, 30 Mar 2009 19:58:20 +0000 (-0600) Subject: Implement disable compose hook for dimp view X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=69fcb704aba86c3e7c6e6b50774d0d41cb02f1b8;p=horde.git Implement disable compose hook for dimp view --- diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index bc0ce3638..278acace7 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -27,6 +27,10 @@ function _removeAutoSaveDraft($index) require_once dirname(__FILE__) . '/lib/base.php'; +/* Determine if compose mode is disabled. */ +$compose_disable = !empty($conf['hooks']['disable_compose']) && + Horde::callHook('_imp_hook_disable_compose', array(), 'imp'); + /* The headers of the message. */ $header = array(); foreach (array('to', 'cc', 'bcc', 'subject', 'in_reply_to', 'references') as $v) { @@ -112,6 +116,10 @@ if (count($_POST)) { break; case 'send_message': + if ($compose_disable) { + break; + } + try { $from = $identity->getFromLine(null, Util::getFormData('from')); } catch (Horde_Exception $e) { diff --git a/imp/js/src/DimpBase.js b/imp/js/src/DimpBase.js index ad65d655a..158057c22 100644 --- a/imp/js/src/DimpBase.js +++ b/imp/js/src/DimpBase.js @@ -2346,15 +2346,20 @@ var DimpBase = { this._setFilterText(true); - /* Add popdown menus. */ - this._addMouseEvents({ id: 'button_reply', type: 'reply' }, true); - DM.disable('button_reply_img', true, true); + /* Add popdown menus. Check for disabled compose at the same time. */ this._addMouseEvents({ id: 'button_other', type: 'otheractions' }, true); DM.addSubMenu('ctx_message_reply', 'ctx_reply'); DM.addSubMenu('ctx_message_setflag', 'ctx_flag'); DM.addSubMenu('oa_setflag', 'ctx_flag'); DM.addSubMenu('ctx_draft_setflag', 'ctx_flag'); + if (DIMP.conf.disable_compose) { + $('button_reply', 'button_forward').compact().invoke('up', 'SPAN').concat($('button_compose', 'composelink', 'ctx_contacts_new')).compact().invoke('remove'); + } else { + this._addMouseEvents({ id: 'button_reply', type: 'reply' }, true); + DM.disable('button_reply_img', true, true); + } + new Drop('dropbase', this._folderDropConfig); if (DIMP.conf.toggle_pref) { diff --git a/imp/js/src/fullmessage-dimp.js b/imp/js/src/fullmessage-dimp.js index 2c91d107a..0692ad703 100644 --- a/imp/js/src/fullmessage-dimp.js +++ b/imp/js/src/fullmessage-dimp.js @@ -136,7 +136,11 @@ var DimpFullmessage = { { DimpCore.init(); - this.addPopdown('reply_link', 'replypopdown'); + if (DIMP.conf.disable_compose) { + tmp = $('reply_link', 'forward_link').compact().invoke('up', 'SPAN').concat([ $('ctx_contacts_new') ]).compact().invoke('remove'); + } else { + this.addPopdown('reply_link', 'replypopdown'); + } /* Set up address linking. */ [ 'from', 'to', 'cc', 'bcc', 'replyTo' ].each(function(a) { diff --git a/imp/lib/DIMP.php b/imp/lib/DIMP.php index 2199bccac..9eb66fa35 100644 --- a/imp/lib/DIMP.php +++ b/imp/lib/DIMP.php @@ -178,6 +178,8 @@ class DIMP ? array() : array_map(array('DIMP', '_appendedFolderPref'), $conf['server']['fixed_folders']), + 'disable_compose' => (!empty($conf['hooks']['disable_compose']) && Horde::callHook('_imp_hook_disable_compose', array(), 'imp')), + 'name' => $registry->get('name', 'dimp'), 'preview_pref' => (bool)$prefs->getValue('dimp_show_preview'), diff --git a/imp/message-dimp.php b/imp/message-dimp.php index 7d3b5b413..9394b7650 100644 --- a/imp/message-dimp.php +++ b/imp/message-dimp.php @@ -38,49 +38,60 @@ if (isset($show_msg_result['error'])) { exit; } -$compose_args = array( - 'folder' => $folder, - 'index' => $index, - 'messageCache' => '', - 'popup' => false, - 'qreply' => true, +$scripts = array( + array('ContextSensitive.js', 'imp', true), + array('fullmessage-dimp.js', 'imp', true), + array('imp.js', 'imp', true) ); -$compose_result = IMP_Views_Compose::showCompose($compose_args); -/* Init IMP_UI_Compose:: object. */ -$imp_ui = new IMP_UI_Compose(); - -/* Attach spellchecker & auto completer. */ -$imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc')); -$imp_ui->attachSpellChecker('dimp'); - -$compose_result['js'] = array_merge($compose_result['js'], array( +$js_out = array( 'DIMP.conf.msg_index = "' . $show_msg_result['index'] . '"', 'DIMP.conf.msg_folder = "' . $show_msg_result['folder'] . '"' -)); +); foreach (array('from', 'to', 'cc', 'bcc', 'replyTo') as $val) { if (!empty($show_msg_result[$val])) { - $compose_result['js'][] = 'DimpFullmessage.' . $val . ' = ' . Horde_Serialize::serialize($show_msg_result[$val], Horde_Serialize::JSON); + $js_out[] = 'DimpFullmessage.' . $val . ' = ' . Horde_Serialize::serialize($show_msg_result[$val], Horde_Serialize::JSON); } } -IMP::addInlineScript($compose_result['js']); -IMP::addInlineScript($compose_result['jsonload'], 'load'); -IMP::addInlineScript(array(DIMP::notify()), 'dom'); +/* Determine if compose mode is disabled. */ +$disable_compose = !empty($conf['hooks']['disable_compose']) && + !Horde::callHook('_imp_hook_disable_compose', array(), 'imp'); -$scripts = array( - array('ContextSensitive.js', 'imp', true), - array('fullmessage-dimp.js', 'imp', true), - array('compose-dimp.js', 'imp', true), - array('imp.js', 'imp', true) -); +if (!$disable_compose) { + $compose_args = array( + 'folder' => $folder, + 'index' => $index, + 'messageCache' => '', + 'popup' => false, + 'qreply' => true, + ); + $compose_result = IMP_Views_Compose::showCompose($compose_args); + + /* Init IMP_UI_Compose:: object. */ + $imp_ui = new IMP_UI_Compose(); + + /* Attach spellchecker & auto completer. */ + $imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc')); + $imp_ui->attachSpellChecker('dimp'); + + $js_out = array_merge($js_out, $compose_result['js']); + $scripts[] = array('compose-dimp.js', 'imp', true); + + IMP::addInlineScript($compose_result['jsonload'], 'load'); +} + +IMP::addInlineScript($js_out); +IMP::addInlineScript(array(DIMP::notify()), 'dom'); DIMP::header($show_msg_result['subject'], $scripts); echo "\n"; require IMP_TEMPLATES . '/chunks/message.php'; IMP::includeScriptFiles(); IMP::outputInlineScript(); -echo $compose_result['jsappend']; +if (!$disable_compose) { + echo $compose_result['jsappend']; +} $notification->notify(array('listeners' => array('javascript'))); echo "\n"; diff --git a/imp/templates/chunks/compose.php b/imp/templates/chunks/compose.php index 2d9f73965..d82f30401 100644 --- a/imp/templates/chunks/compose.php +++ b/imp/templates/chunks/compose.php @@ -15,6 +15,10 @@ $d_read = $GLOBALS['prefs']->getValue('disposition_request_read'); $save_attach = $GLOBALS['prefs']->getValue('save_attachments'); +/* Determine if compose mode is disabled. */ +$compose_disable = !empty($GLOBALS['conf']['hooks']['disable_compose']) && + Horde::callHook('_imp_hook_disable_compose', array(), 'imp'); + // Small utility function to simplify creating dimpactions buttons. // As of right now, we don't show text only links. function _createDAcompose($text, $image, $id) @@ -44,6 +48,7 @@ function _createDAcompose($text, $image, $id)
+ @@ -57,6 +62,7 @@ function _createDAcompose($text, $image, $id) + diff --git a/imp/templates/chunks/message.php b/imp/templates/chunks/message.php index b8c990226..54d5f38e0 100644 --- a/imp/templates/chunks/message.php +++ b/imp/templates/chunks/message.php @@ -107,6 +107,7 @@ function _createDAfmsg($text, $image, $id, $class = '', $show_text = true)
+