1
0

Admin.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\Files_External\Settings;
  25. use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
  26. use OCA\Files_External\Service\BackendService;
  27. use OCA\Files_External\Service\GlobalStoragesService;
  28. use OCP\AppFramework\Http\TemplateResponse;
  29. use OCP\Encryption\IManager;
  30. use OCP\Settings\ISettings;
  31. class Admin implements ISettings {
  32. /** @var IManager */
  33. private $encryptionManager;
  34. /** @var GlobalStoragesService */
  35. private $globalStoragesService;
  36. /** @var BackendService */
  37. private $backendService;
  38. /** @var GlobalAuth */
  39. private $globalAuth;
  40. public function __construct(
  41. IManager $encryptionManager,
  42. GlobalStoragesService $globalStoragesService,
  43. BackendService $backendService,
  44. GlobalAuth $globalAuth
  45. ) {
  46. $this->encryptionManager = $encryptionManager;
  47. $this->globalStoragesService = $globalStoragesService;
  48. $this->backendService = $backendService;
  49. $this->globalAuth = $globalAuth;
  50. }
  51. /**
  52. * @return TemplateResponse
  53. */
  54. public function getForm() {
  55. $parameters = [
  56. 'encryptionEnabled' => $this->encryptionManager->isEnabled(),
  57. 'visibilityType' => BackendService::VISIBILITY_ADMIN,
  58. 'storages' => $this->globalStoragesService->getStorages(),
  59. 'backends' => $this->backendService->getAvailableBackends(),
  60. 'authMechanisms' => $this->backendService->getAuthMechanisms(),
  61. 'dependencies' => \OCA\Files_External\MountConfig::dependencyMessage($this->backendService->getBackends()),
  62. 'allowUserMounting' => $this->backendService->isUserMountingAllowed(),
  63. 'globalCredentials' => $this->globalAuth->getAuth(''),
  64. 'globalCredentialsUid' => '',
  65. ];
  66. return new TemplateResponse('files_external', 'settings', $parameters, '');
  67. }
  68. /**
  69. * @return string the section ID, e.g. 'sharing'
  70. */
  71. public function getSection() {
  72. return 'externalstorages';
  73. }
  74. /**
  75. * @return int whether the form should be rather on the top or bottom of
  76. * the admin section. The forms are arranged in ascending order of the
  77. * priority values. It is required to return a value between 0 and 100.
  78. *
  79. * E.g.: 70
  80. */
  81. public function getPriority() {
  82. return 40;
  83. }
  84. }