2017-10-11 11:09:26 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2024-05-27 15:39:07 +00:00
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2017-10-11 11:09:26 +00:00
|
|
|
*/
|
|
|
|
namespace OCA\DAV\Settings;
|
|
|
|
|
2021-05-16 15:56:50 +00:00
|
|
|
use OCA\DAV\AppInfo\Application;
|
2024-07-13 14:51:16 +00:00
|
|
|
use OCP\App\IAppManager;
|
2017-10-11 11:09:26 +00:00
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2021-05-16 15:56:50 +00:00
|
|
|
use OCP\AppFramework\Services\IInitialState;
|
2017-10-11 11:09:26 +00:00
|
|
|
use OCP\IConfig;
|
2022-03-18 16:40:36 +00:00
|
|
|
use OCP\IURLGenerator;
|
2021-10-14 13:07:14 +00:00
|
|
|
use OCP\Settings\IDelegatedSettings;
|
2017-10-11 11:09:26 +00:00
|
|
|
|
2021-10-14 13:07:14 +00:00
|
|
|
class CalDAVSettings implements IDelegatedSettings {
|
2017-10-11 11:09:26 +00:00
|
|
|
|
2021-10-14 13:07:14 +00:00
|
|
|
private const defaults = [
|
|
|
|
'sendInvitations' => 'yes',
|
|
|
|
'generateBirthdayCalendar' => 'yes',
|
|
|
|
'sendEventReminders' => 'yes',
|
2023-05-04 10:51:58 +00:00
|
|
|
'sendEventRemindersToSharedUsers' => 'yes',
|
2023-08-29 14:16:57 +00:00
|
|
|
'sendEventRemindersPush' => 'yes',
|
2021-10-14 13:07:14 +00:00
|
|
|
];
|
|
|
|
|
2017-10-11 11:09:26 +00:00
|
|
|
/**
|
|
|
|
* CalDAVSettings constructor.
|
|
|
|
*
|
|
|
|
* @param IConfig $config
|
2021-05-16 15:56:50 +00:00
|
|
|
* @param IInitialState $initialState
|
2017-10-11 11:09:26 +00:00
|
|
|
*/
|
2024-10-18 10:04:22 +00:00
|
|
|
public function __construct(
|
|
|
|
private IConfig $config,
|
|
|
|
private IInitialState $initialState,
|
|
|
|
private IURLGenerator $urlGenerator,
|
|
|
|
private IAppManager $appManager,
|
|
|
|
) {
|
2017-10-11 11:09:26 +00:00
|
|
|
}
|
|
|
|
|
2021-05-16 15:56:50 +00:00
|
|
|
public function getForm(): TemplateResponse {
|
2022-03-18 16:40:36 +00:00
|
|
|
$this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars'));
|
2021-10-14 13:07:14 +00:00
|
|
|
foreach (self::defaults as $key => $default) {
|
2021-05-16 15:56:50 +00:00
|
|
|
$value = $this->config->getAppValue(Application::APP_ID, $key, $default);
|
|
|
|
$this->initialState->provideInitialState($key, $value === 'yes');
|
|
|
|
}
|
|
|
|
return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav');
|
2017-10-11 11:09:26 +00:00
|
|
|
}
|
|
|
|
|
2024-07-13 14:51:16 +00:00
|
|
|
public function getSection(): ?string {
|
|
|
|
if (!$this->appManager->isBackendRequired(IAppManager::BACKEND_CALDAV)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-06-27 17:16:21 +00:00
|
|
|
return 'groupware';
|
2017-10-11 11:09:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getPriority() {
|
2018-06-27 17:16:21 +00:00
|
|
|
return 10;
|
2017-10-11 11:09:26 +00:00
|
|
|
}
|
2021-10-14 13:07:14 +00:00
|
|
|
|
|
|
|
public function getName(): ?string {
|
|
|
|
return null; // Only setting in this section
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAuthorizedAppConfig(): array {
|
|
|
|
return [
|
|
|
|
'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/']
|
|
|
|
];
|
|
|
|
}
|
2017-10-11 11:09:26 +00:00
|
|
|
}
|