File: timsieved.php

package info (click to toggle)
ingo1 1.0.1-1sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,368 kB
  • ctags: 921
  • sloc: php: 4,030; xml: 1,182; makefile: 63
file content (84 lines) | stat: -rw-r--r-- 2,558 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
<?php

require_once('Net/Sieve.php');

/**
 * Ingo_Driver_timsieved:: Implements the Sieve_Driver api to allow
 * scripts to up installed and actived via the Cyrus timsieved server.
 *
 * $Horde: ingo/lib/Driver/timsieved.php,v 1.15 2004/05/20 15:48:48 jan Exp $
 *
 * See the enclosed file LICENSE for license information. If you
 * did not receive this file, see http://www.horde.org/licenses.
 *
 * @author  Mike Cochrane <mike@graftonhall.co.nz>
 * @version $Revision: 1.15 $
 * @since   Ingo 0.1
 * @package Ingo
 */
class Ingo_Driver_timsieved extends Ingo_Driver {

    /**
     * Constructor.
     *
     * @access public
     */
    function Ingo_Driver_timsieved($params = array())
    {
        $default_params = array(
            'hostspec'    =>  'localhost',
            'logintype'   =>  'PLAIN',
            'port'        =>  2000,
            'scriptname'  =>  'ingo'
        );
        $this->_params = array_merge($default_params, $params);
    }

    /**
     * Sets a script running on the backend.
     *
     * @param string $script    The sieve script.
     * @param string $username  The backend username.
     * @param string $password  The backend password.
     *
     * @return mixed  True on success.
     *                Returns PEAR_Error on error.
     */
    function setScriptActive($script, $username, $password)
    {
        $sieve = &new Net_Sieve($username,
                                $password,
                                $this->_params['hostspec'],
                                $this->_params['port'],
                                $this->_params['logintype']);

        if (is_a($res = $sieve->getError(), 'PEAR_Error')) {
            return $res;
        }

        return $sieve->installScript($this->_params['scriptname'], $script, true);
    }

    /**
     * Returns the content of the currently active script.
     *
     * @param string $username  The backend username.
     * @param string $password  The backend password.
     *
     * @return string  The complete ruleset of the specified user.
     */
    function getScript($username, $password)
    {
        $sieve = &new Net_Sieve($username,
                                $password,
                                $this->_params['hostspec'],
                                $this->_params['port'],
                                $this->_params['logintype']);

        if (is_a($res = $sieve->getError(), 'PEAR_Error')) {
            return $res;
        }

        return $sieve->getScript($this->_params['scriptname']);
    }
}