Personal.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\Files_External\Settings;
  7. use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
  8. use OCA\Files_External\MountConfig;
  9. use OCA\Files_External\Service\BackendService;
  10. use OCA\Files_External\Service\UserGlobalStoragesService;
  11. use OCP\AppFramework\Http\TemplateResponse;
  12. use OCP\Encryption\IManager;
  13. use OCP\IUserSession;
  14. use OCP\Settings\ISettings;
  15. class Personal implements ISettings {
  16. public function __construct(
  17. private IManager $encryptionManager,
  18. private UserGlobalStoragesService $userGlobalStoragesService,
  19. private BackendService $backendService,
  20. private GlobalAuth $globalAuth,
  21. private IUserSession $userSession,
  22. ) {
  23. }
  24. /**
  25. * @return TemplateResponse
  26. */
  27. public function getForm() {
  28. $uid = $this->userSession->getUser()->getUID();
  29. $parameters = [
  30. 'encryptionEnabled' => $this->encryptionManager->isEnabled(),
  31. 'visibilityType' => BackendService::VISIBILITY_PERSONAL,
  32. 'storages' => $this->userGlobalStoragesService->getStorages(),
  33. 'backends' => $this->backendService->getAvailableBackends(),
  34. 'authMechanisms' => $this->backendService->getAuthMechanisms(),
  35. 'dependencies' => MountConfig::dependencyMessage($this->backendService->getBackends()),
  36. 'allowUserMounting' => $this->backendService->isUserMountingAllowed(),
  37. 'globalCredentials' => $this->globalAuth->getAuth($uid),
  38. 'globalCredentialsUid' => $uid,
  39. ];
  40. return new TemplateResponse('files_external', 'settings', $parameters, '');
  41. }
  42. /**
  43. * @return string the section ID, e.g. 'sharing'
  44. */
  45. public function getSection() {
  46. return 'externalstorages';
  47. }
  48. /**
  49. * @return int whether the form should be rather on the top or bottom of
  50. * the admin section. The forms are arranged in ascending order of the
  51. * priority values. It is required to return a value between 0 and 100.
  52. *
  53. * E.g.: 70
  54. */
  55. public function getPriority() {
  56. return 40;
  57. }
  58. }