mirror of
https://github.com/nextcloud/server.git
synced 2026-02-19 02:38:40 -05:00
fix: add calendar enable
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
This commit is contained in:
parent
c7430d5cb8
commit
477bc4e3f1
7 changed files with 81 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 32.0.0
|
||||
*/
|
||||
public function isEnabled(): bool {
|
||||
return $this->calendarInfo['{http://owncloud.org/ns}calendar-enabled'] ?? true;
|
||||
}
|
||||
|
||||
public function isWritable(): bool {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer;
|
|||
use OCP\Calendar\CalendarExportOptions;
|
||||
use OCP\Calendar\Exceptions\CalendarException;
|
||||
use OCP\Calendar\ICalendarExport;
|
||||
use OCP\Calendar\ICalendarIsEnabled;
|
||||
use OCP\Calendar\ICalendarIsShared;
|
||||
use OCP\Calendar\ICalendarIsWritable;
|
||||
use OCP\Calendar\ICreateFromString;
|
||||
|
|
@ -29,7 +30,7 @@ use Sabre\VObject\Property;
|
|||
use Sabre\VObject\Reader;
|
||||
use function Sabre\Uri\split as uriSplit;
|
||||
|
||||
class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsWritable, ICalendarIsShared, ICalendarExport {
|
||||
class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsWritable, ICalendarIsShared, ICalendarExport, ICalendarIsEnabled {
|
||||
public function __construct(
|
||||
private Calendar $calendar,
|
||||
/** @var array<string, mixed> */
|
||||
|
|
@ -136,6 +137,13 @@ class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIs
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 32.0.0
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ return array(
|
|||
'OCP\\Calendar\\ICalendar' => $baseDir . '/lib/public/Calendar/ICalendar.php',
|
||||
'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\\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',
|
||||
|
|
|
|||
|
|
@ -245,6 +245,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
|
|||
'OCP\\Calendar\\ICalendar' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendar.php',
|
||||
'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\\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 32.0.0
|
||||
*/
|
||||
interface ICalendarIsEnabled {
|
||||
|
||||
/**
|
||||
* Indicates whether the calendar is enabled
|
||||
*
|
||||
* @since 32.0.0
|
||||
*/
|
||||
public function isEnabled(): bool;
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue