summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-11-11 11:29:07 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-11-11 11:29:07 (GMT)
commitf33d333b4588a27179b86d1aad6dc683a97e270e (patch)
tree9063c41591145ef7ef5ad9c78271ffc43c3a976e
parent23f75124088ca8aabb8ab6124a3e7482e93230a8 (diff)
downloadiRony-f33d333b4588a27179b86d1aad6dc683a97e270e.tar.gz
Adapt to API changes for SabreDAV 2.1 / VObject 3.3
-rw-r--r--composer.json10
-rw-r--r--lib/Kolab/CalDAV/CalendarBackend.php47
-rw-r--r--lib/Kolab/CalDAV/Plugin.php4
-rw-r--r--lib/Kolab/CardDAV/ContactsBackend.php143
-rw-r--r--lib/Kolab/CardDAV/LDAPDirectory.php13
-rw-r--r--lib/Kolab/CardDAV/Plugin.php6
-rw-r--r--lib/Kolab/CardDAV/UserAddressBooks.php17
-rw-r--r--lib/Kolab/DAVACL/PrincipalBackend.php9
-rw-r--r--lib/Kolab/Utils/DAVBackend.php31
-rw-r--r--lib/Kolab/Utils/DAVLogger.php8
-rw-r--r--lib/Kolab/Utils/HTTPResponse.php13
-rw-r--r--lib/Kolab/Utils/VObjectUtils.php15
-rw-r--r--public_html/index.php10
13 files changed, 175 insertions, 151 deletions
diff --git a/composer.json b/composer.json
index c95e29d..053ce31 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "kolab/irony",
"description": "iRony - The Kolab WebDAV/CalDAV/CardDAV Server",
"license": "AGPL-3.0",
- "version": "0.3-dev",
+ "version": "0.4-dev",
"repositories": [
{
"type": "pear",
@@ -10,16 +10,12 @@
},
{
"type": "vcs",
- "url": "https://github.com/thomascube/sabre-vobject.git"
- },
- {
- "type": "vcs",
"url": "git://git.kolab.org/git/pear/Net_LDAP3"
}
],
"require": {
- "php": ">=5.3.3",
- "sabre/dav" : "1.8.9"
+ "php": ">=5.4.1",
+ "sabre/dav" : "~2.1.0"
},
"require-dev": {
"pear/mail_mime": ">=1.8.9",
diff --git a/lib/Kolab/CalDAV/CalendarBackend.php b/lib/Kolab/CalDAV/CalendarBackend.php
index df4e7d4..ba31729 100644
--- a/lib/Kolab/CalDAV/CalendarBackend.php
+++ b/lib/Kolab/CalDAV/CalendarBackend.php
@@ -198,45 +198,26 @@ class CalendarBackend extends CalDAV\Backend\AbstractBackend
/**
* Updates properties for a calendar.
*
- * The mutations array uses the propertyName in clark-notation as key,
- * and the array value for the property value. In the case a property
- * should be deleted, the property value will be null.
+ * The list of mutations is stored in a Sabre\DAV\PropPatch object.
+ * To do the actual updates, you must tell this object which properties
+ * you're going to process with the handle() method.
*
- * This method must be atomic. If one property cannot be changed, the
- * entire operation must fail.
+ * Calling the handle method is like telling the PropPatch object "I
+ * promise I can handle updating this property".
*
- * If the operation was successful, true can be returned.
- * If the operation failed, false can be returned.
+ * Read the PropPatch documenation for more info and examples.
*
- * Deletion of a non-existent property is always successful.
- *
- * Lastly, it is optional to return detailed information about any
- * failures. In this case an array should be returned with the following
- * structure:
- *
- * array(
- * 403 => array(
- * '{DAV:}displayname' => null,
- * ),
- * 424 => array(
- * '{DAV:}owner' => null,
- * )
- * )
- *
- * In this example it was forbidden to update {DAV:}displayname.
- * (403 Forbidden), which in turn also caused {DAV:}owner to fail
- * (424 Failed Dependency) because the request needs to be atomic.
- *
- * @param mixed $calendarId
- * @param array $mutations
- * @return bool|array
+ * @param string $path
+ * @param \Sabre\DAV\PropPatch $propPatch
+ * @return void
*/
- public function updateCalendar($calendarId, array $mutations)
+ public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch)
{
- console(__METHOD__, $calendarId, $mutations);
+ console(__METHOD__, $calendarId, $propPatch);
- $folder = $this->get_storage_folder($calendarId);
- return DAVBackend::folder_update($folder, $mutations);
+ if ($folder = $this->get_storage_folder($calendarId)) {
+ DAVBackend::handle_propatch($folder, $propPatch);
+ }
}
/**
diff --git a/lib/Kolab/CalDAV/Plugin.php b/lib/Kolab/CalDAV/Plugin.php
index 5f8d7f2..815f37b 100644
--- a/lib/Kolab/CalDAV/Plugin.php
+++ b/lib/Kolab/CalDAV/Plugin.php
@@ -51,8 +51,8 @@ class Plugin extends CalDAV\Plugin
{
parent::initialize($server);
- $server->subscribeEvent('afterCreateFile', array($this, 'afterWriteContent'));
- $server->subscribeEvent('afterWriteContent', array($this, 'afterWriteContent'));
+ $server->on('afterCreateFile', array($this, 'afterWriteContent'));
+ $server->on('afterWriteContent', array($this, 'afterWriteContent'));
}
/**
diff --git a/lib/Kolab/CardDAV/ContactsBackend.php b/lib/Kolab/CardDAV/ContactsBackend.php
index 1a92fe0..2dff2c7 100644
--- a/lib/Kolab/CardDAV/ContactsBackend.php
+++ b/lib/Kolab/CardDAV/ContactsBackend.php
@@ -29,6 +29,7 @@ use \kolab_storage;
use Sabre\DAV;
use Sabre\CardDAV;
use Sabre\VObject;
+use Sabre\VObject\DateTimeParser;
use Kolab\Utils\DAVBackend;
use Kolab\Utils\VObjectUtils;
@@ -205,25 +206,31 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
}
/**
- * Updates an addressbook's properties
+ * Updates properties for an address book.
*
- * See Sabre\DAV\IProperties for a description of the mutations array, as
- * well as the return value.
+ * The list of mutations is stored in a Sabre\DAV\PropPatch object.
+ * To do the actual updates, you must tell this object which properties
+ * you're going to process with the handle() method.
*
- * @param mixed $addressBookId
- * @param array $mutations
- * @see Sabre\DAV\IProperties::updateProperties
- * @return bool|array
+ * Calling the handle method is like telling the PropPatch object "I
+ * promise I can handle updating this property".
+ *
+ * Read the PropPatch documenation for more info and examples.
+ *
+ * @param string $addressBookId
+ * @param \Sabre\DAV\PropPatch $propPatch
+ * @return void
*/
- public function updateAddressBook($addressBookId, array $mutations)
+ public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch)
{
- console(__METHOD__, $addressBookId, $mutations);
+ console(__METHOD__, $addressBookId, $propPatch);
if ($addressBookId == '__all__')
return false;
- $folder = $this->get_storage_folder($addressBookId);
- return $folder ? DAVBackend::folder_update($folder, $mutations) : false;
+ if ($folder = $this->get_storage_folder($addressBookId)) {
+ DAVBackend::handle_propatch($folder, $propPatch);
+ }
}
/**
@@ -662,9 +669,9 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
$v4 = $this->is_vcard4();
$v4_prefix = $v4 ? '' : 'X-';
- $vc = VObject\Component::create('VCARD');
- $vc->version = $v4 ? '4.0' : '3.0';
- $vc->prodid = '-//Kolab//iRony DAV Server ' . KOLAB_DAV_VERSION . '//Sabre//Sabre VObject ' . VObject\Version::VERSION . '//EN';
+ $vc = new VObject\Component\VCard();
+ $vc->VERSION = $v4 ? '4.0' : '3.0';
+ $vc->PRODID = '-//Kolab//iRony DAV Server ' . KOLAB_DAV_VERSION . '//Sabre//Sabre VObject ' . VObject\Version::VERSION . '//EN';
$vc->add('UID', $contact['uid']);
$vc->add('FN', $contact['name']);
@@ -694,8 +701,8 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
}
}
else if ($contact['surname'] . $contact['firstname'] . $contact['middlename'] . $contact['prefix'] . $contact['suffix'] != '') {
- $n = VObject\Property::create('N');
- $n->setParts(array($contact['surname'], $contact['firstname'], $contact['middlename'], $contact['prefix'], $contact['suffix']));
+ $n = $vc->create('N');
+ $n->setParts(array(strval($contact['surname']), strval($contact['firstname']), strval($contact['middlename']), strval($contact['prefix']), strval($contact['suffix'])));
$vc->add($n);
}
@@ -707,7 +714,7 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
$vc->add('ROLE', $contact['profession']);
if (!empty($contact['organization']) || !empty($contact['department'])) {
- $org = VObject\Property::create('ORG');
+ $org = $vc->create('ORG');
$org->setParts(array($contact['organization'], $contact['department']));
$vc->add($org);
}
@@ -717,7 +724,7 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
foreach ($this->related_map as $type => $field) {
if (!empty($contact[$field])) {
foreach ((array)$contact[$field] as $value) {
- $vc->add(VObject\Property::create('RELATED', $value, array('type' => $type)));
+ $vc->add($vc->create('RELATED', $value, array('type' => $type)));
}
}
}
@@ -736,9 +743,10 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
}
foreach ((array)$contact['email'] as $email) {
- $vemail = VObject\Property::create('EMAIL', $email['address'], array('type' => 'INTERNET'));
- if (!empty($email['type']))
- $vemail->offsetSet(null, new VObject\Parameter('type', strtoupper($email['type'])));
+ $vemail = $vc->create('EMAIL', $email['address'], array('type' => 'INTERNET'));
+ if (!empty($email['type'])) {
+ $vemail['type']->addValue(strtoupper($email['type']));
+ }
$vc->add($vemail);
}
@@ -759,7 +767,7 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
}
foreach ((array)$contact['address'] as $adr) {
- $vadr = VObject\Property::create('ADR', null, array('type' => strtoupper($adr['type'])));
+ $vadr = $vc->create('ADR', null, array('type' => strtoupper($adr['type'])));
$vadr->setParts(array('','', $adr['street'], $adr['locality'], $adr['region'], $adr['code'], $adr['country']));
$vc->add($vadr);
}
@@ -785,15 +793,15 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
if (!empty($contact['birthday']) && $contact['birthday'] instanceof \DateTime) {
// FIXME: Date values are ignored by Thunderbird
$contact['birthday']->_dateonly = true;
- $vc->add(VObjectUtils::datetime_prop('BDAY', $contact['birthday'], false));
+ $vc->add(VObjectUtils::datetime_prop($vc, 'BDAY', $contact['birthday'], false));
}
if (!empty($contact['anniversary']) && $contact['anniversary'] instanceof \DateTime) {
$contact['anniversary']->_dateonly = true;
- $vc->add(VObjectUtils::datetime_prop($v4_prefix . 'ANNIVERSARY', $contact['anniversary'], false));
+ $vc->add(VObjectUtils::datetime_prop($vc, $v4_prefix . 'ANNIVERSARY', $contact['anniversary'], false));
}
if (!empty($contact['categories'])) {
- $cat = VObject\Property::create('CATEGORIES');
+ $cat = $vc->create('CATEGORIES');
$cat->setParts((array)$contact['categories']);
$vc->add($cat);
}
@@ -809,8 +817,8 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
}
if (!empty($contact['photo'])) {
- $vc->PHOTO = base64_encode($contact['photo']);
- $vc->PHOTO->add('BASE64', null);
+ $vc->PHOTO = $contact['photo'];
+ $vc->PHOTO['ENCODING'] = 'b';
}
// add custom properties
@@ -823,8 +831,13 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
$this->_to_apple($contact, $vc);
}
- if (!empty($contact['changed']))
- $vc->add(VObjectUtils::datetime_prop('REV', $contact['changed'], true));
+ if (!empty($contact['changed']) && is_a($contact['changed'], 'DateTime'))
+ $vc->REV = $contact['changed']->format('Ymd\\THis\\Z');
+
+ // convert to VCard4.0
+ // if ($v4) {
+ // $vc->convert(VObject\Document::VCARD40);
+ //}
return $vc->serialize();
}
@@ -845,10 +858,11 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
);
if ($vc->REV) {
- try { $contact['changed'] = $vc->REV->getDateTime(); }
+ try {
+ $contact['changed'] = DateTimeParser::parseDateTime(strval($vc->REV));
+ }
catch (\Exception $e) {
- try { $contact['changed'] = new \DateTime(strval($vc->REV)); }
- catch (\Exception $e) { }
+ // ignore
}
}
@@ -862,21 +876,23 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
if (!($prop instanceof VObject\Property))
continue;
+ $value = strval($prop);
+
switch ($prop->name) {
case 'N':
list($contact['surname'], $contact['firstname'], $contact['middlename'], $contact['prefix'], $contact['suffix']) = $prop->getParts();
break;
case 'NOTE':
- $contact['notes'] = $prop->value;
+ $contact['notes'] = $value;
break;
case 'TITLE':
- $contact['jobtitle'] = $prop->value;
+ $contact['jobtitle'] = $value;
break;
case 'NICKNAME':
- $contact[strtolower($prop->name)] = $prop->value;
+ $contact[strtolower($prop->name)] = $value;
break;
case 'ORG':
@@ -890,54 +906,54 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
case 'EMAIL':
$types = array_values(self::array_filter($prop->offsetGet('type'), 'internet,pref', true));
- $contact['email'][] = array('address' => $prop->value, 'type' => strtolower($types[0] ?: 'other'));
+ $contact['email'][] = array('address' => $value, 'type' => strtolower($types[0] ?: 'other'));
break;
case 'URL':
$types = array_values(self::array_filter($prop->offsetGet('type'), 'internet,pref', true));
- $contact['website'][] = array('url' => $prop->value, 'type' => strtolower($types[0]));
+ $contact['website'][] = array('url' => $value, 'type' => strtolower($types[0]));
break;
case 'TEL':
$types = array_values(self::array_filter($prop->offsetGet('type'), 'internet,pref', true));
$type = strtolower($types[0]);
- $contact['phone'][] = array('number' => $prop->value, 'type' => $phonetypemap[$type] ?: $type);
+ $contact['phone'][] = array('number' => $value, 'type' => $phonetypemap[$type] ?: $type);
break;
case 'ADR':
$type = $prop->offsetGet('type') ?: $prop->parameters[0];
- $adr = array('type' => strtolower($type->value ?: $type->name));
+ $adr = array('type' => strtolower(strval($type) ?: $type->name));
list(,, $adr['street'], $adr['locality'], $adr['region'], $adr['code'], $adr['country']) = $prop->getParts();
$contact['address'][] = $adr;
break;
case 'BDAY':
- $contact['birthday'] = new \DateTime($prop->value);
+ $contact['birthday'] = new \DateTime($value);
$contact['birthday']->_dateonly = true;
break;
case 'ANNIVERSARY':
case 'X-ANNIVERSARY':
- $contact['anniversary'] = new \DateTime($prop->value);
+ $contact['anniversary'] = new \DateTime($value);
$contact['anniversary']->_dateonly = true;
break;
case 'SEX':
case 'GENDER':
case 'X-GENDER':
- $contact['gender'] = $prop->value;
+ $contact['gender'] = $value;
break;
case 'ROLE':
case 'X-PROFESSION':
- $contact['profession'] = $prop->value;
+ $contact['profession'] = $value;
break;
case 'X-MANAGER':
case 'X-ASSISTANT':
case 'X-CHILDREN':
case 'X-SPOUSE':
- $contact[strtolower(substr($prop->name, 2))] = explode(',', $prop->value);
+ $contact[strtolower(substr($prop->name, 2))] = explode(',', $value);
break;
case 'X-JABBER':
@@ -947,15 +963,15 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
case 'X-YAHOO':
case 'X-SKYPE':
$protocol = strtolower(substr($prop->name, 2));
- $contact['im'][] = ($this->improtocols[$protocol] ?: $protocol) . ':' . preg_replace('/^[a-z]+:/i', '', $prop->value);
+ $contact['im'][] = ($this->improtocols[$protocol] ?: $protocol) . ':' . preg_replace('/^[a-z]+:/i', '', $value);
break;
case 'IMPP':
$prot = null;
- if (preg_match('/^[a-z]+:/i', $prop->value))
- list($prot, $val) = explode(':', $prop->value, 2);
+ if (preg_match('/^[a-z]+:/i', $value))
+ list($prot, $val) = explode(':', $value, 2);
else
- $val = $prop->value;
+ $val = $value;
$type = strtolower((string)$prop->offsetGet('X-SERVICE-TYPE'));
$protocol = $type && (!$prot || $prot == 'aim') ? ($this->improtocols[$type] ?: $type) : $prot;
$contact['im'][] = ($this->improtocols[$protocol] ?: $protocol) . ':' . urldecode($val);
@@ -963,45 +979,45 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
case 'PHOTO':
$param = $prop->offsetGet('encoding') ?: $prop->parameters[0];
- if ($param->value && (strtolower($param->value) == 'b' || strtolower($param->value) == 'base64') || strtolower($param->name) == 'base64') {
- $contact['photo'] = base64_decode($prop->value);
+ if (($pvalue = $param->getValue()) && (strtolower($pvalue) == 'b' || strtolower($pvalue) == 'base64') || strtolower($param->name) == 'base64') {
+ $contact['photo'] = $value;
}
break;
// VCard 4.0 properties
case 'FBURL':
- $contact['freebusyurl'] = $prop->value;
+ $contact['freebusyurl'] = $value;
break;
case 'LANG':
- $contact['lang'][] = $prop->value;
+ $contact['lang'][] = $value;
break;
case 'RELATED':
$type = strtolower($prop->offsetGet('type'));
if ($field = $this->related_map[$type]) {
- $contact[$field][] = $prop->value;
+ $contact[$field][] = $value;
}
else {
- $contact['related'][] = $prop->value;
+ $contact['related'][] = $value;
}
break;
case 'KIND':
case 'X-ADDRESSBOOKSERVER-KIND':
- if (strtolower($prop->value) == 'group') {
+ if (strtolower($value) == 'group') {
$contact['_type'] = 'distribution-list';
}
break;
case 'MEMBER':
case 'X-ADDRESSBOOKSERVER-MEMBER':
- if (strpos($prop->value, 'urn:uuid:') === 0) {
- $contact['member'][] = array('uid' => substr($prop->value, 9));
+ if (strpos($value, 'urn:uuid:') === 0) {
+ $contact['member'][] = array('uid' => substr($value, 9));
}
- else if (strpos($prop->value, 'mailto:') === 0) {
- $member = reset(\rcube_mime::decode_address_list(urldecode(substr($prop->value, 7))));
+ else if (strpos($value, 'mailto:') === 0) {
+ $member = reset(\rcube_mime::decode_address_list(urldecode(substr($value, 7))));
if ($member['mailto'])
$contact['member'][] = array('email' => $member['mailto'], 'name' => $member['name']);
}
@@ -1015,7 +1031,7 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
default:
if (substr($prop->name, 0, 2) == 'X-' || substr($prop->name, 0, 6) == 'CUSTOM') {
$prefix = $prop->group ? $prop->group . '.' : '';
- $contact['x-custom'][] = array($prefix . $prop->name, strval($prop->value));
+ $contact['x-custom'][] = array($prefix . $prop->name, strval($value));
}
break;
}
@@ -1036,7 +1052,7 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
foreach ($vc->select($propname) as $prop) {
$labelkey = $prop->group ? $prop->group . '.X-ABLABEL' : 'X-ABLABEL';
$labels = $vc->select($labelkey);
- $field = !empty($labels) && ($label = reset($labels)) ? strtolower(trim($label->value, '_$!<>')) : null;
+ $field = !empty($labels) && ($label = reset($labels)) ? strtolower(trim(strval($label), '_$!<>')) : null;
if ($field) {
$prop->group = null;
$prop->name = ($known_map[$field] ?: $propname . '-' . strtoupper($field));
@@ -1086,10 +1102,9 @@ class ContactsBackend extends CardDAV\Backend\AbstractBackend
$prop->group = $group;
$vc->add($prop);
- $ablabel = new VObject\Property('X-ABLabel');
- $ablabel->name = 'X-ABLabel';
+ $ablabel = $vc->create('X-ABLabel');
$ablabel->group = $group;
- $ablabel->value = in_array($label, $this->xab_known_labels) ? '_$!<'.ucfirst($label).'>!$_' : ucfirst($label);
+ $ablabel->setValue(in_array($label, $this->xab_known_labels) ? '_$!<'.ucfirst($label).'>!$_' : ucfirst($label));
$vc->add($ablabel);
unset($vc->{$name});
diff --git a/lib/Kolab/CardDAV/LDAPDirectory.php b/lib/Kolab/CardDAV/LDAPDirectory.php
index 4030e11..7968ab9 100644
--- a/lib/Kolab/CardDAV/LDAPDirectory.php
+++ b/lib/Kolab/CardDAV/LDAPDirectory.php
@@ -396,17 +396,16 @@ class LDAPDirectory extends DAV\Collection implements \Sabre\CardDAV\IDirectory,
}
/**
- * Updates properties on this node,
+ * Updates properties on this node.
*
- * @param array $mutations
- * @return bool|array
+ * @param PropPatch $propPatch
+ * @return void
*/
- function updateProperties($mutations)
+ public function propPatch(DAV\PropPatch $propPatch)
{
- console(__METHOD__, $mutations);
- return false;
+ console(__METHOD__, $propPatch);
+ // NOP
}
-
/**
* Post-process the given contact record from rcube_ldap
*/
diff --git a/lib/Kolab/CardDAV/Plugin.php b/lib/Kolab/CardDAV/Plugin.php
index 1441d29..ef8a0ec 100644
--- a/lib/Kolab/CardDAV/Plugin.php
+++ b/lib/Kolab/CardDAV/Plugin.php
@@ -50,9 +50,9 @@ class Plugin extends CardDAV\Plugin
{
parent::initialize($server);
- $server->subscribeEvent('beforeMethod', array($this, 'beforeMethod'));
- $server->subscribeEvent('afterCreateFile', array($this, 'afterWriteContent'));
- $server->subscribeEvent('afterWriteContent', array($this, 'afterWriteContent'));
+ $server->on('beforeMethod', array($this, 'beforeMethod'));
+ $server->on('afterCreateFile', array($this, 'afterWriteContent'));
+ $server->on('afterWriteContent', array($this, 'afterWriteContent'));
}
/**
diff --git a/lib/Kolab/CardDAV/UserAddressBooks.php b/lib/Kolab/CardDAV/UserAddressBooks.php
index 6beb78a..56f76f0 100644
--- a/lib/Kolab/CardDAV/UserAddressBooks.php
+++ b/lib/Kolab/CardDAV/UserAddressBooks.php
@@ -118,19 +118,14 @@ class UserAddressBooks extends \Sabre\CardDAV\UserAddressBooks implements DAV\IE
}
/**
- * Updates properties such as the display name and description
+ * Updates properties on this node.
*
- * @param array $mutations
- * @return array
+ * @param PropPatch $propPatch
+ * @return void
*/
- public function updateProperties($mutations)
+ public function propPatch(DAV\PropPatch $propPatch)
{
- $errors = array();
-
- foreach ($mutations as $prop => $val) {
- $errors[403][$prop] = null;
- }
-
- return $errors;
+ console(__METHOD__, $propPatch);
+ // NOP
}
}
diff --git a/lib/Kolab/DAVACL/PrincipalBackend.php b/lib/Kolab/DAVACL/PrincipalBackend.php
index 908aca3..d22cd8e 100644
--- a/lib/Kolab/DAVACL/PrincipalBackend.php
+++ b/lib/Kolab/DAVACL/PrincipalBackend.php
@@ -31,7 +31,7 @@ use Kolab\DAV\Auth\HTTPBasic;
/**
* Kolab Principal Backend
*/
-class PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\BackendInterface
+class PrincipalBackend extends \Sabre\DAVACL\PrincipalBackend\AbstractBackend implements \Sabre\DAVACL\PrincipalBackend\BackendInterface
{
/**
* Sets up the backend.
@@ -138,7 +138,7 @@ class PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\BackendInterfac
// TODO: for now the group principal has only one member, the user itself
list($prefix, $name) = URLUtil::splitPath($principal);
- $principal = $this->getPrincipalByPath($prefix);
+ $principal = $this->getPrincipalByPath($principal);
if (!$principal) throw new Exception('Principal not found');
return array(
@@ -190,7 +190,7 @@ class PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\BackendInterfac
throw new Exception('Setting members of the group is not supported yet');
}
- function updatePrincipal($path, $mutations)
+ function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch)
{
return 0;
}
@@ -217,9 +217,10 @@ class PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\BackendInterfac
*
* @param string $prefixPath
* @param array $searchProperties
+ * @param string $test
* @return array
*/
- function searchPrincipals($prefixPath, array $searchProperties)
+ function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof')
{
console(__METHOD__, $prefixPath, $searchProperties);
diff --git a/lib/Kolab/Utils/DAVBackend.php b/lib/Kolab/Utils/DAVBackend.php
index cb3e56b..7bef0f6 100644
--- a/lib/Kolab/Utils/DAVBackend.php
+++ b/lib/Kolab/Utils/DAVBackend.php
@@ -81,6 +81,33 @@ class DAVBackend
}
/**
+ * Set callback handler for property changes on the given folder
+ *
+ * @param object $folder kolab_storage_folder instance to operate on
+ * @param oject $propPatch PropPatch instance with the property updates
+ */
+ public static function handle_propatch($folder, \Sabre\DAV\PropPatch $propPatch)
+ {
+ $propPatch->handle(
+ array('{DAV:}displayname','{http://apple.com/ns/ical/}calendar-color'),
+ function($mutations) use ($folder) {
+ $result = DAVBackend::folder_update($folder, $mutations);
+ if (is_array($result)) {
+ $ret = array();
+ foreach ($result as $code => $props) {
+ foreach (array_keys($props) as $prop) {
+ $ret[$prop] = $code;
+ }
+ }
+ }
+ else {
+ $ret = $result;
+ }
+ return $ret;
+ });
+ }
+
+ /**
* Updates properties for a recourse (kolab folder)
*
* The mutations array uses the propertyName in clark-notation as key,
@@ -95,8 +122,8 @@ class DAVBackend
* failures is returned.
*
* @param object $folder kolab_storage_folder instance to operate on
- * @param array $mutations Hash array with propeties to change
- * @return bool|array
+ * @param object $mutations Hash array with propeties to change
+ * @return void
*/
public static function folder_update($folder, array $mutations)
{
diff --git a/lib/Kolab/Utils/DAVLogger.php b/lib/Kolab/Utils/DAVLogger.php
index c1c3067..94a39ba 100644
--- a/lib/Kolab/Utils/DAVLogger.php
+++ b/lib/Kolab/Utils/DAVLogger.php
@@ -62,9 +62,9 @@ class DAVLogger extends DAV\ServerPlugin
{
$this->server = $server;
- $server->subscribeEvent('beforeMethod', array($this, '_beforeMethod'), 15);
- $server->subscribeEvent('exception', array($this, '_exception'));
- $server->subscribeEvent('exit', array($this, '_exit'));
+ $server->on('beforeMethod', array($this, '_beforeMethod'), 15);
+ $server->on('exception', array($this, '_exception'));
+ $server->on('exit', array($this, '_exit'));
// replace $server->httpResponse with a derived class that can do logging
$server->httpResponse = new HTTPResponse();
@@ -108,7 +108,7 @@ class DAVLogger extends DAV\ServerPlugin
$http_headers[$hdr] = "$hdr: $value";
}
- $this->write_log('httpraw', $request->getMethod() . ' ' . $request->getUri() . ' ' . $_SERVER['SERVER_PROTOCOL'] . "\n" .
+ $this->write_log('httpraw', $request->getMethod() . ' ' . $request->getUrl() . ' ' . $_SERVER['SERVER_PROTOCOL'] . "\n" .
join("\n", $http_headers) . "\n\n" . $http_body);
}
diff --git a/lib/Kolab/Utils/HTTPResponse.php b/lib/Kolab/Utils/HTTPResponse.php
index 4f4e72d..7fefcba 100644
--- a/lib/Kolab/Utils/HTTPResponse.php
+++ b/lib/Kolab/Utils/HTTPResponse.php
@@ -28,9 +28,9 @@ namespace Kolab\Utils;
*/
class HTTPResponse extends \Sabre\HTTP\Response
{
- private $status;
- private $body = '';
- private $headers = array();
+ protected $status;
+ protected $body = '';
+ protected $_headers = array();
/**
* Sends an HTTP status header to the client.
@@ -52,8 +52,9 @@ class HTTPResponse extends \Sabre\HTTP\Response
* @param bool $replace
* @return bool
*/
- public function setHeader($name, $value, $replace = true) {
- $this->headers[$name] = $value;
+ public function setHeader($name, $value, $replace = true)
+ {
+ $this->_headers[$name] = $value;
return parent::setHeader($name, $value, $replace);
}
@@ -83,7 +84,7 @@ class HTTPResponse extends \Sabre\HTTP\Response
public function dump()
{
$result_headers = '';
- foreach ($this->headers as $hdr => $value) {
+ foreach ($this->_headers as $hdr => $value) {
$result_headers .= "\n$hdr: " . $value;
}
diff --git a/lib/Kolab/Utils/VObjectUtils.php b/lib/Kolab/Utils/VObjectUtils.php
index 82f934b..9131597 100644
--- a/lib/Kolab/Utils/VObjectUtils.php
+++ b/lib/Kolab/Utils/VObjectUtils.php
@@ -61,10 +61,19 @@ class VObjectUtils
* @param string Property name
* @param object DateTime
*/
- public static function datetime_prop($name, $dt, $utc = false)
+ public static function datetime_prop($root, $name, $dt, $utc = false)
{
- $vdt = new Property\DateTime($name);
- $vdt->setDateTime($dt, $dt->_dateonly ? Property\DateTime::DATE : ($utc ? Property\DateTime::UTC : Property\DateTime::LOCALTZ));
+ if ($utc) {
+ $dt->setTimeZone(new \DateTimeZone('UTC'));
+ }
+
+ $vdt = $root->createProperty($name);
+ $vdt->setValue($dt);
+
+ if ($dt->_dateonly) {
+ $vdt['VALUE'] = 'DATE';
+ }
+
return $vdt;
}
diff --git a/public_html/index.php b/public_html/index.php
index 04e7f53..9b9c201 100644
--- a/public_html/index.php
+++ b/public_html/index.php
@@ -5,7 +5,7 @@
*
* This is the public API to provide *DAV-based access to the Kolab Groupware backend
*
- * @version 0.3-dev
+ * @version 0.4-dev
* @author Thomas Bruederli <bruederli@kolabsys.com>
*
* Copyright (C) 2013-2014, Kolab Systems AG <contact@kolabsys.com>
@@ -26,7 +26,7 @@
// define some environment variables used throughout the app and libraries
define('KOLAB_DAV_ROOT', realpath('../'));
-define('KOLAB_DAV_VERSION', '0.3-dev');
+define('KOLAB_DAV_VERSION', '0.4-dev');
define('KOLAB_DAV_START', microtime(true));
define('RCUBE_INSTALL_PATH', KOLAB_DAV_ROOT . '/');
@@ -155,7 +155,7 @@ $server->addPlugin(new \Sabre\DAVACL\Plugin());
if ($services['CALDAV']) {
$caldav_plugin = new \Kolab\CalDAV\Plugin();
- $caldav_plugin->setIMipHandler(new \Kolab\CalDAV\IMip());
+ #$caldav_plugin->setIMipHandler(new \Kolab\CalDAV\IMip());
$server->addPlugin($caldav_plugin);
}
@@ -178,7 +178,7 @@ if (getenv('DAVBROWSER')) {
}
// log exceptions in iRony error log
-$server->subscribeEvent('exception', function($e){
+$server->on('exception', function($e){
if (!($e instanceof \Sabre\DAV\Exception) || $e->getHTTPCode() == 500) {
rcube::raise_error(array(
'code' => 500,
@@ -194,4 +194,4 @@ $server->subscribeEvent('exception', function($e){
$server->exec();
// trigger log
-$server->broadcastEvent('exit', array());
+$server->emit('exit', array());