Personal.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Files_Sharing\Settings;
  8. use OCA\Files_Sharing\AppInfo\Application;
  9. use OCP\AppFramework\Http\TemplateResponse;
  10. use OCP\AppFramework\Services\IInitialState;
  11. use OCP\IConfig;
  12. use OCP\Settings\ISettings;
  13. class Personal implements ISettings {
  14. public function __construct(
  15. private IConfig $config,
  16. private IInitialState $initialState,
  17. private string $userId,
  18. ) {
  19. }
  20. public function getForm(): TemplateResponse {
  21. $defaultAcceptSystemConfig = $this->config->getSystemValueBool('sharing.enable_share_accept', false) ? 'no' : 'yes';
  22. $shareFolderSystemConfig = $this->config->getSystemValue('share_folder', '/');
  23. $acceptDefault = $this->config->getUserValue($this->userId, Application::APP_ID, 'default_accept', $defaultAcceptSystemConfig) === 'yes';
  24. $enforceAccept = $this->config->getSystemValueBool('sharing.force_share_accept', false);
  25. $allowCustomDirectory = $this->config->getSystemValueBool('sharing.allow_custom_share_folder', true);
  26. $shareFolderDefault = $this->config->getUserValue($this->userId, Application::APP_ID, 'share_folder', $shareFolderSystemConfig);
  27. $this->initialState->provideInitialState('accept_default', $acceptDefault);
  28. $this->initialState->provideInitialState('enforce_accept', $enforceAccept);
  29. $this->initialState->provideInitialState('allow_custom_share_folder', $allowCustomDirectory);
  30. $this->initialState->provideInitialState('share_folder', $shareFolderDefault);
  31. $this->initialState->provideInitialState('default_share_folder', $shareFolderSystemConfig);
  32. return new TemplateResponse('files_sharing', 'Settings/personal');
  33. }
  34. public function getSection(): string {
  35. return 'sharing';
  36. }
  37. public function getPriority(): int {
  38. return 90;
  39. }
  40. }