[Pkg-owncloud-commits] [php-sabredav] 07/40: Mapping the old availability property to the new one.
David Prévot
taffit at moszumanska.debian.org
Sat Sep 5 15:24:07 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag 3.1.0-alpha2
in repository php-sabredav.
commit 7611a8ccdc9aa0a63df0ea36ff55fa5ed0229748
Author: Evert Pot <me at evertpot.com>
Date: Fri Jul 24 14:00:13 2015 -0400
Mapping the old availability property to the new one.
Needs test.
---
lib/CalDAV/Schedule/Plugin.php | 48 ++++++++++++++++++++++++++++++++++++++++++
lib/DAV/PropPatch.php | 9 +++++++-
lib/DAV/Server.php | 16 ++++++++++----
3 files changed, 68 insertions(+), 5 deletions(-)
diff --git a/lib/CalDAV/Schedule/Plugin.php b/lib/CalDAV/Schedule/Plugin.php
index 833f67d..c4e1aa0 100644
--- a/lib/CalDAV/Schedule/Plugin.php
+++ b/lib/CalDAV/Schedule/Plugin.php
@@ -101,6 +101,7 @@ class Plugin extends ServerPlugin {
$this->server = $server;
$server->on('method:POST', [$this, 'httpPost']);
$server->on('propFind', [$this, 'propFind']);
+ $server->on('propPatch', [$this, 'propPatch']);
$server->on('calendarObjectChange', [$this, 'calendarObjectChange']);
$server->on('beforeUnbind', [$this, 'beforeUnbind']);
$server->on('schedule', [$this, 'scheduleLocalDelivery']);
@@ -250,6 +251,30 @@ class Plugin extends ServerPlugin {
});
+ // Mapping the old property to the new property.
+ $propFind->handle('{https://calendarserver.org/ns/}calendar-availability', function() use ($propFind, $node) {
+
+ // In case it wasn't clear, the only difference is that we map the
+ // old property to a different namespace.
+ $availProp = '{' . self::NS_CALDAV . '}calendar-availability';
+ $subPropFind = new PropFind(
+ $propFind->getPath(),
+ $availProp
+ );
+
+ $this->server->getPropertiesByNode(
+ $subPropFind,
+ $node
+ );
+
+ $propFind->set(
+ '{https://calendarserver.org/ns/}calendar-availability',
+ $subPropFind->get($availProp),
+ $subPropFind->getStatus($availProp)
+ );
+
+ });
+
// The server currently reports every principal to be of type
// 'INDIVIDUAL'
$propFind->handle('{' . self::NS_CALDAV . '}calendar-user-type', function() {
@@ -261,6 +286,29 @@ class Plugin extends ServerPlugin {
}
/**
+ * This method is called during property updates.
+ *
+ * @param string $path
+ * @param PropPatch $propPatch
+ * @return void
+ */
+ function propPatch($path, PropPatch $propPatch) {
+
+ // Mapping the old property to the new property.
+ $propPatch->handle('{https://calendarserver.org/ns/}calendar-availability', function($value) use ($path) {
+
+ $availProp = '{' . self::NS_CALDAV . '}calendar-availability';
+ $subPropPatch = new PropPatch([$availProp => $value]);
+ $this->server->emit('propPatch', [$path, $subPropPatch]);
+ $subPropPatch->commit();
+
+ return $subPropPatch->getResult()[$availProp];
+
+ });
+
+ }
+
+ /**
* This method is triggered whenever there was a calendar object gets
* created or updated.
*
diff --git a/lib/DAV/PropPatch.php b/lib/DAV/PropPatch.php
index f8f0bdf..56c7412 100644
--- a/lib/DAV/PropPatch.php
+++ b/lib/DAV/PropPatch.php
@@ -71,7 +71,14 @@ class PropPatch {
* "{DAV:}displayname" and a second argument that's a method that does the
* actual updating.
*
- * It's possible to specify more than one property.
+ * It's possible to specify more than one property as an array.
+ *
+ * The callback must return a boolean or an it. If the result is true, the
+ * operation was considered successful. If it's false, it's consided
+ * failed.
+ *
+ * If the result is an integer, we'll use that integer as the http status
+ * code associated with the operation.
*
* @param string|string[] $properties
* @param callable $callback
diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php
index e2a0f08..c8273b1 100644
--- a/lib/DAV/Server.php
+++ b/lib/DAV/Server.php
@@ -751,9 +751,13 @@ class Server extends EventEmitter {
/**
* Returns a list of properties for a path
*
- * This is a simplified version getPropertiesForPath.
- * if you aren't interested in status codes, but you just
- * want to have a flat list of properties. Use this method.
+ * This is a simplified version getPropertiesForPath. If you aren't
+ * interested in status codes, but you just want to have a flat list of
+ * properties, use this method.
+ *
+ * Please note though that any problems related to retrieving properties,
+ * such as permission issues will just result in an empty array being
+ * returned.
*
* @param string $path
* @param array $propertyNames
@@ -761,7 +765,11 @@ class Server extends EventEmitter {
function getProperties($path, $propertyNames) {
$result = $this->getPropertiesForPath($path, $propertyNames, 0);
- return $result[0][200];
+ if (isset($result[0][200])) {
+ return $result[0][200];
+ } else {
+ return [];
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list