diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2021-11-04 16:31:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-04 16:31:29 +0100 |
commit | e1c2c13585d5417db2ed490b2986c1ea04cd808d (patch) | |
tree | 40f4a2a60b282e5c5201384123d47f889f243b99 /apps | |
parent | addab1e79918c05b01c3f602dfa68311c77b5c82 (diff) | |
parent | bc68108f2a2d2686323d2431ad908e602bc9f090 (diff) | |
download | nextcloud-server-e1c2c13585d5417db2ed490b2986c1ea04cd808d.tar.gz nextcloud-server-e1c2c13585d5417db2ed490b2986c1ea04cd808d.zip |
Merge pull request #29536 from nextcloud/fix/add-full-calendar-path-for-public-write
Fix missing calendar path for public write on Calendars
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CalDAV/CalendarImpl.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php index ed37c0a745d..d45e12234d1 100644 --- a/apps/dav/lib/CalDAV/CalendarImpl.php +++ b/apps/dav/lib/CalDAV/CalendarImpl.php @@ -33,6 +33,7 @@ use OCP\Calendar\Exceptions\CalendarException; use OCP\Calendar\ICreateFromString; use OCP\Constants; use Sabre\DAV\Exception\Conflict; +use function Sabre\Uri\split as uriSplit; class CalendarImpl implements ICreateFromString { @@ -145,11 +146,19 @@ class CalendarImpl implements ICreateFromString { // so set the custom principal here $plugin->setCurrentPrincipal($this->calendar->getPrincipalURI()); + if (empty($this->calendarInfo['uri'])) { + throw new CalendarException('Could not write to calendar as URI parameter is missing'); + } + + // Build full calendar path + [, $user] = uriSplit($this->calendar->getPrincipalURI()); + $fullCalendarFilename = sprintf('calendars/%s/%s/%s', $user, $this->calendarInfo['uri'], $name); + $stream = fopen('php://memory', 'rb+'); fwrite($stream, $calendarData); rewind($stream); try { - $server->server->createFile($name, $stream); + $server->server->createFile($fullCalendarFilename, $stream); } catch (Conflict $e) { throw new CalendarException('Could not create new calendar event: ' . $e->getMessage(), 0, $e); } finally { |