diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-01-16 18:11:13 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-01-16 18:11:13 +0100 |
commit | 40931a8b0d5d10c0f711756a4e8a423ff055621e (patch) | |
tree | bac0e1f21d9f3761e7a384928dbd2ab36e9b2a97 /lib | |
parent | a65f666834742f8df25493a11e10063e1e5ff98a (diff) | |
download | nextcloud-server-40931a8b0d5d10c0f711756a4e8a423ff055621e.tar.gz nextcloud-server-40931a8b0d5d10c0f711756a4e8a423ff055621e.zip |
Fix getItemSharedWithUser for groups
Fixed SQL query for whenever a user has more than one group.
Added missing $owner where clause for group lookup.
Added unit tests for the group cases.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/share/share.php | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php index f61f65f35a7..e85f9f06ed3 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -337,17 +337,26 @@ class Share extends \OC\Share\Constants { if(empty($shares) && $user !== null) { $groups = \OC_Group::getUserGroups($user); - $query = \OC_DB::prepare( - 'SELECT * - FROM - `*PREFIX*share` - WHERE - `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)' + $where = 'WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)'; + $arguments = array($itemSource, $itemType, $groups); + $types = array(null, null, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY); + + if ($owner !== null) { + $where .= ' AND `uid_owner` = ?'; + $arguments[] = $owner; + $types[] = null; + } + + // TODO: inject connection, hopefully one day in the future when this + // class isn't static anymore... + $conn = \OC_DB::getConnection(); + $result = $conn->executeQuery( + 'SELECT * FROM `*PREFIX*share` ' . $where, + $arguments, + $types ); - $result = \OC_DB::executeAudited($query, array($itemSource, $itemType, implode(',', $groups))); - - while ($row = $result->fetchRow()) { + while ($row = $result->fetch()) { $shares[] = $row; } } |