Diff for DefaultFilterRules between 5 and 6

+++ How to create default filtering rules for Ingo when using dovecot with sieve

There are situations when you want soto ship a set of new rules for your users. This document aims to tell you how to do this.

I've set up a Debian Lenny system with [http://workaround.org/ispmail/lenny/server-side-sieve-filtering dovecot / sieve] and decided to use horde & ingo to manage my filtering rules. I took advantage of the sieve_global_path option of dovecot to create a global filtering rule. In my case it took care on spam. This rule did what it was supposed to do. But only until the user created his own rules. If the user has it's own filter, the global one is ignored and the user starts to wonder by spam is now delivered to his INBOX.

So what is the task? Define a default rule for ingo that is activated when the user creates his own filtering rules. Together with the global rule in dovecot it will make sure the user is not confused.

First we like to open the file {{ingo/config/prefs.php}}. In this file the default rules are defined. We like to create a rule that moved spam to folder //spam//. So we need to modify **$_prefs['rules']** and **$_prefs['spam']**. For me the two arrays look like this:

<code type="php">
$_prefs['rules'] = array(
    'value' => 'a:1:{i:0;a:8:{s:4:"name";s:11:"Spam Filter";s:7:"combine";i:1;s:10:"conditions";a:0:{}s:6:"action";i:14;s:12:"action-value";s:0:"";s:4:"stop";b:1;s:5:"flags";i:0;s:7:"disable";b:0;}}',
    'locked' => false,
    'shared' => false,
    'type' => 'implicit'

$_prefs['spam'] = array(
    'value' => 'a:2:{s:6:"folder";s:4:"spam";s:5:"level";s:1:"6";}',
    'locked' => false,
    'shared' => false,
    'type' => 'implicit'


I think this is self explaining. The **$_prefs['rules']** defines that there is a rule and **$_prefs['spam']** configures this rule (with spamlevel 6, move to folder spam). I just like to take a look on the **value** elements. [http://lists.horde.org/archives/ingo/Week-of-Mon-20051031/000954.html Kevin M. Myer] has explained how to get the content of this array elements.
# create a fresh user account in you horde installation
# log on using this account and create the rules that you want to have as you default fules and save them
# go to you horde preferences backend (or what ever backend you use to save you rules) and find the info preferences that match this user; for me this were the {{pref_name}} //spam// and //rules// of the {{pref_scope}} //ingo//
# copy the content of {{pref_value}} into you value elements of the spam and rules array in ingo/config/prefs.php

To test this I deleted all user data ( Horde -> Administration -> Users ) of this testuser and logged on again. I now saw the fules that I just defined in the prefs.php file.

So we have made the hardest part. This rules inside ingo are only used by sieve if ingo does actually create a script. Until then the global sieve file is used. To have exactly the same behaviour, I copied the sieve script that ingo created into the global sieve rule file
<code type="sieve">
require "fileinto";
# Spamfilter
if header :comparator "i;ascii-casemap" :contains "X-Spam-Level" "******"  {
    fileinto "spam";