fix PropPatch requests on calendars
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
This commit is contained in:
parent
de983e61e3
commit
3a8c4230be
2 changed files with 19 additions and 8 deletions
|
@ -177,7 +177,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
|||
function propPatch(PropPatch $propPatch) {
|
||||
$mutations = $propPatch->getMutations();
|
||||
// If this is a shared calendar, the user can only change the enabled property, to hide it.
|
||||
if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal']) && (sizeof($mutations) !== 1 || !isset($mutations['{http://owncloud.org/ns}calendar-enabled']))) {
|
||||
if ($this->isShared() && (sizeof($mutations) !== 1 || !isset($mutations['{http://owncloud.org/ns}calendar-enabled']))) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
parent::propPatch($propPatch);
|
||||
|
|
|
@ -106,29 +106,40 @@ class CalendarTest extends TestCase {
|
|||
|
||||
public function dataPropPatch() {
|
||||
return [
|
||||
[[], true],
|
||||
[[
|
||||
['user1', 'user2', [], true],
|
||||
['user1', 'user2', [
|
||||
'{http://owncloud.org/ns}calendar-enabled' => true,
|
||||
], false],
|
||||
[[
|
||||
['user1', 'user2', [
|
||||
'{DAV:}displayname' => true,
|
||||
], true],
|
||||
[[
|
||||
['user1', 'user2', [
|
||||
'{DAV:}displayname' => true,
|
||||
'{http://owncloud.org/ns}calendar-enabled' => true,
|
||||
], true],
|
||||
['user1', 'user1', [], false],
|
||||
['user1', 'user1', [
|
||||
'{http://owncloud.org/ns}calendar-enabled' => true,
|
||||
], false],
|
||||
['user1', 'user1', [
|
||||
'{DAV:}displayname' => true,
|
||||
], false],
|
||||
['user1', 'user1', [
|
||||
'{DAV:}displayname' => true,
|
||||
'{http://owncloud.org/ns}calendar-enabled' => true,
|
||||
], false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataPropPatch
|
||||
*/
|
||||
public function testPropPatch($mutations, $throws) {
|
||||
public function testPropPatch($ownerPrincipal, $principalUri, $mutations, $throws) {
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
|
||||
$backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock();
|
||||
$calendarInfo = [
|
||||
'{http://owncloud.org/ns}owner-principal' => 'user1',
|
||||
'principaluri' => 'user2',
|
||||
'{http://owncloud.org/ns}owner-principal' => $ownerPrincipal,
|
||||
'principaluri' => $principalUri,
|
||||
'id' => 666,
|
||||
'uri' => 'default'
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue