summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-02-11 15:23:13 +0100
committerVincent Petry <pvince81@owncloud.com>2015-02-11 15:23:13 +0100
commitfbbb9fe0fd395ef94c62609fe9ab4c908644d15d (patch)
tree885e83fde2eb667220cecfb0a76f269eb4c84337
parent0e4923b0f98db9b7c52b007b9df01c5ae7c05a47 (diff)
parentc17b236c1967bbefe7b4873e8d0dcaa77bd132f2 (diff)
downloadnextcloud-server-fbbb9fe0fd395ef94c62609fe9ab4c908644d15d.tar.gz
nextcloud-server-fbbb9fe0fd395ef94c62609fe9ab4c908644d15d.zip
Merge pull request #13979 from owncloud/group-share-collition-wrong-type-in-post-hook
Do not overwrite the shareType so the post hook is still correct
-rw-r--r--lib/private/share/share.php10
-rw-r--r--tests/lib/share/share.php11
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 53479ad7144..4753f6ecbfa 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -1857,7 +1857,7 @@ class Share extends \OC\Share\Constants {
$sourceId = ($itemType === 'file' || $itemType === 'folder') ? $fileSource : $itemSource;
$sourceExists = self::getItemSharedWithBySource($itemType, $sourceId, self::FORMAT_NONE, null, true, $user);
- $shareType = ($isGroupShare) ? self::$shareTypeGroupUserUnique : $shareType;
+ $userShareType = ($isGroupShare) ? self::$shareTypeGroupUserUnique : $shareType;
if ($sourceExists) {
$fileTarget = $sourceExists['file_target'];
@@ -1870,12 +1870,12 @@ class Share extends \OC\Share\Constants {
} elseif(!$sourceExists && !$isGroupShare) {
- $itemTarget = Helper::generateTarget($itemType, $itemSource, $shareType, $user,
+ $itemTarget = Helper::generateTarget($itemType, $itemSource, $userShareType, $user,
$uidOwner, $suggestedItemTarget, $parent);
if (isset($fileSource)) {
if ($parentFolder) {
if ($parentFolder === true) {
- $fileTarget = Helper::generateTarget('file', $filePath, $shareType, $user,
+ $fileTarget = Helper::generateTarget('file', $filePath, $userShareType, $user,
$uidOwner, $suggestedFileTarget, $parent);
if ($fileTarget != $groupFileTarget) {
$parentFolders[$user]['folder'] = $fileTarget;
@@ -1885,7 +1885,7 @@ class Share extends \OC\Share\Constants {
$parent = $parentFolder[$user]['id'];
}
} else {
- $fileTarget = Helper::generateTarget('file', $filePath, $shareType,
+ $fileTarget = Helper::generateTarget('file', $filePath, $userShareType,
$user, $uidOwner, $suggestedFileTarget, $parent);
}
} else {
@@ -1916,7 +1916,7 @@ class Share extends \OC\Share\Constants {
'itemType' => $itemType,
'itemSource' => $itemSource,
'itemTarget' => $itemTarget,
- 'shareType' => $shareType,
+ 'shareType' => $userShareType,
'shareWith' => $user,
'uidOwner' => $uidOwner,
'permissions' => $permissions,
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 6a50dd1f962..1ef62dc2b07 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -586,7 +586,10 @@ class Test_Share extends \Test\TestCase {
// Attempt user specific target conflict
OC_User::setUserId($this->user3);
+ \OCP\Util::connectHook('OCP\\Share', 'post_shared', 'DummyHookListener', 'listen');
+
$this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE));
+ $this->assertEquals(OCP\Share::SHARE_TYPE_GROUP, DummyHookListener::$shareType);
OC_User::setUserId($this->user2);
$to_test = OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET);
$this->assertEquals(2, count($to_test));
@@ -1055,3 +1058,11 @@ class DummyShareClass extends \OC\Share\Share {
return parent::groupItems($items, 'test');
}
}
+
+class DummyHookListener {
+ static $shareType = null;
+
+ public static function listen($params) {
+ self::$shareType = $params['shareType'];
+ }
+}