File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55use OCA \DAV \DAV \Sharing \IShareable ;
66use Sabre \DAV \Exception \Forbidden ;
7+ use Sabre \DAV \PropPatch ;
78
89class 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}
Original file line number Diff line number Diff line change 2323use OCA \DAV \DAV \Sharing \IShareable ;
2424use Sabre \DAV \Exception \Forbidden ;
2525use Sabre \DAV \Exception \NotFound ;
26+ use Sabre \DAV \PropPatch ;
2627
2728class 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 ;
Original file line number Diff line number Diff line change 2323
2424use OCA \DAV \CalDAV \CalDavBackend ;
2525use OCA \DAV \CalDAV \Calendar ;
26+ use Sabre \DAV \PropPatch ;
2627use Test \TestCase ;
2728
2829class 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}
Original file line number Diff line number Diff line change 2323
2424use OCA \DAV \CardDAV \AddressBook ;
2525use OCA \DAV \CardDAV \CardDavBackend ;
26+ use Sabre \DAV \PropPatch ;
2627use Test \TestCase ;
2728
2829class 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}
You can’t perform that action at this time.
0 commit comments