Retrieve all file dependent items when looking for file item type

This commit is contained in:
Michael Gapczynski 2012-08-14 11:02:29 -04:00
parent 4c7fd8cd01
commit 937d1b29d8

View file

@ -448,9 +448,16 @@ class Share {
private static function getItems($itemType, $item = null, $shareType = null, $shareWith = null, $uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1, $includeCollections = false, $itemShareWithBySource = false) {
$backend = self::getBackend($itemType);
// Get filesystem root to add it to the file target and remove from the file source
$root = \OC_Filesystem::getRoot();
// If includeCollections is true, find collections of this item type, e.g. a music album contains songs
if ($includeCollections && !isset($item) && $collectionTypes = self::getCollectionItemTypes($itemType)) {
if ($backend instanceof Share_Backend_File_Dependent) {
$root = \OC_Filesystem::getRoot();
} else {
$root = '';
}
if ($itemType == 'file' && !isset($item)) {
$where = 'WHERE file_target IS NOT NULL';
$query_args = array();
} else 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
$item_types = array_merge(array($itemType), $collectionTypes);
$placeholders = join(',', array_fill(0, count($item_types), '?'));
$where = "WHERE item_type IN ('".$placeholders."')";
@ -574,7 +581,7 @@ class Share {
}
// TODO Check this outside of the loop
// Check if this is a collection of the requested item type
if ($row['item_type'] != $itemType) {
if ($row['item_type'] != $itemType && $itemType != 'file' && !isset($item)) {
if ($collectionBackend = self::getBackend($row['item_type'])) {
$row['collection'] = array('item_type' => $itemType, $column => $row[$column]);
// Fetch all of the children sources