Merge pull request #27343 from nextcloud/fix/deleted-objects-deletion-missing-acls
Add missing ACLs for deleted calendar objects to fix deletion
This commit is contained in:
commit
ac4ff6c9e3
|
@ -29,8 +29,11 @@ use OCA\DAV\CalDAV\CalDavBackend;
|
||||||
use OCA\DAV\CalDAV\IRestorable;
|
use OCA\DAV\CalDAV\IRestorable;
|
||||||
use Sabre\CalDAV\ICalendarObject;
|
use Sabre\CalDAV\ICalendarObject;
|
||||||
use Sabre\DAV\Exception\Forbidden;
|
use Sabre\DAV\Exception\Forbidden;
|
||||||
|
use Sabre\DAVACL\ACLTrait;
|
||||||
|
use Sabre\DAVACL\IACL;
|
||||||
|
|
||||||
class DeletedCalendarObject implements ICalendarObject, IRestorable {
|
class DeletedCalendarObject implements IACL, ICalendarObject, IRestorable {
|
||||||
|
use ACLTrait;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $name;
|
private $name;
|
||||||
|
@ -38,19 +41,29 @@ class DeletedCalendarObject implements ICalendarObject, IRestorable {
|
||||||
/** @var mixed[] */
|
/** @var mixed[] */
|
||||||
private $objectData;
|
private $objectData;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
private $principalUri;
|
||||||
|
|
||||||
/** @var CalDavBackend */
|
/** @var CalDavBackend */
|
||||||
private $calDavBackend;
|
private $calDavBackend;
|
||||||
|
|
||||||
public function __construct(string $name,
|
public function __construct(string $name,
|
||||||
array $objectData,
|
array $objectData,
|
||||||
|
string $principalUri,
|
||||||
CalDavBackend $calDavBackend) {
|
CalDavBackend $calDavBackend) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->objectData = $objectData;
|
$this->objectData = $objectData;
|
||||||
$this->calDavBackend = $calDavBackend;
|
$this->calDavBackend = $calDavBackend;
|
||||||
|
$this->principalUri = $principalUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
throw new Forbidden();
|
$this->calDavBackend->deleteCalendarObject(
|
||||||
|
$this->objectData['calendarid'],
|
||||||
|
$this->objectData['uri'],
|
||||||
|
CalDavBackend::CALENDAR_TYPE_CALENDAR,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName() {
|
||||||
|
@ -101,4 +114,23 @@ class DeletedCalendarObject implements ICalendarObject, IRestorable {
|
||||||
public function getCalendarUri(): string {
|
public function getCalendarUri(): string {
|
||||||
return $this->objectData['calendaruri'];
|
return $this->objectData['calendaruri'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getACL(): array {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'privilege' => '{DAV:}read', // For queries
|
||||||
|
'principal' => $this->getOwner(),
|
||||||
|
'protected' => true,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'privilege' => '{DAV:}unbind', // For moving and deletion
|
||||||
|
'principal' => '{DAV:}owner',
|
||||||
|
'protected' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOwner() {
|
||||||
|
return $this->principalUri;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ class DeletedCalendarObjectsCollection implements ICalendarObjectContainer {
|
||||||
return new DeletedCalendarObject(
|
return new DeletedCalendarObject(
|
||||||
$this->getRelativeObjectPath($data),
|
$this->getRelativeObjectPath($data),
|
||||||
$data,
|
$data,
|
||||||
|
$this->principalInfo['uri'],
|
||||||
$this->caldavBackend
|
$this->caldavBackend
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -117,8 +118,8 @@ class DeletedCalendarObjectsCollection implements ICalendarObjectContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calendarQuery(array $filters) {
|
public function calendarQuery(array $filters) {
|
||||||
return array_map(function (array $calendarInfo) {
|
return array_map(function (array $calendarObjectInfo) {
|
||||||
return $this->getRelativeObjectPath($calendarInfo);
|
return $this->getRelativeObjectPath($calendarObjectInfo);
|
||||||
}, $this->caldavBackend->getDeletedCalendarObjectsByPrincipal($this->principalInfo['uri']));
|
}, $this->caldavBackend->getDeletedCalendarObjectsByPrincipal($this->principalInfo['uri']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue