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
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\Settings;
use OCA\DAV\AppInfo\Application;
use OCA\DAV\Service\ExampleContactService;
use OCA\DAV\Service\ExampleEventService;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Services\IInitialState;
use OCP\Settings\ISettings;
class ExampleContentSettings implements ISettings {
public function __construct(
private readonly IAppConfig $appConfig,
private readonly IInitialState $initialState,
private readonly IAppManager $appManager,
private readonly ExampleEventService $exampleEventService,
private readonly ExampleContactService $exampleContactService,
) {
}
public function getForm(): TemplateResponse {
$calendarEnabled = $this->appManager->isEnabledForUser('calendar');
$contactsEnabled = $this->appManager->isEnabledForUser('contacts');
$this->initialState->provideInitialState('calendarEnabled', $calendarEnabled);
$this->initialState->provideInitialState('contactsEnabled', $contactsEnabled);
if ($calendarEnabled) {
$enableDefaultEvent = $this->exampleEventService->shouldCreateExampleEvent();
$this->initialState->provideInitialState('create_example_event', $enableDefaultEvent);
$this->initialState->provideInitialState(
'has_custom_example_event',
$this->exampleEventService->hasCustomExampleEvent(),
);
}
if ($contactsEnabled) {
$this->initialState->provideInitialState(
'enableDefaultContact',
$this->exampleContactService->isDefaultContactEnabled(),
);
$this->initialState->provideInitialState(
'hasCustomDefaultContact',
$this->appConfig->getAppValueBool('hasCustomDefaultContact'),
);
}
return new TemplateResponse(Application::APP_ID, 'settings-example-content');
}
public function getSection(): ?string {
if (!$this->appManager->isEnabledForUser('contacts')
&& !$this->appManager->isEnabledForUser('calendar')) {
return null;
}
return 'groupware';
}
public function getPriority(): int {
return 10;
}
}
|