[Pkg-owncloud-commits] [php-sabredav] 22/36: Using the calendar-availability property.

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 13:35:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit b60aaf68ddfb2f0479c8a9b845c62e3f971996ab
Author: Evert Pot <me at evertpot.com>
Date:   Sun Jul 19 18:21:44 2015 -0400

    Using the calendar-availability property.
---
 lib/CalDAV/Schedule/Plugin.php                  | 27 +++++++++++++++++++++++--
 tests/Sabre/CalDAV/Schedule/PluginBasicTest.php |  6 +++++-
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/lib/CalDAV/Schedule/Plugin.php b/lib/CalDAV/Schedule/Plugin.php
index 6d56180..6832bdb 100644
--- a/lib/CalDAV/Schedule/Plugin.php
+++ b/lib/CalDAV/Schedule/Plugin.php
@@ -72,7 +72,7 @@ class Plugin extends ServerPlugin {
      */
     function getFeatures() {
 
-        return ['calendar-auto-schedule'];
+        return ['calendar-auto-schedule', 'calendar-availability'];
 
     }
 
@@ -763,8 +763,11 @@ class Plugin extends ServerPlugin {
         $result = $aclPlugin->principalSearch(
             ['{http://sabredav.org/ns}email-address' => $email],
             [
-                '{DAV:}principal-URL', $caldavNS . 'calendar-home-set',
+                '{DAV:}principal-URL',
+                $caldavNS . 'calendar-home-set',
+                $caldavNS . 'schedule-inbox-URL',
                 '{http://sabredav.org/ns}email-address',
+
             ]
         );
 
@@ -781,7 +784,14 @@ class Plugin extends ServerPlugin {
                 'href'           => 'mailto:' . $email,
             ];
         }
+        if (!isset($result[0][200][$caldavNS . 'schedule-inbox-URL'])) {
+            return [
+                'request-status' => '3.7;No schedule-inbox-URL property found',
+                'href'           => 'mailto:' . $email,
+            ];
+        }
         $homeSet = $result[0][200][$caldavNS . 'calendar-home-set']->getHref();
+        $inboxUrl = $result[0][200][$caldavNS . 'schedule-inbox-URL']->getHref();
 
         // Grabbing the calendar list
         $objects = [];
@@ -838,6 +848,11 @@ class Plugin extends ServerPlugin {
 
         }
 
+        $inboxProps = $this->server->getProperties(
+            $inboxUrl,
+            $caldavNS . 'calendar-availability'
+        );
+
         $vcalendar = new VObject\Component\VCalendar();
         $vcalendar->METHOD = 'REPLY';
 
@@ -847,6 +862,14 @@ class Plugin extends ServerPlugin {
         $generator->setBaseObject($vcalendar);
         $generator->setTimeZone($calendarTimeZone);
 
+        if ($inboxProps) {
+            $generator->setVAvailability(
+                VObject\Reader::read(
+                    $inboxProps[$caldavNS . 'calendar-availability']
+                )
+            );
+        }
+
         $result = $generator->getResult();
 
         $vcalendar->VFREEBUSY->ATTENDEE = 'mailto:' . $email;
diff --git a/tests/Sabre/CalDAV/Schedule/PluginBasicTest.php b/tests/Sabre/CalDAV/Schedule/PluginBasicTest.php
index 375e6e9..cee911b 100644
--- a/tests/Sabre/CalDAV/Schedule/PluginBasicTest.php
+++ b/tests/Sabre/CalDAV/Schedule/PluginBasicTest.php
@@ -20,7 +20,11 @@ class PluginBasicTest extends \Sabre\DAVServerTest {
     function testOptions() {
 
         $plugin = new Plugin();
-        $this->assertEquals(['calendar-auto-schedule'], $plugin->getFeatures());
+        $expected = [
+            'calendar-auto-schedule',
+            'calendar-availability',
+        ];
+        $this->assertEquals($expected, $plugin->getFeatures());
 
     }
 

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