1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Tom Needham <[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
|
|
|
|
22
|
|
|
namespace OC\Settings\Panels\Admin; |
23
|
|
|
|
24
|
|
|
use OC\Helper\LocaleHelper; |
25
|
|
|
use OC\Settings\Panels\Helper; |
26
|
|
|
use OCP\IConfig; |
27
|
|
|
use OCP\Settings\ISettings; |
28
|
|
|
use OCP\Template; |
29
|
|
|
use OCP\IL10N; |
30
|
|
|
|
31
|
|
|
class FileSharing implements ISettings { |
32
|
|
|
|
33
|
|
|
/** @var IConfig */ |
34
|
|
|
protected $config; |
35
|
|
|
/** @var Helper */ |
36
|
|
|
protected $helper; |
37
|
|
|
/** @var IL10N */ |
38
|
|
|
protected $l; |
39
|
|
|
|
40
|
|
|
public function __construct(IConfig $config, Helper $helper, IL10N $l) { |
41
|
|
|
$this->config = $config; |
42
|
|
|
$this->helper = $helper; |
43
|
|
|
$this->l = $l; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getPriority() { |
47
|
|
|
return 99; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getPanel() { |
51
|
|
|
$this->lfactory = \OC::$server->getL10NFactory(); |
|
|
|
|
52
|
|
|
$activeLangCode = $this->config->getAppValue( |
53
|
|
|
'core', |
54
|
|
|
'shareapi_public_notification_lang', |
55
|
|
|
'owner' |
56
|
|
|
); |
57
|
|
|
$this->localeHelper = new LocaleHelper(); |
|
|
|
|
58
|
|
|
list($userLang, $commonLanguages, $languages) = $this->localeHelper->getNormalizedLanguages( |
|
|
|
|
59
|
|
|
$this->lfactory, |
60
|
|
|
$activeLangCode |
61
|
|
|
); |
62
|
|
|
|
63
|
|
|
// Allow reset to the defaults when mail notification is sent in the lang of owner |
64
|
|
|
if ($userLang['code'] === "owner") { |
65
|
|
|
$userLang['name'] = $this->l->t("Owner language"); |
66
|
|
|
} else { |
67
|
|
|
\array_push( |
68
|
|
|
$commonLanguages, |
69
|
|
|
[ |
70
|
|
|
'code' => 'owner', |
71
|
|
|
'name' => $this->l->t("Owner language") |
72
|
|
|
] |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$selector = new Template('settings', 'language'); |
77
|
|
|
$selector->assign('selectName', 'shareapi_public_notification_lang'); |
78
|
|
|
$selector->assign('selectId', 'shareapiPublicNotificationLang'); |
79
|
|
|
$selector->assign('activelanguage', $userLang); |
80
|
|
|
$selector->assign('commonlanguages', $commonLanguages); |
81
|
|
|
$selector->assign('languages', $languages); |
82
|
|
|
|
83
|
|
|
$template = new Template('settings', 'panels/admin/filesharing'); |
84
|
|
|
$template->assign('allowResharing', $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes')); |
85
|
|
|
$template->assign('shareAPIEnabled', $this->config->getAppValue('core', 'shareapi_enabled', 'yes')); |
86
|
|
|
$template->assign('allowLinks', $this->config->getAppValue('core', 'shareapi_allow_links', 'yes')); |
87
|
|
|
$template->assign('allowPublicUpload', $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes')); |
88
|
|
|
$template->assign('enforceLinkPasswordReadOnly', $this->config->getAppValue('core', 'shareapi_enforce_links_password_read_only', 'no')); |
89
|
|
|
$template->assign('enforceLinkPasswordReadWrite', $this->config->getAppValue('core', 'shareapi_enforce_links_password_read_write', 'no')); |
90
|
|
|
$template->assign('enforceLinkPasswordWriteOnly', $this->config->getAppValue('core', 'shareapi_enforce_links_password_write_only', 'no')); |
91
|
|
|
$template->assign('shareDefaultExpireDateSet', $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no')); |
92
|
|
|
$template->assign('allowPublicMailNotification', $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no')); |
93
|
|
|
$template->assign('publicMailNotificationLang', $selector->fetchPage()); |
94
|
|
|
$template->assign('allowSocialShare', $this->config->getAppValue('core', 'shareapi_allow_social_share', 'yes')); |
95
|
|
|
$template->assign('allowGroupSharing', $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes')); |
96
|
|
|
$template->assign('onlyShareWithGroupMembers', $this->helper->shareWithGroupMembersOnly()); |
97
|
|
|
$template->assign('onlyShareWithMembershipGroups', $this->config->getAppValue('core', 'shareapi_only_share_with_membership_groups', 'no') === 'yes'); |
98
|
|
|
$template->assign('allowMailNotification', $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no')); |
99
|
|
|
$template->assign('allowShareDialogUserEnumeration', $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes')); |
100
|
|
|
$template->assign('shareDialogUserEnumerationGroupMembers', $this->config->getAppValue('core', 'shareapi_share_dialog_user_enumeration_group_members', 'no')); |
101
|
|
|
$excludeGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false; |
102
|
|
|
$template->assign('shareExcludeGroups', $excludeGroups); |
103
|
|
|
$excludedGroupsList = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); |
104
|
|
|
$excludedGroupsList = \json_decode($excludedGroupsList); |
105
|
|
|
$template->assign('shareExcludedGroupsList', $excludedGroupsList !== null ? \implode('|', $excludedGroupsList) : ''); |
106
|
|
|
$template->assign('shareExpireAfterNDays', $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7')); |
107
|
|
|
$template->assign('shareEnforceExpireDate', $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no')); |
108
|
|
|
$template->assign('autoAcceptShare', $this->config->getAppValue('core', 'shareapi_auto_accept_share', 'yes')); |
109
|
|
|
|
110
|
|
|
$permList = [ |
111
|
|
|
[ |
112
|
|
|
'id' => 'cancreate', |
113
|
|
|
'label' => $this->l->t('Create'), |
114
|
|
|
'value' => \OCP\Constants::PERMISSION_CREATE |
115
|
|
|
], |
116
|
|
|
[ |
117
|
|
|
'id' => 'canupdate', |
118
|
|
|
'label' => $this->l->t('Change'), |
119
|
|
|
'value' => \OCP\Constants::PERMISSION_UPDATE |
120
|
|
|
], |
121
|
|
|
[ |
122
|
|
|
'id' => 'candelete', |
123
|
|
|
'label' => $this->l->t('Delete'), |
124
|
|
|
'value' => \OCP\Constants::PERMISSION_DELETE |
125
|
|
|
], |
126
|
|
|
[ |
127
|
|
|
'id' => 'canshare', |
128
|
|
|
'label' => $this->l->t('Share'), |
129
|
|
|
'value' => \OCP\Constants::PERMISSION_SHARE |
130
|
|
|
], |
131
|
|
|
]; |
132
|
|
|
$template->assign('shareApiDefaultPermissions', $this->config->getAppValue('core', 'shareapi_default_permissions', \OCP\Constants::PERMISSION_ALL)); |
133
|
|
|
$template->assign('shareApiDefaultPermissionsCheckboxes', $permList); |
134
|
|
|
$template->assign('coreUserAdditionalInfo', $this->config->getAppValue('core', 'user_additional_info_field', '')); |
135
|
|
|
return $template; |
|
|
|
|
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function getSectionID() { |
139
|
|
|
return 'sharing'; |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: