Back to index

d-push  2.0
synctaskrecurrence.php
Go to the documentation of this file.
00001 <?php
00002 /***********************************************
00003 * File      :   synctaskrecurrence.php
00004 * Project   :   Z-Push
00005 * Descr     :   WBXML tasl recurrence entities that can
00006 *               be 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 // Exactly the same as SyncRecurrence, but then with SYNC_POOMTASKS_*
00050 class SyncTaskRecurrence extends SyncObject {
00051     public $start;
00052     public $type;
00053     public $until;
00054     public $occurrences;
00055     public $interval;
00056     public $dayofweek;
00057     public $dayofmonth;
00058     public $weekofmonth;
00059     public $monthofyear;
00060     public $deadoccur;
00061 
00062     function SyncTaskRecurrence() {
00063         $mapping = array (
00064                     SYNC_POOMTASKS_START                                => array (  self::STREAMER_VAR      => "start",
00065                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE),
00066 
00067                     // Recurrence type
00068                     // 0 = Recurs daily
00069                     // 1 = Recurs weekly
00070                     // 2 = Recurs monthly
00071                     // 3 = Recurs monthly on the nth day
00072                     // 5 = Recurs yearly
00073                     // 6 = Recurs yearly on the nth day
00074                     SYNC_POOMTASKS_TYPE                                 => array (  self::STREAMER_VAR      => "type",
00075                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED   => self::STREAMER_CHECK_SETZERO,
00076                                                                                                                         self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3,5,6) )),
00077 
00078                     SYNC_POOMTASKS_UNTIL                                => array (  self::STREAMER_VAR      => "until",
00079                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE ),
00080 
00081                     SYNC_POOMTASKS_OCCURRENCES                          => array (  self::STREAMER_VAR      => "occurrences",
00082                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => 0,
00083                                                                                                                         self::STREAMER_CHECK_CMPLOWER   => 1000 )),
00084 
00085                     SYNC_POOMTASKS_INTERVAL                             => array (  self::STREAMER_VAR      => "interval",
00086                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => 0,
00087                                                                                                                         self::STREAMER_CHECK_CMPLOWER   => 1000 )),
00088 
00089                     //TODO: check iOS5 sends deadoccur inside of the recurrence
00090                     SYNC_POOMTASKS_DEADOCCUR                            => array (  self::STREAMER_VAR      => "deadoccur"),
00091 
00092                     // DayOfWeek values
00093                     //   1 = Sunday
00094                     //   2 = Monday
00095                     //   4 = Tuesday
00096                     //   8 = Wednesday
00097                     //  16 = Thursday
00098                     //  32 = Friday
00099                     //  62 = Weekdays  // TODO check: value set by WA with daily weekday recurrence
00100                     //  64 = Saturday
00101                     // 127 = The last day of the month. Value valid only in monthly or yearly recurrences.
00102                     SYNC_POOMTASKS_DAYOFWEEK                            => array (  self::STREAMER_VAR      => "dayofweek",
00103                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(1,2,4,8,16,32,62,64,127) )),
00104 
00105                     // DayOfMonth values
00106                     // 1-31 representing the day
00107                     SYNC_POOMTASKS_DAYOFMONTH                           => array (  self::STREAMER_VAR      => "dayofmonth",
00108                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => 0,
00109                                                                                                                         self::STREAMER_CHECK_CMPLOWER   => 32 )),
00110 
00111                     // WeekOfMonth
00112                     // 1-4 = Y st/nd/rd/th week of month
00113                     // 5 = last week of month
00114                     SYNC_POOMTASKS_WEEKOFMONTH                          => array (  self::STREAMER_VAR      => "weekofmonth",
00115                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(1,2,3,4,5) )),
00116 
00117                     // MonthOfYear
00118                     // 1-12 representing the month
00119                     SYNC_POOMTASKS_MONTHOFYEAR                          => array (  self::STREAMER_VAR      => "monthofyear",
00120                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(1,2,3,4,5,6,7,8,9,10,11,12) )),
00121 
00122                 );
00123         parent::SyncObject($mapping);
00124     }
00125 
00137     public function Check($logAsDebug = false) {
00138         $ret = parent::Check($logAsDebug);
00139         if (!$ret)
00140             return false;
00141 
00142         if (isset($this->start) && isset($this->until) && $this->until < $this->start) {
00143             ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'start' is HIGHER than 'until'. Check failed!", get_class($this) ));
00144             return false;
00145         }
00146 
00147         return true;
00148     }
00149 }
00150 
00151 ?>