1
0

Admin.php 1.9 KB

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