Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2513237
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
73 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/ext/Syncroton/Model/AEntry.php b/lib/ext/Syncroton/Model/AEntry.php
index 7667d11..6950563 100644
--- a/lib/ext/Syncroton/Model/AEntry.php
+++ b/lib/ext/Syncroton/Model/AEntry.php
@@ -1,252 +1,284 @@
<?php
/**
* Syncroton
*
* @package Syncroton
* @subpackage Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/
/**
* abstract class to handle ActiveSync entry
*
* @package Syncroton
* @subpackage Model
*/
abstract class Syncroton_Model_AEntry implements Syncroton_Model_IEntry, IteratorAggregate, Countable
{
protected $_xmlBaseElement;
protected $_elements = array();
protected $_properties = array();
protected $_dateTimeFormat = "Y-m-d\TH:i:s.000\Z";
public function __construct($properties = null)
{
if ($properties instanceof SimpleXMLElement) {
$this->setFromSimpleXMLElement($properties);
} elseif (is_array($properties)) {
$this->setFromArray($properties);
}
}
/**
* (non-PHPdoc)
* @see Syncroton_Model_IEntry::appendXML()
*/
public function appendXML(DOMElement $_domParrent)
{
$this->_addXMLNamespaces($_domParrent);
foreach($this->_elements as $elementName => $value) {
// skip empty values
if($value === null || $value === '' || (is_array($value) && empty($value))) {
continue;
}
list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
if ($nameSpace == 'Internal') {
continue;
}
$nameSpace = 'uri:' . $nameSpace;
// strip off any non printable control characters
if (!ctype_print($value)) {
#$value = $this->removeControlChars($value);
}
$element = $_domParrent->ownerDocument->createElementNS($nameSpace, ucfirst($elementName));
if (is_array($value)) {
foreach($value as $subValue) {
$subElement = $_domParrent->ownerDocument->createElementNS($nameSpace, $elementProperties['childName']);
$this->_appendXMLElement($subElement, array(), $subValue);
$element->appendChild($subElement);
}
} else {
$this->_appendXMLElement($element, $elementProperties, $value);
}
$_domParrent->appendChild($element);
}
}
/**
* (non-PHPdoc)
* @see Countable::count()
*/
public function count()
{
return count($this->_elements);
}
/**
* (non-PHPdoc)
* @see IteratorAggregate::getIterator()
*/
public function getIterator()
{
return new ArrayIterator($this->_elements);
}
/**
* (non-PHPdoc)
* @see Syncroton_Model_IEntry::getProperties()
*/
public function getProperties()
{
$properties = array();
foreach($this->_properties as $namespace => $namespaceProperties) {
$properties = array_merge($properties, array_keys($namespaceProperties));
}
return $properties;
}
public function setFromArray(array $properties)
{
$this->_elements = array();
foreach($properties as $key => $value) {
try {
$this->$key = $value; //echo __LINE__ . PHP_EOL;
} catch (InvalidArgumentException $iae) {
//ignore invalid properties
//echo __LINE__ . PHP_EOL; echo $iae->getMessage(); echo $iae->getTraceAsString();
}
}
}
-
- /**
- * set properties from SimpleXMLElement object
- *
- * @param SimpleXMLElement $xmlCollection
- * @throws InvalidArgumentException
- */
- public function setFromSimpleXMLElement(SimpleXMLElement $properties)
- {
- if (!in_array($properties->getName(), (array) $this->_xmlBaseElement)) {
- throw new InvalidArgumentException('Unexpected element name: ' . $properties->getName());
- }
-
- $this->_elements = array();
-
+
+ /**
+ * set properties from SimpleXMLElement object
+ *
+ * @param SimpleXMLElement $xmlCollection
+ * @throws InvalidArgumentException
+ */
+ public function setFromSimpleXMLElement(SimpleXMLElement $properties)
+ {
+ if (!in_array($properties->getName(), (array) $this->_xmlBaseElement)) {
+ throw new InvalidArgumentException('Unexpected element name: ' . $properties->getName());
+ }
+
+ $this->_elements = array();
+
foreach (array_keys($this->_properties) as $namespace) {
if ($namespace == 'Internal') {
continue;
- }
- $functionName = '_parse' . $namespace . 'Namespace';
- $this->$functionName($properties);
- }
-
- return;
+ }
+
+ $functionName = '_parse' . $namespace . 'Namespace';
+ if (method_exists($this, $functionName)) {
+ $this->$functionName($properties);
+ } else {
+ $this->_parseNamespace($properties, $namespace);
+ }
+ }
+
+ return;
}
-
+
/**
* add needed xml namespaces to DomDocument
*
* @param unknown_type $_domParrent
*/
protected function _addXMLNamespaces(DOMElement $_domParrent)
{
foreach($this->_properties as $namespace => $namespaceProperties) {
$_domParrent->ownerDocument->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:'.$namespace, 'uri:'.$namespace);
}
}
protected function _appendXMLElement($element, $elementProperties, $value)
{
if ($value instanceof Syncroton_Model_IEntry) {
$value->appendXML($element);
} else {
if ($value instanceof DateTime) {
$value = $value->format($this->_dateTimeFormat);
} elseif (isset($elementProperties['encoding']) && $elementProperties['encoding'] == 'base64') {
if (is_resource($value)) {
stream_filter_append($value, 'convert.base64-encode');
$value = stream_get_contents($value);
} else {
$value = base64_encode($value);
}
}
$element->appendChild($element->ownerDocument->createTextNode($value));
}
}
/**
*
* @param unknown_type $element
* @throws InvalidArgumentException
* @return multitype:unknown
*/
protected function _getElementProperties($element)
{
foreach($this->_properties as $namespace => $namespaceProperties) {
if (array_key_exists($element, $namespaceProperties)) {
return array($namespace, $namespaceProperties[$element]);
}
}
throw new InvalidArgumentException("$element is no valid property of this object");
}
-
- protected function _parseAirSyncBaseNamespace(SimpleXMLElement $properties)
- {
- // fetch data from Contacts2 namespace
- $children = $properties->children('uri:AirSyncBase');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- case 'Body':
- $this->$elementName = new Syncroton_Model_EmailBody($xmlElement);
-
- break;
-
- default:
- $this->$elementName = (string) $xmlElement;
- }
- }
- }
-
+
+ protected function _parseElement(SimpleXMLElement $xmlElement)
+ {
+ list($namespace, $properties) = $this->_getElementProperties($xmlElement->getName());
+
+ switch ($properties['type']) {
+ case 'datetime':
+ $value = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
+ break;
+
+ case 'number':
+ $value = (int) $xmlElement;
+ break;
+
+ default:
+ $value = (string) $xmlElement;
+ }
+
+ return $value;
+ }
+
+ protected function _parseNamespace(SimpleXMLElement $properties, $namespace)
+ {
+ $children = $properties->children('uri:' . $namespace);
+
+ foreach ($children as $elementName => $xmlElement) {
+ $this->$elementName = $this->_parseElement($xmlElement);
+ }
+ }
+
+ protected function _parseAirSyncBaseNamespace(SimpleXMLElement $properties)
+ {
+ // fetch data from AirSyncBase namespace
+ $children = $properties->children('uri:AirSyncBase');
+
+ foreach ($children as $elementName => $xmlElement) {
+ switch ($elementName) {
+ case 'Body':
+ $this->$elementName = new Syncroton_Model_EmailBody($xmlElement);
+ break;
+
+ default:
+ $this->$elementName = $this->_parseElement($xmlElement);
+ }
+ }
+ }
+
public function &__get($name)
{
$this->_getElementProperties($name);
return $this->_elements[$name];
}
public function __set($name, $value)
{
list ($namespace, $properties) = $this->_getElementProperties($name);
if ($properties['type'] == 'datetime' && !$value instanceof DateTime) {
throw new InvalidArgumentException("value for $name must be an instance of DateTime");
}
$this->_elements[$name] = $value;
}
public function __isset($name)
{
return isset($this->_elements[$name]);
}
public function __unset($name)
{
unset($this->_elements[$name]);
}
}
\ No newline at end of file
diff --git a/lib/ext/Syncroton/Model/Contact.php b/lib/ext/Syncroton/Model/Contact.php
index d5f20e4..c81fcfd 100644
--- a/lib/ext/Syncroton/Model/Contact.php
+++ b/lib/ext/Syncroton/Model/Contact.php
@@ -1,178 +1,148 @@
<?php
/**
* Syncroton
*
* @package Syncroton
* @subpackage Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/
/**
* class to handle ActiveSync contact
*
* @package Syncroton
* @subpackage Model
* @property string Alias
* @property DateTime Anniversary
* @property string AssistantName
* @property string AssistantPhoneNumber
* @property DateTime Birthday
* @property string Business2PhoneNumber
* @property string BusinessAddressCity
* @property Syncroton_Model_EmailBody Body
*/
class Syncroton_Model_Contact extends Syncroton_Model_AEntry
{
protected $_xmlBaseElement = 'ApplicationData';
protected $_properties = array(
'AirSyncBase' => array(
'Body' => array('type' => 'container')
),
'Contacts' => array(
'Alias' => array('type' => 'string'),
'Anniversary' => array('type' => 'datetime'),
'AssistantName' => array('type' => 'string'),
'AssistantPhoneNumber' => array('type' => 'string'),
'Birthday' => array('type' => 'datetime'),
//'BodySize' => 0x0a,
//'BodyTruncated' => 0x0b,
'Business2PhoneNumber' => array('type' => 'string'),
'BusinessAddressCity' => array('type' => 'string'),
'BusinessAddressCountry' => array('type' => 'string'),
'BusinessAddressPostalCode' => array('type' => 'string'),
'BusinessAddressState' => array('type' => 'string'),
'BusinessAddressStreet' => array('type' => 'string'),
'BusinessFaxNumber' => array('type' => 'string'),
'BusinessPhoneNumber' => array('type' => 'string'),
'CarPhoneNumber' => array('type' => 'string'),
'Categories' => array('type' => 'container', 'childName' => 'Category'),
//'Category' => array('type' => 'string'),
'Children' => array('type' => 'container', 'childName' => 'Child'),
//'Child' => array('type' => 'string'),
'CompanyName' => array('type' => 'string'),
'Department' => array('type' => 'string'),
'Email1Address' => array('type' => 'string'),
'Email2Address' => array('type' => 'string'),
'Email3Address' => array('type' => 'string'),
'FileAs' => array('type' => 'string'),
'FirstName' => array('type' => 'string'),
'Home2PhoneNumber' => array('type' => 'string'),
'HomeAddressCity' => array('type' => 'string'),
'HomeAddressCountry' => array('type' => 'string'),
'HomeAddressPostalCode' => array('type' => 'string'),
'HomeAddressState' => array('type' => 'string'),
'HomeAddressStreet' => array('type' => 'string'),
'HomeFaxNumber' => array('type' => 'string'),
'HomePhoneNumber' => array('type' => 'string'),
'JobTitle' => array('type' => 'string'),
'LastName' => array('type' => 'string'),
'MiddleName' => array('type' => 'string'),
'MobilePhoneNumber' => array('type' => 'string'),
'OfficeLocation' => array('type' => 'string'),
'OtherAddressCity' => array('type' => 'string'),
'OtherAddressCountry' => array('type' => 'string'),
'OtherAddressPostalCode' => array('type' => 'string'),
'OtherAddressState' => array('type' => 'string'),
'OtherAddressStreet' => array('type' => 'string'),
'PagerNumber' => array('type' => 'string'),
'Picture' => array('type' => 'string', 'encoding' => 'base64'),
'RadioPhoneNumber' => array('type' => 'string'),
'Rtf' => array('type' => 'string'),
'Spouse' => array('type' => 'string'),
'Suffix' => array('type' => 'string'),
'Title' => array('type' => 'string'),
'WebPage' => array('type' => 'string'),
'WeightedRank' => array('type' => 'string'),
'YomiCompanyName' => array('type' => 'string'),
'YomiFirstName' => array('type' => 'string'),
'YomiLastName' => array('type' => 'string'),
),
'Contacts2' => array(
'AccountName' => array('type' => 'string'),
'CompanyMainPhone' => array('type' => 'string'),
'CustomerId' => array('type' => 'string'),
'GovernmentId' => array('type' => 'string'),
'IMAddress' => array('type' => 'string'),
'IMAddress2' => array('type' => 'string'),
'IMAddress3' => array('type' => 'string'),
'ManagerName' => array('type' => 'string'),
'MMS' => array('type' => 'string'),
'NickName' => array('type' => 'string'),
)
);
protected function _parseContactsNamespace(SimpleXMLElement $properties)
{
// fetch data from Contacts namespace
$children = $properties->children('uri:Contacts');
foreach ($children as $elementName => $xmlElement) {
switch ($elementName) {
case 'Categories':
$categories = array();
foreach ($xmlElement->Category as $category) {
$categories[] = (string) $category;
}
$this->$elementName = $categories;
break;
case 'Children':
$children = array();
foreach ($xmlElement->Child as $child) {
$children[] = (string) $child;
}
$this->$elementName = $children;
break;
case 'Picture':
$this->$elementName = base64_decode((string) $xmlElement);
break;
default:
- list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
-
- switch ($elementProperties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
+ $this->$elementName = $this->_parseElement($xmlElement);
}
}
}
-
- protected function _parseContacts2Namespace(SimpleXMLElement $properties)
- {
- // fetch data from Contacts2 namespace
- $children = $properties->children('uri:Contacts2');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- default:
- $this->$elementName = (string) $xmlElement;
- }
- }
- }
-}
\ No newline at end of file
+}
diff --git a/lib/ext/Syncroton/Model/Email.php b/lib/ext/Syncroton/Model/Email.php
index ba78525..5a982ca 100644
--- a/lib/ext/Syncroton/Model/Email.php
+++ b/lib/ext/Syncroton/Model/Email.php
@@ -1,203 +1,113 @@
<?php
/**
* Syncroton
*
* @package Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/
/**
* class to handle ActiveSync event
*
* @package Model
* @property array Attachments
* @property string ContentType
+ * @property Syncroton_Model_EmailFlag Flag
* @property Syncroton_Model_EmailBody Body
* @property array Cc
* @property array To
* @property int Read
*/
class Syncroton_Model_Email extends Syncroton_Model_AEntry
{
protected $_xmlBaseElement = 'ApplicationData';
protected $_properties = array(
'AirSyncBase' => array(
'Attachments' => array('type' => 'container', 'childName' => 'Attachment'),
'ContentType' => array('type' => 'string'),
'Body' => array('type' => 'container'),
'NativeBodyType' => array('type' => 'number'),
),
'Email' => array(
'BusyStatus' => array('type' => 'number'),
'Categories' => array('type' => 'container', 'childName' => 'Category'),
'Cc' => array('type' => 'string'),
'CompleteTime' => array('type' => 'datetime'),
'ContentClass' => array('type' => 'string'),
'DateReceived' => array('type' => 'datetime'),
#'DayOfMonth' => array('type' => 'number'),
#'DayOfWeek' => array('type' => 'number'),
'DisallowNewTimeProposal' => array('type' => 'number'),
'DisplayTo' => array('type' => 'string'),
'DTStamp' => array('type' => 'datetime'),
'EndTime' => array('type' => 'datetime'),
'Flag' => array('type' => 'container'),
'From' => array('type' => 'string'),
'GlobalObjId' => array('type' => 'string'),
'Importance' => array('type' => 'number'),
'InstanceType' => array('type' => 'number'),
'InternetCPID' => array('type' => 'string'),
#'Interval' => array('type' => 'number'),
'Location' => array('type' => 'string'),
'MeetingRequest' => array('type' => 'container'),
'MessageClass' => array('type' => 'string'),
#'MonthOfYear' => array('type' => 'number'),
#'Occurrences' => array('type' => 'number'),
'Organizer' => array('type' => 'string'),
'Read' => array('type' => 'number'),
#'Recurrence' => array('type' => 'container'),
#'RecurrenceId' => array('type' => 'datetime'),
'Recurrences' => array('type' => 'container'),
'Reminder' => array('type' => 'number'),
'ReplyTo' => array('type' => 'string'),
'ResponseRequested' => array('type' => 'number'),
'Sensitivity' => array('type' => 'number'),
'StartTime' => array('type' => 'datetime'),
'Status' => array('type' => 'number'),
'Subject' => array('type' => 'string'),
'ThreadTopic' => array('type' => 'string'),
'TimeZone' => array('type' => 'timezone'),
'To' => array('type' => 'string'),
#'Type' => array('type' => 'number'),
#'Until' => array('type' => 'datetime'),
#'WeekOfMonth' => array('type' => 'number'),
),
'Email2' => array(
'AccountId' => array('type' => 'string'),
#'CalendarType' => array('type' => 'number'),
'ConversationId' => array('type' => 'byteArray'), // @todo handle this
'ConversationIndex' => array('type' => 'byteArray'), // @todo handle this
#'FirstDayOfWeek' => array('type' => 'number'),
#'IsLeapMonth' => array('type' => 'number'),
'LastVerbExecuted' => array('type' => 'number'),
'LastVerbExecutionTime' => array('type' => 'datetime'),
'MeetingMessageType' => array('type' => 'number'),
'ReceivedAsBcc' => array('type' => 'number'),
'Sender' => array('type' => 'string'),
'UmCallerID' => array('type' => 'string'),
'UmUserNotes' => array('type' => 'string'),
),
);
-
- protected function _parseAirSyncBaseNamespace(SimpleXMLElement $properties)
- {
- // fetch data from AirSyncBase namespace
- $children = $properties->children('uri:AirSyncBase');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- case 'Body':
- $this->$elementName = new Syncroton_Model_EmailBody($xmlElement);
-
- break;
-
- default:
- list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-
+
protected function _parseEmailNamespace(SimpleXMLElement $properties)
{
// fetch data from AirSyncBase namespace
$children = $properties->children('uri:Email');
foreach ($children as $elementName => $xmlElement) {
switch ($elementName) {
- case 'Body':
- $this->$elementName = new Syncroton_Model_EmailBody($xmlElement);
-
- break;
-
case 'Flag':
$this->$elementName = new Syncroton_Model_EmailFlag($xmlElement);
break;
default:
- list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
+ $this->$elementName = $this->_parseElement($xmlElement);
}
}
}
-
- protected function _parseEmail2Namespace(SimpleXMLElement $properties)
- {
- // fetch data from AirSyncBase namespace
- $children = $properties->children('uri:Email2');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- case 'Body':
- $this->$elementName = new Syncroton_Model_EmailBody($xmlElement);
-
- break;
-
- default:
- list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-}
\ No newline at end of file
+}
diff --git a/lib/ext/Syncroton/Model/EmailAttachment.php b/lib/ext/Syncroton/Model/EmailAttachment.php
index e958f7f..4022166 100644
--- a/lib/ext/Syncroton/Model/EmailAttachment.php
+++ b/lib/ext/Syncroton/Model/EmailAttachment.php
@@ -1,187 +1,71 @@
<?php
/**
* Syncroton
*
* @package Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/
/**
* class to handle ActiveSync event
*
* @package Model
* @property string class
* @property string collectionId
* @property bool deletesAsMoves
* @property bool getChanges
* @property string syncKey
* @property int windowSize
*/
class Syncroton_Model_EmailAttachment extends Syncroton_Model_AEntry
{
protected $_xmlBaseElement = 'Attachment';
protected $_properties = array(
'AirSyncBase' => array(
'ContentId' => array('type' => 'string'),
'ContentLocation' => array('type' => 'string'),
'DisplayName' => array('type' => 'string'),
'EstimatedDataSize' => array('type' => 'string'),
'FileReference' => array('type' => 'string'),
'IsInline' => array('type' => 'number'),
'Method' => array('type' => 'string'),
),
'Email2' => array(
'UmAttDuration' => array('type' => 'number'),
'UmAttOrder' => array('type' => 'number'),
),
);
protected function _parseAirSyncBaseNamespace(SimpleXMLElement $properties)
{
// fetch data from Email namespace
$children = $properties->children('uri:AirSyncBase');
foreach ($children as $elementName => $xmlElement) {
switch ($elementName) {
case 'Attachments':
$attachments = array();
foreach ($xmlElement->$elementName as $attachment) {
$attachments[] = new Syncroton_Model_EmailAttachment($attachment);
}
$this->$elementName = $attachments;
break;
case 'Recurrence':
$this->$elementName = new Syncroton_Model_TaskRecurrence($xmlElement);
break;
default:
- $properties = $this->_properties['Email'][$elementName];
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-
- protected function _parseEmailNamespace(SimpleXMLElement $properties)
- {
- // fetch data from Email namespace
- $children = $properties->children('uri:Email');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- case 'Categories':
- $categories = array();
-
- foreach ($xmlElement->$elementName as $category) {
- $categories[] = (string) $category;
- }
-
- $this->$elementName = $categories;
-
- break;
-
- case 'Recurrence':
- $this->$elementName = new Syncroton_Model_TaskRecurrence($xmlElement);
-
- break;
-
- default:
- $properties = $this->_properties['Email'][$elementName];
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-
- protected function _parseEmail2Namespace(SimpleXMLElement $properties)
- {
- // fetch data from Email2 namespace
- $children = $properties->children('uri:Email2');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- default:
- $properties = $this->_properties['Email'][$elementName];
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
+ $this->$elementName = $this->_parseElement($xmlElement);
}
}
}
-
- public function &__get($name)
- {
- if (!array_key_exists($name, $this->_properties['AirSyncBase']) && !array_key_exists($name, $this->_properties['Email2'])) {
- throw new InvalidArgumentException("$name is no valid property of this object");
- }
-
- return $this->_elements[$name];
- }
-
- public function __set($name, $value)
- {
- if (!array_key_exists($name, $this->_properties['AirSyncBase']) && !array_key_exists($name, $this->_properties['Email2'])) {
- throw new InvalidArgumentException("$name is no valid property of this object");
- }
-
- $properties = isset($this->_properties['AirSyncBase'][$name]) ? $this->_properties['AirSyncBase'][$name] : $this->_properties['Email2'][$name];
-
- if ($properties['type'] == 'datetime' && !$value instanceof DateTime) {
- throw new InvalidArgumentException("value for $name must be an instance of DateTime");
- }
-
- $this->_elements[$name] = $value;
- }
}
\ No newline at end of file
diff --git a/lib/ext/Syncroton/Model/EmailBody.php b/lib/ext/Syncroton/Model/EmailBody.php
index 4f2af2c..474d3ba 100644
--- a/lib/ext/Syncroton/Model/EmailBody.php
+++ b/lib/ext/Syncroton/Model/EmailBody.php
@@ -1,188 +1,43 @@
<?php
/**
* Syncroton
*
* @package Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/
/**
* class to handle AirSyncBase:Body
*
* @package Model
* @property int EstimatedDataSize
* @property string Data
* @property string Part
* @property string Preview
* @property bool Truncated
* @property string Type
*/
class Syncroton_Model_EmailBody extends Syncroton_Model_AEntry
{
const TYPE_PLAINTEXT = 1;
const TYPE_HTML = 2;
const TYPE_RTF = 3;
const TYPE_MIME = 4;
protected $_xmlBaseElement = 'Body';
// @todo handle body
protected $_properties = array(
'AirSyncBase' => array(
'Type' => array('type' => 'string'),
'EstimatedDataSize' => array('type' => 'string'),
'Data' => array('type' => 'string'),
'Truncated' => array('type' => 'number'),
'Part' => array('type' => 'number'),
'Preview' => array('type' => 'string'),
),
);
-
- /**
- *
- * @param SimpleXMLElement $xmlCollection
- * @throws InvalidArgumentException
- */
- public function setFromSimpleXMLElement(SimpleXMLElement $properties)
- {
- if ($properties->getName() !== $this->_xmlBaseElement) {
- throw new InvalidArgumentException('Unexpected element name: ' . $properties->getName());
- }
-
- $this->_elements = array();
-
- foreach (array_keys($this->_properties) as $namespace) {
- $functionName = '_parse' . $namespace . 'Namespace';
- $this->$functionName($properties);
- }
-
- $airSyncBaseData = $properties->children('uri:AirSyncBase');
-
- return;
- }
-
- protected function _parseAirSyncBaseNamespace(SimpleXMLElement $properties)
- {
- // fetch data from Email namespace
- $children = $properties->children('uri:AirSyncBase');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- case 'Attachments':
- $attachments = array();
-
- foreach ($xmlElement->$elementName as $attachment) {
- $attachments[] = new Syncroton_Model_EmailAttachment($attachment);
- }
-
- $this->$elementName = $attachments;
-
- break;
-
- case 'Recurrence':
- $this->$elementName = new Syncroton_Model_TaskRecurrence($xmlElement);
-
- break;
-
- default:
- list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
-
- switch ($elementProperties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-
- protected function _parseEmailNamespace(SimpleXMLElement $properties)
- {
- // fetch data from Email namespace
- $children = $properties->children('uri:Email');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- case 'Categories':
- $categories = array();
-
- foreach ($xmlElement->$elementName as $category) {
- $categories[] = (string) $category;
- }
-
- $this->$elementName = $categories;
-
- break;
-
- case 'Recurrence':
- $this->$elementName = new Syncroton_Model_TaskRecurrence($xmlElement);
-
- break;
-
- default:
- $properties = $this->_properties['Email'][$elementName];
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-
- protected function _parseEmail2Namespace(SimpleXMLElement $properties)
- {
- // fetch data from Email2 namespace
- $children = $properties->children('uri:Email2');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- default:
- $properties = $this->_properties['Email'][$elementName];
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-}
\ No newline at end of file
+}
diff --git a/lib/ext/Syncroton/Model/EmailFlag.php b/lib/ext/Syncroton/Model/EmailFlag.php
index 18fe815..2d8d518 100644
--- a/lib/ext/Syncroton/Model/EmailFlag.php
+++ b/lib/ext/Syncroton/Model/EmailFlag.php
@@ -1,106 +1,77 @@
<?php
/**
* Syncroton
*
* @package Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @copyright Copyright (c) 2012-2012 Kolab Systems AG (http://www.kolabsys.com)
* @author Lars Kneschke <l.kneschke@metaways.de>
* @author Aleksander Machniak <machniak@kolabsys.com>
*/
/**
* class to handle ActiveSync Flag element
*
* @package Model
- * @property int Status
- * @property string FlagType
- * @property datetime CompleteTime
+ * @property DateTime CompleteTime
+ * @property DateTime DateCompleted
+ * @property DateTime DueDate
+ * @property string FlagType
+ * @property DateTime OrdinalDate
+ * @property int ReminderSet
+ * @property DateTime ReminderTime
+ * @property DateTime StartDate
+ * @property string Status
+ * @property string Subject
+ * @property string SubOrdinalDate
+ * @property DateTime UtcDueDate
+ * @property DateTime UtcStartDate
*/
class Syncroton_Model_EmailFlag extends Syncroton_Model_AEntry
{
const STATUS_CLEARED = 0;
const STATUS_COMPLETE = 1;
const STATUS_ACTIVE = 2;
protected $_xmlBaseElement = 'Flag';
protected $_properties = array(
'Email' => array(
'CompleteTime' => array('type' => 'datetime'),
'FlagType' => array('type' => 'string'),
+ // Android bug http://code.google.com/p/android/issues/detail?id=36113
+ 'FlagStatus' => array('type' => 'number'),
'Status' => array('type' => 'number'),
),
'Tasks' => array(
'DateCompleted' => array('type' => 'datetime'),
'DueDate' => array('type' => 'datetime'),
'OrdinalDate' => array('type' => 'datetime'),
'ReminderSet' => array('type' => 'number'),
'ReminderTime' => array('type' => 'datetime'),
'StartDate' => array('type' => 'datetime'),
'Subject' => array('type' => 'string'),
'SubOrdinalDate' => array('type' => 'string'),
'UtcStartDate' => array('type' => 'datetime'),
'UtcDueDate' => array('type' => 'datetime'),
),
);
protected function _parseEmailNamespace(SimpleXMLElement $properties)
{
// fetch data from AirSyncBase namespace
$children = $properties->children('uri:Email');
foreach ($children as $elementName => $xmlElement) {
switch ($elementName) {
case 'FlagStatus':
// Android bug http://code.google.com/p/android/issues/detail?id=36113
$elementName = 'Status';
default:
- list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
-
- switch ($elementProperties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
- break;
-
- default:
- $this->$elementName = (string) $xmlElement;
- break;
- }
- }
- }
- }
-
- protected function _parseTasksNamespace(SimpleXMLElement $properties)
- {
- // fetch data from AirSyncBase namespace
- $children = $properties->children('uri:Tasks');
-
- foreach ($children as $elementName => $xmlElement) {
- switch ($elementName) {
- default:
- list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
-
- switch ($elementProperties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
- break;
-
- default:
- $this->$elementName = (string) $xmlElement;
- break;
- }
+ $this->$elementName = $this->_parseElement($xmlElement);
}
}
}
}
diff --git a/lib/ext/Syncroton/Model/Event.php b/lib/ext/Syncroton/Model/Event.php
index 1571b30..b0176b6 100644
--- a/lib/ext/Syncroton/Model/Event.php
+++ b/lib/ext/Syncroton/Model/Event.php
@@ -1,173 +1,122 @@
<?php
/**
* Syncroton
*
* @package Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/
/**
* class to handle ActiveSync event
*
* @package Model
* @property string class
* @property string collectionId
* @property bool deletesAsMoves
* @property bool getChanges
* @property string syncKey
* @property int windowSize
*/
class Syncroton_Model_Event extends Syncroton_Model_AEntry
{
/**
* busy status constants
*/
const BUSY_STATUS_FREE = 0;
const BUSY_STATUS_TENATTIVE = 1;
const BUSY_STATUS_BUSY = 2;
protected $_dateTimeFormat = "Ymd\THis\Z";
protected $_xmlBaseElement = 'ApplicationData';
protected $_properties = array(
'AirSyncBase' => array(
'Body' => array('type' => 'container')
),
'Calendar' => array(
'AllDayEvent' => array('type' => 'number'),
'AppointmentReplyTime' => array('type' => 'datetime'),
'Attendees' => array('type' => 'container', 'childName' => 'Attendee'),
//'Body' => 0x0b,
//'BodyTruncated' => 0x0c,
'BusyStatus' => array('type' => 'number'),
'Categories' => array('type' => 'container', 'childName' => 'Category'),
'DisallowNewTimeProposal' => array('type' => 'number'),
'DtStamp' => array('type' => 'datetime'),
'EndTime' => array('type' => 'datetime'),
'Exceptions' => array('type' => 'container', 'childName' => 'Exception'),
'Location' => array('type' => 'string'),
'MeetingStatus' => array('type' => 'number'),
'OnlineMeetingConfLink' => array('type' => 'string'),
'OnlineMeetingExternalLink' => array('type' => 'string'),
'OrganizerEmail' => array('type' => 'string'),
'OrganizerName' => array('type' => 'string'),
'Recurrence' => array('type' => 'container'),
'Reminder' => array('type' => 'number'),
'ResponseRequested' => array('type' => 'number'),
'ResponseType' => array('type' => 'number'),
//'Rtf' => 0x10,
'Sensitivity' => array('type' => 'number'),
'StartTime' => array('type' => 'datetime'),
'Subject' => array('type' => 'string'),
'Timezone' => array('type' => 'timezone'),
'UID' => array('type' => 'string'),
)
);
protected function _parseCalendarNamespace(SimpleXMLElement $properties)
{
// fetch data from Contacts namespace
$children = $properties->children('uri:Calendar');
foreach ($children as $elementName => $xmlElement) {
switch ($elementName) {
case 'Attendees':
$attendees = array();
foreach ($xmlElement->Attendee as $attendee) {
$attendees[] = new Syncroton_Model_EventAttendee($attendee);
}
$this->$elementName = $attendees;
break;
case 'Categories':
$categories = array();
foreach ($xmlElement->$elementName as $category) {
$categories[] = (string) $category;
}
$this->$elementName = $categories;
break;
case 'Exceptions':
$exceptions = array();
foreach ($xmlElement->Exception as $exception) {
$exceptions[] = new Syncroton_Model_EventException($exception);
}
$this->$elementName = $exceptions;
break;
case 'Recurrence':
$this->$elementName = new Syncroton_Model_EventRecurrence($xmlElement);
break;
default:
- list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
-
- switch ($elementProperties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
+ $this->$elementName = $this->_parseElement($xmlElement);
}
}
}
-
- protected function _parseAirSyncBaseNamespace(SimpleXMLElement $properties)
- {
- // fetch data from AirSyncBase namespace
- $children = $properties->children('uri:AirSyncBase');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- case 'Body':
- $this->$elementName = new Syncroton_Model_EmailBody($xmlElement);
-
- break;
-
- default:
- list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-}
\ No newline at end of file
+}
diff --git a/lib/ext/Syncroton/Model/EventAttendee.php b/lib/ext/Syncroton/Model/EventAttendee.php
index 7827e30..097feb1 100644
--- a/lib/ext/Syncroton/Model/EventAttendee.php
+++ b/lib/ext/Syncroton/Model/EventAttendee.php
@@ -1,126 +1,51 @@
<?php
/**
* Syncroton
*
* @package Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/
/**
* class to handle ActiveSync event
*
* @package Model
* @property string class
* @property string collectionId
* @property bool deletesAsMoves
* @property bool getChanges
* @property string syncKey
* @property int windowSize
*/
class Syncroton_Model_EventAttendee extends Syncroton_Model_AEntry
{
/**
* attendee status
*/
const ATTENDEE_STATUS_UNKNOWN = 0;
const ATTENDEE_STATUS_TENTATIVE = 2;
const ATTENDEE_STATUS_ACCEPTED = 3;
const ATTENDEE_STATUS_DECLINED = 4;
const ATTENDEE_STATUS_NOTRESPONDED = 5;
/**
* attendee types
*/
const ATTENDEE_TYPE_REQUIRED = 1;
const ATTENDEE_TYPE_OPTIONAL = 2;
const ATTENDEE_TYPE_RESOURCE = 3;
+
+ protected $_xmlBaseElement = 'Attendee';
protected $_properties = array(
'Calendar' => array(
'AttendeeStatus' => array('type' => 'number'),
'AttendeeType' => array('type' => 'number'),
'Email' => array('type' => 'string'),
'Name' => array('type' => 'string'),
)
);
-
- /**
- *
- * @param SimpleXMLElement $xmlCollection
- * @throws InvalidArgumentException
- */
- public function setFromSimpleXMLElement(SimpleXMLElement $properties)
- {
- if ($properties->getName() !== 'Attendee') {
- throw new InvalidArgumentException('Unexpected element name: ' . $properties->getName());
- }
-
- $this->_elements = array();
-
- foreach (array_keys($this->_properties) as $namespace) {
- $functionName = '_parse' . $namespace . 'Namespace';
- $this->$functionName($properties);
- }
-
- $airSyncBaseData = $properties->children('uri:AirSyncBase');
-
- return;
- }
-
- protected function _parseCalendarNamespace(SimpleXMLElement $properties)
- {
- // fetch data from Contacts namespace
- $children = $properties->children('uri:Calendar');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- default:
- $properties = $this->_properties['Calendar'][$elementName];
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-
- public function &__get($name)
- {
- if (!array_key_exists($name, $this->_properties['Calendar'])) {
- throw new InvalidArgumentException("$name is no valid property of this object");
- }
-
- return $this->_elements[$name];
- }
-
- public function __set($name, $value)
- {
- if (!array_key_exists($name, $this->_properties['Calendar'])) {
- throw new InvalidArgumentException("$name is no valid property of this object");
- }
-
- $properties = $this->_properties['Calendar'][$name];
-
- if ($properties['type'] == 'datetime' && !$value instanceof DateTime) {
- throw new InvalidArgumentException("value for $name must be an instance of DateTime");
- }
-
- $this->_elements[$name] = $value;
- }
-}
\ No newline at end of file
+}
diff --git a/lib/ext/Syncroton/Model/EventRecurrence.php b/lib/ext/Syncroton/Model/EventRecurrence.php
index d8b9f4c..5d7c021 100644
--- a/lib/ext/Syncroton/Model/EventRecurrence.php
+++ b/lib/ext/Syncroton/Model/EventRecurrence.php
@@ -1,100 +1,70 @@
<?php
/**
* Syncroton
*
* @package Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/
/**
* class to handle ActiveSync event
*
* @package Model
* @property int CalendarType
* @property int DayOfMonth
* @property int DayOfWeek
* @property int FirstDayOfWeek
* @property int Interval
* @property int IsLeapMonth
* @property int MonthOfYear
* @property int Occurrences
* @property int Type
* @property DateTime Until
* @property int WeekOfMonth
*/
class Syncroton_Model_EventRecurrence extends Syncroton_Model_AEntry
{
protected $_xmlBaseElement = 'Recurrence';
/**
* recur types
*/
const TYPE_DAILY = 0; // Recurs daily.
const TYPE_WEEKLY = 1; // Recurs weekly
const TYPE_MONTHLY = 2; // Recurs monthly
const TYPE_MONTHLY_DAYN = 3; // Recurs monthly on the nth day
const TYPE_YEARLY = 5; // Recurs yearly
const TYPE_YEARLY_DAYN = 6; // Recurs yearly on the nth day
/**
* day of week constants
*/
const RECUR_DOW_SUNDAY = 1;
const RECUR_DOW_MONDAY = 2;
const RECUR_DOW_TUESDAY = 4;
const RECUR_DOW_WEDNESDAY = 8;
const RECUR_DOW_THURSDAY = 16;
const RECUR_DOW_FRIDAY = 32;
const RECUR_DOW_SATURDAY = 64;
protected $_dateTimeFormat = "Ymd\THis\Z";
protected $_properties = array(
'Calendar' => array(
'CalendarType' => array('type' => 'number'),
'DayOfMonth' => array('type' => 'number'),
'DayOfWeek' => array('type' => 'number'),
'FirstDayOfWeek' => array('type' => 'number'),
'Interval' => array('type' => 'number'),
'IsLeapMonth' => array('type' => 'number'),
'MonthOfYear' => array('type' => 'number'),
'Occurrences' => array('type' => 'number'),
'Type' => array('type' => 'number'),
'Until' => array('type' => 'datetime'),
'WeekOfMonth' => array('type' => 'number'),
)
);
-
- protected function _parseCalendarNamespace(SimpleXMLElement $properties)
- {
- // fetch data from Contacts namespace
- $children = $properties->children('uri:Calendar');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- default:
- $properties = $this->_properties['Calendar'][$elementName];
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-}
\ No newline at end of file
+}
diff --git a/lib/ext/Syncroton/Model/Task.php b/lib/ext/Syncroton/Model/Task.php
index ec42cff..c824508 100644
--- a/lib/ext/Syncroton/Model/Task.php
+++ b/lib/ext/Syncroton/Model/Task.php
@@ -1,93 +1,77 @@
<?php
/**
* Syncroton
*
* @package Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/
/**
* class to handle ActiveSync event
*
* @package Model
* @property string class
* @property string collectionId
* @property bool deletesAsMoves
* @property bool getChanges
* @property string syncKey
* @property int windowSize
*/
class Syncroton_Model_Task extends Syncroton_Model_AEntry
{
protected $_xmlBaseElement = 'ApplicationData';
protected $_properties = array(
'AirSyncBase' => array(
'Body' => array('type' => 'container')
),
'Tasks' => array(
'Categories' => array('type' => 'container', 'childName' => 'Category'),
'Complete' => array('type' => 'number'),
'DateCompleted' => array('type' => 'datetime'),
'DueDate' => array('type' => 'datetime'),
'Importance' => array('type' => 'number'),
'Recurrence' => array('type' => 'container'),
'ReminderSet' => array('type' => 'number'),
'ReminderTime' => array('type' => 'datetime'),
'Sensitivity' => array('type' => 'number'),
'StartDate' => array('type' => 'datetime'),
'Subject' => array('type' => 'string'),
'UtcDueDate' => array('type' => 'datetime'),
'UtcStartDate' => array('type' => 'datetime'),
)
);
protected function _parseTasksNamespace(SimpleXMLElement $properties)
{
// fetch data from Contacts namespace
$children = $properties->children('uri:Tasks');
foreach ($children as $elementName => $xmlElement) {
switch ($elementName) {
case 'Categories':
$categories = array();
foreach ($xmlElement->$elementName as $category) {
$categories[] = (string) $category;
}
$this->$elementName = $categories;
break;
case 'Recurrence':
$this->$elementName = new Syncroton_Model_TaskRecurrence($xmlElement);
break;
default:
- list ($nameSpace, $elementProperties) = $this->_getElementProperties($elementName);
-
- switch ($elementProperties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
+ $this->$elementName = $this->_parseElement($xmlElement);
}
}
}
}
\ No newline at end of file
diff --git a/lib/ext/Syncroton/Model/TaskRecurrence.php b/lib/ext/Syncroton/Model/TaskRecurrence.php
index 80a1c9c..1a6b712 100644
--- a/lib/ext/Syncroton/Model/TaskRecurrence.php
+++ b/lib/ext/Syncroton/Model/TaskRecurrence.php
@@ -1,177 +1,66 @@
<?php
/**
* Syncroton
*
* @package Model
* @license http://www.tine20.org/licenses/lgpl.html LGPL Version 3
* @copyright Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/
/**
* class to handle ActiveSync event
*
* @package Model
* @property string class
* @property string collectionId
* @property bool deletesAsMoves
* @property bool getChanges
* @property string syncKey
* @property int windowSize
*/
class Syncroton_Model_TaskRecurrence extends Syncroton_Model_AEntry
{
protected $_xmlBaseElement = 'Recurrence';
/**
* recur types
*/
const TYPE_DAILY = 0; // Recurs daily.
const TYPE_WEEKLY = 1; // Recurs weekly
const TYPE_MONTHLY = 2; // Recurs monthly
const TYPE_MONTHLY_DAYN = 3; // Recurs monthly on the nth day
const TYPE_YEARLY = 5; // Recurs yearly
const TYPE_YEARLY_DAYN = 6; // Recurs yearly on the nth day
/**
* day of week constants
*/
const RECUR_DOW_SUNDAY = 1;
const RECUR_DOW_MONDAY = 2;
const RECUR_DOW_TUESDAY = 4;
const RECUR_DOW_WEDNESDAY = 8;
const RECUR_DOW_THURSDAY = 16;
const RECUR_DOW_FRIDAY = 32;
const RECUR_DOW_SATURDAY = 64;
protected $_properties = array(
'Tasks' => array(
'CalendarType' => array('type' => 'number'),
'DayOfMonth' => array('type' => 'number'),
'DayOfWeek' => array('type' => 'number'),
'DeadOccur' => array('type' => 'number'),
'FirstDayOfWeek' => array('type' => 'number'),
'Interval' => array('type' => 'number'),
'IsLeapMonth' => array('type' => 'number'),
'MonthOfYear' => array('type' => 'number'),
'Occurrences' => array('type' => 'number'),
'Regenerate' => array('type' => 'number'),
'Start' => array('type' => 'datetime'),
'Type' => array('type' => 'number'),
'Until' => array('type' => 'datetime'),
'WeekOfMonth' => array('type' => 'number'),
)
);
-
- public function appendXML(DOMElement $_domParrent)
- {
- $_domParrent->ownerDocument->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:Tasks', 'uri:Tasks');
-
- foreach($this->_elements as $elementName => $value) {
- // skip empty values
- if($value === null || $value === '' || (is_array($value) && empty($value))) {
- continue;
- }
-
- $elementProperties = $this->_properties['Tasks'][$elementName];
-
- $nameSpace = 'uri:Tasks';
-
- // strip off any non printable control characters
- if (!ctype_print($value)) {
- #$value = $this->removeControlChars($value);
- }
-
- switch($elementName) {
- default:
- $element = $_domParrent->ownerDocument->createElementNS($nameSpace, $elementName);
-
- if ($value instanceof DateTime) {
- $value = $value->format("Y-m-d\TH:i:s.000\Z");
- }
- $element->appendChild($_domParrent->ownerDocument->createTextNode($value));
-
- $_domParrent->appendChild($element);
- }
- }
-
- }
-
- /**
- *
- * @param SimpleXMLElement $xmlCollection
- * @throws InvalidArgumentException
- */
- public function setFromSimpleXMLElement(SimpleXMLElement $properties)
- {
- if ($properties->getName() !== $this->_xmlBaseElement) {
- throw new InvalidArgumentException('Unexpected element name: ' . $properties->getName());
- }
-
- $this->_elements = array();
-
- foreach (array_keys($this->_properties) as $namespace) {
- $functionName = '_parse' . $namespace . 'Namespace';
- $this->$functionName($properties);
- }
-
- $airSyncBaseData = $properties->children('uri:AirSyncBase');
-
- return;
- }
-
- protected function _parseTasksNamespace(SimpleXMLElement $properties)
- {
- // fetch data from Contacts namespace
- $children = $properties->children('uri:Tasks');
-
- foreach ($children as $elementName => $xmlElement) {
-
- switch ($elementName) {
- default:
- $properties = $this->_properties['Tasks'][$elementName];
-
- switch ($properties['type']) {
- case 'datetime':
- $this->$elementName = new DateTime((string) $xmlElement, new DateTimeZone('UTC'));
-
- break;
-
- case 'number':
- $this->$elementName = (int) $xmlElement;
-
- break;
- default:
- $this->$elementName = (string) $xmlElement;
-
- break;
- }
- }
- }
- }
-
- public function &__get($name)
- {
- if (!array_key_exists($name, $this->_properties['Tasks'])) {
- throw new InvalidArgumentException("$name is no valid property of this object");
- }
-
- return $this->_elements[$name];
- }
-
- public function __set($name, $value)
- {
- if (!array_key_exists($name, $this->_properties['Tasks'])) {
- throw new InvalidArgumentException("$name is no valid property of this object");
- }
-
- $properties = $this->_properties['Tasks'][$name];
-
- if ($properties['type'] == 'datetime' && !$value instanceof DateTime) {
- throw new InvalidArgumentException("value for $name must be an instance of DateTime");
- }
-
- $this->_elements[$name] = $value;
- }
-}
\ No newline at end of file
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Apr 18, 10:12 AM (6 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
435666
Default Alt Text
(73 KB)
Attached To
Mode
R4 syncroton
Attached
Detach File
Event Timeline
Log In to Comment