1 | <?php |
---|
2 | /*********************************************** |
---|
3 | * File : synctask.php |
---|
4 | * Project : Z-Push |
---|
5 | * Descr : WBXML task entities that can be parsed |
---|
6 | * 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 SyncTask extends SyncObject { |
---|
50 | public $body; |
---|
51 | public $complete; |
---|
52 | public $datecompleted; |
---|
53 | public $duedate; |
---|
54 | public $utcduedate; |
---|
55 | public $importance; |
---|
56 | public $recurrence; |
---|
57 | public $regenerate; |
---|
58 | public $deadoccur; |
---|
59 | public $reminderset; |
---|
60 | public $remindertime; |
---|
61 | public $sensitivity; |
---|
62 | public $startdate; |
---|
63 | public $utcstartdate; |
---|
64 | public $subject; |
---|
65 | public $rtf; |
---|
66 | public $categories; |
---|
67 | |
---|
68 | function SyncTask() { |
---|
69 | $mapping = array ( |
---|
70 | SYNC_POOMTASKS_BODY => array ( self::STREAMER_VAR => "body"), |
---|
71 | SYNC_POOMTASKS_COMPLETE => array ( self::STREAMER_VAR => "complete", |
---|
72 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO, |
---|
73 | self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO )), |
---|
74 | |
---|
75 | SYNC_POOMTASKS_DATECOMPLETED => array ( self::STREAMER_VAR => "datecompleted", |
---|
76 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES), |
---|
77 | |
---|
78 | SYNC_POOMTASKS_DUEDATE => array ( self::STREAMER_VAR => "duedate", |
---|
79 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES), |
---|
80 | |
---|
81 | SYNC_POOMTASKS_UTCDUEDATE => array ( self::STREAMER_VAR => "utcduedate", |
---|
82 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES), |
---|
83 | |
---|
84 | // Importance values |
---|
85 | // 0 = Low |
---|
86 | // 1 = Normal |
---|
87 | // 2 = High |
---|
88 | // even the default value 1 is optional, the native android client 2.2 interprets a non-existing value as 0 (low) |
---|
89 | SYNC_POOMTASKS_IMPORTANCE => array ( self::STREAMER_VAR => "importance", |
---|
90 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETONE, |
---|
91 | self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2) )), |
---|
92 | |
---|
93 | SYNC_POOMTASKS_RECURRENCE => array ( self::STREAMER_VAR => "recurrence", |
---|
94 | self::STREAMER_TYPE => "SyncTaskRecurrence"), |
---|
95 | |
---|
96 | SYNC_POOMTASKS_REGENERATE => array ( self::STREAMER_VAR => "regenerate"), |
---|
97 | SYNC_POOMTASKS_DEADOCCUR => array ( self::STREAMER_VAR => "deadoccur"), |
---|
98 | SYNC_POOMTASKS_REMINDERSET => array ( self::STREAMER_VAR => "reminderset", |
---|
99 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO, |
---|
100 | self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO )), |
---|
101 | |
---|
102 | SYNC_POOMTASKS_REMINDERTIME => array ( self::STREAMER_VAR => "remindertime", |
---|
103 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES), |
---|
104 | |
---|
105 | // Sensitivity values |
---|
106 | // 0 = Normal |
---|
107 | // 1 = Personal |
---|
108 | // 2 = Private |
---|
109 | // 3 = Confident |
---|
110 | SYNC_POOMTASKS_SENSITIVITY => array ( self::STREAMER_VAR => "sensitivity", |
---|
111 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) )), |
---|
112 | |
---|
113 | SYNC_POOMTASKS_STARTDATE => array ( self::STREAMER_VAR => "startdate", |
---|
114 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES), |
---|
115 | |
---|
116 | SYNC_POOMTASKS_UTCSTARTDATE => array ( self::STREAMER_VAR => "utcstartdate", |
---|
117 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES), |
---|
118 | |
---|
119 | SYNC_POOMTASKS_SUBJECT => array ( self::STREAMER_VAR => "subject"), |
---|
120 | SYNC_POOMTASKS_RTF => array ( self::STREAMER_VAR => "rtf"), |
---|
121 | SYNC_POOMTASKS_CATEGORIES => array ( self::STREAMER_VAR => "categories", |
---|
122 | self::STREAMER_ARRAY => SYNC_POOMTASKS_CATEGORY), |
---|
123 | ); |
---|
124 | |
---|
125 | if (Request::GetProtocolVersion() >= 12.0) { |
---|
126 | $mapping[SYNC_AIRSYNCBASE_BODY] = array ( self::STREAMER_VAR => "asbody", |
---|
127 | self::STREAMER_TYPE => "SyncBaseBody"); |
---|
128 | |
---|
129 | //unset these properties because airsyncbase body and attachments will be used instead |
---|
130 | unset($mapping[SYNC_POOMTASKS_BODY]); |
---|
131 | } |
---|
132 | |
---|
133 | parent::SyncObject($mapping); |
---|
134 | } |
---|
135 | |
---|
136 | /** |
---|
137 | * Method checks if the object has the minimum of required parameters |
---|
138 | * and fullfills semantic dependencies |
---|
139 | * |
---|
140 | * This overloads the general check() with special checks to be executed |
---|
141 | * |
---|
142 | * @param boolean $logAsDebug (opt) default is false, so messages are logged in WARN log level |
---|
143 | * |
---|
144 | * @access public |
---|
145 | * @return boolean |
---|
146 | */ |
---|
147 | public function Check($logAsDebug = false) { |
---|
148 | $ret = parent::Check($logAsDebug); |
---|
149 | |
---|
150 | // semantic checks general "turn off switch" |
---|
151 | if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) |
---|
152 | return $ret; |
---|
153 | |
---|
154 | if (!$ret) |
---|
155 | return false; |
---|
156 | |
---|
157 | if (isset($this->startdate) && isset($this->duedate) && $this->duedate < $this->startdate) { |
---|
158 | ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'startdate' is HIGHER than 'duedate'. Check failed!", get_class($this) )); |
---|
159 | return false; |
---|
160 | } |
---|
161 | |
---|
162 | if (isset($this->utcstartdate) && isset($this->utcduedate) && $this->utcduedate < $this->utcstartdate) { |
---|
163 | ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'utcstartdate' is HIGHER than 'utcduedate'. Check failed!", get_class($this) )); |
---|
164 | return false; |
---|
165 | } |
---|
166 | |
---|
167 | if (isset($this->duedate) && $this->duedate != Utils::getDayStartOfTimestamp($this->duedate)) { |
---|
168 | $this->duedate = Utils::getDayStartOfTimestamp($this->duedate); |
---|
169 | ZLog::Write(LOGLEVEL_DEBUG, "Set the due time to the start of the day"); |
---|
170 | if (isset($this->startdate) && $this->duedate < $this->startdate) { |
---|
171 | $this->startdate = Utils::getDayStartOfTimestamp($this->startdate); |
---|
172 | ZLog::Write(LOGLEVEL_DEBUG, "Set the start date to the start of the day"); |
---|
173 | } |
---|
174 | } |
---|
175 | |
---|
176 | return true; |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | ?> |
---|