]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix for bug #1942: Allow user to share with every group if "allow users to share...
authorBjörn Schießle <schiessle@owncloud.com>
Tue, 9 Oct 2012 08:36:24 +0000 (10:36 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Tue, 9 Oct 2012 08:36:24 +0000 (10:36 +0200)
core/ajax/share.php
lib/public/share.php

index 446d4cc32ec8bd1999e28d940fb8fc39b3602775..8309a062119c74f4e584c25fba0a6ef91f7c2e1c 100644 (file)
@@ -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
index 75363d081c0b7062e01d0b64b82c9be7a4a9087e..1db3a0b2c1de80685b073936d084fe51f09bd9ae 100644 (file)
@@ -173,6 +173,7 @@ class Share {
        */\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
@@ -185,7 +186,7 @@ class Share {
                                \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
@@ -208,7 +209,7 @@ class Share {
                                \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