@@ -20,52 +20,52 @@ |
||
| 20 | 20 | use Psr\Log\LoggerInterface; |
| 21 | 21 | |
| 22 | 22 | class AvailabilitySettings implements ISettings { |
| 23 | - public function __construct( |
|
| 24 | - protected IConfig $config, |
|
| 25 | - protected IInitialState $initialState, |
|
| 26 | - protected ?string $userId, |
|
| 27 | - private LoggerInterface $logger, |
|
| 28 | - private IAvailabilityCoordinator $coordinator, |
|
| 29 | - private AbsenceMapper $absenceMapper, |
|
| 30 | - ) { |
|
| 31 | - } |
|
| 23 | + public function __construct( |
|
| 24 | + protected IConfig $config, |
|
| 25 | + protected IInitialState $initialState, |
|
| 26 | + protected ?string $userId, |
|
| 27 | + private LoggerInterface $logger, |
|
| 28 | + private IAvailabilityCoordinator $coordinator, |
|
| 29 | + private AbsenceMapper $absenceMapper, |
|
| 30 | + ) { |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public function getForm(): TemplateResponse { |
|
| 34 | - $this->initialState->provideInitialState( |
|
| 35 | - 'user_status_automation', |
|
| 36 | - $this->config->getUserValue( |
|
| 37 | - $this->userId, |
|
| 38 | - 'dav', |
|
| 39 | - 'user_status_automation', |
|
| 40 | - 'no' |
|
| 41 | - ) |
|
| 42 | - ); |
|
| 43 | - $hideAbsenceSettings = !$this->coordinator->isEnabled(); |
|
| 44 | - $this->initialState->provideInitialState('hide_absence_settings', $hideAbsenceSettings); |
|
| 45 | - if (!$hideAbsenceSettings) { |
|
| 46 | - try { |
|
| 47 | - $absence = $this->absenceMapper->findByUserId($this->userId); |
|
| 48 | - $this->initialState->provideInitialState('absence', $absence); |
|
| 49 | - } catch (DoesNotExistException) { |
|
| 50 | - // The user has not yet set up an absence period. |
|
| 51 | - // Logging this error is not necessary. |
|
| 52 | - } catch (\OCP\DB\Exception $e) { |
|
| 53 | - $this->logger->error("Could not find absence data for user $this->userId: " . $e->getMessage(), [ |
|
| 54 | - 'exception' => $e, |
|
| 55 | - ]); |
|
| 56 | - } |
|
| 57 | - } |
|
| 33 | + public function getForm(): TemplateResponse { |
|
| 34 | + $this->initialState->provideInitialState( |
|
| 35 | + 'user_status_automation', |
|
| 36 | + $this->config->getUserValue( |
|
| 37 | + $this->userId, |
|
| 38 | + 'dav', |
|
| 39 | + 'user_status_automation', |
|
| 40 | + 'no' |
|
| 41 | + ) |
|
| 42 | + ); |
|
| 43 | + $hideAbsenceSettings = !$this->coordinator->isEnabled(); |
|
| 44 | + $this->initialState->provideInitialState('hide_absence_settings', $hideAbsenceSettings); |
|
| 45 | + if (!$hideAbsenceSettings) { |
|
| 46 | + try { |
|
| 47 | + $absence = $this->absenceMapper->findByUserId($this->userId); |
|
| 48 | + $this->initialState->provideInitialState('absence', $absence); |
|
| 49 | + } catch (DoesNotExistException) { |
|
| 50 | + // The user has not yet set up an absence period. |
|
| 51 | + // Logging this error is not necessary. |
|
| 52 | + } catch (\OCP\DB\Exception $e) { |
|
| 53 | + $this->logger->error("Could not find absence data for user $this->userId: " . $e->getMessage(), [ |
|
| 54 | + 'exception' => $e, |
|
| 55 | + ]); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - \OCP\Util::addStyle(Application::APP_ID, 'settings-personal-availability'); |
|
| 60 | - \OCP\Util::addScript(Application::APP_ID, 'settings-personal-availability'); |
|
| 61 | - return new TemplateResponse(Application::APP_ID, 'settings-personal-availability'); |
|
| 62 | - } |
|
| 59 | + \OCP\Util::addStyle(Application::APP_ID, 'settings-personal-availability'); |
|
| 60 | + \OCP\Util::addScript(Application::APP_ID, 'settings-personal-availability'); |
|
| 61 | + return new TemplateResponse(Application::APP_ID, 'settings-personal-availability'); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - public function getSection(): string { |
|
| 65 | - return 'availability'; |
|
| 66 | - } |
|
| 64 | + public function getSection(): string { |
|
| 65 | + return 'availability'; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function getPriority(): int { |
|
| 69 | - return 10; |
|
| 70 | - } |
|
| 68 | + public function getPriority(): int { |
|
| 69 | + return 10; |
|
| 70 | + } |
|
| 71 | 71 | } |
@@ -16,62 +16,62 @@ |
||
| 16 | 16 | |
| 17 | 17 | class CalDAVSettings implements IDelegatedSettings { |
| 18 | 18 | |
| 19 | - private const defaults = [ |
|
| 20 | - 'sendInvitations' => 'yes', |
|
| 21 | - 'generateBirthdayCalendar' => 'yes', |
|
| 22 | - 'sendEventReminders' => 'yes', |
|
| 23 | - 'sendEventRemindersToSharedUsers' => 'yes', |
|
| 24 | - 'sendEventRemindersPush' => 'yes', |
|
| 25 | - ]; |
|
| 19 | + private const defaults = [ |
|
| 20 | + 'sendInvitations' => 'yes', |
|
| 21 | + 'generateBirthdayCalendar' => 'yes', |
|
| 22 | + 'sendEventReminders' => 'yes', |
|
| 23 | + 'sendEventRemindersToSharedUsers' => 'yes', |
|
| 24 | + 'sendEventRemindersPush' => 'yes', |
|
| 25 | + ]; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * CalDAVSettings constructor. |
|
| 29 | - * |
|
| 30 | - * @param IConfig $config |
|
| 31 | - * @param IInitialState $initialState |
|
| 32 | - */ |
|
| 33 | - public function __construct( |
|
| 34 | - private IConfig $config, |
|
| 35 | - private IInitialState $initialState, |
|
| 36 | - private IURLGenerator $urlGenerator, |
|
| 37 | - private IAppManager $appManager, |
|
| 38 | - ) { |
|
| 39 | - } |
|
| 27 | + /** |
|
| 28 | + * CalDAVSettings constructor. |
|
| 29 | + * |
|
| 30 | + * @param IConfig $config |
|
| 31 | + * @param IInitialState $initialState |
|
| 32 | + */ |
|
| 33 | + public function __construct( |
|
| 34 | + private IConfig $config, |
|
| 35 | + private IInitialState $initialState, |
|
| 36 | + private IURLGenerator $urlGenerator, |
|
| 37 | + private IAppManager $appManager, |
|
| 38 | + ) { |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function getForm(): TemplateResponse { |
|
| 42 | - $this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars')); |
|
| 43 | - foreach (self::defaults as $key => $default) { |
|
| 44 | - $value = $this->config->getAppValue(Application::APP_ID, $key, $default); |
|
| 45 | - $this->initialState->provideInitialState($key, $value === 'yes'); |
|
| 46 | - } |
|
| 41 | + public function getForm(): TemplateResponse { |
|
| 42 | + $this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars')); |
|
| 43 | + foreach (self::defaults as $key => $default) { |
|
| 44 | + $value = $this->config->getAppValue(Application::APP_ID, $key, $default); |
|
| 45 | + $this->initialState->provideInitialState($key, $value === 'yes'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - \OCP\Util::addScript(Application::APP_ID, 'settings-admin-caldav'); |
|
| 49 | - \OCP\Util::addStyle(Application::APP_ID, 'settings-admin-caldav'); |
|
| 50 | - return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav'); |
|
| 51 | - } |
|
| 48 | + \OCP\Util::addScript(Application::APP_ID, 'settings-admin-caldav'); |
|
| 49 | + \OCP\Util::addStyle(Application::APP_ID, 'settings-admin-caldav'); |
|
| 50 | + return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav'); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function getSection(): ?string { |
|
| 54 | - if (!$this->appManager->isBackendRequired(IAppManager::BACKEND_CALDAV)) { |
|
| 55 | - return null; |
|
| 56 | - } |
|
| 53 | + public function getSection(): ?string { |
|
| 54 | + if (!$this->appManager->isBackendRequired(IAppManager::BACKEND_CALDAV)) { |
|
| 55 | + return null; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return 'groupware'; |
|
| 59 | - } |
|
| 58 | + return 'groupware'; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @return int |
|
| 63 | - */ |
|
| 64 | - public function getPriority() { |
|
| 65 | - return 10; |
|
| 66 | - } |
|
| 61 | + /** |
|
| 62 | + * @return int |
|
| 63 | + */ |
|
| 64 | + public function getPriority() { |
|
| 65 | + return 10; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function getName(): ?string { |
|
| 69 | - return null; // Only setting in this section |
|
| 70 | - } |
|
| 68 | + public function getName(): ?string { |
|
| 69 | + return null; // Only setting in this section |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - public function getAuthorizedAppConfig(): array { |
|
| 73 | - return [ |
|
| 74 | - 'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/'] |
|
| 75 | - ]; |
|
| 76 | - } |
|
| 72 | + public function getAuthorizedAppConfig(): array { |
|
| 73 | + return [ |
|
| 74 | + 'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/'] |
|
| 75 | + ]; |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -18,56 +18,56 @@ |
||
| 18 | 18 | use OCP\Settings\ISettings; |
| 19 | 19 | |
| 20 | 20 | class ExampleContentSettings implements ISettings { |
| 21 | - public function __construct( |
|
| 22 | - private readonly IAppConfig $appConfig, |
|
| 23 | - private readonly IInitialState $initialState, |
|
| 24 | - private readonly IAppManager $appManager, |
|
| 25 | - private readonly ExampleEventService $exampleEventService, |
|
| 26 | - private readonly ExampleContactService $exampleContactService, |
|
| 27 | - ) { |
|
| 28 | - } |
|
| 21 | + public function __construct( |
|
| 22 | + private readonly IAppConfig $appConfig, |
|
| 23 | + private readonly IInitialState $initialState, |
|
| 24 | + private readonly IAppManager $appManager, |
|
| 25 | + private readonly ExampleEventService $exampleEventService, |
|
| 26 | + private readonly ExampleContactService $exampleContactService, |
|
| 27 | + ) { |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function getForm(): TemplateResponse { |
|
| 31 | - $calendarEnabled = $this->appManager->isEnabledForUser('calendar'); |
|
| 32 | - $contactsEnabled = $this->appManager->isEnabledForUser('contacts'); |
|
| 33 | - $this->initialState->provideInitialState('calendarEnabled', $calendarEnabled); |
|
| 34 | - $this->initialState->provideInitialState('contactsEnabled', $contactsEnabled); |
|
| 30 | + public function getForm(): TemplateResponse { |
|
| 31 | + $calendarEnabled = $this->appManager->isEnabledForUser('calendar'); |
|
| 32 | + $contactsEnabled = $this->appManager->isEnabledForUser('contacts'); |
|
| 33 | + $this->initialState->provideInitialState('calendarEnabled', $calendarEnabled); |
|
| 34 | + $this->initialState->provideInitialState('contactsEnabled', $contactsEnabled); |
|
| 35 | 35 | |
| 36 | - if ($calendarEnabled) { |
|
| 37 | - $enableDefaultEvent = $this->exampleEventService->shouldCreateExampleEvent(); |
|
| 38 | - $this->initialState->provideInitialState('create_example_event', $enableDefaultEvent); |
|
| 39 | - $this->initialState->provideInitialState( |
|
| 40 | - 'has_custom_example_event', |
|
| 41 | - $this->exampleEventService->hasCustomExampleEvent(), |
|
| 42 | - ); |
|
| 43 | - } |
|
| 36 | + if ($calendarEnabled) { |
|
| 37 | + $enableDefaultEvent = $this->exampleEventService->shouldCreateExampleEvent(); |
|
| 38 | + $this->initialState->provideInitialState('create_example_event', $enableDefaultEvent); |
|
| 39 | + $this->initialState->provideInitialState( |
|
| 40 | + 'has_custom_example_event', |
|
| 41 | + $this->exampleEventService->hasCustomExampleEvent(), |
|
| 42 | + ); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - if ($contactsEnabled) { |
|
| 46 | - $this->initialState->provideInitialState( |
|
| 47 | - 'enableDefaultContact', |
|
| 48 | - $this->exampleContactService->isDefaultContactEnabled(), |
|
| 49 | - ); |
|
| 50 | - $this->initialState->provideInitialState( |
|
| 51 | - 'hasCustomDefaultContact', |
|
| 52 | - $this->appConfig->getAppValueBool('hasCustomDefaultContact'), |
|
| 53 | - ); |
|
| 54 | - } |
|
| 45 | + if ($contactsEnabled) { |
|
| 46 | + $this->initialState->provideInitialState( |
|
| 47 | + 'enableDefaultContact', |
|
| 48 | + $this->exampleContactService->isDefaultContactEnabled(), |
|
| 49 | + ); |
|
| 50 | + $this->initialState->provideInitialState( |
|
| 51 | + 'hasCustomDefaultContact', |
|
| 52 | + $this->appConfig->getAppValueBool('hasCustomDefaultContact'), |
|
| 53 | + ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - \OCP\Util::addStyle(Application::APP_ID, 'settings-admin-example-content'); |
|
| 57 | - \OCP\Util::addScript(Application::APP_ID, 'settings-admin-example-content'); |
|
| 58 | - return new TemplateResponse(Application::APP_ID, 'settings-admin-example-content'); |
|
| 59 | - } |
|
| 56 | + \OCP\Util::addStyle(Application::APP_ID, 'settings-admin-example-content'); |
|
| 57 | + \OCP\Util::addScript(Application::APP_ID, 'settings-admin-example-content'); |
|
| 58 | + return new TemplateResponse(Application::APP_ID, 'settings-admin-example-content'); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function getSection(): ?string { |
|
| 62 | - if (!$this->appManager->isEnabledForUser('contacts') |
|
| 63 | - && !$this->appManager->isEnabledForUser('calendar')) { |
|
| 64 | - return null; |
|
| 65 | - } |
|
| 61 | + public function getSection(): ?string { |
|
| 62 | + if (!$this->appManager->isEnabledForUser('contacts') |
|
| 63 | + && !$this->appManager->isEnabledForUser('calendar')) { |
|
| 64 | + return null; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return 'groupware'; |
|
| 68 | - } |
|
| 67 | + return 'groupware'; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function getPriority(): int { |
|
| 71 | - return 10; |
|
| 72 | - } |
|
| 70 | + public function getPriority(): int { |
|
| 71 | + return 10; |
|
| 72 | + } |
|
| 73 | 73 | } |