fixes dav share issue with owner

Signed-off-by: Georg Ehrke <developer@georgehrke.com>
This commit is contained in:
Georg Ehrke 2018-11-14 20:50:46 +01:00
parent 8cb7ce7b6e
commit beb4b1c190
No known key found for this signature in database
GPG Key ID: 9D98FD9380A1CB43
2 changed files with 18 additions and 14 deletions

View File

@ -130,6 +130,10 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
]; ];
} }
if (!$this->isShared()) {
return $acl;
}
if ($this->getOwner() !== parent::getOwner()) { if ($this->getOwner() !== parent::getOwner()) {
$acl[] = [ $acl[] = [
'privilege' => '{DAV:}read', 'privilege' => '{DAV:}read',
@ -159,14 +163,9 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
} }
$acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl); $acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl);
if (!$this->isShared()) {
return $acl;
}
$allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public']; $allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public'];
return array_filter($acl, function($rule) use ($allowedPrincipals) { return array_filter($acl, function($rule) use ($allowedPrincipals) {
return in_array($rule['principal'], $allowedPrincipals); return \in_array($rule['principal'], $allowedPrincipals, true);
}); });
} }

View File

@ -104,12 +104,17 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
'privilege' => '{DAV:}read', 'privilege' => '{DAV:}read',
'principal' => $this->getOwner(), 'principal' => $this->getOwner(),
'protected' => true, 'protected' => true,
]]; ],[
$acl[] = [
'privilege' => '{DAV:}write', 'privilege' => '{DAV:}write',
'principal' => $this->getOwner(), 'principal' => $this->getOwner(),
'protected' => true, 'protected' => true,
]
]; ];
if (!$this->isShared()) {
return $acl;
}
if ($this->getOwner() !== parent::getOwner()) { if ($this->getOwner() !== parent::getOwner()) {
$acl[] = [ $acl[] = [
'privilege' => '{DAV:}read', 'privilege' => '{DAV:}read',
@ -132,11 +137,11 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
]; ];
} }
if ($this->isShared()) { $acl = $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl);
return $acl; $allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/system'];
} return array_filter($acl, function($rule) use ($allowedPrincipals) {
return \in_array($rule['principal'], $allowedPrincipals, true);
return $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl); });
} }
public function getChildACL() { public function getChildACL() {