Back to index

d-push  2.0
synctask.php
Go to the documentation of this file.
00001 <?php
00002 /***********************************************
00003 * File      :   synctask.php
00004 * Project   :   Z-Push
00005 * Descr     :   WBXML task entities that can be parsed
00006 *               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 SyncTask extends SyncObject {
00050     public $body;
00051     public $complete;
00052     public $datecompleted;
00053     public $duedate;
00054     public $utcduedate;
00055     public $importance;
00056     public $recurrence;
00057     public $regenerate;
00058     public $deadoccur;
00059     public $reminderset;
00060     public $remindertime;
00061     public $sensitivity;
00062     public $startdate;
00063     public $utcstartdate;
00064     public $subject;
00065     public $rtf;
00066     public $categories;
00067 
00068     function SyncTask() {
00069         $mapping = array (
00070                     SYNC_POOMTASKS_BODY                                 => array (  self::STREAMER_VAR      => "body"),
00071                     SYNC_POOMTASKS_COMPLETE                             => array (  self::STREAMER_VAR      => "complete",
00072                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETZERO,
00073                                                                                                                         self::STREAMER_CHECK_ZEROORONE      => self::STREAMER_CHECK_SETZERO )),
00074 
00075                     SYNC_POOMTASKS_DATECOMPLETED                        => array (  self::STREAMER_VAR      => "datecompleted",
00076                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES),
00077 
00078                     SYNC_POOMTASKS_DUEDATE                              => array (  self::STREAMER_VAR      => "duedate",
00079                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES),
00080 
00081                     SYNC_POOMTASKS_UTCDUEDATE                           => array (  self::STREAMER_VAR      => "utcduedate",
00082                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES),
00083 
00084                     // Importance values
00085                     // 0 = Low
00086                     // 1 = Normal
00087                     // 2 = High
00088                     // even the default value 1 is optional, the native android client 2.2 interprets a non-existing value as 0 (low)
00089                     SYNC_POOMTASKS_IMPORTANCE                           => array (  self::STREAMER_VAR      => "importance",
00090                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETONE,
00091                                                                                                                         self::STREAMER_CHECK_ONEVALUEOF     => array(0,1,2) )),
00092 
00093                     SYNC_POOMTASKS_RECURRENCE                           => array (  self::STREAMER_VAR      => "recurrence",
00094                                                                                     self::STREAMER_TYPE     => "SyncTaskRecurrence"),
00095 
00096                     SYNC_POOMTASKS_REGENERATE                           => array (  self::STREAMER_VAR      => "regenerate"),
00097                     SYNC_POOMTASKS_DEADOCCUR                            => array (  self::STREAMER_VAR      => "deadoccur"),
00098                     SYNC_POOMTASKS_REMINDERSET                          => array (  self::STREAMER_VAR      => "reminderset",
00099                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETZERO,
00100                                                                                                                         self::STREAMER_CHECK_ZEROORONE      => self::STREAMER_CHECK_SETZERO )),
00101 
00102                     SYNC_POOMTASKS_REMINDERTIME                         => array (  self::STREAMER_VAR      => "remindertime",
00103                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES),
00104 
00105                     // Sensitivity values
00106                     // 0 = Normal
00107                     // 1 = Personal
00108                     // 2 = Private
00109                     // 3 = Confident
00110                     SYNC_POOMTASKS_SENSITIVITY                          => array (  self::STREAMER_VAR      => "sensitivity",
00111                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) )),
00112 
00113                     SYNC_POOMTASKS_STARTDATE                            => array (  self::STREAMER_VAR      => "startdate",
00114                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES),
00115 
00116                     SYNC_POOMTASKS_UTCSTARTDATE                         => array (  self::STREAMER_VAR      => "utcstartdate",
00117                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES),
00118 
00119                     SYNC_POOMTASKS_SUBJECT                              => array (  self::STREAMER_VAR      => "subject"),
00120                     SYNC_POOMTASKS_RTF                                  => array (  self::STREAMER_VAR      => "rtf"),
00121                     SYNC_POOMTASKS_CATEGORIES                           => array (  self::STREAMER_VAR      => "categories",
00122                                                                                     self::STREAMER_ARRAY    => SYNC_POOMTASKS_CATEGORY),
00123                 );
00124 
00125             if (Request::GetProtocolVersion() >= 12.0) {
00126             $mapping[SYNC_AIRSYNCBASE_BODY]                             = array (   self::STREAMER_VAR      => "asbody",
00127                                                                                     self::STREAMER_TYPE     => "SyncBaseBody");
00128 
00129             //unset these properties because airsyncbase body and attachments will be used instead
00130             unset($mapping[SYNC_POOMTASKS_BODY]);
00131         }
00132 
00133         parent::SyncObject($mapping);
00134     }
00135 
00147     public function Check($logAsDebug = false) {
00148         $ret = parent::Check($logAsDebug);
00149         if (!$ret)
00150             return false;
00151 
00152         if (isset($this->startdate) && isset($this->duedate) && $this->duedate < $this->startdate) {
00153             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) ));
00154             return false;
00155         }
00156 
00157         if (isset($this->utcstartdate) && isset($this->utcduedate) && $this->utcduedate < $this->utcstartdate) {
00158             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) ));
00159             return false;
00160         }
00161 
00162         if (isset($this->duedate) && $this->duedate != Utils::getDayStartOfTimestamp($this->duedate)) {
00163             $this->duedate = Utils::getDayStartOfTimestamp($this->duedate);
00164             ZLog::Write(LOGLEVEL_DEBUG, "Set the due time to the start of the day");
00165             if (isset($this->startdate) && $this->duedate < $this->startdate) {
00166                 $this->startdate = Utils::getDayStartOfTimestamp($this->startdate);
00167                 ZLog::Write(LOGLEVEL_DEBUG, "Set the start date to the start of the day");
00168             }
00169         }
00170 
00171         return true;
00172     }
00173 }
00174 
00175 ?>