Capabilities.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2021 Vincent Petry <vincent@nextcloud.com>
  4. *
  5. * @author Vincent Petry <vincent@nextcloud.com>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OCA\Provisioning_API;
  24. use OCA\FederatedFileSharing\FederatedShareProvider;
  25. use OCP\App\IAppManager;
  26. use OCP\Capabilities\ICapability;
  27. class Capabilities implements ICapability {
  28. /** @var IAppManager */
  29. private $appManager;
  30. public function __construct(IAppManager $appManager) {
  31. $this->appManager = $appManager;
  32. }
  33. /**
  34. * Function an app uses to return the capabilities
  35. *
  36. * @return array Array containing the apps capabilities
  37. */
  38. public function getCapabilities() {
  39. $federatedScopeEnabled = $this->appManager->isEnabledForUser('federation');
  40. $publishedScopeEnabled = false;
  41. $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
  42. if ($federatedFileSharingEnabled) {
  43. /** @var FederatedShareProvider $shareProvider */
  44. $shareProvider = \OC::$server->query(FederatedShareProvider::class);
  45. $publishedScopeEnabled = $shareProvider->isLookupServerUploadEnabled();
  46. }
  47. return [
  48. 'provisioning_api' => [
  49. 'version' => $this->appManager->getAppVersion('provisioning_api'),
  50. 'AccountPropertyScopesVersion' => 2,
  51. 'AccountPropertyScopesFederatedEnabled' => $federatedScopeEnabled,
  52. 'AccountPropertyScopesPublishedEnabled' => $publishedScopeEnabled,
  53. ]
  54. ];
  55. }
  56. }