Merge pull request #4621 from nextcloud/fix_readonly_shared_calendar_proppatch

fix PROPPATCH requests to read-only shared calendars
This commit is contained in:
Morris Jobke 2017-05-08 12:42:30 -05:00 committed by GitHub
commit 2d707fdfb5
3 changed files with 11 additions and 2 deletions

View File

@ -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() {

View File

@ -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',

View File

@ -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',