Merge pull request #13920 from owncloud/sharing_no_user_entry_for_group_shares

only create a db entry for the user in case of a name conflict on group share
This commit is contained in:
Thomas Müller 2015-04-09 23:37:02 +02:00
commit 5abbf6d5b0
2 changed files with 14 additions and 2 deletions

View 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;
}
}

View 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;