summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-10 16:04:10 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-10 16:04:10 +0100
commitc8c9cd36dd5dba9b9fd6427cd3a5c1b85e308e3c (patch)
tree19e9d147889f31a4ff47cbd325cb7adbca4bf6f1
parentb3c1379b8c15f4f81cbf1d2a3f4c63e41b4406ed (diff)
parent85521879cd573e66139eb3256c37cf13a4a80599 (diff)
downloadnextcloud-server-c8c9cd36dd5dba9b9fd6427cd3a5c1b85e308e3c.tar.gz
nextcloud-server-c8c9cd36dd5dba9b9fd6427cd3a5c1b85e308e3c.zip
Merge pull request #23079 from owncloud/readonly-birthday-cal
The birthday_calendar is read-only
-rw-r--r--apps/dav/lib/caldav/calendar.php13
-rw-r--r--apps/dav/tests/unit/caldav/calendartest.php7
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);