[Pkg-owncloud-commits] [php-sabre-vobject] 08/38: Support for SCHEDULE-FORCE-SEND
David Prévot
taffit at moszumanska.debian.org
Tue Sep 23 03:10:21 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch upstream
in repository php-sabre-vobject.
commit 7b932245e7d24c7f72358fee600c23ce9fa62798
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Mon Sep 15 16:50:22 2014 +0100
Support for SCHEDULE-FORCE-SEND
Fixes #120.
---
ChangeLog.md | 1 +
lib/ITip/Broker.php | 32 +++++-
tests/VObject/ITip/BrokerAttendeeReplyTest.php | 61 +++++++++++
tests/VObject/ITip/BrokerUpdateEventTest.php | 136 +++++++++++++++++++++++++
4 files changed, 228 insertions(+), 2 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 2fbe843..18cf89d 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -7,6 +7,7 @@ ChangeLog
* Changed: iTip broker now sets RSVP status to false when replies are received.
* #118: iTip Message now has a `getScheduleStatus()` method.
* #119: Support for detecting 'significant changes'.
+* #120: Support for `SCHEDULE-FORCE-SEND`.
3.3.1 (2014-08-18)
diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php
index ed69b75..e1362dc 100644
--- a/lib/ITip/Broker.php
+++ b/lib/ITip/Broker.php
@@ -453,18 +453,21 @@ class Broker {
'oldInstances' => $attendee['instances'],
'newInstances' => array(),
'name' => $attendee['name'],
+ 'forceSend' => null,
);
}
foreach($eventInfo['attendees'] as $attendee) {
if (isset($attendees[$attendee['href']])) {
$attendees[$attendee['href']]['name'] = $attendee['name'];
$attendees[$attendee['href']]['newInstances'] = $attendee['instances'];
+ $attendees[$attendee['href']]['forceSend'] = $attendee['forceSend'];
} else {
$attendees[$attendee['href']] = array(
'href' => $attendee['href'],
'oldInstances' => array(),
'newInstances' => $attendee['instances'],
'name' => $attendee['name'],
+ 'forceSend' => $attendee['forceSend'],
);
}
}
@@ -531,6 +534,7 @@ class Broker {
// difference in instances that the attendee is invited to.
$message->significantChange =
+ $attendee['forceSend'] === 'REQUEST' ||
array_keys($attendee['oldInstances']) != array_keys($attendee['newInstances']) ||
$oldEventInfo['significantChangeHash']!==$eventInfo['significantChangeHash'];
@@ -543,7 +547,7 @@ class Broker {
// is not a part of to add to the list of exceptions.
$exceptions = array();
foreach($eventInfo['instances'] as $instanceId=>$vevent) {
- if (!isset($attendee['newInstances'][$instanceId])) {;
+ if (!isset($attendee['newInstances'][$instanceId])) {
$exceptions[] = $instanceId;
}
}
@@ -561,6 +565,16 @@ class Broker {
}
}
+ // Cleaning up any scheduling information that
+ // shouldn't be sent along.
+ unset($currentEvent->ORGANIZER['SCHEDULE-FORCE-SEND']);
+ unset($currentEvent->ORGANIZER['SCHEDULE-STATUS']);
+
+ foreach($currentEvent->ATTENDEE as $attendee) {
+ unset($attendee['SCHEDULE-FORCE-SEND']);
+ unset($attendee['SCHEDULE-STATUS']);
+ }
+
}
$icalMsg->add($currentEvent);
@@ -651,7 +665,7 @@ class Broker {
foreach($instances as $instance) {
- if ($instance['oldstatus']==$instance['newstatus']) {
+ if ($instance['oldstatus']==$instance['newstatus'] && $eventInfo['organizerForceSend'] !== 'REPLY') {
// Skip
continue;
}
@@ -706,6 +720,7 @@ class Broker {
$uid = null;
$organizer = null;
$organizerName = null;
+ $organizerForceSend = null;
$sequence = null;
$timezone = null;
@@ -741,6 +756,10 @@ class Broker {
throw new SameOrganizerForAllComponentsException('Every instance of the event must have the same organizer.');
}
}
+ $organizerForceSend =
+ isset($vevent->ORGANIZER['SCHEDULE-FORCE-SEND']) ?
+ strtoupper($vevent->ORGANIZER['SCHEDULE-FORCE-SEND']) :
+ null;
}
if (is_null($sequence) && isset($vevent->SEQUENCE)) {
$sequence = $vevent->SEQUENCE->getValue();
@@ -767,10 +786,17 @@ class Broker {
strtoupper($attendee['PARTSTAT']) :
'NEEDS-ACTION';
+ $forceSend =
+ isset($attendee['SCHEDULE-FORCE-SEND']) ?
+ strtoupper($attendee['SCHEDULE-FORCE-SEND']) :
+ null;
+
+
if (isset($attendees[$attendee->getNormalizedValue()])) {
$attendees[$attendee->getNormalizedValue()]['instances'][$recurId] = array(
'id' => $recurId,
'partstat' => $partStat,
+ 'force-send' => $forceSend,
);
} else {
$attendees[$attendee->getNormalizedValue()] = array(
@@ -782,6 +808,7 @@ class Broker {
),
),
'name' => isset($attendee['CN'])?(string)$attendee['CN']:null,
+ 'forceSend' => $forceSend,
);
}
@@ -806,6 +833,7 @@ class Broker {
'uid',
'organizer',
'organizerName',
+ 'organizerForceSend',
'instances',
'attendees',
'sequence',
diff --git a/tests/VObject/ITip/BrokerAttendeeReplyTest.php b/tests/VObject/ITip/BrokerAttendeeReplyTest.php
index 305fe67..fa900ef 100644
--- a/tests/VObject/ITip/BrokerAttendeeReplyTest.php
+++ b/tests/VObject/ITip/BrokerAttendeeReplyTest.php
@@ -229,11 +229,72 @@ END:VEVENT
END:VCALENDAR
ICS;
+
$expected = array();
$result = $this->parse($oldMessage, $newMessage, $expected);
}
+ function testNoChangeForceSend() {
+
+ $oldMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+
+ $newMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;SCHEDULE-FORCE-SEND=REPLY;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;PARTSTAT=NEEDS-ACTION;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+ $version = \Sabre\VObject\Version::VERSION;
+ $expected = array(
+ array(
+ 'uid' => 'foobar',
+ 'method' => 'REPLY',
+ 'component' => 'VEVENT',
+ 'sender' => 'mailto:one at example.org',
+ 'senderName' => 'One',
+ 'recipient' => 'mailto:strunk at example.org',
+ 'recipientName' => 'Strunk',
+ 'message' => <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Sabre//Sabre VObject $version//EN
+CALSCALE:GREGORIAN
+METHOD:REPLY
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;PARTSTAT=NEEDS-ACTION;CN=One:mailto:one at example.org
+END:VEVENT
+END:VCALENDAR
+ICS
+ )
+
+ );
+ $result = $this->parse($oldMessage, $newMessage, $expected);
+
+ }
+
function testNoRelevantAttendee() {
$oldMessage = <<<ICS
diff --git a/tests/VObject/ITip/BrokerUpdateEventTest.php b/tests/VObject/ITip/BrokerUpdateEventTest.php
index 332d1c9..96d362c 100644
--- a/tests/VObject/ITip/BrokerUpdateEventTest.php
+++ b/tests/VObject/ITip/BrokerUpdateEventTest.php
@@ -422,6 +422,142 @@ ICS
}
+ function testInviteNoChange() {
+
+ $oldMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+
+ $newMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:2
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+ $version = \Sabre\VObject\Version::VERSION;
+
+ $expected = array(
+ array(
+ 'uid' => 'foobar',
+ 'method' => 'REQUEST',
+ 'component' => 'VEVENT',
+ 'sender' => 'mailto:strunk at example.org',
+ 'senderName' => 'Strunk',
+ 'recipient' => 'mailto:one at example.org',
+ 'recipientName' => 'One',
+ 'significantChange' => false,
+ 'message' => <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Sabre//Sabre VObject $version//EN
+CALSCALE:GREGORIAN
+METHOD:REQUEST
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:2
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS
+
+ ),
+
+ );
+
+ $result = $this->parse($oldMessage, $newMessage, $expected);
+
+ }
+
+ function testInviteNoChangeForceSend() {
+
+ $oldMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+
+ $newMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:2
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;SCHEDULE-FORCE-SEND=REQUEST;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+ $version = \Sabre\VObject\Version::VERSION;
+
+ $expected = array(
+ array(
+ 'uid' => 'foobar',
+ 'method' => 'REQUEST',
+ 'component' => 'VEVENT',
+ 'sender' => 'mailto:strunk at example.org',
+ 'senderName' => 'Strunk',
+ 'recipient' => 'mailto:one at example.org',
+ 'recipientName' => 'One',
+ 'significantChange' => true,
+ 'message' => <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Sabre//Sabre VObject $version//EN
+CALSCALE:GREGORIAN
+METHOD:REQUEST
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:2
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS
+
+ ),
+
+ );
+
+ $result = $this->parse($oldMessage, $newMessage, $expected);
+
+ }
+
function parse($oldMessage, $newMessage, $expected = array()) {
$broker = new Broker();
--
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