Allow on-demand filter application (if filter backend supports) in DIMP.
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 12 Jun 2009 18:43:33 +0000 (12:43 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 12 Jun 2009 18:43:33 +0000 (12:43 -0600)
imp/ajax.php
imp/docs/CHANGES
imp/js/src/DimpBase.js
imp/lib/Views/ListMessages.php
imp/templates/index/index-dimp.inc
imp/templates/javascript_defs_dimp.php

index a68eb62..4d2cd50 100644 (file)
@@ -67,6 +67,7 @@ function _changed($mbox, $compare, $rw = null)
 function _getListMessages($mbox, $change)
 {
     $args = array(
+        'applyfilter' => Horde_Util::getPost('applyfilter'),
         'cached' => Horde_Util::getPost('cached'),
         'cacheid' => Horde_Util::getPost('cacheid'),
         'mbox' => $mbox,
index 552cfe8..9bb8565 100644 (file)
@@ -2,6 +2,7 @@
 v5.0-git
 --------
 
+[mms] Allow on-demand filter application (if filter backend supports) in DIMP.
 [mms] Add full IMAP subscription support to DIMP.
 [mms] Add message information to preview screen (DIMP).
 [mms] Add Alt + PGUP/PGDN shortcut to scroll through preview message (DIMP).
index bef77eb..a2c7f0b 100644 (file)
@@ -547,6 +547,17 @@ var DimpBase = {
                 if (this.folderswitch) {
                     this.folderswitch = false;
 
+                    tmp = $('applyfilterlink');
+                    if (tmp) {
+                        if (this.isSearch() ||
+                            (!DIMP.conf.filter_any &&
+                             this.folder.toUpperCase() != 'INBOX')) {
+                            tmp.hide();
+                        } else {
+                            tmp.show();
+                        }
+                    }
+
                     if (this.folder == DIMP.conf.spam_mbox) {
                         if (!DIMP.conf.spam_spammbox && $('button_spam')) {
                             [ $('button_spam').up(), $('ctx_message_spam') ].invoke('hide');
@@ -1555,6 +1566,13 @@ var DimpBase = {
                 e.stop();
                 return;
 
+            case 'applyfilterlink':
+                if (this.viewport) {
+                    this.viewport.reload({ applyfilter: 1 });
+                }
+                e.stop();
+                return;
+
             case 'appportal':
             case 'appoptions':
                 this.go(id.substring(3));
index 5254384..beb363d 100644 (file)
@@ -15,7 +15,7 @@ class IMP_Views_ListMessages
     /**
      * Returns a list of messages for use with ViewPort.
      *
-     * @var array $args  TODO
+     * @var array $args  TODO (applyfilter)
      *
      * @return array  TODO
      */
@@ -45,8 +45,9 @@ class IMP_Views_ListMessages
 
         /* Run filters now. */
         if (!empty($_SESSION['imp']['filteravail']) &&
-            ($mbox == 'INBOX') &&
-            $GLOBALS['prefs']->getValue('filter_on_display')) {
+            !empty($args['applyfilter']) ||
+            (($mbox == 'INBOX') &&
+             $GLOBALS['prefs']->getValue('filter_on_display'))) {
             $imp_filter = new IMP_Filter();
             $imp_filter->filter($mbox);
         }
index a50a7ec..946ab71 100644 (file)
@@ -64,6 +64,9 @@ function _simpleButton($id, $text, $image, $imagedir = null)
     <?php echo _simpleButton('fetchmaillink', _("_Fetch Mail"), 'fetchmail.png') ?>
 <?php endif; ?>
     <?php echo _simpleButton('alertsloglink', _("Alerts _Log"), 'info_icon.png', $hordeimg) ?>
+<?php if (!empty($_SESSION['imp']['filteravail'])): ?>
+    <?php echo _simpleButton('applyfilterlink', _("Apply Filter"), 'filters.png') ?>
+<?php endif; ?>
    </ul>
    <div class="sepfull" style="width:<?php echo $sidebar_width ?>"></div>
    <ul id="serviceActions">
index 22e7220..1fa5356 100644 (file)
@@ -61,6 +61,7 @@ $code['conf'] = array_filter(array(
     'buffer_pages' => intval($GLOBALS['conf']['dimp']['viewport']['buffer_pages']),
     'debug' => intval(!empty($GLOBALS['conf']['dimp']['js']['debug'])),
     'disable_compose' => intval(!empty($GLOBALS['conf']['hooks']['disable_compose']) && Horde::callHook('_imp_hook_disable_compose', array(), 'imp')),
+    'filter_any' => intval($GLOBALS['prefs']->getValue('filter_any_mailbox')),
     'fixed_folders' => empty($GLOBALS['conf']['server']['fixed_folders'])
         ? array()
         : array_map(array('DIMP', '_appendedFolderPref'), $GLOBALS['conf']['server']['fixed_folders']),