filter checking on inbox refresh

Liam Hoekenga liamr@umich.edu
Fri, 9 Nov 2001 18:28:36 -0500 (EST)


hey guys -

seemed to me it might be nice if there were a preference you could set
such that if you'd written personal filter rules, that you could have them
automatically applied everytime your INBOX was refreshed (either by the
"refresh" icon in the mailbox header, or if you've set the "New Mail"
preference to check your inbox periodically).  The new preference is
called "filter_on_refresh" and it's operation is based on the code that
supports "filter_on_login".

This patch will work for IMP 2.3.7 (IMP 3.0RC1?).  Attached is what I've
come up with.

Liam
------------------------------------------------------------------------------

diff -p -N -U 4 -r imp/config/prefs.php imp-UM/config/prefs.php
--- imp/config/prefs.php.dist	Fri Nov  9 18:13:51 2001
+++ imp-UM/config/prefs.php.dist	Fri Nov  9 13:07:36 2001
@@ -32,9 +32,9 @@ $prefGroups['timezone'] = array(
 $prefGroups['filters'] = array(
     'column' => _("Mail Management"),
     'label' => _("Filters"),
     'desc' => _("Create filtering rules to organize your incoming mail, sort it into folders, and delete spam."),
-    'members' => array('filters_link', 'filter_on_login')
+    'members' => array('filters_link', 'filter_on_login', 'filter_on_refresh')
 );

 $prefGroups['viewing'] = array(
     'column' => _("Mail Management"),
@@ -529,7 +529,16 @@ $_prefs['filter_on_login'] = array(
     'locked' => false,
     'shared' => false,
     'type' => 'checkbox',
     'desc' => _("Apply filter rules upon logging on.")
+);
+
+// run filters with mail refresh?
+$_prefs['filter_on_refresh'] = array(
+    'value' => 0,
+    'locked' => false,
+    'shared' => false,
+    'type' => 'checkbox',
+    'desc' => _("Apply filter rules when INBOX is refreshed.")
 );

 ?>
diff -p -N -U 4 -r imp/mailbox.php imp-UM/mailbox.php
--- imp/mailbox.php	Wed Oct 31 14:55:35 2001
+++ imp-UM/mailbox.php	Fri Nov  9 17:44:55 2001
@@ -524,9 +524,16 @@ if ($end != 0) {
 }

 /* If user wants the mailbox to be refreshed, set time here */
 $refresh_time = $prefs->getValue('refresh_time');
-$refresh_url = Horde::applicationUrl("mailbox.php?page=$page&uniq=".uniqid(rand()));
+
+/* If the user wants to run filters on refresh,
+ * make sure they get run.
+ */
+if ($prefs->getValue('filter_on_refresh')) {
+    $actionID = FILTER;
+}
+$refresh_url = Horde::applicationUrl("mailbox.php?actionID=$actionID&page=$page&uniq=".uniqid(rand()));

 $title = $imp['label'];
 if ($conf['compress_pages']) {
     include_once 'HTTP/Compress.php';
diff -p -N -U 4 -r imp/templates/mailbox/header.inc imp-UM/templates/mailbox/header.inc
--- imp/templates/mailbox/header.inc	Wed Oct 31 14:56:36 2001
+++ imp-UM/templates/mailbox/header.inc	Fri Nov  9 17:57:17 2001
@@ -4,9 +4,16 @@
 <table border="0" width="100%" cellpadding="0" cellspacing="0">
 <tr>
     <td align="left" width="39%" class="header" nowrap="nowrap">
         &nbsp;<?= $imp['label'] ?>
-        <a class="menuitem" onmouseover="status='<?= sprintf("%s %s", _("Refresh"), $imp['label']) ?>'; return true;" onmouseout="status='';" href="<?= Horde::url("mailbox.php?page=$page&uniq=" . uniqid(rand())) ?>">
+	<?
+	/* If the user wants to run filters on refresh,
+	 * make sure they get run.
+	 */
+	if ($prefs->getValue('filter_on_refresh')) {
+		$actionID = FILTER;
+	}?>
+        <a class="menuitem" onmouseover="status='<?= sprintf("%s %s", _("Refresh"), $imp['label']) ?>'; return true;" onmouseout="status='';" href="<?= Horde::url("mailbox.php?actionID=$actionID&page=$page&uniq=" . uniqid(rand())) ?>">
         <?= Horde::img('reload.gif', 'alt="' . sprintf("%s %s", _("Refresh"), $imp['label']) . '" hspace="2"') ?></a>
 <?php if (!$prefs->isLocked('filters') && $imp['label'] == 'INBOX'): ?>
         <a class="menuitem" onmouseover="status='<?= sprintf("%s %s", _("Filter"), $imp['label']) ?>'; return true;" onmouseout="status='';" href="<?= Horde::url("mailbox.php?actionID=" . FILTER . "&page=$page&uniq=" . uniqid(rand())) ?>">
         <?= Horde::img('filters.gif', 'alt="' . sprintf("%s %s", _("Apply Filters on"), $imp['label']) . '"') ?></a>&nbsp;
diff -p -N -U 4 -r imp/templates/prefs/filters.inc imp-UM/templates/prefs/filters.inc
--- imp/templates/prefs/filters.inc	Wed Oct 31 14:56:41 2001
+++ imp-UM/templates/prefs/filters.inc	Fri Nov  9 12:54:23 2001
@@ -18,8 +18,13 @@
     <?php if (!$prefs->isLocked('filter_on_login')): ?>
         <input type="checkbox" name="filter_on_login"<?= $fol_check ?> />
         <?= _("Apply filter rules upon logging on") ?>
     <?php endif; ?>
+
+    <?php if (!$prefs->isLocked('filter_on_refresh')): ?>
+        <input type="checkbox" name="filter_on_refresh"<?= $for_check ?> />
+        <?= _("Apply filter rules when INBOX is refreshed") ?>
+    <?php endif; ?>
     </td>
 </tr>
 </table>






>From chuck@horde.org Date: Fri,  9 Nov 2001 18:49:20 -0500
Return-Path: <chuck@horde.org>
Mailing-List: contact imp-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list imp@lists.horde.org
Received: (qmail 59046 invoked from network); 9 Nov 2001 23:49:58 -0000
Received: from h00104bc60b3c.ne.mediaone.net (HELO marina.horde.org) (24.91.197.108)
  by clark.horde.org with SMTP; 9 Nov 2001 23:49:58 -0000
Received: by marina.horde.org (Postfix, from userid 33)
	id 23F6739AF; Fri,  9 Nov 2001 18:49:21 -0500 (EST)
Received: from 192.168.0.101 ( [192.168.0.101])
	as user chuck@localhost by marina.horde.org with HTTP;
	Fri,  9 Nov 2001 18:49:20 -0500
Message-ID: <1005349760.3bec6b80f0fab@marina.horde.org>
Date: Fri,  9 Nov 2001 18:49:20 -0500
From: Chuck Hagenbuch <chuck@horde.org>
To: imp@lists.horde.org
References: <1005060667.3be8023bc6f10@horde.imp.lieder.ath.cx>
In-Reply-To: <1005060667.3be8023bc6f10@horde.imp.lieder.ath.cx>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 4.0
Subject: Re: [imp] Name completition

Quoting Alexander Skwar <ASkwar@DigitalProjects.com>:

> Could this please be changed so that the results are sorted and that
> there are no dupes?  I'd consider a dupe to be an entry which is all the
> same after converting it to all lower (or upper) case and removing
> unneccessary spaces in between the name.

Duplicate are now removed in HEAD. Sorting is... I'm not sure what to sort by. 
I'll take a patch for it.

I'll commit the duplicate removal code to RELENG_1 if there are no problems or 
objections.

-chuck

--
Charles Hagenbuch, <chuck@horde.org>
"What was and what may be, lie, like children whose faces we cannot see, in the
arms of silence. All we ever have is here, now." - Ursula K. Le Guin