[Pkg-owncloud-commits] [php-sabredav] 113/220: Sharing plugin now automatically hooks up principal info.
David Prévot
taffit at moszumanska.debian.org
Thu May 12 01:21:14 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit fbf3362a24bb0148f14ab117a0789d0fda8ddab6
Author: Evert Pot <me at evertpot.com>
Date: Wed Mar 30 00:57:18 2016 -0400
Sharing plugin now automatically hooks up principal info.
---
bin/migrateto32.php | 25 ++++++++++++++++++-------
examples/sql/sqlite.calendars.sql | 2 +-
lib/CalDAV/Backend/PDO.php | 10 +++++++---
lib/CalDAV/Xml/Request/Share.php | 2 +-
lib/DAV/Sharing/Plugin.php | 7 +++++--
lib/DAVACL/Plugin.php | 8 ++++++++
6 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/bin/migrateto32.php b/bin/migrateto32.php
index 15859ca..59732b5 100755
--- a/bin/migrateto32.php
+++ b/bin/migrateto32.php
@@ -97,7 +97,7 @@ CREATE TABLE calendarinstances (
id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
calendarid INTEGER UNSIGNED NOT NULL,
principaluri VARBINARY(100),
- access TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1 = owner, 2 = readwrite, 3 = read',
+ access TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1 = owner, 2 = read, 3 = readwrite',
displayname VARCHAR(100),
uri VARBINARY(200),
description TEXT,
@@ -105,8 +105,13 @@ CREATE TABLE calendarinstances (
calendarcolor VARBINARY(10),
timezone TEXT,
transparent TINYINT(1) NOT NULL DEFAULT '0',
- UNIQUE(principaluri, uri)
-);
+ share_href VARBINARY(100),
+ share_displayname VARCHAR(100),
+ share_invitestatus TINYINT(1) NOT NULL DEFAULT '2' COMMENT '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid',
+ UNIQUE(principaluri, uri),
+ UNIQUE(calendarid, principaluri),
+ UNIQUE(calendarid, share_href)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
SQL
);
$pdo->exec("
@@ -139,16 +144,22 @@ FROM calendars
$pdo->exec(<<<SQL
CREATE TABLE calendarinstances (
id integer primary key asc NOT NULL,
- calendarid integer NOT NULL,
- principaluri text NOT NULL,
- access integer COMMENT '1 = owner, 2 = readwrite, 3 = read' NOT NULL DEFAULT '1',
+ calendarid integer,
+ principaluri text,
+ access integer COMMENT '1 = owner, 2 = read, 3 = readwrite' NOT NULL DEFAULT '1',
displayname text,
uri text NOT NULL,
description text,
calendarorder integer,
calendarcolor text,
timezone text,
- transparent bool
+ transparent bool,
+ share_href text,
+ share_displayname text,
+ share_invitestatus integer DEFAULT '2',
+ UNIQUE (principaluri, uri),
+ UNIQUE (calendarid, principaluri),
+ UNIQUE (calendarid, share_href)
);
SQL
);
diff --git a/examples/sql/sqlite.calendars.sql b/examples/sql/sqlite.calendars.sql
index f3f2ade..1c80704 100644
--- a/examples/sql/sqlite.calendars.sql
+++ b/examples/sql/sqlite.calendars.sql
@@ -21,7 +21,7 @@ CREATE TABLE calendars (
CREATE TABLE calendarinstances (
id integer primary key asc NOT NULL,
calendarid integer NOT NULL,
- principaluri text NOT NULL,
+ principaluri text NULL,
access integer COMMENT '1 = owner, 2 = read, 3 = readwrite' NOT NULL DEFAULT '1',
displayname text,
uri text NOT NULL,
diff --git a/lib/CalDAV/Backend/PDO.php b/lib/CalDAV/Backend/PDO.php
index d2b5cf6..933e235 100644
--- a/lib/CalDAV/Backend/PDO.php
+++ b/lib/CalDAV/Backend/PDO.php
@@ -356,7 +356,7 @@ SQL
$stmt->execute([$instanceId]);
$access = $stmt->fetchColumn();
- if ($access === 1) {
+ if ($access === \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER) {
/**
* If the user is the owner of the calendar, we delete all data and all
@@ -1383,6 +1383,10 @@ INSERT INTO ' . $this->calendarInstancesTableName . '
// If the server could not determine the principal automatically,
// we will mark the invite status as invalid.
$sharee->inviteStatus = \Sabre\DAV\Sharing\Plugin::INVITE_INVALID;
+ } else {
+ // Because sabre/dav does not yet have an invitation system,
+ // every invite is automatically accepted for now.
+ $sharee->inviteStatus = \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED;
}
foreach ($currentInvites as $oldSharee) {
@@ -1396,7 +1400,7 @@ INSERT INTO ' . $this->calendarInstancesTableName . '
$updateStmt->execute([
$sharee->access,
isset($sharee->properties['{DAV:}displayname']) ? $sharee->properties['{DAV:}displayname'] : null,
- $sharee->inviteStatus,
+ $sharee->inviteStatus ? : $oldSharee->inviteStatus,
$calendarId,
$sharee->href
]);
@@ -1412,7 +1416,7 @@ INSERT INTO ' . $this->calendarInstancesTableName . '
\Sabre\DAV\UUIDUtil::getUUID(),
$sharee->href,
isset($sharee->properties['{DAV:}displayname']) ? $sharee->properties['{DAV:}displayname'] : null,
- $sharee->inviteStatus,
+ $sharee->inviteStatus ? : \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE,
$instanceId
]);
diff --git a/lib/CalDAV/Xml/Request/Share.php b/lib/CalDAV/Xml/Request/Share.php
index 22c01f3..b5d9a13 100644
--- a/lib/CalDAV/Xml/Request/Share.php
+++ b/lib/CalDAV/Xml/Request/Share.php
@@ -61,7 +61,7 @@ class Share implements XmlDeserializable {
*/
static function xmlDeserialize(Reader $reader) {
- $elems = $reader->parseInnerTree([
+ $elems = $reader->parseGetElements([
'{' . Plugin::NS_CALENDARSERVER . '}set' => 'Sabre\\Xml\\Element\\KeyValue',
'{' . Plugin::NS_CALENDARSERVER . '}remove' => 'Sabre\\Xml\\Element\\KeyValue',
]);
diff --git a/lib/DAV/Sharing/Plugin.php b/lib/DAV/Sharing/Plugin.php
index 8db4137..23b9067 100644
--- a/lib/DAV/Sharing/Plugin.php
+++ b/lib/DAV/Sharing/Plugin.php
@@ -134,9 +134,12 @@ class Plugin extends ServerPlugin {
$acl->checkPrivileges($path, '{DAV:}share');
}
- // By default all sharees are marked as not having responded yet.
foreach ($sharees as $sharee) {
- $sharee->inviteStatus = self::INVITE_NORESPONSE;
+ // We're going to attempt to get a local principal uri for a share
+ // href by emitting the getPrincipalByUri event.
+ $principal = null;
+ $this->server->emit('getPrincipalByUri', [$sharee->href, &$principal]);
+ $sharee->principal = $principal;
}
$node->updateInvites($sharees);
diff --git a/lib/DAVACL/Plugin.php b/lib/DAVACL/Plugin.php
index 601dffe..f025bdc 100644
--- a/lib/DAVACL/Plugin.php
+++ b/lib/DAVACL/Plugin.php
@@ -683,6 +683,14 @@ class Plugin extends DAV\ServerPlugin {
$server->on('report', [$this, 'report']);
$server->on('method:ACL', [$this, 'httpAcl']);
$server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
+ $server->on('getPrincipalByUri', function($principal, &$uri) {
+
+ $uri = $this->getPrincipalByUri($principal);
+
+ // Break event chain
+ if ($uri) return false;
+
+ });
array_push($server->protectedProperties,
'{DAV:}alternate-URI-set',
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-php/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list