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

Revision 3637, 6.1 KB checked in by emersonfaria, 13 years ago (diff)

Ticket #1476 - Commit inicial dos arquivos do Projeto Z-Push customizados para o Expresso

  • 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
20        function __construct()
21        {
22                global $BACKEND_EMAIL, $BACKEND_CONTACTS, $BACKEND_CALENDAR;
23                if (isset($BACKEND_EMAIL)) $this->BackendEmail = new $BACKEND_EMAIL();
24                if (isset($BACKEND_CONTACTS)) $this->BackendContacts = new $BACKEND_CONTACTS();
25                if (isset($BACKEND_CALENDAR)) $this->BackendCalendar = new $BACKEND_CALENDAR();
26        }
27
28        function Logon($username, $domain, $password) {
29                global $BACKEND_EMAIL;
30                if (isset($BACKEND_EMAIL)) return $this->BackendEmail->Logon($username, $domain, $password);
31                else return true;
32        }
33
34        function Logoff() {
35                global $BACKEND_EMAIL;
36                if (isset($BACKEND_EMAIL)) return $this->BackendEmail->Logoff();
37                else return true;
38        }
39
40        function Setup($user, $devid, $protocolversion) {
41                debugLog('BackendProxy::Setup('.$user.','.$devid.','.$protocolversion.')');
42                global $BACKEND_EMAIL, $BACKEND_CONTACTS, $BACKEND_CALENDAR;
43                if (isset($BACKEND_EMAIL)) $this->BackendEmail->Setup($user, $devid, $protocolversion);
44                if (isset($BACKEND_CONTACTS)) $this->BackendContacts->Setup($user, $devid, $protocolversion);
45                if (isset($BACKEND_CALENDAR)) $this->BackendCalendar->Setup($user, $devid, $protocolversion);
46                return true;
47        }
48
49        function SendMail($rfc822, $forward = false, $reply = false, $parent = false) {
50                global $BACKEND_EMAIL;
51                if (isset($BACKEND_EMAIL)) return $this->BackendEmail->SendMail($rfc822, $forward, $reply, $parent);
52                else return false;
53        }
54
55        function GetWasteBasket() {
56                if (isset($BACKEND_EMAIL)) return $this->BackendEmail->GetWasteBasket();
57                else return false;
58        }
59
60        function GetMessageList($folderid, $cutoffdate) {
61                if ($folderid == 'root') {
62                        return $this->BackendContacts->GetMessageList($folderid, $cutoffdate);
63                } else if ($folderid == 'calendar') {
64                        return $this->BackendCalendar->GetMessageList($folderid, $cutoffdate);
65                } else return $this->BackendEmail->GetMessageList($folderid, $cutoffdate);
66        }
67
68        function GetFolderList() {
69                global $BACKEND_EMAIL, $BACKEND_CONTACTS, $BACKEND_CALENDAR;
70                $folders = Array();
71                if (isset($BACKEND_EMAIL)) $folders += $this->BackendEmail->GetFolderList();
72                if (isset($BACKEND_CALENDAR)) array_push($folders, $this->BackendCalendar->GetFolderList());
73                if (isset($BACKEND_CONTACTS)) array_push($folders, $this->BackendContacts->GetFolderList());
74                return $folders;
75        }
76
77        function GetFolder($id) {
78                if ($id == 'root') {
79                        return $this->BackendContacts->GetFolder($id);
80                } else if ($id == 'calendar') {
81                        return $this->BackendCalendar->GetFolder($id);
82                } else return $this->BackendEmail->GetFolder($id);
83        }
84
85        function StatFolder($id) {
86                if ($id == 'root') {
87                        return $this->BackendContacts->StatFolder($id);
88                } else if ($id == 'calendar') {
89                        return $this->BackendCalendar->StatFolder($id);
90                } else return $this->BackendEmail->StatFolder($id);
91        }
92
93        function GetAttachmentData($attname) {
94                list($folderid, $id, $part) = explode(":", $attname);
95                if ($folderid == 'root') {
96                        return $this->BackendContacts->GetAttachmentData($attname);
97                } else if ($folderid == 'calendar') {
98                        return $this->BackendCalendar->GetAttachmentData($attname);
99                } else return $this->BackendEmail->GetAttachmentData($attname);
100        }
101
102        function StatMessage($folderid, $id) {
103                if ($folderid == 'root') {
104                        return $this->BackendContacts->StatMessage($folderid, $id);
105                } else if ($folderid == 'calendar') {
106                        return $this->BackendCalendar->StatMessage($folderid, $id);
107                } else return $this->BackendEmail->StatMessage($folderid, $id);
108        }
109
110        function GetMessage($folderid, $id, $truncsize, $mimesupport = 0) {
111                if ($folderid == 'root') {
112                        return $this->BackendContacts->GetMessage($folderid, $id, $truncsize, $mimesupport = 0);
113                } else if ($folderid == 'calendar') {
114                        return $this->BackendCalendar->GetMessage($folderid, $id, $truncsize, $mimesupport = 0);
115                } else return $this->BackendEmail->GetMessage($folderid, $id, $truncsize, $mimesupport = 0);
116        }
117
118        function DeleteMessage($folderid, $id) {
119                if ($folderid == 'root') {
120                        return $this->BackendContacts->DeleteMessage($folderid, $id);
121                } else if ($folderid == 'calendar') {
122                        return $this->BackendCalendar->DeleteMessage($folderid, $id);
123                } else return $this->BackendEmail->DeleteMessage($folderid, $id);
124        }
125
126        function SetReadFlag($folderid, $id, $flags) {
127                if ($folderid == 'root') {
128                        return $this->BackendContacts->SetReadFlag($folderid, $id, $flags);
129                } else if ($folderid == 'calendar') {
130                        return $this->BackendCalendar->SetReadFlag($folderid, $id, $flags);
131                } else return $this->BackendEmail->SetReadFlag($folderid, $id, $flags);
132        }
133
134        function ChangeMessage($folderid, $id, $message) {
135                if ($folderid == 'root') {
136                        return $this->BackendContacts->ChangeMessage($folderid, $id, $message);
137                } else if ($folderid == 'calendar') {
138                        return $this->BackendCalendar->ChangeMessage($folderid, $id, $message);
139                } else return $this->BackendEmail->ChangeMessage($folderid, $id, $message);
140        }
141
142        function MoveMessage($folderid, $id, $newfolderid) {
143                if ($folderid == 'root') {
144                        return $this->BackendContacts->MoveMessage($folderid, $id, $newfolderid);
145                } else if ($folderid == 'calendar') {
146                        return $this->BackendCalendar->MoveMessage($folderid, $id, $newfolderid);
147                } else return $this->BackendEmail->MoveMessage($folderid, $id, $newfolderid);
148        }
149        function AlterPing() {
150                //TODO:  Verificar como deve ser tratado esse método
151                //if (isset($BACKEND_EMAIL)) return true;
152                return true;
153        }
154        function AlterPingChanges($folderid, &$syncstate) {
155                if ($folderid == 'root') {
156                        return $this->BackendContacts->AlterPingChanges($folderid, &$syncstate);
157                } else if ($folderid == 'calendar') {
158                        return $this->BackendCalendar->AlterPingChanges($folderid, &$syncstate);
159                } else return $this->BackendEmail->AlterPingChanges($folderid, &$syncstate);
160        }
161};
162?>
Note: See TracBrowser for help on using the repository browser.