[Pkg-owncloud-commits] [php-sabredav] 93/275: Delegating some scheduling functionality to vobject's new itip stuff.

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 a4d56d0c38f7edd59199d08af991557df899b43c
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Thu Jul 17 01:26:18 2014 -0400

    Delegating some scheduling functionality to vobject's new itip stuff.
---
 composer.json                                      |  2 +-
 lib/CalDAV/Schedule/Plugin.php                     | 61 +++++-----------------
 .../Sabre/CalDAV/Schedule/DeliverNewEventTest.php  |  6 +--
 3 files changed, 16 insertions(+), 53 deletions(-)

diff --git a/composer.json b/composer.json
index 4dce44d..3ab5925 100644
--- a/composer.json
+++ b/composer.json
@@ -15,7 +15,7 @@
     ],
     "require": {
         "php": ">=5.4.1",
-        "sabre/vobject" : "~3.2.0",
+        "sabre/vobject" : "dev-itip",
         "sabre/event" : "~1.0.0",
         "sabre/http" : "~2.0.2",
         "ext-dom": "*",
diff --git a/lib/CalDAV/Schedule/Plugin.php b/lib/CalDAV/Schedule/Plugin.php
index 7b17a61..ed54e9d 100644
--- a/lib/CalDAV/Schedule/Plugin.php
+++ b/lib/CalDAV/Schedule/Plugin.php
@@ -12,6 +12,7 @@ use
     Sabre\HTTP\RequestInterface,
     Sabre\HTTP\ResponseInterface,
     Sabre\VObject,
+    Sabre\VObject\ITip,
     Sabre\DAVACL,
     Sabre\CalDAV\ICalendar,
     Sabre\DAV\Exception\NotFound,
@@ -404,58 +405,20 @@ class Plugin extends ServerPlugin {
             return;
         }
 
-        // For each attendee we're going to generate a scheduling message.
-        // We do this based on the original object.
-        //
-        // $vObj is the copy for the user that created the object. We will use
-        // that to update some values, such as SCHEDULE-STATUS per attendee.
-        $original = clone $vObj;
-
-        foreach($vevent->ATTENDEE as $attendee) {
-
-            if (!isset($attendee['SCHEDULE-AGENT'])) {
-                $agent = 'SERVER';
-            } else {
-                $agent = strtoupper($attendee['SCHEDULE-AGENT']);
-            }
-
-            // The SCHEDULE-AGENT parameter is 'SERVER' by default, but if it
-            // was set to 'NONE' or 'CLIENT', we are not responsible for
-            // delivering the message.
-            if ($agent!=='SERVER') continue;
-
-            $status = null;
+        $broker = new VObject\ITip\Broker();
+        $messages = $broker->createEvent($vObj);
 
-            // Currently only handling mailto: addresses.
-            if (strtolower(substr($attendee->getValue(),0,7))!=='mailto:') {
-                $status = '5.1;This server can currently only handle mailto: addresses';
-            } else {
+        foreach($messages as $message) {
 
-                $iTipMessage = new ITipMessage();
+            $this->deliver($message);
 
-                // Stripping the mailto:
-                $iTipMessage->recipient = strtolower(substr($attendee->getValue(), 7));
-                if (isset($attendee['CN'])) $iTipMessage->recipientName = (string)$attendee['CN'];
+            foreach($vObj->VEVENT->ATTENDEE as $attendee) {
 
-                $iTipMessage->sender = strtolower(substr($organizer, 7));
-                if (isset($vevent->ORGANIZER['CN'])) $iTipMessage->senderName = (string)$vevent->ORGANIZER['CN'];
-
-                // Skipping if sender matches the recipient
-                if ($iTipMessage->sender === $iTipMessage->recipient) {
-                    continue;
+                if ($attendee->getValue() === $message->recipient) {
+                    $attendee['SCHEDULE-STATUS'] = $message->scheduleStatus;
+                    break;
                 }
 
-                $iTipMessage->method = 'REQUEST';
-
-                $iTipBody = clone $original;
-                $iTipBody->METHOD = 'REQUEST';
-
-                $iTipMessage->message = $iTipBody;
-
-                $this->deliver($iTipMessage);
-
-                $attendee['SCHEDULE-STATUS'] = $iTipMessage->scheduleStatus;
-
             }
 
         }
@@ -476,10 +439,10 @@ class Plugin extends ServerPlugin {
     /**
      * This method is responsible for delivering the ITip message.
      *
-     * @param ITipMessage $itipMessage
+     * @param ITip\Message $itipMessage
      * @return void
      */
-    public function deliver(ITipMessage $iTipMessage) {
+    public function deliver(ITip\Message $iTipMessage) {
 
         /*
         $iTipMessage->scheduleStatus =
@@ -514,7 +477,7 @@ class Plugin extends ServerPlugin {
         $caldavNS = '{' . Plugin::NS_CALDAV . '}';
 
         $result = $aclPlugin->principalSearch(
-            ['{http://sabredav.org/ns}email-address' => $iTipMessage->recipient],
+            ['{http://sabredav.org/ns}email-address' => substr($iTipMessage->recipient, 7)],
             [
                 '{DAV:}principal-URL',
                  $caldavNS . 'calendar-home-set',
diff --git a/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php b/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php
index 0b796d8..3336da2 100644
--- a/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php
+++ b/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php
@@ -79,10 +79,10 @@ ICS
         $this->assertEquals(1, count($messages));
         $message = $messages[0];
 
-        $this->assertInstanceOf('\Sabre\CalDAV\Schedule\ITipMessage', $message);
-        $this->assertEquals('user2.sabredav at sabredav.org', $message->recipient);
+        $this->assertInstanceOf('\Sabre\VObject\ITip\Message', $message);
+        $this->assertEquals('mailto:user2.sabredav at sabredav.org', $message->recipient);
         $this->assertEquals('Roxy Kesh', $message->recipientName);
-        $this->assertEquals('user1.sabredav at sabredav.org', $message->sender);
+        $this->assertEquals('mailto:user1.sabredav at sabredav.org', $message->sender);
         $this->assertEquals('Administrator', $message->senderName);
         $this->assertEquals('REQUEST', $message->method);
 

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