File: spamd.php

package info (click to toggle)
horde-sam 0.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,292 kB
  • ctags: 363
  • sloc: php: 1,449; xml: 646; makefile: 64; sql: 60; sh: 30
file content (91 lines) | stat: -rw-r--r-- 2,853 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php

/** Backend-specific 'false' value. */
define('_SAM_OPTION_OFF', '0');

/** Backend-specific 'true' value. */
define('_SAM_OPTION_ON',  '1');

/**
 * Base class for all SpamAssassin drivers.
 *
 * $Horde: sam/lib/Driver/spamd.php,v 1.7 2006/01/13 19:52:06 jan Exp $
 *
 * Copyright 2003-2006 Chris Bowlby <excalibur@hub.org>
 * Copyright 2003-2006 Max Kalika <max@horde.org>
 * Copyright 2004-2006 Jan Schneider <jan@horde.org>
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * @author  Chris Bowlby <excalibur@hub.org>
 * @author  Max Kalika <max@horde.org>
 * @author  Jan Schneider <jan@horde.org>
 * @since   SAM 0.1
 * @package Sam
 * @abstract
 */
class SAM_Driver_spamd extends SAM_Driver {

    /**
     * List of the capabilities supported by this driver.
     *
     * @var array
     */
    var $_capabilities = array('hit_level',
                               'report_safe',
                               'rewrite_sub',
                               'subject_tag',
                               'skip_rbl',
                               'whitelist_to',
                               'whitelist_from',
                               'blacklist_to',
                               'blacklist_from',
                               'rewrite_header_sub',
                               'rewrite_header_to',
                               'rewrite_header_from');

    /**
     * List of Sam to SpamAssassin options mappings.
     *
     * @var array
     */
    var $_option_map = array('hit_level' => 'required_hits',
                             'rewrite_sub' => 'rewrite_subject',
                             'skip_rbl' => 'skip_rbl_checks',
                             'score_level' => 'required_score');

    /**
     * Converts a Sam attribute to an option that SpamAssassin will use.
     *
     * @access protected
     *
     * @param string $attribute  The SAM attribute to convert.
     *
     * @return string  The converted SpamAssassin option or the original
     *                 attribute if no match is found.
     */
    function _mapAttributeToOption($attribute)
    {
        return isset($this->_option_map[$attribute])
               ? $this->_option_map[$attribute] : $attribute;
    }

    /**
     * Converts a SpamAssassin option to a Sam attribute.
     *
     * @access protected
     *
     * @param string $option  The SpamAssassin option to convert.
     *
     * @return string  The converted Sam attribute or the original option if
     *                 no match is found.
     */
    function _mapOptionToAttribute($option)
    {
        $attribute_map = array_flip($this->_option_map);
        return isset($attribute_map[$option])
               ? $attribute_map[$option] : $option;
    }

}