Admin.php 2.2 KB

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