From 189911650958b2bdca8f733a8f891af373c96ae9 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 1 Aug 2016 15:07:22 +0200 Subject: [PATCH] move getPublicCalendar inside the caldav backend --- apps/dav/lib/CalDAV/CalDavBackend.php | 26 ++++++++++++++++++---- apps/dav/lib/CalDAV/PublicCalendarRoot.php | 8 +------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index e6a023bda6..1be8db160c 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -42,6 +42,7 @@ use Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp; use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet; use Sabre\DAV; use Sabre\DAV\Exception\Forbidden; +use Sabre\DAV\Exception\NotFound; use Sabre\DAV\PropPatch; use Sabre\HTTP\URLUtil; use Sabre\VObject\DateTimeParser; @@ -289,7 +290,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription return array_values($calendars); } -<<<<<<< HEAD private function getUserDisplayName($uid) { if (!isset($this->userDisplayNames[$uid])) { $user = $this->userManager->get($uid); @@ -302,8 +302,11 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription } return $this->userDisplayNames[$uid]; -======= - + } + + /** + * @return array + */ public function getPublicCalendars() { $fields = array_values($this->propertyMap); $fields[] = 'a.id'; @@ -354,7 +357,22 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $result->closeCursor(); return array_values($calendars); ->>>>>>> bf223b9... Add new root collection public-calendars which holds all public calendars + } + + /** + * @param string $uri + * @return Calendar + * @throws NotFound + */ + public function getPublicCalendar($uri) { + $l10n = \OC::$server->getL10N('dav'); + foreach ($this->getPublicCalendars() as $calendar) { + if ($calendar['uri'] === $uri) { + // TODO: maybe implement a new class PublicCalendar ??? + return new Calendar($this, $calendar, $l10n); + } + } + throw new NotFound('Node with name \'' . $uri . '\' could not be found'); } /** diff --git a/apps/dav/lib/CalDAV/PublicCalendarRoot.php b/apps/dav/lib/CalDAV/PublicCalendarRoot.php index 797074f7e5..b8d209d707 100644 --- a/apps/dav/lib/CalDAV/PublicCalendarRoot.php +++ b/apps/dav/lib/CalDAV/PublicCalendarRoot.php @@ -47,13 +47,7 @@ class PublicCalendarRoot extends Collection { * @inheritdoc */ function getChild($name) { - foreach ($this->caldavBackend->getPublicCalendars() as $calendar) { - if ($calendar['uri'] === $name) { - // TODO: maybe implement a new class PublicCalendar ??? - return new Calendar($this->caldavBackend, $calendar, $this->l10n); - } - } - throw new NotFound('Node with name \'' . $name . '\' could not be found'); + return $this->caldavBackend->getPublicCalendar($name); } /**