Skip to content

Commit 95e218b

Browse files
DeepDiver1975nickvergessen
authored andcommitted
For 9.0 we don't have the possibility to store calendar and addressbook properties on a per-user basis and therefore we simple don't allow this for now
1 parent d98217d commit 95e218b

4 files changed

Lines changed: 51 additions & 3 deletions

File tree

apps/dav/lib/caldav/calendar.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use OCA\DAV\DAV\Sharing\IShareable;
66
use Sabre\DAV\Exception\Forbidden;
7+
use Sabre\DAV\PropPatch;
78

89
class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
910

@@ -103,4 +104,11 @@ function delete() {
103104
}
104105
parent::delete();
105106
}
107+
108+
function propPatch(PropPatch $propPatch) {
109+
if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
110+
throw new Forbidden();
111+
}
112+
parent::propPatch($propPatch);
113+
}
106114
}

apps/dav/lib/carddav/addressbook.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use OCA\DAV\DAV\Sharing\IShareable;
2424
use Sabre\DAV\Exception\Forbidden;
2525
use Sabre\DAV\Exception\NotFound;
26+
use Sabre\DAV\PropPatch;
2627

2728
class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
2829

@@ -83,14 +84,14 @@ function getACL() {
8384
}
8485

8586
// add the current user
86-
if (isset($this->addressBookInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'])) {
87-
$owner = $this->addressBookInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'];
87+
if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
88+
$owner = $this->addressBookInfo['{http://owncloud.org/ns}owner-principal'];
8889
$acl[] = [
8990
'privilege' => '{DAV:}read',
9091
'principal' => $owner,
9192
'protected' => true,
9293
];
93-
if ($this->addressBookInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only']) {
94+
if ($this->addressBookInfo['{http://owncloud.org/ns}read-only']) {
9495
$acl[] = [
9596
'privilege' => '{DAV:}write',
9697
'principal' => $owner,
@@ -162,6 +163,13 @@ function delete() {
162163
parent::delete();
163164
}
164165

166+
function propPatch(PropPatch $propPatch) {
167+
if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
168+
throw new Forbidden();
169+
}
170+
parent::propPatch($propPatch);
171+
}
172+
165173
public function getContactsGroups() {
166174
/** @var CardDavBackend $cardDavBackend */
167175
$cardDavBackend = $this->carddavBackend;

apps/dav/tests/unit/caldav/calendartest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
use OCA\DAV\CalDAV\CalDavBackend;
2525
use OCA\DAV\CalDAV\Calendar;
26+
use Sabre\DAV\PropPatch;
2627
use Test\TestCase;
2728

2829
class CalendarTest extends TestCase {
@@ -63,4 +64,19 @@ public function testDeleteFromGroup() {
6364
$c = new Calendar($backend, $calendarInfo);
6465
$c->delete();
6566
}
67+
68+
/**
69+
* @expectedException \Sabre\DAV\Exception\Forbidden
70+
*/
71+
public function testPropPatch() {
72+
/** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
73+
$backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock();
74+
$calendarInfo = [
75+
'{http://owncloud.org/ns}owner-principal' => 'user1',
76+
'principaluri' => 'user2',
77+
'id' => 666
78+
];
79+
$c = new Calendar($backend, $calendarInfo);
80+
$c->propPatch(new PropPatch([]));
81+
}
6682
}

apps/dav/tests/unit/carddav/addressbooktest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
use OCA\DAV\CardDAV\AddressBook;
2525
use OCA\DAV\CardDAV\CardDavBackend;
26+
use Sabre\DAV\PropPatch;
2627
use Test\TestCase;
2728

2829
class AddressBookTest extends TestCase {
@@ -61,4 +62,19 @@ public function testDeleteFromGroup() {
6162
$c = new AddressBook($backend, $calendarInfo);
6263
$c->delete();
6364
}
65+
66+
/**
67+
* @expectedException \Sabre\DAV\Exception\Forbidden
68+
*/
69+
public function testPropPatch() {
70+
/** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */
71+
$backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock();
72+
$calendarInfo = [
73+
'{http://owncloud.org/ns}owner-principal' => 'user1',
74+
'principaluri' => 'user2',
75+
'id' => 666
76+
];
77+
$c = new AddressBook($backend, $calendarInfo);
78+
$c->propPatch(new PropPatch([]));
79+
}
6480
}

0 commit comments

Comments
 (0)