summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-08-16 12:20:14 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-08-16 12:20:14 -0400
commitdf8a2e5361714838637457373f9957c76fbf449f (patch)
tree4067c30456a8d5221e19c59f030e7b223bd2bc2a /lib
parent9cb3113f421fd57529aa5e9d10a5e9ca9beece70 (diff)
downloadnextcloud-server-df8a2e5361714838637457373f9957c76fbf449f.tar.gz
nextcloud-server-df8a2e5361714838637457373f9957c76fbf449f.zip
File sharing cleanup, works perfectly I think :)
Diffstat (limited to 'lib')
-rw-r--r--lib/files.php4
-rw-r--r--lib/public/share.php29
2 files changed, 23 insertions, 10 deletions
diff --git a/lib/files.php b/lib/files.php
index fee71b777b3..07d432f8066 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -41,9 +41,9 @@ class OC_Files {
$pos = strpos($directory, '/', 8);
// Get shared folder name
if ($pos !== false) {
- $itemTarget = substr($directory, 0, $pos);
+ $itemTarget = substr($directory, 7, $pos - 7);
} else {
- $itemTarget = $directory;
+ $itemTarget = substr($directory, 7);
}
$files = OCP\Share::getItemSharedWith('folder', $itemTarget, OC_Share_Backend_File::FORMAT_FILE_APP, array('folder' => $directory, 'mimetype_filter' => $mimetype_filter));
}
diff --git a/lib/public/share.php b/lib/public/share.php
index c420943da26..940bf2d48a0 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -399,23 +399,28 @@ 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
+ // Get filesystem root to add it to the file target and remove from the file source, match file_source with the file cache
if ($backend instanceof Share_Backend_File_Dependent) {
+ $fileDependent = true;
$root = \OC_Filesystem::getRoot();
+ // TODO No need to do this for FORMAT_STATUSES and loading the item in the dropdown, it's a performance waste
+ $where = 'INNER JOIN *PREFIX*fscache ON file_source = *PREFIX*fscache.id ';
} else {
+ $fileDependent = false;
+ $where = '';
$root = '';
}
if ($itemType == 'file' && !isset($item)) {
- $where = 'WHERE file_target IS NOT NULL';
+ $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."')";
+ $where .= "WHERE item_type IN ('".$placeholders."')";
$query_args = $item_types;
- } else {
- $where = "WHERE item_type = ?";
+ } else if ($itemType != 'file' && $itemType != 'folder') {
+ $where .= "WHERE item_type = ?";
$query_args = array($itemType);
}
if (isset($shareType) && isset($shareWith)) {
@@ -445,7 +450,6 @@ class Share {
$query_args[] = self::$shareTypeGroupUserUnique;
}
if ($itemType == 'file' || $itemType == 'folder') {
- $where = "INNER JOIN *PREFIX*fscache ON file_source = *PREFIX*fscache.id ".$where;
$column = 'file_source';
} else {
$column = 'item_source';
@@ -491,6 +495,7 @@ class Share {
}
$where .= ' LIMIT '.$limit;
}
+ // TODO Optimize selects
if ($format == self::FORMAT_STATUSES) {
if ($itemType == 'file' || $itemType == 'folder') {
$select = '*PREFIX*share.id, item_type, *PREFIX*share.parent, share_type, *PREFIX*fscache.path as file_source';
@@ -505,7 +510,15 @@ class Share {
$select = 'id, item_type, item_source, parent, share_type, share_with, permissions, stime, file_source';
}
} else {
- $select = '*';
+ if ($fileDependent) {
+ if (($itemType == 'file' || $itemType == 'folder') && $format == \OC_Share_Backend_File::FORMAT_FILE_APP || $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT) {
+ $select = '*PREFIX*share.id, item_type, *PREFIX*share.parent, share_type, share_with, permissions, file_target, *PREFIX*fscache.id, path as file_source, name, ctime, mtime, mimetype, size, encrypted, versioned, writable';
+ } else {
+ $select = '*PREFIX*share.id, item_type, item_source, item_target, *PREFIX*share.parent, share_type, share_with, permissions, stime, path as file_source, file_target';
+ }
+ } else {
+ $select = '*';
+ }
}
}
$root = strlen($root);
@@ -534,7 +547,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 && $itemType != 'file' && !isset($item)) {
- if ($collectionBackend = self::getBackend($row['item_type'])) {
+ 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]);