diff --git a/core/ajax/share.php b/core/ajax/share.php index 446d4cc32ec8bd1999e28d940fb8fc39b3602775..8309a062119c74f4e584c25fba0a6ef91f7c2e1c 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -123,7 +123,11 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo } } $count = 0; - $groups = OC_Group::getUserGroups(OC_User::getUser()); + if (\OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global') == 'groups_only') { + $groups = OC_Group::getUserGroups(OC_User::getUser()); + } else { + $groups = OC_Group::getGroups(); + } foreach ($groups as $group) { if ($count < 4) { if (stripos($group, $_GET['search']) !== false diff --git a/lib/public/share.php b/lib/public/share.php index 75363d081c0b7062e01d0b64b82c9be7a4a9087e..1db3a0b2c1de80685b073936d084fe51f09bd9ae 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -173,6 +173,7 @@ class Share { */ public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) { $uidOwner = \OC_User::getUser(); + $sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global'); // Verify share type and sharing conditions are met if ($shareType === self::SHARE_TYPE_USER) { if ($shareWith == $uidOwner) { @@ -185,7 +186,7 @@ class Share { \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } - if (\OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global') == 'groups_only') { + if ($sharingPolicy == 'groups_only') { $inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith)); if (empty($inGroup)) { $message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' is not a member of any groups that '.$uidOwner.' is a member of'; @@ -208,7 +209,7 @@ class Share { \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } - if (!\OC_Group::inGroup($uidOwner, $shareWith)) { + if ($sharingPolicy == 'groups_only' && !\OC_Group::inGroup($uidOwner, $shareWith)) { $message = 'Sharing '.$itemSource.' failed, because '.$uidOwner.' is not a member of the group '.$shareWith; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message);