diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-02 13:50:46 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-03 17:18:22 +0100 |
commit | 8c14ce01ba361cffefee7e450e8b51743fcc4f4c (patch) | |
tree | 45fa04c5f08fd6c1d9dd4dadc0a386a6e71e446e /apps/dav/lib/carddav | |
parent | ef06d6bdaaa5b0686bd1f6fb32866cfe36481434 (diff) | |
download | nextcloud-server-8c14ce01ba361cffefee7e450e8b51743fcc4f4c.tar.gz nextcloud-server-8c14ce01ba361cffefee7e450e8b51743fcc4f4c.zip |
Deleting a shared address book results in unshare
Diffstat (limited to 'apps/dav/lib/carddav')
-rw-r--r-- | apps/dav/lib/carddav/addressbook.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/apps/dav/lib/carddav/addressbook.php b/apps/dav/lib/carddav/addressbook.php index 513eae4d723..ca3f5ba0ef6 100644 --- a/apps/dav/lib/carddav/addressbook.php +++ b/apps/dav/lib/carddav/addressbook.php @@ -21,6 +21,7 @@ namespace OCA\DAV\CardDAV; use OCA\DAV\DAV\Sharing\IShareable; +use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\NotFound; class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable { @@ -132,4 +133,32 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable { public function getResourceId() { return $this->addressBookInfo['id']; } + + function getOwner() { + if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { + return $this->addressBookInfo['{http://owncloud.org/ns}owner-principal']; + } + return parent::getOwner(); + } + + function delete() { + if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { + $principal = 'principal:' . parent::getOwner(); + $shares = $this->getShares(); + $shares = array_filter($shares, function($share) use ($principal){ + return $share['href'] === $principal; + }); + if (empty($shares)) { + throw new Forbidden(); + } + + /** @var CardDavBackend $cardDavBackend */ + $cardDavBackend = $this->carddavBackend; + $cardDavBackend->updateShares($this, [], [ + 'href' => $principal + ]); + return; + } + parent::delete(); + } } |