1
0

CalDAVSettings.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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\AppFramework\Http\TemplateResponse;
  9. use OCP\AppFramework\Services\IInitialState;
  10. use OCP\IConfig;
  11. use OCP\IURLGenerator;
  12. use OCP\Settings\IDelegatedSettings;
  13. class CalDAVSettings implements IDelegatedSettings {
  14. /** @var IConfig */
  15. private $config;
  16. /** @var IInitialState */
  17. private $initialState;
  18. private IURLGenerator $urlGenerator;
  19. private const defaults = [
  20. 'sendInvitations' => 'yes',
  21. 'generateBirthdayCalendar' => 'yes',
  22. 'sendEventReminders' => 'yes',
  23. 'sendEventRemindersToSharedUsers' => 'yes',
  24. 'sendEventRemindersPush' => 'yes',
  25. ];
  26. /**
  27. * CalDAVSettings constructor.
  28. *
  29. * @param IConfig $config
  30. * @param IInitialState $initialState
  31. */
  32. public function __construct(IConfig $config, IInitialState $initialState, IURLGenerator $urlGenerator) {
  33. $this->config = $config;
  34. $this->initialState = $initialState;
  35. $this->urlGenerator = $urlGenerator;
  36. }
  37. public function getForm(): TemplateResponse {
  38. $this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars'));
  39. foreach (self::defaults as $key => $default) {
  40. $value = $this->config->getAppValue(Application::APP_ID, $key, $default);
  41. $this->initialState->provideInitialState($key, $value === 'yes');
  42. }
  43. return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav');
  44. }
  45. /**
  46. * @return string
  47. */
  48. public function getSection() {
  49. return 'groupware';
  50. }
  51. /**
  52. * @return int
  53. */
  54. public function getPriority() {
  55. return 10;
  56. }
  57. public function getName(): ?string {
  58. return null; // Only setting in this section
  59. }
  60. public function getAuthorizedAppConfig(): array {
  61. return [
  62. 'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/']
  63. ];
  64. }
  65. }