Capabilities.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\Provisioning_API;
  7. use OCA\FederatedFileSharing\FederatedShareProvider;
  8. use OCP\App\IAppManager;
  9. use OCP\Capabilities\ICapability;
  10. class Capabilities implements ICapability {
  11. /** @var IAppManager */
  12. private $appManager;
  13. public function __construct(IAppManager $appManager) {
  14. $this->appManager = $appManager;
  15. }
  16. /**
  17. * Function an app uses to return the capabilities
  18. *
  19. * @return array{
  20. * provisioning_api: array{
  21. * version: string,
  22. * AccountPropertyScopesVersion: int,
  23. * AccountPropertyScopesFederatedEnabled: bool,
  24. * AccountPropertyScopesPublishedEnabled: bool,
  25. * },
  26. * }
  27. */
  28. public function getCapabilities() {
  29. $federatedScopeEnabled = $this->appManager->isEnabledForUser('federation');
  30. $publishedScopeEnabled = false;
  31. $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
  32. if ($federatedFileSharingEnabled) {
  33. /** @var FederatedShareProvider $shareProvider */
  34. $shareProvider = \OC::$server->query(FederatedShareProvider::class);
  35. $publishedScopeEnabled = $shareProvider->isLookupServerUploadEnabled();
  36. }
  37. return [
  38. 'provisioning_api' => [
  39. 'version' => $this->appManager->getAppVersion('provisioning_api'),
  40. 'AccountPropertyScopesVersion' => 2,
  41. 'AccountPropertyScopesFederatedEnabled' => $federatedScopeEnabled,
  42. 'AccountPropertyScopesPublishedEnabled' => $publishedScopeEnabled,
  43. ]
  44. ];
  45. }
  46. }