Sharing.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  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 OC\Settings\Admin;
  24. use OC\Share\Share;
  25. use OCP\AppFramework\Http\TemplateResponse;
  26. use OCP\IConfig;
  27. use OCP\Settings\ISettings;
  28. use OCP\Util;
  29. class Sharing implements ISettings {
  30. /** @var IConfig */
  31. private $config;
  32. /**
  33. * @param IConfig $config
  34. */
  35. public function __construct(IConfig $config) {
  36. $this->config = $config;
  37. }
  38. /**
  39. * @return TemplateResponse
  40. */
  41. public function getForm() {
  42. $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
  43. $excludeGroupsList = !is_null(json_decode($excludedGroups))
  44. ? implode('|', json_decode($excludedGroups, true)) : '';
  45. $parameters = [
  46. // Built-In Sharing
  47. 'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'),
  48. 'allowLinks' => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'),
  49. 'allowPublicUpload' => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'),
  50. 'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'),
  51. 'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'),
  52. 'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(),
  53. 'onlyShareWithGroupMembers' => Share::shareWithGroupMembersOnly(),
  54. 'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'),
  55. 'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'),
  56. 'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'),
  57. 'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'),
  58. 'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false,
  59. 'shareExcludedGroupsList' => $excludeGroupsList,
  60. 'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null),
  61. ];
  62. return new TemplateResponse('settings', 'admin/sharing', $parameters, '');
  63. }
  64. /**
  65. * @return string the section ID, e.g. 'sharing'
  66. */
  67. public function getSection() {
  68. return 'sharing';
  69. }
  70. /**
  71. * @return int whether the form should be rather on the top or bottom of
  72. * the admin section. The forms are arranged in ascending order of the
  73. * priority values. It is required to return a value between 0 and 100.
  74. *
  75. * E.g.: 70
  76. */
  77. public function getPriority() {
  78. return 0;
  79. }
  80. }