From a5cab28bea6188ce840d7d115064c4780531e13d Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Thu, 7 Mar 2013 11:12:59 -0500 Subject: Fix fetching source path of shared files --- apps/files_sharing/lib/share/file.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'apps/files_sharing/lib/share/file.php') diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php index 0aeb763d89a..fa43e87b49e 100644 --- a/apps/files_sharing/lib/share/file.php +++ b/apps/files_sharing/lib/share/file.php @@ -73,7 +73,9 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent { if ($format == self::FORMAT_SHARED_STORAGE) { // Only 1 item should come through for this format call return array( + 'parent' => $items[key($items)]['parent'], 'path' => $items[key($items)]['path'], + 'storage' => $items[key($items)]['storage'], 'permissions' => $items[key($items)]['permissions'], 'uid_owner' => $items[key($items)]['uid_owner'] ); @@ -139,13 +141,28 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent { $source = \OCP\Share::getItemSharedWith('folder', $folder, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE); if ($source) { $source['path'] = $source['path'].substr($target, strlen($folder)); - return $source; } } else { $source = \OCP\Share::getItemSharedWith('file', $target, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE); - if ($source) { - return $source; + } + if ($source) { + if (isset($source['parent'])) { + $parent = $source['parent']; + while (isset($parent)) { + $query = \OC_DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1); + $item = $query->execute(array($parent))->fetchRow(); + if (isset($item['parent'])) { + $parent = $item['parent']; + } else { + $fileOwner = $item['uid_owner']; + break; + } + } + } else { + $fileOwner = $source['uid_owner']; } + $source['fileOwner'] = $fileOwner; + return $source; } \OCP\Util::writeLog('files_sharing', 'File source not found for: '.$target, \OCP\Util::ERROR); return false; -- cgit v1.2.3