nextcloud/apps/dav/lib/CalDAV/PublicCalendar.php
Pawel Boguslawski 66b7f2effd
Extract cs:allowed-sharing-modes into it's own plugin
So that it's still there when we disable the PublishPlugin

And disable sharing calendars via link when sharik via link is disabled

This mod disallows sharing calendars via link when `shareapi_allow_links`
is disabled.

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Signed-off-by: Carl Schwan <carlschwan@kde.org>
Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
2026-06-11 10:49:27 +02:00

75 lines
1.9 KiB
PHP

<?php
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\CalDAV;
use Sabre\DAV\Exception\NotFound;
class PublicCalendar extends Calendar {
/**
* @param string $name
* @throws NotFound
*/
#[\Override]
public function getChild($name): PublicCalendarObject {
$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
if (!$obj) {
throw new NotFound('Calendar object not found');
}
if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
throw new NotFound('Calendar object not found');
}
$obj['acl'] = $this->getChildACL();
return new PublicCalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
}
/**
* @return PublicCalendarObject[]
*/
#[\Override]
public function getChildren(): array {
$objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']);
$children = [];
foreach ($objs as $obj) {
if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
continue;
}
$obj['acl'] = $this->getChildACL();
$children[] = new PublicCalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
}
return $children;
}
/**
* @param string[] $paths
* @return PublicCalendarObject[]
*/
#[\Override]
public function getMultipleChildren(array $paths): array {
$objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
$children = [];
foreach ($objs as $obj) {
if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
continue;
}
$obj['acl'] = $this->getChildACL();
$children[] = new PublicCalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
}
return $children;
}
/**
* Public calendars are always shared
*/
#[\Override]
public function isShared(): bool {
return true;
}
}