Implement disable compose hook for dimp view
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Mar 2009 19:58:20 +0000 (13:58 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Mar 2009 19:59:26 +0000 (13:59 -0600)
imp/compose-dimp.php
imp/js/src/DimpBase.js
imp/js/src/fullmessage-dimp.js
imp/lib/DIMP.php
imp/message-dimp.php
imp/templates/chunks/compose.php
imp/templates/chunks/message.php

index bc0ce36..278acac 100644 (file)
@@ -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) {
index ad65d65..158057c 100644 (file)
@@ -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) {
index 2c91d10..0692ad7 100644 (file)
@@ -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) {
index 2199bcc..9eb66fa 100644 (file)
@@ -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'),
index 7d3b5b4..9394b76 100644 (file)
@@ -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 "<body>\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 "</body>\n</html>";
index 2d9f739..d82f304 100644 (file)
 $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)
 <input type="hidden" id="composeCache" name="composeCache" value="<?php echo $composeCache ?>" />
 
 <div class="dimpActions dimpActionsCompose">
+<?php if (!$compose_disable): ?>
  <span>
   <?php _createDAcompose(_("Send"), 'Forward', 'send_button') ?>
  </span>
@@ -57,6 +62,7 @@ function _createDAcompose($text, $image, $id)
    <label><input type="checkbox" class="checkbox" id="save_sent_mail" name="save_sent_mail"<?php if ($identity->saveSentmail()) echo ' checked="checked"' ?> /> <?php echo _("Save in ") ?><span id="sent_mail_folder_label"><?php echo $sent_mail_folder ?></span></label>
   </span>
 <?php endif; ?>
+<?php endif; ?>
  <span>
   <?php _createDAcompose(_("Check Spelling"), 'Spellcheck', 'spellcheck') ?>
  </span>
index b8c9902..54d5f38 100644 (file)
@@ -107,6 +107,7 @@ function _createDAfmsg($text, $image, $id, $class = '', $show_text = true)
   </div>
  </div>
 
+<?php if (!$disable_compose): ?>
  <div id="qreply" style="display:none">
   <div class="header">
    <div class="headercloseimg"><?php echo IMP::img('close.png', 'X', array(), $horde_img) ?></div>
@@ -123,6 +124,7 @@ function _createDAfmsg($text, $image, $id, $class = '', $show_text = true)
  <a id="ctx_reply_reply_list"><span class="contextImg"></span><?php echo _("To List") ?></a>
 <?php endif; ?>
 </div>
+<?php endif; ?>
 
 <div class="context" id="ctx_contacts" style="display:none">
  <a id="ctx_contacts_new"><span class="contextImg"></span><?php echo _("New Message") ?></a>