Capabilities.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  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, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCA\Files_Sharing;
  24. use OCP\Capabilities\ICapability;
  25. use \OCP\IConfig;
  26. /**
  27. * Class Capabilities
  28. *
  29. * @package OCA\Files_Sharing
  30. */
  31. class Capabilities implements ICapability {
  32. /** @var IConfig */
  33. private $config;
  34. public function __construct(IConfig $config) {
  35. $this->config = $config;
  36. }
  37. /**
  38. * Return this classes capabilities
  39. *
  40. * @return array
  41. */
  42. public function getCapabilities() {
  43. $res = [];
  44. if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
  45. $res['api_enabled'] = false;
  46. $res['public'] = ['enabled' => false];
  47. $res['user'] = ['send_mail' => false];
  48. $res['resharing'] = false;
  49. } else {
  50. $res['api_enabled'] = true;
  51. $public = [];
  52. $public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes';
  53. if ($public['enabled']) {
  54. $public['password'] = [];
  55. $public['password']['enforced'] = ($this->config->getAppValue('core', 'shareapi_enforce_links_password', 'no') === 'yes');
  56. $public['expire_date'] = [];
  57. $public['expire_date']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes';
  58. if ($public['expire_date']['enabled']) {
  59. $public['expire_date']['days'] = $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
  60. $public['expire_date']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes';
  61. }
  62. $public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no') === 'yes';
  63. $public['upload'] = $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes';
  64. $public['upload_files_drop'] = $public['upload'];
  65. }
  66. $res['public'] = $public;
  67. $res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';
  68. $res['user']['send_mail'] = false;
  69. $res['user']['expire_date']['enabled'] = true;
  70. // deprecated in favour of 'group', but we need to keep it for now
  71. // in order to stay compatible with older clients
  72. $res['group_sharing'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes';
  73. $res['group'] = [];
  74. $res['group']['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes';
  75. $res['group']['expire_date']['enabled'] = true;
  76. }
  77. //Federated sharing
  78. $res['federation'] = [
  79. 'outgoing' => $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes',
  80. 'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes',
  81. 'expire_date' => ['enabled' => true]
  82. ];
  83. return [
  84. 'files_sharing' => $res,
  85. ];
  86. }
  87. }