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

This commit is contained in:
Thomas Müller 2016-02-09 15:03:15 +01:00 committed by Joas Schilling
parent 0945cb7a0e
commit b1a1a46193
4 changed files with 51 additions and 3 deletions

View File

@ -23,6 +23,7 @@ namespace OCA\DAV\CalDAV;
use OCA\DAV\DAV\Sharing\IShareable;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\PropPatch;
class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
@ -122,4 +123,11 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
}
parent::delete();
}
function propPatch(PropPatch $propPatch) {
if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
throw new Forbidden();
}
parent::propPatch($propPatch);
}
}

View File

@ -23,6 +23,7 @@ namespace OCA\DAV\CardDAV;
use OCA\DAV\DAV\Sharing\IShareable;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\PropPatch;
class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
@ -83,14 +84,14 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
}
// add the current user
if (isset($this->addressBookInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'])) {
$owner = $this->addressBookInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'];
if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
$owner = $this->addressBookInfo['{http://owncloud.org/ns}owner-principal'];
$acl[] = [
'privilege' => '{DAV:}read',
'principal' => $owner,
'protected' => true,
];
if ($this->addressBookInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only']) {
if ($this->addressBookInfo['{http://owncloud.org/ns}read-only']) {
$acl[] = [
'privilege' => '{DAV:}write',
'principal' => $owner,
@ -162,6 +163,13 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
parent::delete();
}
function propPatch(PropPatch $propPatch) {
if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
throw new Forbidden();
}
parent::propPatch($propPatch);
}
public function getContactsGroups() {
/** @var CardDavBackend $cardDavBackend */
$cardDavBackend = $this->carddavBackend;

View File

@ -23,6 +23,7 @@ namespace OCA\DAV\Tests\Unit\CalDAV;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Calendar;
use Sabre\DAV\PropPatch;
use Test\TestCase;
class CalendarTest extends TestCase {
@ -63,4 +64,19 @@ class CalendarTest extends TestCase {
$c = new Calendar($backend, $calendarInfo);
$c->delete();
}
/**
* @expectedException \Sabre\DAV\Exception\Forbidden
*/
public function testPropPatch() {
/** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
$backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock();
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',
'principaluri' => 'user2',
'id' => 666
];
$c = new Calendar($backend, $calendarInfo);
$c->propPatch(new PropPatch([]));
}
}

View File

@ -23,6 +23,7 @@ namespace OCA\DAV\Tests\Unit\CardDAV;
use OCA\DAV\CardDAV\AddressBook;
use OCA\DAV\CardDAV\CardDavBackend;
use Sabre\DAV\PropPatch;
use Test\TestCase;
class AddressBookTest extends TestCase {
@ -61,4 +62,19 @@ class AddressBookTest extends TestCase {
$c = new AddressBook($backend, $calendarInfo);
$c->delete();
}
/**
* @expectedException \Sabre\DAV\Exception\Forbidden
*/
public function testPropPatch() {
/** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */
$backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock();
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',
'principaluri' => 'user2',
'id' => 666
];
$c = new AddressBook($backend, $calendarInfo);
$c->propPatch(new PropPatch([]));
}
}