1
0

CalDAVSettings.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com>
  4. *
  5. * @author Georg Ehrke <oc.list@georgehrke.com>
  6. * @author Julius Härtl <jus@bitgrid.net>
  7. * @author Thomas Citharel <nextcloud@tcit.fr>
  8. * @author François Freitag <mail@franek.fr>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\DAV\Settings;
  27. use OCA\DAV\AppInfo\Application;
  28. use OCP\AppFramework\Http\TemplateResponse;
  29. use OCP\AppFramework\Services\IInitialState;
  30. use OCP\IConfig;
  31. use OCP\IURLGenerator;
  32. use OCP\Settings\IDelegatedSettings;
  33. class CalDAVSettings implements IDelegatedSettings {
  34. /** @var IConfig */
  35. private $config;
  36. /** @var IInitialState */
  37. private $initialState;
  38. private IURLGenerator $urlGenerator;
  39. private const defaults = [
  40. 'sendInvitations' => 'yes',
  41. 'generateBirthdayCalendar' => 'yes',
  42. 'sendEventReminders' => 'yes',
  43. 'sendEventRemindersToSharedUsers' => 'yes',
  44. 'sendEventRemindersPush' => 'yes',
  45. ];
  46. /**
  47. * CalDAVSettings constructor.
  48. *
  49. * @param IConfig $config
  50. * @param IInitialState $initialState
  51. */
  52. public function __construct(IConfig $config, IInitialState $initialState, IURLGenerator $urlGenerator) {
  53. $this->config = $config;
  54. $this->initialState = $initialState;
  55. $this->urlGenerator = $urlGenerator;
  56. }
  57. public function getForm(): TemplateResponse {
  58. $this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars'));
  59. foreach (self::defaults as $key => $default) {
  60. $value = $this->config->getAppValue(Application::APP_ID, $key, $default);
  61. $this->initialState->provideInitialState($key, $value === 'yes');
  62. }
  63. return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav');
  64. }
  65. /**
  66. * @return string
  67. */
  68. public function getSection() {
  69. return 'groupware';
  70. }
  71. /**
  72. * @return int
  73. */
  74. public function getPriority() {
  75. return 10;
  76. }
  77. public function getName(): ?string {
  78. return null; // Only setting in this section
  79. }
  80. public function getAuthorizedAppConfig(): array {
  81. return [
  82. 'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/']
  83. ];
  84. }
  85. }