From 003241e8474da4239d69fc63b3e812b86d0e3667 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 9 Oct 2012 10:36:24 +0200 Subject: [PATCH] fix for bug #1942: Allow user to share with every group if "allow users to share with anyone" is set --- core/ajax/share.php | 6 +++++- lib/public/share.php | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/ajax/share.php b/core/ajax/share.php index 446d4cc32ec..8309a062119 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 75363d081c0..1db3a0b2c1d 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); -- 2.39.5