aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CalDAV/CalendarHome.php
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2020-01-27 13:21:57 +0100
committerGeorg Ehrke <developer@georgehrke.com>2020-02-18 14:35:14 +0100
commitb46e5cb270b1730a6e6d4a98e52ca672eafebd39 (patch)
treea67f62762d13273c5b0037078443dc081f61744d /apps/dav/lib/CalDAV/CalendarHome.php
parenta1fc233fcb30d9181415ad24a4141f0285b6899a (diff)
downloadnextcloud-server-b46e5cb270b1730a6e6d4a98e52ca672eafebd39.tar.gz
nextcloud-server-b46e5cb270b1730a6e6d4a98e52ca672eafebd39.zip
Allow apps to provide Calendars in user's calendarHome
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/dav/lib/CalDAV/CalendarHome.php')
-rw-r--r--apps/dav/lib/CalDAV/CalendarHome.php36
1 files changed, 34 insertions, 2 deletions
diff --git a/apps/dav/lib/CalDAV/CalendarHome.php b/apps/dav/lib/CalDAV/CalendarHome.php
index b491c2304d2..ce29ed12db6 100644
--- a/apps/dav/lib/CalDAV/CalendarHome.php
+++ b/apps/dav/lib/CalDAV/CalendarHome.php
@@ -26,6 +26,9 @@
namespace OCA\DAV\CalDAV;
+use OCA\DAV\AppInfo\PluginManager;
+use OCA\DAV\CalDAV\Integration\ExternalCalendar;
+use OCA\DAV\CalDAV\Integration\ICalendarProvider;
use Sabre\CalDAV\Backend\BackendInterface;
use Sabre\CalDAV\Backend\NotificationSupport;
use Sabre\CalDAV\Backend\SchedulingSupport;
@@ -44,6 +47,9 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome {
/** @var \OCP\IConfig */
private $config;
+ /** @var PluginManager */
+ private $pluginManager;
+
/** @var bool */
private $returnCachedSubscriptions=false;
@@ -51,6 +57,10 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome {
parent::__construct($caldavBackend, $principalInfo);
$this->l10n = \OC::$server->getL10N('dav');
$this->config = \OC::$server->getConfig();
+ $this->pluginManager = new PluginManager(
+ \OC::$server,
+ \OC::$server->getAppManager()
+ );
}
/**
@@ -66,7 +76,7 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome {
function createExtendedCollection($name, MkCol $mkCol) {
$reservedNames = [BirthdayService::BIRTHDAY_CALENDAR_URI];
- if (in_array($name, $reservedNames)) {
+ if (\in_array($name, $reservedNames, true) || ExternalCalendar::doesViolateReservedName($name)) {
throw new MethodNotAllowed('The resource you tried to create has a reserved name');
}
@@ -104,6 +114,14 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome {
}
}
+ foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
+ /** @var ICalendarProvider $calendarPlugin */
+ $calendars = $calendarPlugin->fetchAllForCalendarHome($this->principalInfo['uri']);
+ foreach ($calendars as $calendar) {
+ $objects[] = $calendar;
+ }
+ }
+
return $objects;
}
@@ -139,7 +157,21 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome {
return new Subscription($this->caldavBackend, $subscription);
}
}
+ }
+
+ if (ExternalCalendar::isAppGeneratedCalendar($name)) {
+ [$appId, $calendarUri] = ExternalCalendar::splitAppGeneratedCalendarUri($name);
+ foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
+ /** @var ICalendarProvider $calendarPlugin */
+ if ($calendarPlugin->getAppId() !== $appId) {
+ continue;
+ }
+
+ if ($calendarPlugin->hasCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri)) {
+ return $calendarPlugin->getCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri);
+ }
+ }
}
throw new NotFound('Node with name \'' . $name . '\' could not be found');
@@ -155,7 +187,7 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome {
return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
}
-
+
public function enableCachedSubscriptionsForThisRequest() {
$this->returnCachedSubscriptions = true;
}