[Pkg-owncloud-commits] [php-sabredav] 91/275: Moved getCalendarObjectsByUID to base interface.
David Prévot
taffit at moszumanska.debian.org
Thu Sep 25 14:55:55 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 938da2282ff94878a09a9e081db7613daa2d1f94
Author: Evert Pot <me at evertpot.com>
Date: Wed Jul 16 01:20:01 2014 -0400
Moved getCalendarObjectsByUID to base interface.
Added a christmas tree of doom.
---
lib/CalDAV/Backend/AbstractBackend.php | 65 +++++++++++++++++++++++++++++++++
lib/CalDAV/Backend/BackendInterface.php | 15 +++++---
lib/CalDAV/Backend/PDO.php | 20 ----------
lib/CalDAV/CalendarHome.php | 24 ++++++++++++
4 files changed, 99 insertions(+), 25 deletions(-)
diff --git a/lib/CalDAV/Backend/AbstractBackend.php b/lib/CalDAV/Backend/AbstractBackend.php
index 1f14ec2..a5e3723 100644
--- a/lib/CalDAV/Backend/AbstractBackend.php
+++ b/lib/CalDAV/Backend/AbstractBackend.php
@@ -146,5 +146,70 @@ abstract class AbstractBackend implements BackendInterface {
}
+ /**
+ * Searches through all of a users calendars and calendar objects to find
+ * an object with a specific UID.
+ *
+ * This method should return the path to this object, relative to the
+ * calendar home, so this path usually only contains two parts:
+ *
+ * calendarpath/objectpath.ics
+ *
+ * If the uid is not found, return null.
+ *
+ * This method should only consider * objects that the principal owns, so
+ * any calendars owned by other principals that also appear in this
+ * collection should be ignored.
+ *
+ * @param string $principalUri
+ * @param string $uid
+ * @return string|null
+ */
+ public function getCalendarObjectByUID($principalUri, $uid) {
+
+ // Note: this is a super slow naive implementation of this method. You
+ // are highly recommended to optimize it, if your backend allows it.
+ foreach($this->getCalendarsForUser($principalUri) as $calendar) {
+
+ // We must ignore calendars owned by other principals.
+ if ($calendar['principaluri']!==$principalUri) {
+ continue;
+ }
+
+ $results = $this->calendarQuery(
+ $calendar['id'],
+ [
+ 'name' => 'VCALENDAR',
+ 'prop-filters' => [],
+ 'comp-filters' => [
+ [
+ 'name' => 'VEVENT',
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ 'comp-filters' => [],
+ 'prop-filters' => [
+ [
+ 'name' => 'UID',
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ 'text-match' => [
+ 'value' => $uid,
+ 'negate-condition' => false,
+ 'collation' => 'i;octet',
+ ],
+ ],
+ ]
+ ]
+ ],
+ ]
+ );
+ if ($results) {
+ // We have a match
+ return $calendar['uri'] . '/' . $results[0];
+ }
+
+ }
+
+ }
}
diff --git a/lib/CalDAV/Backend/BackendInterface.php b/lib/CalDAV/Backend/BackendInterface.php
index 3a2156a..190c29d 100644
--- a/lib/CalDAV/Backend/BackendInterface.php
+++ b/lib/CalDAV/Backend/BackendInterface.php
@@ -247,15 +247,20 @@ interface BackendInterface {
* Searches through all of a users calendars and calendar objects to find
* an object with a specific UID.
*
- * The returned data should contain all the information getCalendarObject
- * also returns, but also include a 'calendarUri' property. This property
- * should *just* be the basename of the calendar.
+ * This method should return the path to this object, relative to the
+ * calendar home, so this path usually only contains two parts:
*
- * Return false if the object cannot be found.
+ * calendarpath/objectpath.ics
+ *
+ * If the uid is not found, return null.
+ *
+ * This method should only consider * objects that the principal owns, so
+ * any calendars owned by other principals that also appear in this
+ * collection should be ignored.
*
* @param string $principalUri
* @param string $uid
- * @return array|bool
+ * @return string|null
*/
public function getCalendarObjectByUID($principalUri, $uid);
diff --git a/lib/CalDAV/Backend/PDO.php b/lib/CalDAV/Backend/PDO.php
index 4e745e4..9f42e21 100755
--- a/lib/CalDAV/Backend/PDO.php
+++ b/lib/CalDAV/Backend/PDO.php
@@ -1172,24 +1172,4 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S
}
- /**
- * Searches through all of a users calendars and calendar objects to find
- * an object with a specific UID.
- *
- * The returned data should contain all the information getCalendarObject
- * also returns, but also include a 'calendarUri' property. This property
- * should *just* be the basename of the calendar.
- *
- * Return false if the object cannot be found.
- *
- * @param string $principalUri
- * @param string $uid
- * @return array|bool
- */
- public function getCalendarObjectByUID($principalUri, $uid) {
-
- throw new \Exception('Not implemented yet');
-
- }
-
}
diff --git a/lib/CalDAV/CalendarHome.php b/lib/CalDAV/CalendarHome.php
index 6d07a49..cc4717c 100644
--- a/lib/CalDAV/CalendarHome.php
+++ b/lib/CalDAV/CalendarHome.php
@@ -371,4 +371,28 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL {
}
+ /**
+ * Searches through all of a users calendars and calendar objects to find
+ * an object with a specific UID.
+ *
+ * This method should return the path to this object, relative to the
+ * calendar home, so this path usually only contains two parts:
+ *
+ * calendarpath/objectpath.ics
+ *
+ * If the uid is not found, return null.
+ *
+ * This method should only consider * objects that the principal owns, so
+ * any calendars owned by other principals that also appear in this
+ * collection should be ignored.
+ *
+ * @param string $uid
+ * @return string|null
+ */
+ public function getCalendarObjectByUID($uid) {
+
+ $this->caldavBackend->getCalendarObjectByUID($this->principalInfo['uri'], $uid);
+
+ }
+
}
--
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