[ingo] Filtering on the message contents, not a header
JM Coursimault
Horde at coursimault.com
Tue Jun 13 08:51:19 PDT 2006
>> ingo/lib/Script/procmail.php is the backend driver file. You should
>> just have to add INGO_STORAGE_TYPE_BODY to the $_types array, and
>> implement the test as necessary in the driver.
OK, done. Now it's possible, with the procmail backend, to filter on
the body as well as on the headers.
I've also cleaned up a bug on the Procmail flags which caused the
"case sensitive" flag to appear only for the first condition, as well
as putting it as many times as there were case-sensitive conditions.
Perhaps it was already corrected in newer versions.
Here is the diff -u against ingo 1.1.1. I guess that it can be applied
on newer versions as well. I'm not an experienced patcher, so if
something's wrong, just tell me.
Cheers
-- JM
--- procmail.php.orig 2006-06-13 16:21:27.000000000 +0200
+++ procmail.php 2006-06-13 17:11:05.000000000 +0200
@@ -50,6 +50,7 @@
*/
var $_types = array(
INGO_STORAGE_TYPE_HEADER,
+ INGO_STORAGE_TYPE_BODY
);
/**
@@ -500,10 +501,6 @@
function addCondition($condition = array())
{
$flag = (!empty($condition['case'])) ? 'D' : '';
- if (empty($this->_conditions)) {
- $this->addFlag($flag);
- }
-
$match = (isset($condition['match'])) ? $condition['match'] : null;
switch ($condition['field']) {
@@ -512,6 +509,12 @@
$prefix = '';
break;
+ case 'Body':
+ $flag.='B';
+ $string='* ';
+ $prefix='';
+ break;
+
default:
$string = '* ^' . $condition['field'] . ':';
$prefix = ' ';
@@ -557,7 +560,7 @@
if (!$this->_valid) {
return '';
}
-
+ /* Set the global flags for the whole rule, each condition
will add its own (such as Body or Case Sensitive) */
$text[] = ':0 ' . $this->_flags;
foreach ($this->_conditions as $condition) {
if ($nest > 0) {
@@ -565,6 +568,7 @@
$text[] = str_repeat(' ', $nest) . ':0 ' .
$condition['flags'];
$text[] = str_repeat(' ', $nest) . $condition['condition'];
} else {
+ $text[0].= $condition['flags'];
$text[] = $condition['condition'];
}
$nest++;
More information about the ingo
mailing list