fix for bug #1942: Allow user to share with every group if "allow users to share with anyone" is set
This commit is contained in:
parent
f1fc73ea5b
commit
003241e847
2 changed files with 8 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue