Merge pull request #4621 from nextcloud/fix_readonly_shared_calendar_proppatch

fix PROPPATCH requests to read-only shared calendars
pull/4745/head
Morris Jobke 8 years ago committed by GitHub
commit 2d707fdfb5
  1. 9
      apps/dav/lib/CalDAV/Calendar.php
  2. 2
      apps/dav/tests/unit/CalDAV/CalendarTest.php
  3. 2
      apps/dav/tests/unit/CalDAV/PublicCalendarTest.php

@ -145,11 +145,16 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
];
}
if ($this->isShared()) {
$acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl);
if (!$this->isShared()) {
return $acl;
}
return $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl);
$allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public'];
return array_filter($acl, function($rule) use ($allowedPrincipals) {
return in_array($rule['principal'], $allowedPrincipals);
});
}
public function getChildACL() {

@ -246,6 +246,7 @@ class CalendarTest extends TestCase {
]);
$backend->expects($this->any())->method('getCalendarObject')
->willReturn($calObject2)->with(666, 'event-2');
$backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
$calendarInfo = [
'principaluri' => 'user2',
@ -333,6 +334,7 @@ EOD;
]);
$backend->expects($this->any())->method('getCalendarObject')
->willReturn($calObject1)->with(666, 'event-1');
$backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => $isShared ? 'user1' : 'user2',

@ -51,6 +51,7 @@ class PublicCalendarTest extends CalendarTest {
]);
$backend->expects($this->any())->method('getCalendarObject')
->willReturn($calObject2)->with(666, 'event-2');
$backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user2',
@ -135,6 +136,7 @@ EOD;
]);
$backend->expects($this->any())->method('getCalendarObject')
->willReturn($calObject1)->with(666, 'event-1');
$backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',

Loading…
Cancel
Save