summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-12-23 17:10:05 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2015-01-07 16:36:13 +0100
commitb6f63e9b3d8554e1d7ed45a4dbc224a38bc7dfa8 (patch)
tree09ca64a72ef19940a1e73ccdcd43c68227164d6a
parent40330bf4927b5b9bcfcfe5833f13d575c1ee18d4 (diff)
downloadnextcloud-server-b6f63e9b3d8554e1d7ed45a4dbc224a38bc7dfa8.tar.gz
nextcloud-server-b6f63e9b3d8554e1d7ed45a4dbc224a38bc7dfa8.zip
don't delete share table entries for the unique name if re-share permission was removed
-rw-r--r--apps/files_sharing/tests/share.php32
-rw-r--r--lib/private/share/helper.php8
2 files changed, 36 insertions, 4 deletions
diff --git a/apps/files_sharing/tests/share.php b/apps/files_sharing/tests/share.php
index 83ef17f49d1..b8c8b70bd1f 100644
--- a/apps/files_sharing/tests/share.php
+++ b/apps/files_sharing/tests/share.php
@@ -246,6 +246,38 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase {
\OC::$server->getConfig()->deleteSystemValue('share_folder');
}
+ function testShareWithGroupUniqueName() {
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
+ \OC\Files\Filesystem::file_put_contents('test.txt', 'test');
+
+ $fileInfo = \OC\Files\Filesystem::getFileInfo('test.txt');
+
+ $this->assertTrue(
+ \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1, 23)
+ );
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+
+ $items = \OCP\Share::getItemsSharedWith('file');
+ $this->assertSame('/test.txt' ,$items[0]['file_target']);
+ $this->assertSame(23, $items[0]['permissions']);
+
+ \OC\Files\Filesystem::rename('test.txt', 'new test.txt');
+
+ $items = \OCP\Share::getItemsSharedWith('file');
+ $this->assertSame('/new test.txt' ,$items[0]['file_target']);
+ $this->assertSame(23, $items[0]['permissions']);
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
+ \OCP\Share::setPermissions('file', $items[0]['item_source'], $items[0]['share_type'], $items[0]['share_with'], 3);
+
+ $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
+ $items = \OCP\Share::getItemsSharedWith('file');
+
+ $this->assertSame('/new test.txt' ,$items[0]['file_target']);
+ $this->assertSame(3, $items[0]['permissions']);
+ }
+
/**
* shared files should never have delete permissions
* @dataProvider DataProviderTestFileSharePermissions
diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php
index 3d20ba2d27f..5b27f0e6f50 100644
--- a/lib/private/share/helper.php
+++ b/lib/private/share/helper.php
@@ -96,12 +96,12 @@ class Helper extends \OC\Share\Constants {
// finding and deleting the reshares by a single user of a group share
if (count($ids) == 1 && isset($uidOwner)) {
$query = \OC_DB::prepare('SELECT `id`, `share_with`, `item_type`, `share_type`, `item_target`, `file_target`, `parent`'
- .' FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.') AND `uid_owner` = ?');
- $result = $query->execute(array($uidOwner));
+ .' FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.') AND `uid_owner` = ? AND `share_type` != ?');
+ $result = $query->execute(array($uidOwner, self::$shareTypeGroupUserUnique));
} else {
$query = \OC_DB::prepare('SELECT `id`, `share_with`, `item_type`, `share_type`, `item_target`, `file_target`, `parent`, `uid_owner`'
- .' FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.')');
- $result = $query->execute();
+ .' FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.') AND `share_type` != ?');
+ $result = $query->execute(array(self::$shareTypeGroupUserUnique));
}
// Reset parents array, only go through loop again if items are found
$parents = array();