diff options
Diffstat (limited to 'apps/dav/lib/CalDAV/CalendarHome.php')
-rw-r--r-- | apps/dav/lib/CalDAV/CalendarHome.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/apps/dav/lib/CalDAV/CalendarHome.php b/apps/dav/lib/CalDAV/CalendarHome.php index 3429c24705d..3e645db459f 100644 --- a/apps/dav/lib/CalDAV/CalendarHome.php +++ b/apps/dav/lib/CalDAV/CalendarHome.php @@ -32,15 +32,21 @@ use Sabre\CalDAV\Schedule\Inbox; use Sabre\CalDAV\Schedule\Outbox; use Sabre\CalDAV\Subscriptions\Subscription; use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\Exception\MethodNotAllowed; +use Sabre\DAV\MkCol; class CalendarHome extends \Sabre\CalDAV\CalendarHome { /** @var \OCP\IL10N */ private $l10n; + /** @var \OCP\IConfig */ + private $config; + public function __construct(BackendInterface $caldavBackend, $principalInfo) { parent::__construct($caldavBackend, $principalInfo); $this->l10n = \OC::$server->getL10N('dav'); + $this->config = \OC::$server->getConfig(); } /** @@ -53,11 +59,24 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome { /** * @inheritdoc */ + function createExtendedCollection($name, MkCol $mkCol) { + $reservedNames = [BirthdayService::BIRTHDAY_CALENDAR_URI]; + + if (in_array($name, $reservedNames)) { + throw new MethodNotAllowed('The resource you tried to create has a reserved name'); + } + + parent::createExtendedCollection($name, $mkCol); + } + + /** + * @inheritdoc + */ function getChildren() { $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); $objects = []; foreach ($calendars as $calendar) { - $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n); + $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config); } if ($this->caldavBackend instanceof SchedulingSupport) { @@ -98,7 +117,7 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome { // Calendars foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) { if ($calendar['uri'] === $name) { - return new Calendar($this->caldavBackend, $calendar, $this->l10n); + return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config); } } |