diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index 359e26b16f..a559026c5b 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -1,7 +1,6 @@ "files_sharing_administration", +OC_APP::addSettingsPage( array( "id" => "files_sharing_administration", "order" => 10, "href" => OC_HELPER::linkTo( "files_sharing", "admin.php" ), "name" => "Share", diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php index b739656acf..a37f7da8ca 100644 --- a/apps/files_sharing/lib_share.php +++ b/apps/files_sharing/lib_share.php @@ -81,9 +81,16 @@ class OC_SHARE { * @return source path */ public static function getSource($target) { + // Break up the $target to get only the first part in case it is inside a folder + $parts = explode("/", $target); $query = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ?"); - $result = $query->execute(array($target, $_SESSION['user_id']))->fetchAll(); - return $result[0]['source']; + $result = $query->execute(array($parts[0], $_SESSION['user_id']))->fetchAll(); + $source = $result[0]['source']; + // Add the $parts back in + foreach (array_slice($parts, 1) as $part) { + $source .= $part; + } + return $source; } /** diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php index a4d0b2354b..4e0089b2c0 100644 --- a/apps/files_sharing/sharedstorage.php +++ b/apps/files_sharing/sharedstorage.php @@ -58,15 +58,22 @@ class OC_FILESTORAGE_SHARED { } } - // TODO add all files from db in array public function opendir($path) { - global $FAKEDIRS; - $sharedItems = OC_SHARE::getItemsSharedWith(); - foreach ($sharedItems as $item) { - $files[] = $item['target']; + if ($path == "" || $path == "/") { + global $FAKEDIRS; + $sharedItems = OC_SHARE::getItemsSharedWith(); + foreach ($sharedItems as $item) { + $files[] = $item['target']; + } + $FAKEDIRS['shared'] = $files; + return opendir('fakedir://shared'); + } else { + $source = OC_SHARE::getSource($path); + if ($source) { + $storage = OC_FILESYSTEM::getStorage($source); + return $storage->opendir($this->getInternalPath($source)); + } } - $FAKEDIRS['shared'] = $files; - return opendir('fakedir://shared'); } public function is_dir($path) { @@ -144,7 +151,7 @@ class OC_FILESTORAGE_SHARED { if ($path == "" || $path == "/") { $dbpath = $_SESSION['user_id']."/files/Share/"; } else { - $dbpath = $path; + $dbpath = substr(OC_SHARE::getSource($path), 1); } $query = OC_DB::prepare("SELECT size FROM *PREFIX*foldersize WHERE path=?"); $size = $query->execute(array($dbpath))->fetchAll();