1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<?php
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\Settings;
use OCA\DAV\AppInfo\Application;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
use OCP\IURLGenerator;
use OCP\Settings\IDelegatedSettings;
class CalDAVSettings implements IDelegatedSettings {
/** @var IConfig */
private $config;
/** @var IInitialState */
private $initialState;
private IURLGenerator $urlGenerator;
private IAppManager $appManager;
private const defaults = [
'sendInvitations' => 'yes',
'generateBirthdayCalendar' => 'yes',
'sendEventReminders' => 'yes',
'sendEventRemindersToSharedUsers' => 'yes',
'sendEventRemindersPush' => 'yes',
];
/**
* CalDAVSettings constructor.
*
* @param IConfig $config
* @param IInitialState $initialState
*/
public function __construct(IConfig $config, IInitialState $initialState, IURLGenerator $urlGenerator, IAppManager $appManager) {
$this->config = $config;
$this->initialState = $initialState;
$this->urlGenerator = $urlGenerator;
$this->appManager = $appManager;
}
public function getForm(): TemplateResponse {
$this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars'));
foreach (self::defaults as $key => $default) {
$value = $this->config->getAppValue(Application::APP_ID, $key, $default);
$this->initialState->provideInitialState($key, $value === 'yes');
}
return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav');
}
public function getSection(): ?string {
if (!$this->appManager->isBackendRequired(IAppManager::BACKEND_CALDAV)) {
return null;
}
return 'groupware';
}
/**
* @return int
*/
public function getPriority() {
return 10;
}
public function getName(): ?string {
return null; // Only setting in this section
}
public function getAuthorizedAppConfig(): array {
return [
'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/']
];
}
}
|