summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-08-27 15:50:13 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-08-27 20:37:38 -0400
commit0ad16e84c5f208d94f1f41447db3a23949942d45 (patch)
treeb6197a8b8b7d7942afed7477c1a0e3ec41434065 /lib
parent0a9d1ed3a645efda56ae757f45aa7efb5a35ce4f (diff)
downloadnextcloud-server-0ad16e84c5f208d94f1f41447db3a23949942d45.tar.gz
nextcloud-server-0ad16e84c5f208d94f1f41447db3a23949942d45.zip
Fix share collection query
Diffstat (limited to 'lib')
-rw-r--r--lib/public/share.php62
1 files changed, 34 insertions, 28 deletions
diff --git a/lib/public/share.php b/lib/public/share.php
index 15fb73d8d88..964394d75db 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -504,29 +504,33 @@ class Share {
}
}
if (isset($item)) {
+ if ($includeCollections && $collectionTypes = self::getCollectionItemTypes($itemType)) {
+ $where .= ' AND (';
+ } else {
+ $where .= ' AND';
+ }
// If looking for own shared items, check item_source else check item_target
if (isset($uidOwner) || $itemShareWithBySource) {
// If item type is a file, file source needs to be checked in case the item was converted
if ($itemType == 'file' || $itemType == 'folder') {
- $where .= ' AND `file_source` = ?';
+ $where .= ' `file_source` = ?';
$column = 'file_source';
} else {
- $where .= ' AND `item_source` = ?';
+ $where .= ' `item_source` = ?';
$column = 'item_source';
}
} else {
if ($itemType == 'file' || $itemType == 'folder') {
- $where .= ' AND `file_target` = ?';
+ $where .= ' `file_target` = ?';
} else {
- $where .= ' AND `item_target` = ?';
+ $where .= ' `item_target` = ?';
}
}
$queryArgs[] = $item;
if ($includeCollections && $collectionTypes = self::getCollectionItemTypes($itemType)) {
- // TODO Bart - this doesn't work with only one argument
-// $placeholders = join(',', array_fill(0, count($collectionTypes), '?'));
-// $where .= " OR item_type IN ('".$placeholders."')";
-// $queryArgs = array_merge($queryArgs, $collectionTypes);
+ $placeholders = join(',', array_fill(0, count($collectionTypes), '?'));
+ $where .= ' OR item_type IN ('.$placeholders.'))';
+ $queryArgs = array_merge($queryArgs, $collectionTypes);
}
}
if ($limit != -1 && !$includeCollections) {
@@ -629,28 +633,30 @@ class Share {
}
}
// Check if this is a collection of the requested item type
- if ($includeCollections && $row['item_type'] != $itemType && ($collectionBackend = self::getBackend($row['item_type'])) && $collectionBackend instanceof Share_Backend_Collection) {
- $row['collection'] = array('item_type' => $itemType, $column => $row[$column]);
- // Fetch all of the children sources
- $children = $collectionBackend->getChildren($row[$column]);
- foreach ($children as $child) {
- $childItem = $row;
- $childItem['item_source'] = $child;
-// $childItem['item_target'] = $child['target']; TODO
- if (isset($item)) {
- if ($childItem[$column] == $item) {
- // Return only the item instead of a 2-dimensional array
- if ($limit == 1 && $format == self::FORMAT_NONE) {
- return $childItem;
- } else {
- // Unset the items array and break out of both loops
- $items = array();
- $items[] = $childItem;
- break 2;
+ if ($includeCollections && $row['item_type'] != $itemType) {
+ if (($collectionBackend = self::getBackend($row['item_type'])) && $collectionBackend instanceof Share_Backend_Collection) {
+ $row['collection'] = array('item_type' => $itemType, $column => $row[$column]);
+ // Fetch all of the children sources
+ $children = $collectionBackend->getChildren($row[$column]);
+ foreach ($children as $child) {
+ $childItem = $row;
+ $childItem['item_source'] = $child;
+ // $childItem['item_target'] = $child['target']; TODO
+ if (isset($item)) {
+ if ($childItem[$column] == $item) {
+ // Return only the item instead of a 2-dimensional array
+ if ($limit == 1 && $format == self::FORMAT_NONE) {
+ return $childItem;
+ } else {
+ // Unset the items array and break out of both loops
+ $items = array();
+ $items[] = $childItem;
+ break 2;
+ }
}
+ } else {
+ $collectionItems[] = $childItem;
}
- } else {
- $collectionItems[] = $childItem;
}
}
// Remove collection item