Back to index

d-push  2.0
syncappointment.php
Go to the documentation of this file.
00001 <?php
00002 /***********************************************
00003 * File      :   syncappointment.php
00004 * Project   :   Z-Push
00005 * Descr     :   WBXML appointment entities that can be
00006 *               parsed directly (as a stream) from WBXML.
00007 *               It is automatically decoded
00008 *               according to $mapping,
00009 *               and the Sync WBXML mappings.
00010 *
00011 * Created   :   05.09.2011
00012 *
00013 * Copyright 2007 - 2011 Zarafa Deutschland GmbH
00014 *
00015 * This program is free software: you can redistribute it and/or modify
00016 * it under the terms of the GNU Affero General Public License, version 3,
00017 * as published by the Free Software Foundation with the following additional
00018 * term according to sec. 7:
00019 *
00020 * According to sec. 7 of the GNU Affero General Public License, version 3,
00021 * the terms of the AGPL are supplemented with the following terms:
00022 *
00023 * "Zarafa" is a registered trademark of Zarafa B.V.
00024 * "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
00025 * The licensing of the Program under the AGPL does not imply a trademark license.
00026 * Therefore any rights, title and interest in our trademarks remain entirely with us.
00027 *
00028 * However, if you propagate an unmodified version of the Program you are
00029 * allowed to use the term "Z-Push" to indicate that you distribute the Program.
00030 * Furthermore you may use our trademarks where it is necessary to indicate
00031 * the intended purpose of a product or service provided you use it in accordance
00032 * with honest practices in industrial or commercial matters.
00033 * If you want to propagate modified versions of the Program under the name "Z-Push",
00034 * you may only do so if you have a written permission by Zarafa Deutschland GmbH
00035 * (to acquire a permission please contact Zarafa at trademark@zarafa.com).
00036 *
00037 * This program is distributed in the hope that it will be useful,
00038 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00039 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00040 * GNU Affero General Public License for more details.
00041 *
00042 * You should have received a copy of the GNU Affero General Public License
00043 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00044 *
00045 * Consult LICENSE file for details
00046 ************************************************/
00047 
00048 
00049 class SyncAppointment extends SyncObject {
00050     public $timezone;
00051     public $dtstamp;
00052     public $starttime;
00053     public $subject;
00054     public $uid;
00055     public $organizername;
00056     public $organizeremail;
00057     public $location;
00058     public $endtime;
00059     public $recurrence;
00060     public $sensitivity;
00061     public $busystatus;
00062     public $alldayevent;
00063     public $reminder;
00064     public $rtf;
00065     public $meetingstatus;
00066     public $attendees;
00067     public $body;
00068     public $bodytruncated;
00069     public $exception;
00070     public $deleted;
00071     public $exceptionstarttime;
00072     public $categories;
00073 
00074     // AS 12.0 props
00075     public $asbody;
00076     public $nativebodytype;
00077 
00078     // AS 14.0 props
00079     public $disallownewtimeprop;
00080     public $responsetype;
00081     public $responserequested;
00082 
00083 
00084     function SyncAppointment() {
00085         $mapping = array(
00086                     SYNC_POOMCAL_TIMEZONE                               => array (  self::STREAMER_VAR      => "timezone"),
00087 
00088                     SYNC_POOMCAL_DTSTAMP                                => array (  self::STREAMER_VAR      => "dtstamp",
00089                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE,
00090                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETZERO)),
00091 
00092                     SYNC_POOMCAL_STARTTIME                              => array (  self::STREAMER_VAR      => "starttime",
00093                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE,
00094                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETZERO,
00095                                                                                                                         self::STREAMER_CHECK_CMPLOWER       => SYNC_POOMCAL_ENDTIME ) ),
00096 
00097 
00098                     SYNC_POOMCAL_SUBJECT                                => array (  self::STREAMER_VAR      => "subject",
00099                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETEMPTY)),
00100 
00101                     SYNC_POOMCAL_UID                                    => array (  self::STREAMER_VAR      => "uid"),
00102                     SYNC_POOMCAL_ORGANIZERNAME                          => array (  self::STREAMER_VAR      => "organizername"), // verified below
00103                     SYNC_POOMCAL_ORGANIZEREMAIL                         => array (  self::STREAMER_VAR      => "organizeremail"), // verified below
00104                     SYNC_POOMCAL_LOCATION                               => array (  self::STREAMER_VAR      => "location"),
00105                     SYNC_POOMCAL_ENDTIME                                => array (  self::STREAMER_VAR      => "endtime",
00106                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE,
00107                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETONE,
00108                                                                                                                         self::STREAMER_CHECK_CMPHIGHER      => SYNC_POOMCAL_STARTTIME ) ),
00109 
00110                     SYNC_POOMCAL_RECURRENCE                             => array (  self::STREAMER_VAR      => "recurrence",
00111                                                                                     self::STREAMER_TYPE     => "SyncRecurrence"),
00112 
00113                     // Sensitivity values
00114                     // 0 = Normal
00115                     // 1 = Personal
00116                     // 2 = Private
00117                     // 3 = Confident
00118                     SYNC_POOMCAL_SENSITIVITY                            => array (  self::STREAMER_VAR      => "sensitivity",
00119                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) )),
00120 
00121                     // Busystatus values
00122                     // 0 = Free
00123                     // 1 = Tentative
00124                     // 2 = Busy
00125                     // 3 = Out of office
00126                     SYNC_POOMCAL_BUSYSTATUS                             => array (  self::STREAMER_VAR      => "busystatus",
00127                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED   => self::STREAMER_CHECK_SETTWO,
00128                                                                                                                         self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) )),
00129 
00130                     SYNC_POOMCAL_ALLDAYEVENT                            => array (  self::STREAMER_VAR      => "alldayevent",
00131                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ZEROORONE      => self::STREAMER_CHECK_SETZERO)),
00132 
00133                     SYNC_POOMCAL_REMINDER                               => array (  self::STREAMER_VAR      => "reminder",
00134                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER      => -1)),
00135 
00136                     SYNC_POOMCAL_RTF                                    => array (  self::STREAMER_VAR      => "rtf"),
00137 
00138                     // Meetingstatus values
00139                     //  0 = is not a meeting
00140                     //  1 = is a meeting
00141                     //  3 = Meeting received
00142                     //  5 = Meeting is canceled
00143                     //  7 = Meeting is canceled and received
00144                     //  9 = as 1
00145                     // 11 = as 3
00146                     // 13 = as 5
00147                     // 15 = as 7
00148                     SYNC_POOMCAL_MEETINGSTATUS                          => array (  self::STREAMER_VAR      => "meetingstatus",
00149                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1,3,5,7,9,11,13,15) )),
00150 
00151                     SYNC_POOMCAL_ATTENDEES                              => array (  self::STREAMER_VAR      => "attendees",
00152                                                                                     self::STREAMER_TYPE     => "SyncAttendee",
00153                                                                                     self::STREAMER_ARRAY    => SYNC_POOMCAL_ATTENDEE),
00154 
00155                     SYNC_POOMCAL_BODY                                   => array (  self::STREAMER_VAR      => "body"),
00156                     SYNC_POOMCAL_BODYTRUNCATED                          => array (  self::STREAMER_VAR      => "bodytruncated"),
00157                     SYNC_POOMCAL_EXCEPTIONS                             => array (  self::STREAMER_VAR      => "exceptions",
00158                                                                                     self::STREAMER_TYPE     => "SyncAppointmentException",
00159                                                                                     self::STREAMER_ARRAY    => SYNC_POOMCAL_EXCEPTION),
00160 
00161                     SYNC_POOMCAL_CATEGORIES                             => array (  self::STREAMER_VAR      => "categories",
00162                                                                                     self::STREAMER_ARRAY    => SYNC_POOMCAL_CATEGORY),
00163                 );
00164 
00165         if (Request::GetProtocolVersion() >= 12.0) {
00166             $mapping[SYNC_AIRSYNCBASE_BODY]                             = array (   self::STREAMER_VAR      => "asbody",
00167                                                                                     self::STREAMER_TYPE     => "SyncBaseBody");
00168 
00169             $mapping[SYNC_AIRSYNCBASE_NATIVEBODYTYPE]                   = array (   self::STREAMER_VAR      => "nativebodytype");
00170 
00171             //unset these properties because airsyncbase body and attachments will be used instead
00172             unset($mapping[SYNC_POOMCAL_BODY], $mapping[SYNC_POOMCAL_BODYTRUNCATED]);
00173         }
00174 
00175         if(Request::GetProtocolVersion() >= 14.0) {
00176             $mapping[SYNC_POOMCAL_DISALLOWNEWTIMEPROPOSAL]              = array (   self::STREAMER_VAR      => "disallownewtimeprop");
00177             $mapping[SYNC_POOMCAL_RESPONSEREQUESTED]                    = array (   self::STREAMER_VAR      => "responserequested");
00178             $mapping[SYNC_POOMCAL_RESPONSETYPE]                         = array (   self::STREAMER_VAR      => "responsetype");
00179         }
00180 
00181         parent::SyncObject($mapping);
00182     }
00183 
00196     public function Check($logAsDebug = false) {
00197         $ret = parent::Check($logAsDebug);
00198         if (!$ret)
00199             return false;
00200 
00201         if ($this->meetingstatus > 0) {
00202             if (!isset($this->organizername) || !isset($this->organizeremail)) {
00203                 ZLog::Write(LOGLEVEL_WARN, "SyncAppointment->Check(): Parameter 'organizername' and 'organizeremail' should be set for a meeting request");
00204             }
00205         }
00206 
00207         // do not sync a recurrent appointment without a timezone
00208         if (isset($this->recurrence) && !isset($this->timezone)) {
00209             ZLog::Write(LOGLEVEL_ERROR, "SyncAppointment->Check(): timezone for a recurring appointment is not set.");
00210             return false;
00211         }
00212 
00213         return true;
00214     }
00215 }
00216 
00217 ?>