Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/dav/lib/CalDAV/CachedSubscriptionImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
namespace OCA\DAV\CalDAV;

use OCP\Calendar\ICalendar;
use OCP\Calendar\ICalendarIsEnabled;
use OCP\Calendar\ICalendarIsShared;
use OCP\Calendar\ICalendarIsWritable;
use OCP\Constants;

class CachedSubscriptionImpl implements ICalendar, ICalendarIsShared, ICalendarIsWritable {
class CachedSubscriptionImpl implements ICalendar, ICalendarIsEnabled, ICalendarIsShared, ICalendarIsWritable {

public function __construct(
private CachedSubscription $calendar,
Expand Down Expand Up @@ -86,6 +87,13 @@ public function getPermissions(): int {
return $result;
}

/**
* @since 31.0.6
*/
public function isEnabled(): bool {
return $this->calendarInfo['{http://owncloud.org/ns}calendar-enabled'] ?? true;
}

public function isWritable(): bool {
return false;
}
Expand Down
12 changes: 11 additions & 1 deletion apps/dav/lib/CalDAV/CalendarImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin;
use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer;
use OCP\Calendar\Exceptions\CalendarException;
use OCP\Calendar\ICalendarIsEnabled;
use OCP\Calendar\ICalendarIsShared;
use OCP\Calendar\ICalendarIsWritable;
use OCP\Calendar\ICreateFromString;
use OCP\Calendar\IHandleImipMessage;
use OCP\Constants;
Expand All @@ -24,7 +27,7 @@
use Sabre\VObject\Reader;
use function Sabre\Uri\split as uriSplit;

class CalendarImpl implements ICreateFromString, IHandleImipMessage {
class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsWritable, ICalendarIsShared, ICalendarIsEnabled {
public function __construct(
private Calendar $calendar,
/** @var array<string, mixed> */
Expand Down Expand Up @@ -131,6 +134,13 @@ public function getPermissions(): int {
return $result;
}

/**
* @since 31.0.6
*/
public function isEnabled(): bool {
return $this->calendarInfo['{http://owncloud.org/ns}calendar-enabled'] ?? true;
}

/**
* @since 31.0.0
*/
Expand Down
23 changes: 23 additions & 0 deletions apps/dav/lib/CalDAV/CalendarProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
namespace OCA\DAV\CalDAV;

use OCA\DAV\Db\Property;
use OCA\DAV\Db\PropertyMapper;
use OCP\Calendar\ICalendarProvider;
use OCP\IConfig;
use OCP\IL10N;
Expand All @@ -20,6 +22,7 @@ public function __construct(
private IL10N $l10n,
private IConfig $config,
private LoggerInterface $logger,
private PropertyMapper $propertyMapper,
) {
}

Expand All @@ -35,6 +38,7 @@ public function getCalendars(string $principalUri, array $calendarUris = []): ar

$iCalendars = [];
foreach ($calendarInfos as $calendarInfo) {
$calendarInfo = array_merge($calendarInfo, $this->getAdditionalProperties($calendarInfo['principaluri'], $calendarInfo['uri']));
$calendar = new Calendar($this->calDavBackend, $calendarInfo, $this->l10n, $this->config, $this->logger);
$iCalendars[] = new CalendarImpl(
$calendar,
Expand All @@ -44,4 +48,23 @@ public function getCalendars(string $principalUri, array $calendarUris = []): ar
}
return $iCalendars;
}

public function getAdditionalProperties(string $principalUri, string $calendarUri): array {
$user = str_replace('principals/users/', '', $principalUri);
$path = 'calendars/' . $user . '/' . $calendarUri;

$properties = $this->propertyMapper->findPropertiesByPath($user, $path);

$list = [];
foreach ($properties as $property) {
if ($property instanceof Property) {
$list[$property->getPropertyname()] = match ($property->getPropertyname()) {
'{http://owncloud.org/ns}calendar-enabled' => (bool)$property->getPropertyvalue(),
default => $property->getPropertyvalue()
};
}
}

return $list;
}
}
14 changes: 14 additions & 0 deletions apps/dav/lib/Db/PropertyMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,18 @@ public function findPropertyByPathAndName(string $userId, string $path, string $
return $this->findEntities($selectQb);
}

/**
* @return Property[]
*/
public function findPropertiesByPath(string $userId, string $path): array {
$selectQb = $this->db->getQueryBuilder();
$selectQb->select('*')
->from(self::TABLE_NAME)
->where(
$selectQb->expr()->eq('userid', $selectQb->createNamedParameter($userId)),
$selectQb->expr()->eq('propertypath', $selectQb->createNamedParameter($path)),
);
return $this->findEntities($selectQb);
}

}
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
'OCP\\Calendar\\IAvailabilityResult' => $baseDir . '/lib/public/Calendar/IAvailabilityResult.php',
'OCP\\Calendar\\ICalendar' => $baseDir . '/lib/public/Calendar/ICalendar.php',
'OCP\\Calendar\\ICalendarEventBuilder' => $baseDir . '/lib/public/Calendar/ICalendarEventBuilder.php',
'OCP\\Calendar\\ICalendarIsEnabled' => $baseDir . '/lib/public/Calendar/ICalendarIsEnabled.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',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Calendar\\IAvailabilityResult' => __DIR__ . '/../../..' . '/lib/public/Calendar/IAvailabilityResult.php',
'OCP\\Calendar\\ICalendar' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendar.php',
'OCP\\Calendar\\ICalendarEventBuilder' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarEventBuilder.php',
'OCP\\Calendar\\ICalendarIsEnabled' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsEnabled.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',
Expand Down
24 changes: 24 additions & 0 deletions lib/public/Calendar/ICalendarIsEnabled.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Calendar;

/**
* ICalendar Interface Extension
*
* @since 31.0.6
*/
interface ICalendarIsEnabled {

/**
* Indicates whether the calendar is enabled
*
* @since 31.0.6
*/
public function isEnabled(): bool;

}
Loading