mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Merge pull request #13016 from owncloud/sharing_fixes
don't delete share table entries for the unique name if re-share permission was removed
This commit is contained in:
commit
bfb6e350d5
3 changed files with 38 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -73,9 +73,9 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
|
|||
$return = OCP\Share::setPermissions(
|
||||
$_POST['itemType'],
|
||||
$_POST['itemSource'],
|
||||
$_POST['shareType'],
|
||||
(int)$_POST['shareType'],
|
||||
$_POST['shareWith'],
|
||||
$_POST['permissions']
|
||||
(int)$_POST['permissions']
|
||||
);
|
||||
($return) ? OC_JSON::success() : OC_JSON::error();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue