[Pkg-owncloud-commits] [php-sabre-vobject] 02/43: Adding DTSTART to CANCEL and REPLY messages.

David Prévot taffit at moszumanska.debian.org
Fri Oct 10 14:16:14 UTC 2014


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

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

commit bed14898ea333e71450d4f197db0e51f01de697e
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Mon Sep 22 15:44:53 2014 +0100

    Adding DTSTART to CANCEL and REPLY messages.
    
    Also bumped version to 3.3.3
    
    Fixes #142.
---
 ChangeLog.md                                   |  6 ++++
 lib/ITip/Broker.php                            | 29 +++++++++++++--
 lib/Version.php                                |  2 +-
 tests/VObject/ITip/BrokerAttendeeReplyTest.php | 10 ++++++
 tests/VObject/ITip/BrokerDeleteEventTest.php   |  3 ++
 tests/VObject/ITip/BrokerUpdateEventTest.php   | 50 +++++++-------------------
 6 files changed, 60 insertions(+), 40 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index 1845caf..b164a28 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,6 +1,12 @@
 ChangeLog
 =========
 
+3.3.3 (2014-??-??)
+------------------
+
+* #142: `CANCEL` and `REPLY` messages now include the `DTSTART` fromi the
+  original event.
+
 3.3.2 (2014-09-19)
 ------------------
 
diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php
index ad8094b..91aab15 100644
--- a/lib/ITip/Broker.php
+++ b/lib/ITip/Broker.php
@@ -518,6 +518,7 @@ class Broker {
                 if (isset($calendar->VEVENT->SUMMARY)) {
                     $event->add('SUMMARY', $calendar->VEVENT->SUMMARY->getValue());
                 }
+                $event->add(clone $calendar->VEVENT->DTSTART);
                 $org = $event->add('ORGANIZER', $eventInfo['organizer']);
                 if ($eventInfo['organizerName']) $org['CN'] = $eventInfo['organizerName'];
                 $event->add('ATTENDEE', $attendee['href'], array(
@@ -671,6 +672,17 @@ class Broker {
             }
         }
 
+        // Gathering a few extra properties for each instance.
+        foreach($instances as $recurId=>$instanceInfo) {
+
+            if (isset($eventInfo['instances'][$recurId])) {
+                $instances[$recurId]['dtstart'] = clone $eventInfo['instances'][$recurId]->DTSTART;
+            } else {
+                $instances[$recurId]['dtstart'] = $recurId;
+            }
+
+        }
+
         $message = new Message();
         $message->uid = $eventInfo['uid'];
         $message->method = 'REPLY';
@@ -697,8 +709,21 @@ class Broker {
                 'UID' => $message->uid,
                 'SEQUENCE' => $message->sequence,
             ));
-            if (isset($calendar->VEVENT->SUMMARY)) {
-                $event->add('SUMMARY', $calendar->VEVENT->SUMMARY->getValue());
+            $summary = isset($calendar->VEVENT->SUMMARY)?$calendar->VEVENT->SUMMARY->getValue():'';
+            // Adding properties from the correct source instance
+            if (isset($eventInfo['instances'][$instance['id']])) {
+                $instanceObj = $eventInfo['instances'][$instance['id']];
+                $event->add(clone $instanceObj->DTSTART);
+                if (isset($instanceObj->SUMMARY)) {
+                    $event->add('SUMMARY', $instanceObj->SUMMARY->getValue());
+                } elseif ($summary) {
+                    $event->add('SUMMARY', $summary);
+                }
+            } else {
+                $event->add('DTSTART', DateTimeParser::parseDateTime($instance['id'], $eventInfo['timezone']));
+                if ($summary) {
+                    $event->add('SUMMARY', $summary);
+                }
             }
             if ($instance['id'] !== 'master') {
                 $event->{'RECURRENCE-ID'} = DateTimeParser::parseDateTime($instance['id'], $eventInfo['timezone']);
diff --git a/lib/Version.php b/lib/Version.php
index 1794f2c..acd59d6 100644
--- a/lib/Version.php
+++ b/lib/Version.php
@@ -14,6 +14,6 @@ class Version {
     /**
      * Full version number
      */
-    const VERSION = '3.3.2';
+    const VERSION = '3.3.3';
 
 }
diff --git a/tests/VObject/ITip/BrokerAttendeeReplyTest.php b/tests/VObject/ITip/BrokerAttendeeReplyTest.php
index 9737d4c..489af30 100644
--- a/tests/VObject/ITip/BrokerAttendeeReplyTest.php
+++ b/tests/VObject/ITip/BrokerAttendeeReplyTest.php
@@ -53,6 +53,7 @@ METHOD:REPLY
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART:20140716T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one at example.org
 END:VEVENT
@@ -157,6 +158,7 @@ METHOD:REPLY
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART:20140726T120000Z
 RECURRENCE-ID:20140726T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one at example.org
@@ -164,6 +166,7 @@ END:VEVENT
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART:20140724T120000Z
 RECURRENCE-ID:20140724T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one at example.org
@@ -171,6 +174,7 @@ END:VEVENT
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART:20140728T120000Z
 RECURRENCE-ID:20140728T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;PARTSTAT=TENTATIVE;CN=One:mailto:one at example.org
@@ -178,6 +182,7 @@ END:VEVENT
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART:20140729T120000Z
 RECURRENCE-ID:20140729T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one at example.org
@@ -185,6 +190,7 @@ END:VEVENT
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART:20140725T120000Z
 RECURRENCE-ID:20140725T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one at example.org
@@ -283,6 +289,7 @@ METHOD:REPLY
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART:20140716T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;PARTSTAT=NEEDS-ACTION;CN=One:mailto:one at example.org
 END:VEVENT
@@ -388,6 +395,7 @@ METHOD:REPLY
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART:20140818T200000Z
 RECURRENCE-ID:20140818T200000Z
 ORGANIZER:mailto:organizer at example.org
 ATTENDEE;PARTSTAT=DECLINED:mailto:one at example.org
@@ -458,6 +466,7 @@ METHOD:REPLY
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART;TZID=America/Toronto:20140818T200000
 RECURRENCE-ID;TZID=America/Toronto:20140818T200000
 ORGANIZER:mailto:organizer at example.org
 ATTENDEE;PARTSTAT=DECLINED:mailto:one at example.org
@@ -520,6 +529,7 @@ METHOD:REPLY
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART:20140716T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one at example.org
 END:VEVENT
diff --git a/tests/VObject/ITip/BrokerDeleteEventTest.php b/tests/VObject/ITip/BrokerDeleteEventTest.php
index e58eec3..183f840 100644
--- a/tests/VObject/ITip/BrokerDeleteEventTest.php
+++ b/tests/VObject/ITip/BrokerDeleteEventTest.php
@@ -45,6 +45,7 @@ BEGIN:VEVENT
 UID:foobar
 SEQUENCE:2
 SUMMARY:foo
+DTSTART:20140716T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;CN=One:mailto:one at example.org
 END:VEVENT
@@ -70,6 +71,7 @@ BEGIN:VEVENT
 UID:foobar
 SEQUENCE:2
 SUMMARY:foo
+DTSTART:20140716T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;CN=Two:mailto:two at example.org
 END:VEVENT
@@ -123,6 +125,7 @@ METHOD:REPLY
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:1
+DTSTART:20140716T120000Z
 SUMMARY:foo
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one at example.org
diff --git a/tests/VObject/ITip/BrokerUpdateEventTest.php b/tests/VObject/ITip/BrokerUpdateEventTest.php
index c8c0f31..afaa448 100644
--- a/tests/VObject/ITip/BrokerUpdateEventTest.php
+++ b/tests/VObject/ITip/BrokerUpdateEventTest.php
@@ -2,7 +2,7 @@
 
 namespace Sabre\VObject\ITip;
 
-class BrokerUpdateTest extends \PHPUnit_Framework_TestCase {
+class BrokerUpdateTest extends BrokerTester {
 
     function testInviteChange() {
 
@@ -61,6 +61,7 @@ BEGIN:VEVENT
 UID:foobar
 SEQUENCE:2
 SUMMARY:foo
+DTSTART:20140716T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;CN=One:mailto:one at example.org
 END:VEVENT
@@ -128,7 +129,7 @@ ICS
             ),
         );
 
-        $this->parse($oldMessage, $newMessage, $expected);
+        $this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk at example.org');
 
     }
 
@@ -190,7 +191,7 @@ ICS
 
         );
 
-        $this->parse($oldMessage, $newMessage, $expected);
+        $this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk at example.org');
 
     }
 
@@ -222,7 +223,7 @@ ICS;
         $version = \Sabre\VObject\Version::VERSION;
 
         $expected = array();
-        $this->parse($oldMessage, $newMessage, $expected);
+        $this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk at example.org');
 
     }
 
@@ -290,7 +291,7 @@ ICS
             ),
         );
 
-        $this->parse($oldMessage, $newMessage, $expected);
+        $this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk at example.org');
 
     }
 
@@ -356,6 +357,7 @@ METHOD:CANCEL
 BEGIN:VEVENT
 UID:foobar
 SEQUENCE:2
+DTSTART:20140716T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;CN=One:mailto:one at example.org
 END:VEVENT
@@ -423,7 +425,7 @@ ICS
             ),
         );
 
-        $this->parse($oldMessage, $newMessage, $expected);
+        $this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk at example.org');
 
     }
 
@@ -491,7 +493,7 @@ ICS
 
         );
 
-        $this->parse($oldMessage, $newMessage, $expected);
+        $this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk at example.org');
 
     }
 
@@ -559,35 +561,7 @@ ICS
 
         );
 
-        $this->parse($oldMessage, $newMessage, $expected);
-
-    }
-
-    function parse($oldMessage, $newMessage, $expected = array()) {
-
-        $broker = new Broker();
-        $result = $broker->parseEvent($newMessage, 'mailto:strunk at example.org', $oldMessage);
-
-        $this->assertEquals(count($expected), count($result));
-
-        foreach($expected as $index=>$ex) {
-
-            $message = $result[$index];
-
-            foreach($ex as $key=>$val) {
-
-                if ($key==='message') {
-                    $this->assertEquals(
-                        str_replace("\n", "\r\n", $val),
-                        rtrim($message->message->serialize(), "\r\n")
-                    );
-                } else {
-                    $this->assertEquals($val, $message->$key);
-                }
-
-            }
-
-        }
+        $this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk at example.org');
 
     }
 
@@ -644,6 +618,7 @@ BEGIN:VEVENT
 UID:foobar
 SEQUENCE:2
 SUMMARY:foo
+DTSTART:20140716T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;CN=One:mailto:one at example.org
 END:VEVENT
@@ -670,6 +645,7 @@ BEGIN:VEVENT
 UID:foobar
 SEQUENCE:2
 SUMMARY:foo
+DTSTART:20140716T120000Z
 ORGANIZER;CN=Strunk:mailto:strunk at example.org
 ATTENDEE;CN=Two:mailto:two at example.org
 END:VEVENT
@@ -679,7 +655,7 @@ ICS
             ),
         );
 
-        $result = $this->parse($oldMessage, $newMessage, $expected);
+        $result = $this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk at example.org');
 
     }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list