Admin.php 2.9 KB

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