diff options
Diffstat (limited to 'apps/dav/lib/Settings/ExampleContentSettings.php')
-rw-r--r-- | apps/dav/lib/Settings/ExampleContentSettings.php | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/apps/dav/lib/Settings/ExampleContentSettings.php b/apps/dav/lib/Settings/ExampleContentSettings.php index f5607b6a31b..7b6f9b03a3a 100644 --- a/apps/dav/lib/Settings/ExampleContentSettings.php +++ b/apps/dav/lib/Settings/ExampleContentSettings.php @@ -9,28 +9,56 @@ declare(strict_types=1); 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\IConfig; use OCP\Settings\ISettings; class ExampleContentSettings implements ISettings { - public function __construct( - private IConfig $config, - private IInitialState $initialState, - private IAppManager $appManager, + private readonly IAppConfig $appConfig, + private readonly IInitialState $initialState, + private readonly IAppManager $appManager, + private readonly ExampleEventService $exampleEventService, + private readonly ExampleContactService $exampleContactService, ) { } public function getForm(): TemplateResponse { - $enableDefaultContact = $this->config->getAppValue(Application::APP_ID, 'enableDefaultContact', 'no'); - $this->initialState->provideInitialState('enableDefaultContact', $enableDefaultContact); + $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')) { + if (!$this->appManager->isEnabledForUser('contacts') + && !$this->appManager->isEnabledForUser('calendar')) { return null; } @@ -40,5 +68,4 @@ class ExampleContentSettings implements ISettings { public function getPriority(): int { return 10; } - } |