diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-10 14:32:46 +0300 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-10 23:36:11 +0300 |
commit | 62a36ee884ed689da0590b30bb96332c9fe6f0d5 (patch) | |
tree | 7801b1bdd8139f07986662b4e280c78fee8c0b78 /apps | |
parent | a58e374956d8459dacfcd4d4a20e272bab421d0a (diff) |
The birthday_calendar is read-only
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/caldav/calendar.php | 13 | ||||
-rw-r--r-- | apps/dav/tests/unit/caldav/calendartest.php | 7 |
2 files changed, 13 insertions, 7 deletions
diff --git a/apps/dav/lib/caldav/calendar.php b/apps/dav/lib/caldav/calendar.php index 55f1acec396..1e87f9b4333 100644 --- a/apps/dav/lib/caldav/calendar.php +++ b/apps/dav/lib/caldav/calendar.php @@ -22,11 +22,20 @@ namespace OCA\DAV\CalDAV; use OCA\DAV\DAV\Sharing\IShareable; +use Sabre\CalDAV\Backend\BackendInterface; use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\PropPatch; class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { + public function __construct(BackendInterface $caldavBackend, $calendarInfo) { + parent::__construct($caldavBackend, $calendarInfo); + + if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) { + $this->calendarInfo['{http://sabredav.org/ns}read-only'] = true; + } + } + /** * Updates the list of shares. * @@ -100,10 +109,6 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { } function delete() { - if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) { - throw new Forbidden(); - } - if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { $principal = 'principal:' . parent::getOwner(); $shares = $this->getShares(); diff --git a/apps/dav/tests/unit/caldav/calendartest.php b/apps/dav/tests/unit/caldav/calendartest.php index c41070ea435..e7f4d57067c 100644 --- a/apps/dav/tests/unit/caldav/calendartest.php +++ b/apps/dav/tests/unit/caldav/calendartest.php @@ -32,7 +32,7 @@ class CalendarTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */ $backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock(); $backend->expects($this->once())->method('updateShares'); - $backend->method('getShares')->willReturn([ + $backend->expects($this->any())->method('getShares')->willReturn([ ['href' => 'principal:user2'] ]); $calendarInfo = [ @@ -52,7 +52,7 @@ class CalendarTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */ $backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock(); $backend->expects($this->never())->method('updateShares'); - $backend->method('getShares')->willReturn([ + $backend->expects($this->any())->method('getShares')->willReturn([ ['href' => 'principal:group2'] ]); $calendarInfo = [ @@ -90,7 +90,8 @@ class CalendarTest extends TestCase { $calendarInfo = [ '{http://owncloud.org/ns}owner-principal' => 'user1', 'principaluri' => 'user2', - 'id' => 666 + 'id' => 666, + 'uri' => 'default' ]; $c = new Calendar($backend, $calendarInfo); |