]> source.dussan.org Git - nextcloud-server.git/commitdiff
only create a db entry for the user in case of a name conflict on group share
authorBjoern Schiessle <schiessle@owncloud.com>
Thu, 5 Feb 2015 13:00:05 +0000 (14:00 +0100)
committerBjoern Schiessle <schiessle@owncloud.com>
Thu, 9 Apr 2015 09:16:08 +0000 (11:16 +0200)
lib/private/share/share.php
tests/lib/share/share.php

index e624e8da451b0304a390dfd85f217a91ae8bb586..729dbe79d38d6ee47f0cd44971b6646204a30f49 100644 (file)
@@ -1905,7 +1905,11 @@ class Share extends \OC\Share\Constants {
                $isGroupShare = false;
                if ($shareType == self::SHARE_TYPE_GROUP) {
                        $isGroupShare = true;
-                       $users = \OC_Group::usersInGroup($shareWith['group']);
+                       if (isset($shareWith['users'])) {
+                               $users = $shareWith['users'];
+                       } else {
+                               $users = \OC_Group::usersInGroup($shareWith['group']);
+                       }
                        // remove current user from list
                        if (in_array(\OCP\User::getUser(), $users)) {
                                unset($users[array_search(\OCP\User::getUser(), $users)]);
@@ -2016,7 +2020,8 @@ class Share extends \OC\Share\Constants {
                                        $fileTarget = null;
                                }
 
-                               if ($itemTarget === $groupItemTarget && (isset($fileSource) && $fileTarget === $groupItemTarget)) {
+                               if (($itemTarget === $groupItemTarget) &&
+                                       (!isset($fileSource) || $fileTarget === $groupFileTarget)) {
                                        continue;
                                }
                        }
index 523f7b379a0a24e79d3edd76d18524e17c3f2a41..124ad450e2e7bf4910fd36417c0ff7ca34b72d8e 100644 (file)
@@ -545,6 +545,13 @@ class Test_Share extends \Test\TestCase {
                // Valid share
                $this->shareUserOneTestFileWithGroupOne();
 
+               // check if only the group share was created and not a single db-entry for each user
+               $statement = \OCP\DB::prepare('select `id` from `*PREFIX*share`');
+               $query = $statement->execute();
+               $result = $query->fetchAll();
+               $this->assertSame(1, count($result));
+
+
                // Attempt to share again
                OC_User::setUserId($this->user1);
                $message = 'Sharing test.txt failed, because this item is already shared with '.$this->group1;