diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php index 7b47963240e0a..80e4d14f5f6f7 100644 --- a/apps/dav/lib/CalDAV/CalendarImpl.php +++ b/apps/dav/lib/CalDAV/CalendarImpl.php @@ -16,6 +16,7 @@ use OCP\Calendar\Exceptions\CalendarException; use OCP\Calendar\ICalendarExport; use OCP\Calendar\ICalendarIsEnabled; +use OCP\Calendar\ICalendarIsPublic; use OCP\Calendar\ICalendarIsShared; use OCP\Calendar\ICalendarIsWritable; use OCP\Calendar\ICreateFromString; @@ -32,7 +33,7 @@ use function Sabre\Uri\split as uriSplit; -class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsWritable, ICalendarIsShared, ICalendarExport, ICalendarIsEnabled { +class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsWritable, ICalendarIsShared, ICalendarExport, ICalendarIsEnabled, ICalendarIsPublic { public function __construct( private Calendar $calendar, /** @var array */ @@ -168,6 +169,13 @@ public function isShared(): bool { return $this->calendar->isShared(); } + /** + * @since 33.0.1, 32.0.7, 31.0.14.1, 30.0.17.8 + */ + public function getPublicToken(): ?string { + return $this->calendar->getPublishStatus() ?: null; + } + /** * @throws CalendarException */ @@ -336,5 +344,4 @@ public function export(?CalendarExportOptions $options = null): Generator { } } } - } diff --git a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php index 6c966d800c7d5..5df78b02d8f87 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php @@ -33,7 +33,7 @@ protected function setUp(): void { $this->backend = $this->createMock(CalDavBackend::class); $this->calendar = $this->createMock(Calendar::class); $this->calendarInfo = [ - 'id' => 'fancy_id_123', + 'id' => 123, '{DAV:}displayname' => 'user readable name 123', '{http://apple.com/ns/ical/}calendar-color' => '#AABBCC', 'uri' => '/this/is/a/uri', @@ -62,7 +62,7 @@ protected function setUp(): void { public function testGetKey(): void { - $this->assertEquals($this->calendarImpl->getKey(), 'fancy_id_123'); + $this->assertEquals($this->calendarImpl->getKey(), '123'); } public function testGetDisplayname(): void { @@ -73,6 +73,18 @@ public function testGetDisplayColor(): void { $this->assertEquals($this->calendarImpl->getDisplayColor(), '#AABBCC'); } + public function testGetPublicToken(): void { + $publicToken = $this->calendar->setPublishStatus(true); + + $this->assertEquals($this->calendarImpl->getPublicToken(), $publicToken); + } + + public function testGetPublicTokenWithPrivateCalendar(): void { + $this->calendar->setPublishStatus(false); + + $this->assertNull($this->calendarImpl->getPublicToken()); + } + public function testSearch(): void { $this->backend->expects($this->once()) ->method('search') @@ -266,5 +278,4 @@ public function getHrefs(): array { $calendarImpl->handleIMipMessage('fakeUser', $vObject->serialize()); } - } diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 93f5def20a52a..aaf6df2810194 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -222,6 +222,7 @@ 'OCP\\Calendar\\ICalendarEventBuilder' => $baseDir . '/lib/public/Calendar/ICalendarEventBuilder.php', 'OCP\\Calendar\\ICalendarExport' => $baseDir . '/lib/public/Calendar/ICalendarExport.php', 'OCP\\Calendar\\ICalendarIsEnabled' => $baseDir . '/lib/public/Calendar/ICalendarIsEnabled.php', + 'OCP\\Calendar\\ICalendarIsPublic' => $baseDir . '/lib/public/Calendar/ICalendarIsPublic.php', 'OCP\\Calendar\\ICalendarIsShared' => $baseDir . '/lib/public/Calendar/ICalendarIsShared.php', 'OCP\\Calendar\\ICalendarIsWritable' => $baseDir . '/lib/public/Calendar/ICalendarIsWritable.php', 'OCP\\Calendar\\ICalendarProvider' => $baseDir . '/lib/public/Calendar/ICalendarProvider.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index bc27a12cf46b6..c395e56acae69 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -263,6 +263,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Calendar\\ICalendarEventBuilder' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarEventBuilder.php', 'OCP\\Calendar\\ICalendarExport' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarExport.php', 'OCP\\Calendar\\ICalendarIsEnabled' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsEnabled.php', + 'OCP\\Calendar\\ICalendarIsPublic' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsPublic.php', 'OCP\\Calendar\\ICalendarIsShared' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsShared.php', 'OCP\\Calendar\\ICalendarIsWritable' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsWritable.php', 'OCP\\Calendar\\ICalendarProvider' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarProvider.php', diff --git a/lib/public/Calendar/ICalendarIsPublic.php b/lib/public/Calendar/ICalendarIsPublic.php new file mode 100644 index 0000000000000..1cf66de2ddcdc --- /dev/null +++ b/lib/public/Calendar/ICalendarIsPublic.php @@ -0,0 +1,21 @@ +