Skip to content

Commit

Permalink
Merge pull request #29241 from owncloud/share_with_group_membership_only
Browse files Browse the repository at this point in the history
Share with group membership only
  • Loading branch information
Vincent Petry authored Oct 30, 2017
2 parents 44db583 + ad3f111 commit e320296
Show file tree
Hide file tree
Showing 14 changed files with 1,901 additions and 1,670 deletions.
1 change: 1 addition & 0 deletions apps/files_sharing/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function getCapabilities() {
$res['group_sharing'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes';

$res['share_with_group_members_only'] = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'yes') === 'yes';
$res['share_with_membership_groups_only'] = $this->config->getAppValue('core', 'shareapi_only_share_with_membership_groups', 'yes') === 'yes';

$user_enumeration = [];
$user_enumeration['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
Expand Down
8 changes: 6 additions & 2 deletions apps/files_sharing/lib/Controller/ShareesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class ShareesController extends OCSController {
/** @var bool */
protected $shareWithGroupOnly = false;

/** @var bool */
protected $shareWithMembershipGroupOnly = false;

/** @var bool */
protected $shareeEnumeration = true;

Expand Down Expand Up @@ -240,7 +243,7 @@ protected function getGroups($search) {
}

$userGroups = [];
if (!empty($groups) && ($this->shareWithGroupOnly || $this->shareeEnumerationGroupMembers)) {
if (!empty($groups) && ($this->shareWithMembershipGroupOnly || $this->shareeEnumerationGroupMembers)) {
// Intersect all the groups that match with the groups this user is a member of
$userGroups = $this->groupManager->getUserGroups($this->userSession->getUser(), 'sharing');
$userGroups = array_map(function (IGroup $group) { return $group->getGID(); }, $userGroups);
Expand Down Expand Up @@ -277,7 +280,7 @@ protected function getGroups($search) {
// On page one we try if the search result has a direct hit on the
// user id and if so, we add that to the exact match list
$group = $this->groupManager->get($search);
if ($group instanceof IGroup && (!$this->shareWithGroupOnly || in_array($group->getGID(), $userGroups))) {
if ($group instanceof IGroup && (!$this->shareWithMembershipGroupOnly || in_array($group->getGID(), $userGroups))) {
array_push($this->result['exact']['groups'], [
'label' => $group->getDisplayName(),
'value' => [
Expand Down Expand Up @@ -524,6 +527,7 @@ public function search($search = '', $itemType = null, $page = 1, $perPage = 200
}

$this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
$this->shareWithMembershipGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_membership_groups', 'no') === 'yes';
$this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
if ($this->shareeEnumeration) {
$this->shareeEnumerationGroupMembers = $this->config->getAppValue('core', 'shareapi_share_dialog_user_enumeration_group_members', 'no') === 'yes';
Expand Down
Loading

0 comments on commit e320296

Please sign in to comment.