diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-09-08 23:07:43 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-09-08 23:09:57 -0400 |
commit | b163bd514f65999cd8aa66262d10ca92dcdf99d1 (patch) | |
tree | fdda277cf4d0b7c8918258714f2e1ab8849faf72 /lib | |
parent | a050915167cdcb0f5b99d5c0007ed9f9f25a20de (diff) | |
download | nextcloud-server-b163bd514f65999cd8aa66262d10ca92dcdf99d1.tar.gz nextcloud-server-b163bd514f65999cd8aa66262d10ca92dcdf99d1.zip |
Fix fetching shared children items, fixes problem with displaying owner of a shared file inside a shared folder
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/share.php | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/public/share.php b/lib/public/share.php index a3cfe4f6ddb..87144735a68 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -458,8 +458,8 @@ class Share { $collectionTypes[] = $type; } } - if (count($collectionTypes) > 1) { - unset($collectionTypes[0]); + // Return array if collections were found or the item type is a collection itself - collections can be inside collections + if (count($collectionTypes) > 1 || self::getBackend($itemType) instanceof Share_Backend_Collection) { return $collectionTypes; } return false; @@ -504,10 +504,9 @@ class Share { $root = ''; if ($includeCollections && !isset($item) && ($collectionTypes = self::getCollectionItemTypes($itemType))) { // If includeCollections is true, find collections of this item type, e.g. a music album contains songs - $itemTypes = array_merge(array($itemType), $collectionTypes); - $placeholders = join(',', array_fill(0, count($itemTypes), '?')); - $where = ' WHERE `item_type` IN ('.$placeholders.')'; - $queryArgs = $itemTypes; + $placeholders = join(',', array_fill(0, count($collectionTypes), '?')); + $where .= ' OR item_type IN ('.$placeholders.'))'; + $queryArgs = $collectionTypes; } else { $where = ' WHERE `item_type` = ?'; $queryArgs = array($itemType); @@ -690,15 +689,25 @@ class Share { } } // Check if this is a collection of the requested item type - if ($includeCollections && $row['item_type'] != $itemType) { + if ($includeCollections && in_array($row['item_type'], $collectionTypes)) { 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 ($row['item_type'] != 'file' && $row['item_type'] != 'folder') { + $childItem['item_source'] = $child['source']; + $childItem['item_target'] = $child['target']; + } + if ($backend instanceof Share_Backend_File_Dependent) { + if ($row['item_type'] == 'file' || $row['item_type'] == 'folder') { + $childItem['file_source'] = $child['source']; + } else { + $childItem['file_source'] = \OC_FileCache::getId($child['file_path']); + } + $childItem['file_target'] = $child['file_path']; + } if (isset($item)) { if ($childItem[$column] == $item) { // Return only the item instead of a 2-dimensional array @@ -1167,7 +1176,7 @@ interface Share_Backend_Collection extends Share_Backend { /** * @brief Get the sources of the children of the item * @param string Item source - * @return array Returns an array of sources + * @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable */ public function getChildren($itemSource); |