Admin.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 Bjoern Schiessle <bjoern@schiessle.org>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\FederatedFileSharing\Settings;
  26. use OCA\FederatedFileSharing\FederatedShareProvider;
  27. use OCP\AppFramework\Http\TemplateResponse;
  28. use OCP\AppFramework\Services\IInitialState;
  29. use OCP\GlobalScale\IConfig;
  30. use OCP\IL10N;
  31. use OCP\IURLGenerator;
  32. use OCP\Settings\IDelegatedSettings;
  33. class Admin implements IDelegatedSettings {
  34. private FederatedShareProvider $fedShareProvider;
  35. private IConfig $gsConfig;
  36. private IL10N $l;
  37. private IURLGenerator $urlGenerator;
  38. private IInitialState $initialState;
  39. /**
  40. * Admin constructor.
  41. */
  42. public function __construct(
  43. FederatedShareProvider $fedShareProvider,
  44. IConfig $globalScaleConfig,
  45. IL10N $l,
  46. IURLGenerator $urlGenerator,
  47. IInitialState $initialState
  48. ) {
  49. $this->fedShareProvider = $fedShareProvider;
  50. $this->gsConfig = $globalScaleConfig;
  51. $this->l = $l;
  52. $this->urlGenerator = $urlGenerator;
  53. $this->initialState = $initialState;
  54. }
  55. /**
  56. * @return TemplateResponse
  57. */
  58. public function getForm() {
  59. $this->initialState->provideInitialState('internalOnly', $this->gsConfig->onlyInternalFederation());
  60. $this->initialState->provideInitialState('sharingFederatedDocUrl', $this->urlGenerator->linkToDocs('admin-sharing-federated'));
  61. $this->initialState->provideInitialState('outgoingServer2serverShareEnabled', $this->fedShareProvider->isOutgoingServer2serverShareEnabled());
  62. $this->initialState->provideInitialState('incomingServer2serverShareEnabled', $this->fedShareProvider->isIncomingServer2serverShareEnabled());
  63. $this->initialState->provideInitialState('federatedGroupSharingSupported', $this->fedShareProvider->isFederatedGroupSharingSupported());
  64. $this->initialState->provideInitialState('outgoingServer2serverGroupShareEnabled', $this->fedShareProvider->isOutgoingServer2serverGroupShareEnabled());
  65. $this->initialState->provideInitialState('incomingServer2serverGroupShareEnabled', $this->fedShareProvider->isIncomingServer2serverGroupShareEnabled());
  66. $this->initialState->provideInitialState('lookupServerEnabled', $this->fedShareProvider->isLookupServerQueriesEnabled());
  67. $this->initialState->provideInitialState('lookupServerUploadEnabled', $this->fedShareProvider->isLookupServerUploadEnabled());
  68. return new TemplateResponse('federatedfilesharing', 'settings-admin', [], '');
  69. }
  70. /**
  71. * @return string the section ID, e.g. 'sharing'
  72. */
  73. public function getSection() {
  74. return 'sharing';
  75. }
  76. /**
  77. * @return int whether the form should be rather on the top or bottom of
  78. * the admin section. The forms are arranged in ascending order of the
  79. * priority values. It is required to return a value between 0 and 100.
  80. *
  81. * E.g.: 70
  82. */
  83. public function getPriority() {
  84. return 20;
  85. }
  86. public function getName(): ?string {
  87. return $this->l->t('Federated Cloud Sharing');
  88. }
  89. public function getAuthorizedAppConfig(): array {
  90. return [
  91. 'files_sharing' => [
  92. 'outgoing_server2server_share_enabled',
  93. 'incoming_server2server_share_enabled',
  94. 'federatedGroupSharingSupported',
  95. 'outgoingServer2serverGroupShareEnabled',
  96. 'incomingServer2serverGroupShareEnabled',
  97. 'lookupServerEnabled',
  98. 'lookupServerUploadEnabled',
  99. ],
  100. ];
  101. }
  102. }