1
0

Capabilities.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
  5. *
  6. * @author Bjoern Schiessle <bjoern@schiessle.org>
  7. * @author John Molakvoæ <skjnldsv@protonmail.com>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\ShareByMail;
  27. use OCA\ShareByMail\Settings\SettingsManager;
  28. use OCP\App\IAppManager;
  29. use OCP\Capabilities\ICapability;
  30. use OCP\Share\IManager;
  31. class Capabilities implements ICapability {
  32. /** @var IManager */
  33. private $manager;
  34. /** @var SettingsManager */
  35. private $settingsManager;
  36. /** @var IAppManager */
  37. private $appManager;
  38. public function __construct(IManager $manager,
  39. SettingsManager $settingsManager,
  40. IAppManager $appManager) {
  41. $this->manager = $manager;
  42. $this->settingsManager = $settingsManager;
  43. $this->appManager = $appManager;
  44. }
  45. /**
  46. * @return array{
  47. * files_sharing: array{
  48. * sharebymail: array{
  49. * enabled: bool,
  50. * send_password_by_mail: bool,
  51. * upload_files_drop: array{
  52. * enabled: bool,
  53. * },
  54. * password: array{
  55. * enabled: bool,
  56. * enforced: bool,
  57. * },
  58. * expire_date: array{
  59. * enabled: bool,
  60. * enforced: bool,
  61. * },
  62. * }
  63. * }
  64. * }|array<empty>
  65. */
  66. public function getCapabilities(): array {
  67. if (!$this->appManager->isEnabledForUser('files_sharing')) {
  68. return [];
  69. }
  70. return [
  71. 'files_sharing' =>
  72. [
  73. 'sharebymail' =>
  74. [
  75. 'enabled' => $this->manager->shareApiAllowLinks(),
  76. 'send_password_by_mail' => $this->settingsManager->sendPasswordByMail(),
  77. 'upload_files_drop' => [
  78. 'enabled' => true,
  79. ],
  80. 'password' => [
  81. 'enabled' => true,
  82. 'enforced' => $this->manager->shareApiLinkEnforcePassword(),
  83. ],
  84. 'expire_date' => [
  85. 'enabled' => true,
  86. 'enforced' => $this->manager->shareApiLinkDefaultExpireDateEnforced(),
  87. ],
  88. ]
  89. ]
  90. ];
  91. }
  92. }