CalDAVSettings.php 1.8 KB

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