[Pkg-owncloud-commits] [php-sabredav] 83/275: New events are delivered to attendees inbox and default calendar.
David Prévot
taffit at moszumanska.debian.org
Thu Sep 25 14:55:54 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 811207c3dc760994acf410ad28cbd4eae8324511
Author: Evert Pot <me at evertpot.com>
Date: Thu Jul 3 00:31:22 2014 -0400
New events are delivered to attendees inbox and default calendar.
---
bin/migrateto21.php | 43 ++++++++++++++++++-
lib/CalDAV/Backend/PDO.php | 4 +-
lib/CalDAV/Schedule/Plugin.php | 48 +++++++++++++++++++++-
.../Sabre/CalDAV/Schedule/DeliverNewEventTest.php | 7 ++++
4 files changed, 97 insertions(+), 5 deletions(-)
diff --git a/bin/migrateto21.php b/bin/migrateto21.php
index 7fffe95..f6cac91 100755
--- a/bin/migrateto21.php
+++ b/bin/migrateto21.php
@@ -9,7 +9,9 @@ if ($argc<2) {
This script help you migrate from a pre-2.1 database to 2.1 and later
-The 'calendarobjects' table will be upgraded.
+Changes:
+ The 'calendarobjects' table will be upgraded.
+ 'schedulingobjects' will be created.
If you don't use the default PDO CalDAV or CardDAV backend, it's pointless to
run this script.
@@ -145,4 +147,43 @@ if ($addUid) {
}
+echo "Creating 'schedulingobjects'\n";
+
+switch($driver) {
+
+ case 'mysql' :
+ $pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects
+(
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ principaluri VARCHAR(255),
+ calendardata MEDIUMBLOB,
+ uri VARCHAR(200),
+ lastmodified INT(11) UNSIGNED,
+ etag VARCHAR(32),
+ size INT(11) UNSIGNED NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ ');
+ break;
+
+
+ case 'sqlite' :
+ $pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects (
+ id integer primary key asc,
+ principaluri text,
+ calendardata blob,
+ uri text,
+ lastmodified integer,
+ etag text,
+ size integer
+)
+');
+ break;
+ $pdo->exec('
+ CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri);
+ ');
+ break;
+}
+
+echo "Done.\n";
+
echo "Upgrade to 2.1 schema completed.\n";
diff --git a/lib/CalDAV/Backend/PDO.php b/lib/CalDAV/Backend/PDO.php
index 05edbc6..4e745e4 100755
--- a/lib/CalDAV/Backend/PDO.php
+++ b/lib/CalDAV/Backend/PDO.php
@@ -1167,8 +1167,8 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S
*/
public function createSchedulingObject($principalUri, $objectUri, $objectData) {
- $stmt = $this->pdo->prepare('INSERT INTO '.$this->schedulingObjectTableName.' (principaluri, calendardata, uri, lastmodified, etag, size) VALUES (?, ?, ?, UNIX_TIMESTAMP(), ?, ?)');
- $stmt->execute([$principalUri, $objectData, $objectUri, md5($objectData), strlen($objectData) ]);
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->schedulingObjectTableName.' (principaluri, calendardata, uri, lastmodified, etag, size) VALUES (?, ?, ?, ?, ?, ?)');
+ $stmt->execute([$principalUri, $objectData, $objectUri, time(), md5($objectData), strlen($objectData) ]);
}
diff --git a/lib/CalDAV/Schedule/Plugin.php b/lib/CalDAV/Schedule/Plugin.php
index 86c3e49..afda459 100644
--- a/lib/CalDAV/Schedule/Plugin.php
+++ b/lib/CalDAV/Schedule/Plugin.php
@@ -307,6 +307,27 @@ class Plugin extends ServerPlugin {
return new Href($inboxPath);
});
+
+ $propFind->handle('{' . self::NS_CALDAV . '}schedule-default-calendar-URL', function() use ($principalUrl, $caldavPlugin) {
+
+ // We don't support customizing this property yet, so in the
+ // meantime we just grab the first calendar in the home-set.
+ $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
+
+ $nodes = $this->server->tree->getNodeForPath($calendarHomePath)->getChildren();
+
+ foreach($nodes as $node) {
+
+ if ($node instanceof ICalendar) {
+
+ return new Href($calendarHomePath . '/' . $node->getName());
+
+ }
+
+ }
+
+ });
+
// The calendar-user-address-set property is basically mapped to
// the {DAV:}alternate-URI-set property.
$propFind->handle('{' . self::NS_CALDAV . '}calendar-user-address-set', function() use ($node) {
@@ -315,6 +336,14 @@ class Plugin extends ServerPlugin {
return new HrefList($addresses, false);
});
+ // The server currently reports every principal to be of type
+ // 'INDIVIDUAL'
+ $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-type', function() {
+
+ return 'INDIVIDUAL';
+
+ });
+
}
/**
@@ -500,13 +529,28 @@ class Plugin extends ServerPlugin {
return;
}
+ if (!isset($result[0][200][$caldavNS . 'schedule-inbox-URL'])) {
+ $iTipMessage->scheduleStatus = '3.7; Could not find local inbox';
+ return;
+ }
+ if (!isset($result[0][200][$caldavNS . 'schedule-default-calendar-URL'])) {
+ $iTipMessage->scheduleStatus = '3.7; Could not find a schedule-default-calendar-URL property';
+ return;
+ }
+
+ $calendarPath = $result[0][200][$caldavNS . 'schedule-default-calendar-URL']->getHref();
$inboxPath = $result[0][200][$caldavNS . 'schedule-inbox-URL']->getHref();
// Note that we are bypassing ACL on purpose by calling this directly.
// We may need to look a bit deeper into this later. Supporting ACL
- // here would be nice
+ // here would be nice.
$inbox = $this->server->tree->getNodeForPath($inboxPath);
- $inbox->createFile('sabredav-' . \Sabre\DAV\UUIDUtil::getUUID() . '.ics', $iTipMessage->message->serialize());
+ $calendar = $this->server->tree->getNodeForPath($calendarPath);
+
+ $objectPath = 'sabredav-' . \Sabre\DAV\UUIDUtil::getUUID() . '.ics';
+
+ $inbox->createFile($objectPath, $iTipMessage->message->serialize());
+ $calendar->createFile($objectPath, $iTipMessage->message->serialize());
$iTipMessage->scheduleStatus = '1.2;Message delivered locally';
diff --git a/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php b/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php
index 937fc9b..0b796d8 100644
--- a/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php
+++ b/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php
@@ -23,6 +23,13 @@ class DeliverNewEventTest extends \Sabre\DAVServerTest {
]
);
+ $this->caldavBackend->createCalendar(
+ 'principals/user2',
+ 'default',
+ [
+
+ ]
+ );
}
--
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