source: sandbox/2.4.2-expresso1/prototype/services/Sieve.php @ 5539

Revision 5539, 2.1 KB checked in by airton, 12 years ago (diff)

Ticket #2088 - Melhorias no editor de regras de filtro de mensagens do Expresso

Line 
1<?php
2$_SESSION['rootPath'] =  ROOTPATH.'/..';
3//if(isset($_SESSION['rootPath']) ) $_SESSION['rootPath'] = ROOTPATH;
4require_once ROOTPATH.'/../library/Net/Sieve.php';
5
6
7class Sieve extends Net_Sieve implements Service
8{
9    var $config;
10       
11    public function open( $config )
12    {   
13                $this->config = $config;
14                       
15                if( PEAR::isError( $error = $this->connect( $config['host'] , $config['port'] , $config['options'] , $config['useTLS'] ) ) ) {
16                        return $error->toString();
17                }
18               
19                if( PEAR::isError( $error = $this->login( $config['user'] , $config['password'] , $config['loginType'] ) ) ) {
20                        return $error->toString();
21                }
22               
23                if( PEAR::isError( $error = $this->getError() ) ) {
24                        return $error->toString();
25                }       
26    }
27
28    public function find( $URI, $justthese = false, $criteria = false )
29    {
30        $return = $this->listScripts();
31
32        if( !is_array($return) )
33            throw new Exception( $return->toString() );
34
35        $array_return = array();
36
37        foreach( $return as $i => $id )
38                $array_return[] = $this->read( array( 'id' => $id ) );
39        return $array_return;
40    }
41
42   
43
44    public function read( $URI, $justthese = false )
45    {
46                return array( 'name' => $URI['id'],
47                      'content' => $this->getScript( $URI['id'] ),
48                      'active' => ($this->getActive() === $URI['id']) );
49    }
50       
51    public function create( $URI, $data )
52    {   
53                if( $this->installScript( $data['name'], $data['content'], $data['active'] ) )
54                        return array('id' => $data['name']);
55
56                return false;
57    }
58
59    public function delete( $URI, $justthese = false, $criteria = false )
60    {
61        return $this->removeScript( $URI['id'] );
62    }
63
64    public function update( $URI, $data, $criteria = false )
65    {
66        $this->delete( $URI );
67        return $this->create($URI , $data);
68    }
69
70
71    public function close()
72    {
73        $this->disconnect();
74    }
75
76    public function replace( $URI, $data, $criteria = false )
77    {}
78
79    public function deleteAll( $URI, $justthese = false, $criteria = false )
80    {}
81
82    public function setup()
83    {}
84
85    public function teardown()
86    {}
87
88    public function begin( $uri )
89    {}
90
91    public function commit( $uri )
92    {
93        return( true );
94    }
95
96    public function rollback( $uri )
97    {}
98}
Note: See TracBrowser for help on using the repository browser.