From beb4b1c19097c02d96ae85e238b89aeb111926aa Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 14 Nov 2018 20:50:46 +0100 Subject: [PATCH] fixes dav share issue with owner Signed-off-by: Georg Ehrke --- apps/dav/lib/CalDAV/Calendar.php | 11 +++++------ apps/dav/lib/CardDAV/AddressBook.php | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php index 75e78daf50..1b758ad34f 100644 --- a/apps/dav/lib/CalDAV/Calendar.php +++ b/apps/dav/lib/CalDAV/Calendar.php @@ -130,6 +130,10 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { ]; } + if (!$this->isShared()) { + return $acl; + } + if ($this->getOwner() !== parent::getOwner()) { $acl[] = [ 'privilege' => '{DAV:}read', @@ -159,14 +163,9 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { } $acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl); - - if (!$this->isShared()) { - return $acl; - } - $allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public']; return array_filter($acl, function($rule) use ($allowedPrincipals) { - return in_array($rule['principal'], $allowedPrincipals); + return \in_array($rule['principal'], $allowedPrincipals, true); }); } diff --git a/apps/dav/lib/CardDAV/AddressBook.php b/apps/dav/lib/CardDAV/AddressBook.php index eb5bebaa2e..fd653b3d4a 100644 --- a/apps/dav/lib/CardDAV/AddressBook.php +++ b/apps/dav/lib/CardDAV/AddressBook.php @@ -104,12 +104,17 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable { 'privilege' => '{DAV:}read', 'principal' => $this->getOwner(), 'protected' => true, - ]]; - $acl[] = [ + ],[ 'privilege' => '{DAV:}write', 'principal' => $this->getOwner(), 'protected' => true, - ]; + ] + ]; + + if (!$this->isShared()) { + return $acl; + } + if ($this->getOwner() !== parent::getOwner()) { $acl[] = [ 'privilege' => '{DAV:}read', @@ -132,11 +137,11 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable { ]; } - if ($this->isShared()) { - return $acl; - } - - return $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl); + $acl = $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl); + $allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/system']; + return array_filter($acl, function($rule) use ($allowedPrincipals) { + return \in_array($rule['principal'], $allowedPrincipals, true); + }); } public function getChildACL() {