source: trunk/prototype/services/Sieve.php @ 5341

Revision 5341, 2.3 KB checked in by wmerlotto, 12 years ago (diff)

Ticket #2434 - Commit inicial do novo módulo de agenda do Expresso - expressoCalendar

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        if( PEAR::isError( $error = $this->login( $config['user'] , $config['password'] , $config['loginType'] ) ) )
19            return $error->toString();
20
21        if( PEAR::isError( $error = $this->getError() ) )
22            return $error->toString();
23    }
24
25    public function find( $URI, $context, $justthese = false, $criteria = false )
26    {
27        $return = $this->listScripts();
28
29        if( !is_array($return) )
30            throw new Exception( $return->toString() );
31
32        $array_return = array();
33
34        foreach( $return as $i => $id )
35                $array_return[] = $this->read( array( 'id' => $id ) );
36
37//      ob_start();
38//         print_r( $array_return );
39//         $output = ob_get_clean();
40//         file_put_contents( "/tmp/2.log",  $output , FILE_APPEND);
41
42        return $array_return;
43    }
44
45   
46
47    public function read( $URI, $justthese = false )
48    {
49        return array( 'name' => $URI['id'],
50                      'content' => $this->getScript( $URI['id'] ),
51                      'active' => ($this->getActive() === $URI['id']) );
52    }
53       
54    public function create( $URI, $data )
55    {
56        if( $this->installScript( $data['name'], $data['content'], $data['active'] ) )
57            return array('id' => $data['name']);
58
59        return false;
60    }
61
62    public function delete( $URI, $justthese = false, $criteria = false )
63    {
64        return $this->removeScript( $URI['id'] );
65    }
66
67    public function update( $URI, $data, $criteria = false )
68    {
69        $this->delete( $URI );
70        return $this->create($URI , $data);
71    }
72
73
74    public function close()
75    {
76        $this->disconnect();
77    }
78
79    public function replace( $URI, $data, $criteria = false )
80    {}
81
82    public function deleteAll( $URI, $justthese = false, $criteria = false )
83    {}
84
85    public function setup()
86    {}
87
88    public function teardown()
89    {}
90
91    public function begin( $uri )
92    {}
93
94    public function commit( $uri )
95    {
96        return( true );
97    }
98
99    public function rollback( $uri )
100    {}
101}
Note: See TracBrowser for help on using the repository browser.