summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/carddav
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-02 13:50:46 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-03 17:18:22 +0100
commit8c14ce01ba361cffefee7e450e8b51743fcc4f4c (patch)
tree45fa04c5f08fd6c1d9dd4dadc0a386a6e71e446e /apps/dav/lib/carddav
parentef06d6bdaaa5b0686bd1f6fb32866cfe36481434 (diff)
downloadnextcloud-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.php29
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();
+ }
}