capabilities.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * @author Roeland Jago Douma <roeland@famdouma.nl>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace OCA\Files_Sharing;
  22. use \OCP\IConfig;
  23. /**
  24. * Class Capabilities
  25. *
  26. * @package OCA\Files_Sharing
  27. */
  28. class Capabilities {
  29. /** @var IConfig */
  30. private $config;
  31. /**
  32. * @param IConfig $config
  33. */
  34. public function __construct(IConfig $config) {
  35. $this->config = $config;
  36. }
  37. /**
  38. * @return \OC_OCS_Result
  39. */
  40. public static function getCapabilities() {
  41. $config = \OC::$server->getConfig();
  42. $cap = new Capabilities($config);
  43. return $cap->getCaps();
  44. }
  45. /**
  46. * @return \OC_OCS_Result
  47. */
  48. public function getCaps() {
  49. $res = [];
  50. $public = [];
  51. $public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes';
  52. if ($public['enabled']) {
  53. $public['password'] = [];
  54. $public['password']['enforced'] = ($this->config->getAppValue('core', 'shareapi_enforce_links_password', 'yes') === 'yes');
  55. $public['expire_date'] = [];
  56. $public['expire_date']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'yes') === 'yes';
  57. if ($public['expire_date']['enabled']) {
  58. $public['expire_date']['days'] = $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
  59. $public['expire_date']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'yes') === 'yes';
  60. }
  61. $public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'yes') === 'yes';
  62. }
  63. $res["public"] = $public;
  64. $res['user']['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'yes') === 'yes';
  65. $res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';
  66. return new \OC_OCS_Result([
  67. 'capabilities' => [
  68. 'files_sharing' => $res
  69. ],
  70. ]);
  71. }
  72. }