Admin.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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\FederatedFileSharing\Settings;
  7. use OCA\FederatedFileSharing\FederatedShareProvider;
  8. use OCP\AppFramework\Http\TemplateResponse;
  9. use OCP\AppFramework\Services\IInitialState;
  10. use OCP\GlobalScale\IConfig;
  11. use OCP\IL10N;
  12. use OCP\IURLGenerator;
  13. use OCP\Settings\IDelegatedSettings;
  14. class Admin implements IDelegatedSettings {
  15. private FederatedShareProvider $fedShareProvider;
  16. private IConfig $gsConfig;
  17. private IL10N $l;
  18. private IURLGenerator $urlGenerator;
  19. private IInitialState $initialState;
  20. /**
  21. * Admin constructor.
  22. */
  23. public function __construct(
  24. FederatedShareProvider $fedShareProvider,
  25. IConfig $globalScaleConfig,
  26. IL10N $l,
  27. IURLGenerator $urlGenerator,
  28. IInitialState $initialState
  29. ) {
  30. $this->fedShareProvider = $fedShareProvider;
  31. $this->gsConfig = $globalScaleConfig;
  32. $this->l = $l;
  33. $this->urlGenerator = $urlGenerator;
  34. $this->initialState = $initialState;
  35. }
  36. /**
  37. * @return TemplateResponse
  38. */
  39. public function getForm() {
  40. $this->initialState->provideInitialState('internalOnly', $this->gsConfig->onlyInternalFederation());
  41. $this->initialState->provideInitialState('sharingFederatedDocUrl', $this->urlGenerator->linkToDocs('admin-sharing-federated'));
  42. $this->initialState->provideInitialState('outgoingServer2serverShareEnabled', $this->fedShareProvider->isOutgoingServer2serverShareEnabled());
  43. $this->initialState->provideInitialState('incomingServer2serverShareEnabled', $this->fedShareProvider->isIncomingServer2serverShareEnabled());
  44. $this->initialState->provideInitialState('federatedGroupSharingSupported', $this->fedShareProvider->isFederatedGroupSharingSupported());
  45. $this->initialState->provideInitialState('outgoingServer2serverGroupShareEnabled', $this->fedShareProvider->isOutgoingServer2serverGroupShareEnabled());
  46. $this->initialState->provideInitialState('incomingServer2serverGroupShareEnabled', $this->fedShareProvider->isIncomingServer2serverGroupShareEnabled());
  47. $this->initialState->provideInitialState('lookupServerEnabled', $this->fedShareProvider->isLookupServerQueriesEnabled());
  48. $this->initialState->provideInitialState('lookupServerUploadEnabled', $this->fedShareProvider->isLookupServerUploadEnabled());
  49. return new TemplateResponse('federatedfilesharing', 'settings-admin', [], '');
  50. }
  51. /**
  52. * @return string the section ID, e.g. 'sharing'
  53. */
  54. public function getSection() {
  55. return 'sharing';
  56. }
  57. /**
  58. * @return int whether the form should be rather on the top or bottom of
  59. * the admin section. The forms are arranged in ascending order of the
  60. * priority values. It is required to return a value between 0 and 100.
  61. *
  62. * E.g.: 70
  63. */
  64. public function getPriority() {
  65. return 20;
  66. }
  67. public function getName(): ?string {
  68. return $this->l->t('Federated Cloud Sharing');
  69. }
  70. public function getAuthorizedAppConfig(): array {
  71. return [
  72. 'files_sharing' => [
  73. 'outgoing_server2server_share_enabled',
  74. 'incoming_server2server_share_enabled',
  75. 'federatedGroupSharingSupported',
  76. 'outgoingServer2serverGroupShareEnabled',
  77. 'incomingServer2serverGroupShareEnabled',
  78. 'lookupServerEnabled',
  79. 'lookupServerUploadEnabled',
  80. ],
  81. ];
  82. }
  83. }