summaryrefslogtreecommitdiffstats
path: root/lib/private/share/share.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-07-08 10:33:42 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-07-08 10:33:42 +0200
commit0fe81d2f214c59dbe223e949232475fb8a6f24b9 (patch)
tree6691ff58e98c4b2748695c0867bf1bd27b1f4b33 /lib/private/share/share.php
parent2fd84607eed7281ab4d507bc4fffb4fd7c9233e0 (diff)
parent40eaf71a333267288873462a33855bd0d082f21d (diff)
downloadnextcloud-server-0fe81d2f214c59dbe223e949232475fb8a6f24b9.tar.gz
nextcloud-server-0fe81d2f214c59dbe223e949232475fb8a6f24b9.zip
Merge pull request #17330 from owncloud/fix-share-path-for-group-exceptions
Fix the path for users which have an exception for a group share
Diffstat (limited to 'lib/private/share/share.php')
-rw-r--r--lib/private/share/share.php38
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 14909c6f8ce..7fcbb695c68 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -142,15 +142,25 @@ class Share extends Constants {
while ($source !== -1) {
// Fetch all shares with another user
- $query = \OC_DB::prepare(
- 'SELECT `share_with`, `file_source`, `file_target`
+ if (!$returnUserPaths) {
+ $query = \OC_DB::prepare(
+ 'SELECT `share_with`, `file_source`, `file_target`
+ FROM
+ `*PREFIX*share`
+ WHERE
+ `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')'
+ );
+ $result = $query->execute(array($source, self::SHARE_TYPE_USER));
+ } else {
+ $query = \OC_DB::prepare(
+ 'SELECT `share_with`, `file_source`, `file_target`
FROM
`*PREFIX*share`
WHERE
- `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')'
- );
-
- $result = $query->execute(array($source, self::SHARE_TYPE_USER));
+ `item_source` = ? AND `share_type` IN (?, ?) AND `item_type` IN (\'file\', \'folder\')'
+ );
+ $result = $query->execute(array($source, self::SHARE_TYPE_USER, self::$shareTypeGroupUserUnique));
+ }
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
@@ -182,7 +192,12 @@ class Share extends Constants {
$shares = array_merge($shares, $usersInGroup);
if ($returnUserPaths) {
foreach ($usersInGroup as $user) {
- $fileTargets[(int) $row['file_source']][$user] = $row;
+ if (!isset($fileTargets[(int) $row['file_source']][$user])) {
+ // When the user already has an entry for this file source
+ // the file is either shared directly with him as well, or
+ // he has an exception entry (because of naming conflict).
+ $fileTargets[(int) $row['file_source']][$user] = $row;
+ }
}
}
}
@@ -238,9 +253,6 @@ class Share extends Constants {
// Include owner in list of users, if requested
if ($includeOwner) {
$shares[] = $ownerUser;
- if ($returnUserPaths) {
- $sharePaths[$ownerUser] = $path;
- }
}
if ($returnUserPaths) {
@@ -268,6 +280,12 @@ class Share extends Constants {
}
}
+ if ($includeOwner) {
+ $sharePaths[$ownerUser] = $path;
+ } else {
+ unset($sharePaths[$ownerUser]);
+ }
+
return $sharePaths;
}