[7589] | 1 | <?php |
---|
| 2 | /*********************************************** |
---|
| 3 | * File : synctaskrecurrence.php |
---|
| 4 | * Project : Z-Push |
---|
| 5 | * Descr : WBXML tasl recurrence entities that can |
---|
| 6 | * be 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 | // Exactly the same as SyncRecurrence, but then with SYNC_POOMTASKS_* |
---|
| 50 | class SyncTaskRecurrence extends SyncObject { |
---|
| 51 | public $start; |
---|
| 52 | public $type; |
---|
| 53 | public $until; |
---|
| 54 | public $occurrences; |
---|
| 55 | public $interval; |
---|
| 56 | public $dayofweek; |
---|
| 57 | public $dayofmonth; |
---|
| 58 | public $weekofmonth; |
---|
| 59 | public $monthofyear; |
---|
| 60 | public $deadoccur; |
---|
| 61 | |
---|
| 62 | function SyncTaskRecurrence() { |
---|
| 63 | $mapping = array ( |
---|
| 64 | SYNC_POOMTASKS_START => array ( self::STREAMER_VAR => "start", |
---|
| 65 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE), |
---|
| 66 | |
---|
| 67 | // Recurrence type |
---|
| 68 | // 0 = Recurs daily |
---|
| 69 | // 1 = Recurs weekly |
---|
| 70 | // 2 = Recurs monthly |
---|
| 71 | // 3 = Recurs monthly on the nth day |
---|
| 72 | // 5 = Recurs yearly |
---|
| 73 | // 6 = Recurs yearly on the nth day |
---|
| 74 | SYNC_POOMTASKS_TYPE => array ( self::STREAMER_VAR => "type", |
---|
| 75 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO, |
---|
| 76 | self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3,5,6) )), |
---|
| 77 | |
---|
| 78 | SYNC_POOMTASKS_UNTIL => array ( self::STREAMER_VAR => "until", |
---|
| 79 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE ), |
---|
| 80 | |
---|
| 81 | SYNC_POOMTASKS_OCCURRENCES => array ( self::STREAMER_VAR => "occurrences", |
---|
| 82 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => 0, |
---|
| 83 | self::STREAMER_CHECK_CMPLOWER => 1000 )), |
---|
| 84 | |
---|
| 85 | SYNC_POOMTASKS_INTERVAL => array ( self::STREAMER_VAR => "interval", |
---|
| 86 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => 0, |
---|
| 87 | self::STREAMER_CHECK_CMPLOWER => 1000 )), |
---|
| 88 | |
---|
| 89 | //TODO: check iOS5 sends deadoccur inside of the recurrence |
---|
| 90 | SYNC_POOMTASKS_DEADOCCUR => array ( self::STREAMER_VAR => "deadoccur"), |
---|
| 91 | |
---|
| 92 | // DayOfWeek values |
---|
| 93 | // 1 = Sunday |
---|
| 94 | // 2 = Monday |
---|
| 95 | // 4 = Tuesday |
---|
| 96 | // 8 = Wednesday |
---|
| 97 | // 16 = Thursday |
---|
| 98 | // 32 = Friday |
---|
| 99 | // 62 = Weekdays // TODO check: value set by WA with daily weekday recurrence |
---|
| 100 | // 64 = Saturday |
---|
| 101 | // 127 = The last day of the month. Value valid only in monthly or yearly recurrences. |
---|
| 102 | SYNC_POOMTASKS_DAYOFWEEK => array ( self::STREAMER_VAR => "dayofweek", |
---|
| 103 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(1,2,4,8,16,32,62,64,127) )), |
---|
| 104 | |
---|
| 105 | // DayOfMonth values |
---|
| 106 | // 1-31 representing the day |
---|
| 107 | SYNC_POOMTASKS_DAYOFMONTH => array ( self::STREAMER_VAR => "dayofmonth", |
---|
| 108 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => 0, |
---|
| 109 | self::STREAMER_CHECK_CMPLOWER => 32 )), |
---|
| 110 | |
---|
| 111 | // WeekOfMonth |
---|
| 112 | // 1-4 = Y st/nd/rd/th week of month |
---|
| 113 | // 5 = last week of month |
---|
| 114 | SYNC_POOMTASKS_WEEKOFMONTH => array ( self::STREAMER_VAR => "weekofmonth", |
---|
| 115 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(1,2,3,4,5) )), |
---|
| 116 | |
---|
| 117 | // MonthOfYear |
---|
| 118 | // 1-12 representing the month |
---|
| 119 | SYNC_POOMTASKS_MONTHOFYEAR => array ( self::STREAMER_VAR => "monthofyear", |
---|
| 120 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(1,2,3,4,5,6,7,8,9,10,11,12) )), |
---|
| 121 | |
---|
| 122 | ); |
---|
| 123 | parent::SyncObject($mapping); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | * Method checks if the object has the minimum of required parameters |
---|
| 128 | * and fullfills semantic dependencies |
---|
| 129 | * |
---|
| 130 | * This overloads the general check() with special checks to be executed |
---|
| 131 | * |
---|
| 132 | * @param boolean $logAsDebug (opt) default is false, so messages are logged in WARN log level |
---|
| 133 | * |
---|
| 134 | * @access public |
---|
| 135 | * @return boolean |
---|
| 136 | */ |
---|
| 137 | public function Check($logAsDebug = false) { |
---|
| 138 | $ret = parent::Check($logAsDebug); |
---|
| 139 | |
---|
| 140 | // semantic checks general "turn off switch" |
---|
| 141 | if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) |
---|
| 142 | return $ret; |
---|
| 143 | |
---|
| 144 | if (!$ret) |
---|
| 145 | return false; |
---|
| 146 | |
---|
| 147 | if (isset($this->start) && isset($this->until) && $this->until < $this->start) { |
---|
| 148 | 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) )); |
---|
| 149 | return false; |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | return true; |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | ?> |
---|