source: contrib/z-push/backend/BackendProxy.php @ 3754

Revision 3754, 6.4 KB checked in by emersonfaria, 13 years ago (diff)

Ticket #1551 - Correcoes de bugs e Melhorias de formatacao de email no Z-Push.

  • Property svn:executable set to *
Line 
1<?php
2/***********************************************
3 * File      :   BackendProxy.php
4 * Project   :   Z-Push
5 * Descr     :   It route calls to three Backends thru one interface.
6 *
7 * Created   :   04.10.2010 - emerson-faria.nobre@serpro.gov.br
8 *
9 * ï¿œ Zarafa Deutschland GmbH, www.zarafaserver.de
10 * This file is distributed under GPL v2.
11 * Consult LICENSE file for details
12 ************************************************/
13include_once('diffbackend.php');
14
15class BackendProxy extends BackendDiff {
16        var $BackendEmail;
17        var $BackendContacts;
18        var $BackendCalendar;
19        var $folderid;
20
21        function __construct()
22        {
23                global $BACKEND_EMAIL, $BACKEND_CONTACTS, $BACKEND_CALENDAR;
24                if (isset($BACKEND_EMAIL)) $this->BackendEmail = new $BACKEND_EMAIL();
25                if (isset($BACKEND_CONTACTS)) $this->BackendContacts = new $BACKEND_CONTACTS();
26                if (isset($BACKEND_CALENDAR)) $this->BackendCalendar = new $BACKEND_CALENDAR();
27        }
28
29        function Logon($username, $domain, $password) {
30                global $BACKEND_EMAIL;
31                if (isset($BACKEND_EMAIL)) return $this->BackendEmail->Logon($username, $domain, $password);
32                else return true;
33        }
34
35        function Logoff() {
36                global $BACKEND_EMAIL;
37                if (isset($BACKEND_EMAIL)) return $this->BackendEmail->Logoff();
38                else return true;
39        }
40
41        function Setup($user, $devid, $protocolversion) {
42                debugLog('BackendProxy::Setup('.$user.','.$devid.','.$protocolversion.')');
43                global $BACKEND_EMAIL, $BACKEND_CONTACTS, $BACKEND_CALENDAR;
44                $this->_user = $user;
45                $this->_devid = $devid;
46                $this->_protocolversion = $protocolversion;
47                if (isset($BACKEND_EMAIL)) $this->BackendEmail->Setup($user, $devid, $protocolversion);
48                if (isset($BACKEND_CONTACTS)) $this->BackendContacts->Setup($user, $devid, $protocolversion);
49                if (isset($BACKEND_CALENDAR)) $this->BackendCalendar->Setup($user, $devid, $protocolversion);
50                return true;
51        }
52
53        function GetExporter($folderid = false) {
54                $this->folderid = $folderid;
55                return parent::GetExporter($folderid);
56        }
57
58        function SendMail($rfc822, $forward = false, $reply = false, $parent = false) {
59                global $BACKEND_EMAIL;
60                if (isset($BACKEND_EMAIL)) return $this->BackendEmail->SendMail($rfc822, $forward, $reply, $parent);
61                else return false;
62        }
63
64        function GetWasteBasket() {
65                if (isset($BACKEND_EMAIL)) return $this->BackendEmail->GetWasteBasket();
66                else return false;
67        }
68
69        function GetMessageList($folderid, $cutoffdate) {
70                if ($folderid == 'root') {
71                        return $this->BackendContacts->GetMessageList($folderid, $cutoffdate);
72                } else if ($folderid == 'calendar') {
73                        return $this->BackendCalendar->GetMessageList($folderid, $cutoffdate);
74                } else return $this->BackendEmail->GetMessageList($folderid, $cutoffdate);
75        }
76
77        function GetFolderList() {
78                global $BACKEND_EMAIL, $BACKEND_CONTACTS, $BACKEND_CALENDAR;
79                $folders = Array();
80                if (isset($BACKEND_EMAIL)) $folders += $this->BackendEmail->GetFolderList();
81                if (isset($BACKEND_CALENDAR)) array_push($folders, $this->BackendCalendar->GetFolderList());
82                if (isset($BACKEND_CONTACTS)) array_push($folders, $this->BackendContacts->GetFolderList());
83                return $folders;
84        }
85
86        function GetFolder($id) {
87                if ($id == 'root') {
88                        return $this->BackendContacts->GetFolder($id);
89                } else if ($id == 'calendar') {
90                        return $this->BackendCalendar->GetFolder($id);
91                } else return $this->BackendEmail->GetFolder($id);
92        }
93
94        function StatFolder($id) {
95                if ($id == 'root') {
96                        return $this->BackendContacts->StatFolder($id);
97                } else if ($id == 'calendar') {
98                        return $this->BackendCalendar->StatFolder($id);
99                } else return $this->BackendEmail->StatFolder($id);
100        }
101
102        function GetAttachmentData($attname) {
103                list($folderid, $id, $part) = explode(":", $attname);
104                if ($folderid == 'root') {
105                        return $this->BackendContacts->GetAttachmentData($attname);
106                } else if ($folderid == 'calendar') {
107                        return $this->BackendCalendar->GetAttachmentData($attname);
108                } else return $this->BackendEmail->GetAttachmentData($attname);
109        }
110
111        function StatMessage($folderid, $id) {
112                if ($folderid == 'root') {
113                        return $this->BackendContacts->StatMessage($folderid, $id);
114                } else if ($folderid == 'calendar') {
115                        return $this->BackendCalendar->StatMessage($folderid, $id);
116                } else return $this->BackendEmail->StatMessage($folderid, $id);
117        }
118
119        function GetMessage($folderid, $id, $truncsize, $mimesupport = 0) {
120                if ($folderid == 'root') {
121                        return $this->BackendContacts->GetMessage($folderid, $id, $truncsize, $mimesupport = 0);
122                } else if ($folderid == 'calendar') {
123                        return $this->BackendCalendar->GetMessage($folderid, $id, $truncsize, $mimesupport = 0);
124                } else return $this->BackendEmail->GetMessage($folderid, $id, $truncsize, $mimesupport = 0);
125        }
126
127        function DeleteMessage($folderid, $id) {
128                if ($folderid == 'root') {
129                        return $this->BackendContacts->DeleteMessage($folderid, $id);
130                } else if ($folderid == 'calendar') {
131                        return $this->BackendCalendar->DeleteMessage($folderid, $id);
132                } else return $this->BackendEmail->DeleteMessage($folderid, $id);
133        }
134
135        function SetReadFlag($folderid, $id, $flags) {
136                if ($folderid == 'root') {
137                        return $this->BackendContacts->SetReadFlag($folderid, $id, $flags);
138                } else if ($folderid == 'calendar') {
139                        return $this->BackendCalendar->SetReadFlag($folderid, $id, $flags);
140                } else return $this->BackendEmail->SetReadFlag($folderid, $id, $flags);
141        }
142
143        function ChangeMessage($folderid, $id, $message) {
144                if ($folderid == 'root') {
145                        return $this->BackendContacts->ChangeMessage($folderid, $id, $message);
146                } else if ($folderid == 'calendar') {
147                        return $this->BackendCalendar->ChangeMessage($folderid, $id, $message);
148                } else return $this->BackendEmail->ChangeMessage($folderid, $id, $message);
149        }
150
151        function MoveMessage($folderid, $id, $newfolderid) {
152                if ($folderid == 'root') {
153                        return $this->BackendContacts->MoveMessage($folderid, $id, $newfolderid);
154                } else if ($folderid == 'calendar') {
155                        return $this->BackendCalendar->MoveMessage($folderid, $id, $newfolderid);
156                } else return $this->BackendEmail->MoveMessage($folderid, $id, $newfolderid);
157        }
158
159        function AlterPing() {
160                if ($this->folderid == 'root') {
161                        return false;
162                } else if ($this->folderid == 'calendar') {
163                        return false;
164                } else return true;
165        }
166
167        function AlterPingChanges($folderid, &$syncstate) {
168                if ($folderid == 'root') {
169                        return $this->BackendContacts->AlterPingChanges($folderid, &$syncstate);
170                } else if ($folderid == 'calendar') {
171                        return $this->BackendCalendar->AlterPingChanges($folderid, &$syncstate);
172                } else return $this->BackendEmail->AlterPingChanges($folderid, &$syncstate);
173        }
174};
175?>
Note: See TracBrowser for help on using the repository browser.