[Pkg-owncloud-commits] [php-sabredav] 28/275: Calendar-query and calendar-multiget for inbox.

David Prévot taffit at moszumanska.debian.org
Thu Sep 25 14:55:47 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 663153fb43dc35b4cd1de2cdc74347f7eae29765
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Mon Jan 6 18:33:15 2014 +0100

    Calendar-query and calendar-multiget for inbox.
---
 lib/Sabre/CalDAV/Backend/AbstractBackend.php       |  3 +-
 lib/Sabre/CalDAV/ICalendar.php                     | 20 +-----------
 ...{ICalendar.php => ICalendarObjectContainer.php} | 21 +++++++------
 lib/Sabre/CalDAV/Plugin.php                        |  4 +--
 lib/Sabre/CalDAV/Schedule/IInbox.php               |  2 +-
 lib/Sabre/CalDAV/Schedule/Inbox.php                | 36 +++++++++++++++++++++-
 6 files changed, 51 insertions(+), 35 deletions(-)

diff --git a/lib/Sabre/CalDAV/Backend/AbstractBackend.php b/lib/Sabre/CalDAV/Backend/AbstractBackend.php
index 6ae6c66..9a7fd9c 100644
--- a/lib/Sabre/CalDAV/Backend/AbstractBackend.php
+++ b/lib/Sabre/CalDAV/Backend/AbstractBackend.php
@@ -161,8 +161,7 @@ abstract class AbstractBackend implements BackendInterface {
             $object = $this->getCalendarObject($object['calendarid'], $object['uri']);
         }
 
-        $data = is_resource($object['calendardata'])?stream_get_contents($object['calendardata']):$object['calendardata'];
-        $vObject = VObject\Reader::read($data);
+        $vObject = VObject\Reader::read($object['calendardata']);
 
         $validator = new CalDAV\CalendarQueryValidator();
         return $validator->validate($vObject, $filters);
diff --git a/lib/Sabre/CalDAV/ICalendar.php b/lib/Sabre/CalDAV/ICalendar.php
index a939f7b..052221d 100644
--- a/lib/Sabre/CalDAV/ICalendar.php
+++ b/lib/Sabre/CalDAV/ICalendar.php
@@ -15,25 +15,7 @@ use
  * @author Evert Pot (http://evertpot.com/)
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-interface ICalendar extends DAV\ICollection, DAVACL\IACL {
+interface ICalendar extends ICalendarObjectContainer, DAVACL\IACL {
 
-    /**
-     * Performs a calendar-query on the contents of this calendar.
-     *
-     * The calendar-query is defined in RFC4791 : CalDAV. Using the
-     * calendar-query it is possible for a client to request a specific set of
-     * object, based on contents of iCalendar properties, date-ranges and
-     * iCalendar component types (VTODO, VEVENT).
-     *
-     * This method should just return a list of (relative) urls that match this
-     * query.
-     *
-     * The list of filters are specified as an array. The exact array is
-     * documented by \Sabre\CalDAV\CalendarQueryParser.
-     *
-     * @param array $filters
-     * @return array
-     */
-    public function calendarQuery(array $filters);
 
 }
diff --git a/lib/Sabre/CalDAV/ICalendar.php b/lib/Sabre/CalDAV/ICalendarObjectContainer.php
similarity index 65%
copy from lib/Sabre/CalDAV/ICalendar.php
copy to lib/Sabre/CalDAV/ICalendarObjectContainer.php
index a939f7b..6343e94 100644
--- a/lib/Sabre/CalDAV/ICalendar.php
+++ b/lib/Sabre/CalDAV/ICalendarObjectContainer.php
@@ -2,20 +2,20 @@
 
 namespace Sabre\CalDAV;
 
-use
-    Sabre\DAV,
-    Sabre\DAVACL;
-
 /**
- * Calendar interface
+ * This interface represents a node that may contain calendar objects.
+ *
+ * This is the shared parent for both the Inbox collection and calendars 
+ * resources.
  *
- * Implement this interface to allow a node to be recognized as an calendar.
+ * In most cases you will likely want to look at ICalendar instead of this 
+ * interface.
  *
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
+ * @copyright Copyright (C) 2007-2014 fruux GmbH. All rights reserved.
+ * @author Evert Pot (http://evertpot.com/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-interface ICalendar extends DAV\ICollection, DAVACL\IACL {
+interface ICalendarObjectContainer extends \Sabre\DAV\ICollection {
 
     /**
      * Performs a calendar-query on the contents of this calendar.
@@ -36,4 +36,5 @@ interface ICalendar extends DAV\ICollection, DAVACL\IACL {
      */
     public function calendarQuery(array $filters);
 
-}
+
+} 
diff --git a/lib/Sabre/CalDAV/Plugin.php b/lib/Sabre/CalDAV/Plugin.php
index 1109f16..ca3f927 100644
--- a/lib/Sabre/CalDAV/Plugin.php
+++ b/lib/Sabre/CalDAV/Plugin.php
@@ -132,7 +132,7 @@ class Plugin extends DAV\ServerPlugin {
         $node = $this->server->tree->getNodeForPath($uri);
 
         $reports = array();
-        if ($node instanceof ICalendar || $node instanceof ICalendarObject) {
+        if ($node instanceof ICalendarObjectContainer || $node instanceof ICalendarObject) {
             $reports[] = '{' . self::NS_CALDAV . '}calendar-multiget';
             $reports[] = '{' . self::NS_CALDAV . '}calendar-query';
         }
@@ -555,7 +555,7 @@ class Plugin extends DAV\ServerPlugin {
 
         // If we're dealing with a calendar, the calendar itself is responsible
         // for the calendar-query.
-        if ($node instanceof ICalendar && $depth = 1) {
+        if ($node instanceof ICalendarObjectContainer && $depth = 1) {
 
             $nodePaths = $node->calendarQuery($parser->filters);
 
diff --git a/lib/Sabre/CalDAV/Schedule/IInbox.php b/lib/Sabre/CalDAV/Schedule/IInbox.php
index 375ba13..0f7357e 100644
--- a/lib/Sabre/CalDAV/Schedule/IInbox.php
+++ b/lib/Sabre/CalDAV/Schedule/IInbox.php
@@ -10,6 +10,6 @@ namespace Sabre\CalDAV\Schedule;
  * @author Evert Pot (http://evertpot.com/)
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-interface IInbox extends \Sabre\DAV\ICollection, \Sabre\DAVACL\IACL {
+interface IInbox extends \Sabre\CalDAV\ICalendarObjectContainer, \Sabre\DAVACL\IACL {
 
 }
diff --git a/lib/Sabre/CalDAV/Schedule/Inbox.php b/lib/Sabre/CalDAV/Schedule/Inbox.php
index 94f12bf..fcd215b 100644
--- a/lib/Sabre/CalDAV/Schedule/Inbox.php
+++ b/lib/Sabre/CalDAV/Schedule/Inbox.php
@@ -6,7 +6,8 @@ use
     Sabre\DAV,
     Sabre\CalDAV,
     Sabre\DAVACL,
-    Sabre\CalDAV\Backend;
+    Sabre\CalDAV\Backend,
+    Sabre\VObject;
 
 /**
  * The CalDAV scheduling inbox 
@@ -165,4 +166,37 @@ class Inbox extends DAV\Collection implements IInbox {
 
     }
 
+    /**
+     * Performs a calendar-query on the contents of this calendar.
+     *
+     * The calendar-query is defined in RFC4791 : CalDAV. Using the
+     * calendar-query it is possible for a client to request a specific set of
+     * object, based on contents of iCalendar properties, date-ranges and
+     * iCalendar component types (VTODO, VEVENT).
+     *
+     * This method should just return a list of (relative) urls that match this
+     * query.
+     *
+     * The list of filters are specified as an array. The exact array is
+     * documented by \Sabre\CalDAV\CalendarQueryParser.
+     *
+     * @param array $filters
+     * @return array
+     */
+    public function calendarQuery(array $filters) {
+
+        $result = [];
+        $validator = new CalDAV\CalendarQueryValidator();
+
+        $objects = $this->getChildren();
+        foreach($objects as $object) {
+            $vObject = VObject\Reader::read($object['calendardata']);
+            if ($validator->validate($vObject, $filters)) {
+                $result[] = $object['uri'];
+            }
+        }
+        return $result;
+
+    }
+
 }

-- 
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