[7589] | 1 | <?php |
---|
| 2 | /*********************************************** |
---|
| 3 | * File : syncappointment.php |
---|
| 4 | * Project : Z-Push |
---|
| 5 | * Descr : WBXML appointment entities that can be |
---|
| 6 | * parsed directly (as a stream) from WBXML. |
---|
| 7 | * It is automatically decoded |
---|
| 8 | * according to $mapping, |
---|
| 9 | * and the Sync WBXML mappings. |
---|
| 10 | * |
---|
| 11 | * Created : 05.09.2011 |
---|
| 12 | * |
---|
| 13 | * Copyright 2007 - 2012 Zarafa Deutschland GmbH |
---|
| 14 | * |
---|
| 15 | * This program is free software: you can redistribute it and/or modify |
---|
| 16 | * it under the terms of the GNU Affero General Public License, version 3, |
---|
| 17 | * as published by the Free Software Foundation with the following additional |
---|
| 18 | * term according to sec. 7: |
---|
| 19 | * |
---|
| 20 | * According to sec. 7 of the GNU Affero General Public License, version 3, |
---|
| 21 | * the terms of the AGPL are supplemented with the following terms: |
---|
| 22 | * |
---|
| 23 | * "Zarafa" is a registered trademark of Zarafa B.V. |
---|
| 24 | * "Z-Push" is a registered trademark of Zarafa Deutschland GmbH |
---|
| 25 | * The licensing of the Program under the AGPL does not imply a trademark license. |
---|
| 26 | * Therefore any rights, title and interest in our trademarks remain entirely with us. |
---|
| 27 | * |
---|
| 28 | * However, if you propagate an unmodified version of the Program you are |
---|
| 29 | * allowed to use the term "Z-Push" to indicate that you distribute the Program. |
---|
| 30 | * Furthermore you may use our trademarks where it is necessary to indicate |
---|
| 31 | * the intended purpose of a product or service provided you use it in accordance |
---|
| 32 | * with honest practices in industrial or commercial matters. |
---|
| 33 | * If you want to propagate modified versions of the Program under the name "Z-Push", |
---|
| 34 | * you may only do so if you have a written permission by Zarafa Deutschland GmbH |
---|
| 35 | * (to acquire a permission please contact Zarafa at trademark@zarafa.com). |
---|
| 36 | * |
---|
| 37 | * This program is distributed in the hope that it will be useful, |
---|
| 38 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 39 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 40 | * GNU Affero General Public License for more details. |
---|
| 41 | * |
---|
| 42 | * You should have received a copy of the GNU Affero General Public License |
---|
| 43 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
| 44 | * |
---|
| 45 | * Consult LICENSE file for details |
---|
| 46 | ************************************************/ |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | class SyncAppointment extends SyncObject { |
---|
| 50 | public $timezone; |
---|
| 51 | public $dtstamp; |
---|
| 52 | public $starttime; |
---|
| 53 | public $subject; |
---|
| 54 | public $uid; |
---|
| 55 | public $organizername; |
---|
| 56 | public $organizeremail; |
---|
| 57 | public $location; |
---|
| 58 | public $endtime; |
---|
| 59 | public $recurrence; |
---|
| 60 | public $sensitivity; |
---|
| 61 | public $busystatus; |
---|
| 62 | public $alldayevent; |
---|
| 63 | public $reminder; |
---|
| 64 | public $rtf; |
---|
| 65 | public $meetingstatus; |
---|
| 66 | public $attendees; |
---|
| 67 | public $body; |
---|
| 68 | public $bodytruncated; |
---|
| 69 | public $exception; |
---|
| 70 | public $deleted; |
---|
| 71 | public $exceptionstarttime; |
---|
| 72 | public $categories; |
---|
| 73 | |
---|
| 74 | // AS 12.0 props |
---|
| 75 | public $asbody; |
---|
| 76 | public $nativebodytype; |
---|
| 77 | |
---|
| 78 | // AS 14.0 props |
---|
| 79 | public $disallownewtimeprop; |
---|
| 80 | public $responsetype; |
---|
| 81 | public $responserequested; |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | function SyncAppointment() { |
---|
| 85 | $mapping = array( |
---|
| 86 | SYNC_POOMCAL_TIMEZONE => array ( self::STREAMER_VAR => "timezone"), |
---|
| 87 | |
---|
| 88 | SYNC_POOMCAL_DTSTAMP => array ( self::STREAMER_VAR => "dtstamp", |
---|
| 89 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
---|
| 90 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO)), |
---|
| 91 | |
---|
| 92 | SYNC_POOMCAL_STARTTIME => array ( self::STREAMER_VAR => "starttime", |
---|
| 93 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
---|
| 94 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO, |
---|
| 95 | self::STREAMER_CHECK_CMPLOWER => SYNC_POOMCAL_ENDTIME ) ), |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | SYNC_POOMCAL_SUBJECT => array ( self::STREAMER_VAR => "subject", |
---|
| 99 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETEMPTY)), |
---|
| 100 | |
---|
| 101 | SYNC_POOMCAL_UID => array ( self::STREAMER_VAR => "uid"), |
---|
| 102 | SYNC_POOMCAL_ORGANIZERNAME => array ( self::STREAMER_VAR => "organizername"), // verified below |
---|
| 103 | SYNC_POOMCAL_ORGANIZEREMAIL => array ( self::STREAMER_VAR => "organizeremail"), // verified below |
---|
| 104 | SYNC_POOMCAL_LOCATION => array ( self::STREAMER_VAR => "location"), |
---|
| 105 | SYNC_POOMCAL_ENDTIME => array ( self::STREAMER_VAR => "endtime", |
---|
| 106 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
---|
| 107 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETONE, |
---|
| 108 | self::STREAMER_CHECK_CMPHIGHER => SYNC_POOMCAL_STARTTIME ) ), |
---|
| 109 | |
---|
| 110 | SYNC_POOMCAL_RECURRENCE => array ( self::STREAMER_VAR => "recurrence", |
---|
| 111 | self::STREAMER_TYPE => "SyncRecurrence"), |
---|
| 112 | |
---|
| 113 | // Sensitivity values |
---|
| 114 | // 0 = Normal |
---|
| 115 | // 1 = Personal |
---|
| 116 | // 2 = Private |
---|
| 117 | // 3 = Confident |
---|
| 118 | SYNC_POOMCAL_SENSITIVITY => array ( self::STREAMER_VAR => "sensitivity", |
---|
| 119 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) )), |
---|
| 120 | |
---|
| 121 | // Busystatus values |
---|
| 122 | // 0 = Free |
---|
| 123 | // 1 = Tentative |
---|
| 124 | // 2 = Busy |
---|
| 125 | // 3 = Out of office |
---|
| 126 | SYNC_POOMCAL_BUSYSTATUS => array ( self::STREAMER_VAR => "busystatus", |
---|
| 127 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETTWO, |
---|
| 128 | self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) )), |
---|
| 129 | |
---|
| 130 | SYNC_POOMCAL_ALLDAYEVENT => array ( self::STREAMER_VAR => "alldayevent", |
---|
| 131 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO)), |
---|
| 132 | |
---|
| 133 | SYNC_POOMCAL_REMINDER => array ( self::STREAMER_VAR => "reminder", |
---|
| 134 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1)), |
---|
| 135 | |
---|
| 136 | SYNC_POOMCAL_RTF => array ( self::STREAMER_VAR => "rtf"), |
---|
| 137 | |
---|
| 138 | // Meetingstatus values |
---|
| 139 | // 0 = is not a meeting |
---|
| 140 | // 1 = is a meeting |
---|
| 141 | // 3 = Meeting received |
---|
| 142 | // 5 = Meeting is canceled |
---|
| 143 | // 7 = Meeting is canceled and received |
---|
| 144 | // 9 = as 1 |
---|
| 145 | // 11 = as 3 |
---|
| 146 | // 13 = as 5 |
---|
| 147 | // 15 = as 7 |
---|
| 148 | SYNC_POOMCAL_MEETINGSTATUS => array ( self::STREAMER_VAR => "meetingstatus", |
---|
| 149 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,3,5,7,9,11,13,15) )), |
---|
| 150 | |
---|
| 151 | SYNC_POOMCAL_ATTENDEES => array ( self::STREAMER_VAR => "attendees", |
---|
| 152 | self::STREAMER_TYPE => "SyncAttendee", |
---|
| 153 | self::STREAMER_ARRAY => SYNC_POOMCAL_ATTENDEE), |
---|
| 154 | |
---|
| 155 | SYNC_POOMCAL_BODY => array ( self::STREAMER_VAR => "body"), |
---|
| 156 | SYNC_POOMCAL_BODYTRUNCATED => array ( self::STREAMER_VAR => "bodytruncated"), |
---|
| 157 | SYNC_POOMCAL_EXCEPTIONS => array ( self::STREAMER_VAR => "exceptions", |
---|
| 158 | self::STREAMER_TYPE => "SyncAppointmentException", |
---|
| 159 | self::STREAMER_ARRAY => SYNC_POOMCAL_EXCEPTION), |
---|
| 160 | |
---|
| 161 | SYNC_POOMCAL_CATEGORIES => array ( self::STREAMER_VAR => "categories", |
---|
| 162 | self::STREAMER_ARRAY => SYNC_POOMCAL_CATEGORY), |
---|
| 163 | ); |
---|
| 164 | |
---|
| 165 | if (Request::GetProtocolVersion() >= 12.0) { |
---|
| 166 | $mapping[SYNC_AIRSYNCBASE_BODY] = array ( self::STREAMER_VAR => "asbody", |
---|
| 167 | self::STREAMER_TYPE => "SyncBaseBody"); |
---|
| 168 | |
---|
| 169 | $mapping[SYNC_AIRSYNCBASE_NATIVEBODYTYPE] = array ( self::STREAMER_VAR => "nativebodytype"); |
---|
| 170 | |
---|
| 171 | //unset these properties because airsyncbase body and attachments will be used instead |
---|
| 172 | unset($mapping[SYNC_POOMCAL_BODY], $mapping[SYNC_POOMCAL_BODYTRUNCATED]); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | if(Request::GetProtocolVersion() >= 14.0) { |
---|
| 176 | $mapping[SYNC_POOMCAL_DISALLOWNEWTIMEPROPOSAL] = array ( self::STREAMER_VAR => "disallownewtimeprop"); |
---|
| 177 | $mapping[SYNC_POOMCAL_RESPONSEREQUESTED] = array ( self::STREAMER_VAR => "responserequested"); |
---|
| 178 | $mapping[SYNC_POOMCAL_RESPONSETYPE] = array ( self::STREAMER_VAR => "responsetype"); |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | parent::SyncObject($mapping); |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | /** |
---|
| 185 | * Method checks if the object has the minimum of required parameters |
---|
| 186 | * and fullfills semantic dependencies |
---|
| 187 | * |
---|
| 188 | * This overloads the general check() with special checks to be executed |
---|
| 189 | * Checks if SYNC_POOMCAL_ORGANIZERNAME and SYNC_POOMCAL_ORGANIZEREMAIL are correctly set |
---|
| 190 | * |
---|
| 191 | * @param boolean $logAsDebug (opt) default is false, so messages are logged in WARN log level |
---|
| 192 | * |
---|
| 193 | * @access public |
---|
| 194 | * @return boolean |
---|
| 195 | */ |
---|
| 196 | public function Check($logAsDebug = false) { |
---|
| 197 | $ret = parent::Check($logAsDebug); |
---|
| 198 | |
---|
| 199 | // semantic checks general "turn off switch" |
---|
| 200 | if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) |
---|
| 201 | return $ret; |
---|
| 202 | |
---|
| 203 | if (!$ret) |
---|
| 204 | return false; |
---|
| 205 | |
---|
| 206 | if ($this->meetingstatus > 0) { |
---|
| 207 | if (!isset($this->organizername) || !isset($this->organizeremail)) { |
---|
| 208 | ZLog::Write(LOGLEVEL_WARN, "SyncAppointment->Check(): Parameter 'organizername' and 'organizeremail' should be set for a meeting request"); |
---|
| 209 | } |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | // do not sync a recurrent appointment without a timezone |
---|
| 213 | if (isset($this->recurrence) && !isset($this->timezone)) { |
---|
| 214 | ZLog::Write(LOGLEVEL_ERROR, "SyncAppointment->Check(): timezone for a recurring appointment is not set."); |
---|
| 215 | return false; |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | return true; |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | ?> |
---|