diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2013-03-07 11:12:59 -0500 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2013-03-07 11:12:59 -0500 |
commit | a5cab28bea6188ce840d7d115064c4780531e13d (patch) | |
tree | 6dd8b77c35c6a2082616d9427f573441ab63e5e4 /apps/files_sharing/lib/share/file.php | |
parent | e5a497c9248fcab82b84befbc3842affccc71f9d (diff) | |
download | nextcloud-server-a5cab28bea6188ce840d7d115064c4780531e13d.tar.gz nextcloud-server-a5cab28bea6188ce840d7d115064c4780531e13d.zip |
Fix fetching source path of shared files
Diffstat (limited to 'apps/files_sharing/lib/share/file.php')
-rw-r--r-- | apps/files_sharing/lib/share/file.php | 23 |
1 files changed, 20 insertions, 3 deletions
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; |