1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Roeland Jago Douma <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
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
|
|
|
|
23
|
|
|
use OCP\Capabilities\ICapability; |
24
|
|
|
use OCP\IConfig; |
25
|
|
|
use OCP\Util\UserSearch; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class Capabilities |
29
|
|
|
* |
30
|
|
|
* @package OCA\Files_Sharing |
31
|
|
|
*/ |
32
|
|
|
class Capabilities implements ICapability { |
33
|
|
|
|
34
|
|
|
/** @var IConfig */ |
35
|
|
|
private $config; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var UserSearch |
39
|
|
|
*/ |
40
|
|
|
private $userSearch; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Capabilities constructor. |
44
|
|
|
* |
45
|
|
|
* @param IConfig $config |
46
|
|
|
* @param UserSearch $userSearch |
47
|
|
|
*/ |
48
|
|
|
public function __construct(IConfig $config, UserSearch $userSearch) { |
49
|
|
|
$this->config = $config; |
50
|
|
|
$this->userSearch = $userSearch; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Return this classes capabilities |
55
|
|
|
* |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
|
|
public function getCapabilities() { |
59
|
|
|
$res = []; |
60
|
|
|
|
61
|
|
|
if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { |
62
|
|
|
$res['api_enabled'] = false; |
63
|
|
|
$res['public'] = ['enabled' => false]; |
64
|
|
|
$res['user'] = ['send_mail' => false]; |
65
|
|
|
$res['resharing'] = false; |
66
|
|
|
} else { |
67
|
|
|
$res['api_enabled'] = true; |
68
|
|
|
|
69
|
|
|
$public = []; |
70
|
|
|
$public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes'; |
71
|
|
|
if ($public['enabled']) { |
72
|
|
|
$public['password'] = []; |
73
|
|
|
$public['password']['enforced_for'] = []; |
74
|
|
|
$roPasswordEnforced = $this->config->getAppValue('core', 'shareapi_enforce_links_password_read_only', 'no') === 'yes'; |
75
|
|
|
$rwPasswordEnforced = $this->config->getAppValue('core', 'shareapi_enforce_links_password_read_write', 'no') === 'yes'; |
76
|
|
|
$woPasswordEnforced = $this->config->getAppValue('core', 'shareapi_enforce_links_password_write_only', 'no') === 'yes'; |
77
|
|
|
$public['password']['enforced_for']['read_only'] = $roPasswordEnforced; |
78
|
|
|
$public['password']['enforced_for']['read_write'] = $rwPasswordEnforced; |
79
|
|
|
$public['password']['enforced_for']['upload_only'] = $woPasswordEnforced; |
80
|
|
|
$public['password']['enforced'] = $roPasswordEnforced || $rwPasswordEnforced || $woPasswordEnforced; |
81
|
|
|
|
82
|
|
|
$public['expire_date'] = []; |
83
|
|
|
$public['expire_date']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; |
84
|
|
|
if ($public['expire_date']['enabled']) { |
85
|
|
|
$public['expire_date']['days'] = $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
86
|
|
|
$public['expire_date']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
$public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no') === 'yes'; |
90
|
|
|
$public['social_share'] = $this->config->getAppValue('core', 'shareapi_allow_social_share', 'yes') === 'yes'; |
91
|
|
|
$public['upload'] = $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes'; |
92
|
|
|
$public['multiple'] = true; |
93
|
|
|
$public['supports_upload_only'] = true; |
94
|
|
|
} |
95
|
|
|
$res["public"] = $public; |
96
|
|
|
|
97
|
|
|
$res['user']['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no') === 'yes'; |
98
|
|
|
|
99
|
|
|
$res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes'; |
100
|
|
|
|
101
|
|
|
$res['group_sharing'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes'; |
102
|
|
|
|
103
|
|
|
$res['share_with_group_members_only'] = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'yes') === 'yes'; |
104
|
|
|
$res['share_with_membership_groups_only'] = $this->config->getAppValue('core', 'shareapi_only_share_with_membership_groups', 'yes') === 'yes'; |
105
|
|
|
|
106
|
|
|
$user_enumeration = []; |
107
|
|
|
$user_enumeration['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes'; |
108
|
|
|
if ($user_enumeration['enabled']) { |
109
|
|
|
$user_enumeration['group_members_only'] = $this->config->getAppValue('core', 'shareapi_share_dialog_user_enumeration_group_members', 'no') === 'yes'; |
110
|
|
|
} |
111
|
|
|
$res["user_enumeration"] = $user_enumeration; |
112
|
|
|
|
113
|
|
|
$res['default_permissions'] = (int)$this->config->getAppValue('core', 'shareapi_default_permissions', \OCP\Constants::PERMISSION_ALL); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
//Federated sharing |
117
|
|
|
$res['federation'] = [ |
118
|
|
|
'outgoing' => $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes', |
119
|
|
|
'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes' |
120
|
|
|
]; |
121
|
|
|
|
122
|
|
|
$res['search_min_length'] = $this->userSearch->getSearchMinLength(); |
123
|
|
|
|
124
|
|
|
return [ |
125
|
|
|
'files_sharing' => $res, |
126
|
|
|
]; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|