summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-01-16 18:11:13 +0100
committerVincent Petry <pvince81@owncloud.com>2015-01-20 22:07:21 +0100
commit18d46dfdeb2facc9f5c5d9f1827b27714acb96dd (patch)
treecba9f1e6489be99eced609b569e137a7343425c0 /lib/private
parent5f70ed188b7d661929ec04b687f11fcb305d8334 (diff)
downloadnextcloud-server-18d46dfdeb2facc9f5c5d9f1827b27714acb96dd.tar.gz
nextcloud-server-18d46dfdeb2facc9f5c5d9f1827b27714acb96dd.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. Backport of 40931a8b0d5d10c0f711756a4e8a423ff055621e from master
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/share/share.php29
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index b637b87b5eb..be113568a3b 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -287,7 +287,7 @@ class Share extends \OC\Share\Constants {
* Get the item of item type shared with a given user by source
* @param string $itemType
* @param string $itemSource
- * @param string $user User user to whom the item was shared
+ * @param string $user User to whom the item was shared
* @param int $shareType only look for a specific share type
* @return array Return list of items with file_target, permissions and expiration
*/
@@ -332,18 +332,23 @@ 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 (?)'
- );
-
- $result = \OC_DB::executeAudited($query, array($itemSource, $itemType, implode(',', $groups)));
+ if (!empty($groups)) {
+ $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);
+
+ // 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
+ );
- while ($row = $result->fetchRow()) {
- $shares[] = $row;
+ while ($row = $result->fetch()) {
+ $shares[] = $row;
+ }
}
}