}
}
$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
*/\r
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) {\r
$uidOwner = \OC_User::getUser();\r
+ $sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');\r
// Verify share type and sharing conditions are met\r
if ($shareType === self::SHARE_TYPE_USER) {\r
if ($shareWith == $uidOwner) {\r
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);\r
throw new \Exception($message);\r
}\r
- if (\OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global') == 'groups_only') {\r
+ if ($sharingPolicy == 'groups_only') {\r
$inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith));\r
if (empty($inGroup)) {\r
$message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' is not a member of any groups that '.$uidOwner.' is a member of';\r
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);\r
throw new \Exception($message);\r
}\r
- if (!\OC_Group::inGroup($uidOwner, $shareWith)) {\r
+ if ($sharingPolicy == 'groups_only' && !\OC_Group::inGroup($uidOwner, $shareWith)) {\r
$message = 'Sharing '.$itemSource.' failed, because '.$uidOwner.' is not a member of the group '.$shareWith;\r
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);\r
throw new \Exception($message);\r