aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Share20/ShareDisableChecker.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Share20/ShareDisableChecker.php')
-rw-r--r--lib/private/Share20/ShareDisableChecker.php32
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/private/Share20/ShareDisableChecker.php b/lib/private/Share20/ShareDisableChecker.php
index 9d0c2b8c2b4..1e72ce84a59 100644
--- a/lib/private/Share20/ShareDisableChecker.php
+++ b/lib/private/Share20/ShareDisableChecker.php
@@ -35,7 +35,9 @@ class ShareDisableChecker {
return $this->sharingDisabledForUsersCache[$userId];
}
- if ($this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') {
+ $excludeGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no');
+
+ if ($excludeGroups && $excludeGroups !== 'no') {
$groupsList = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
$excludedGroups = json_decode($groupsList);
if (is_null($excludedGroups)) {
@@ -48,14 +50,28 @@ class ShareDisableChecker {
return false;
}
$usersGroups = $this->groupManager->getUserGroupIds($user);
- if (!empty($usersGroups)) {
- $remainingGroups = array_diff($usersGroups, $excludedGroups);
- // if the user is only in groups which are disabled for sharing then
- // sharing is also disabled for the user
- if (empty($remainingGroups)) {
- $this->sharingDisabledForUsersCache[$userId] = true;
- return true;
+ if ($excludeGroups !== 'allow') {
+ if (!empty($usersGroups)) {
+ $remainingGroups = array_diff($usersGroups, $excludedGroups);
+ // if the user is only in groups which are disabled for sharing then
+ // sharing is also disabled for the user
+ if (empty($remainingGroups)) {
+ $this->sharingDisabledForUsersCache[$userId] = true;
+ return true;
+ }
+ }
+ } else {
+ if (!empty($usersGroups)) {
+ $remainingGroups = array_intersect($usersGroups, $excludedGroups);
+ // if the user is in any group which is allowed for sharing then
+ // sharing is also allowed for the user
+ if (!empty($remainingGroups)) {
+ $this->sharingDisabledForUsersCache[$userId] = false;
+ return false;
+ }
}
+ $this->sharingDisabledForUsersCache[$userId] = true;
+ return true;
}
}