Capabilities.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\ShareByMail;
  8. use OCA\ShareByMail\Settings\SettingsManager;
  9. use OCP\App\IAppManager;
  10. use OCP\Capabilities\ICapability;
  11. use OCP\Share\IManager;
  12. class Capabilities implements ICapability {
  13. /** @var IManager */
  14. private $manager;
  15. /** @var SettingsManager */
  16. private $settingsManager;
  17. /** @var IAppManager */
  18. private $appManager;
  19. public function __construct(IManager $manager,
  20. SettingsManager $settingsManager,
  21. IAppManager $appManager) {
  22. $this->manager = $manager;
  23. $this->settingsManager = $settingsManager;
  24. $this->appManager = $appManager;
  25. }
  26. /**
  27. * @return array{
  28. * files_sharing: array{
  29. * sharebymail: array{
  30. * enabled: bool,
  31. * send_password_by_mail: bool,
  32. * upload_files_drop: array{
  33. * enabled: bool,
  34. * },
  35. * password: array{
  36. * enabled: bool,
  37. * enforced: bool,
  38. * },
  39. * expire_date: array{
  40. * enabled: bool,
  41. * enforced: bool,
  42. * },
  43. * }
  44. * }
  45. * }|array<empty>
  46. */
  47. public function getCapabilities(): array {
  48. if (!$this->appManager->isEnabledForUser('files_sharing')) {
  49. return [];
  50. }
  51. return [
  52. 'files_sharing' =>
  53. [
  54. 'sharebymail' =>
  55. [
  56. 'enabled' => $this->manager->shareApiAllowLinks(),
  57. 'send_password_by_mail' => $this->settingsManager->sendPasswordByMail(),
  58. 'upload_files_drop' => [
  59. 'enabled' => true,
  60. ],
  61. 'password' => [
  62. 'enabled' => true,
  63. 'enforced' => $this->manager->shareApiLinkEnforcePassword(),
  64. ],
  65. 'expire_date' => [
  66. 'enabled' => true,
  67. 'enforced' => $this->manager->shareApiLinkDefaultExpireDateEnforced(),
  68. ],
  69. ]
  70. ]
  71. ];
  72. }
  73. }