[Pkg-owncloud-commits] [php-sabredav] 14/42: Support for calendar-timezone in scheduling freebusy request.

David Prévot taffit at moszumanska.debian.org
Fri Nov 28 22:47:48 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 b363dec61755f7da5abc4aea2bc6de4bca131f22
Author: Evert Pot <me at evertpot.com>
Date:   Thu Nov 13 20:25:18 2014 -0500

    Support for calendar-timezone in scheduling freebusy request.
---
 lib/CalDAV/Schedule/Plugin.php                      | 14 +++++++++++++-
 tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php |  3 ++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/CalDAV/Schedule/Plugin.php b/lib/CalDAV/Schedule/Plugin.php
index 38492d2..e4f04c5 100644
--- a/lib/CalDAV/Schedule/Plugin.php
+++ b/lib/CalDAV/Schedule/Plugin.php
@@ -3,6 +3,7 @@
 namespace Sabre\CalDAV\Schedule;
 
 use
+    DateTimeZone,
     Sabre\DAV\Server,
     Sabre\DAV\ServerPlugin,
     Sabre\DAV\Property\Href,
@@ -790,14 +791,24 @@ class Plugin extends ServerPlugin {
             }
 
             $sct = $caldavNS . 'schedule-calendar-transp';
-            $props = $node->getProperties([$sct]);
+            $ctz = $caldavNS . 'calendar-timezone';
+            $props = $node->getProperties([$sct, $ctz]);
 
             if (isset($props[$sct]) && $props[$sct]->getValue() == ScheduleCalendarTransp::TRANSPARENT) {
+                // If a calendar is marked as 'transparent', it means we must
+                // ignore it for free-busy purposes.
                 continue;
             }
 
             $aclPlugin->checkPrivileges($homeSet . $node->getName() ,$caldavNS . 'read-free-busy');
 
+            if (isset($props[$ctz])) {
+                $vtimezoneObj = VObject\Reader::read($props[$ctz]);
+                $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
+            } else {
+                $calendarTimeZone = new DateTimeZone('UTC');
+            }
+
             // Getting the list of object uris within the time-range
             $urls = $node->calendarQuery([
                 'name' => 'VCALENDAR',
@@ -834,6 +845,7 @@ class Plugin extends ServerPlugin {
         $generator->setObjects($objects);
         $generator->setTimeRange($start, $end);
         $generator->setBaseObject($vcalendar);
+        $generator->setTimeZone($calendarTimeZone);
 
         $result = $generator->getResult();
 
diff --git a/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php b/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
index eda0b8f..614934b 100644
--- a/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
+++ b/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
@@ -24,6 +24,7 @@ class FreeBusyRequestTest extends \PHPUnit_Framework_TestCase {
                 'principaluri' => 'principals/user2',
                 'id'           => 1,
                 'uri'          => 'calendar1',
+                '{' . CalDAV\Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR",
             ),
             array(
                 'principaluri' => 'principals/user2',
@@ -296,7 +297,7 @@ ICS;
             '<d:href>mailto:user3.sabredav at sabredav.org</d:href>',
             '<cal:request-status>2.0;Success</cal:request-status>',
             '<cal:request-status>3.7;Could not find principal</cal:request-status>',
-            'FREEBUSY;FBTYPE=BUSY:20110101T130000Z/20110101T140000Z',
+            'FREEBUSY;FBTYPE=BUSY:20110101T120000Z/20110101T130000Z',
         );
 
         foreach($strings as $string) {

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