$this->shareWith($shareable, $element);
}
foreach($remove as $element) {
- $this->unshare($shareable->getResourceId(), $element);
+ $this->unshare($shareable, $element);
}
}
return;
}
+ // don't share with owner
+ if ($shareable->getOwner() === $parts[1]) {
+ return;
+ }
+
// remove the share if it already exists
- $this->unshare($shareable->getResourceId(), $element['href']);
+ $this->unshare($shareable, $element['href']);
$access = self::ACCESS_READ;
if (isset($element['readOnly'])) {
$access = $element['readOnly'] ? self::ACCESS_READ : self::ACCESS_READ_WRITE;
}
/**
- * @param int $resourceId
+ * @param IShareable $shareable
* @param string $element
*/
- private function unshare($resourceId, $element) {
+ private function unshare($shareable, $element) {
$parts = explode(':', $element, 2);
if ($parts[0] !== 'principal') {
return;
}
+ // don't share with owner
+ if ($shareable->getOwner() === $parts[1]) {
+ return;
+ }
+
$query = $this->db->getQueryBuilder();
$query->delete('dav_shares')
- ->where($query->expr()->eq('resourceid', $query->createNamedParameter($resourceId)))
+ ->where($query->expr()->eq('resourceid', $query->createNamedParameter($shareable->getResourceId())))
->andWhere($query->expr()->eq('type', $query->createNamedParameter($this->resourceType)))
->andWhere($query->expr()->eq('principaluri', $query->createNamedParameter($parts[1])))
;