Back to index

d-push  2.0
diffbackend.php
Go to the documentation of this file.
00001 <?php
00002 /***********************************************
00003 * File      :   diffbackend.php
00004 * Project   :   Z-Push
00005 * Descr     :   This is the abstract differential backend.
00006 *               By implementing this backends there is no need
00007 *               to worry about importers and exporters. Also
00008 *               tracking incremental changes is not necessary,
00009 *               as the DiffState used by the DiffBackend offers
00010 *               this functionality by comparing the list of objects
00011 *               available "last time" with the list of objects
00012 *               available "now".
00013 *               Please note that the differential mechanism
00014 *               can consume a considerable amount of memory and cpu
00015 *               power when synchronizing folders with many items.
00016 *
00017 * Created   :   02.01.2012
00018 *
00019 * Copyright 2007 - 2012 Zarafa Deutschland GmbH
00020 *
00021 * This program is free software: you can redistribute it and/or modify
00022 * it under the terms of the GNU Affero General Public License, version 3,
00023 * as published by the Free Software Foundation with the following additional
00024 * term according to sec. 7:
00025 *
00026 * According to sec. 7 of the GNU Affero General Public License, version 3,
00027 * the terms of the AGPL are supplemented with the following terms:
00028 *
00029 * "Zarafa" is a registered trademark of Zarafa B.V.
00030 * "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
00031 * The licensing of the Program under the AGPL does not imply a trademark license.
00032 * Therefore any rights, title and interest in our trademarks remain entirely with us.
00033 *
00034 * However, if you propagate an unmodified version of the Program you are
00035 * allowed to use the term "Z-Push" to indicate that you distribute the Program.
00036 * Furthermore you may use our trademarks where it is necessary to indicate
00037 * the intended purpose of a product or service provided you use it in accordance
00038 * with honest practices in industrial or commercial matters.
00039 * If you want to propagate modified versions of the Program under the name "Z-Push",
00040 * you may only do so if you have a written permission by Zarafa Deutschland GmbH
00041 * (to acquire a permission please contact Zarafa at trademark@zarafa.com).
00042 *
00043 * This program is distributed in the hope that it will be useful,
00044 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00045 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00046 * GNU Affero General Public License for more details.
00047 *
00048 * You should have received a copy of the GNU Affero General Public License
00049 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00050 *
00051 * Consult LICENSE file for details
00052 ************************************************/
00053 
00054 // default backend
00055 include_once('lib/default/backend.php');
00056 
00057 // DiffBackend components
00058 include_once('diffstate.php');
00059 include_once('importchangesdiff.php');
00060 include_once('exportchangesdiff.php');
00061 
00062 
00063 abstract class BackendDiff extends Backend {
00064     protected $store;
00065 
00085     public function Setup($store, $checkACLonly = false, $folderid = false) {
00086         $this->store = $store;
00087 
00088         return true;
00089     }
00090 
00100     function GetHierarchy() {
00101         $folders = array();
00102 
00103         $fl = $this->GetFolderList();
00104         if (is_array($fl))
00105             foreach($fl as $f)
00106                 $folders[] = $this->GetFolder($f['id']);
00107 
00108         return $folders;
00109     }
00110 
00121     public function GetImporter($folderid = false) {
00122         return new ImportChangesDiff($this, $folderid);
00123     }
00124 
00135     public function GetExporter($folderid = false) {
00136         return new ExportChangesDiff($this, $folderid);
00137     }
00138 
00150     public function Fetch($folderid, $id, $contentparameters) {
00151         // override truncation
00152         $contentparameters->SetTruncation(SYNC_TRUNCATION_ALL);
00153         $msg = $this->GetMessage($folderid, $id, $contentparameters);
00154         if ($msg === false)
00155             throw new StatusException("BackendDiff->Fetch('%s','%s'): Error, unable retrieve message from backend", SYNC_STATUS_OBJECTNOTFOUND);
00156         return $msg;
00157     }
00158 
00171     public function MeetingResponse($requestid, $folderid, $response) {
00172         throw new StatusException(sprintf("BackendDiff->MeetingResponse('%s','%s','%s'): Error, this functionality is not supported by the diff backend", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_MAILBOXERROR);
00173     }
00174 
00190     public abstract function GetFolderList();
00191 
00201     public abstract function GetFolder($id);
00202 
00219     public abstract function StatFolder($id);
00220 
00234     public abstract function ChangeFolder($folderid, $oldid, $displayname, $type);
00235 
00246     public abstract function DeleteFolder($id, $parentid);
00247 
00265     public abstract function GetMessageList($folderid, $cutoffdate);
00266 
00280     public abstract function GetMessage($folderid, $id, $contentparameters);
00281 
00299     public abstract function StatMessage($folderid, $id);
00300 
00316     public abstract function ChangeMessage($folderid, $id, $message);
00317 
00334     public abstract function SetReadFlag($folderid, $id, $flags);
00335 
00350     public abstract function DeleteMessage($folderid, $id);
00351 
00366     public abstract function MoveMessage($folderid, $id, $newfolderid);
00367 
00368 }
00369 ?>