mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #52705 from nextcloud/backport/51081/stable31
[stable31] fix(CalDAV): add calendar enable
This commit is contained in:
commit
72cae91ee7
7 changed files with 83 additions and 2 deletions
|
|
@ -9,11 +9,12 @@ declare(strict_types=1);
|
|||
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,
|
||||
|
|
@ -86,6 +87,13 @@ class CachedSubscriptionImpl implements ICalendar, ICalendarIsShared, ICalendarI
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ namespace OCA\DAV\CalDAV;
|
|||
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;
|
||||
|
|
@ -24,7 +27,7 @@ use Sabre\VObject\Property;
|
|||
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> */
|
||||
|
|
@ -131,6 +134,13 @@ class CalendarImpl implements ICreateFromString, IHandleImipMessage {
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 31.0.6
|
||||
*/
|
||||
public function isEnabled(): bool {
|
||||
return $this->calendarInfo['{http://owncloud.org/ns}calendar-enabled'] ?? true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 31.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace OCA\DAV\CalDAV;
|
||||
|
||||
use OCA\DAV\Db\Property;
|
||||
use OCA\DAV\Db\PropertyMapper;
|
||||
use OCP\Calendar\ICalendarProvider;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
|
|
@ -20,6 +22,7 @@ class CalendarProvider implements ICalendarProvider {
|
|||
private IL10N $l10n,
|
||||
private IConfig $config,
|
||||
private LoggerInterface $logger,
|
||||
private PropertyMapper $propertyMapper,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -35,6 +38,7 @@ class CalendarProvider implements ICalendarProvider {
|
|||
|
||||
$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,
|
||||
|
|
@ -44,4 +48,23 @@ class CalendarProvider implements ICalendarProvider {
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,4 +38,18 @@ class PropertyMapper extends QBMapper {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ return array(
|
|||
'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',
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
24
lib/public/Calendar/ICalendarIsEnabled.php
Normal file
24
lib/public/Calendar/ICalendarIsEnabled.php
Normal file
|
|
@ -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…
Reference in a new issue