diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-10-18 01:41:15 -0700 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-10-18 01:41:15 -0700 |
commit | 33cf4708d5a4d683766ae70a67138e1cac934850 (patch) | |
tree | dc48088ee4d7830d0037937011a675ac29fec567 /apps | |
parent | 0755aca5018952a93c389be58d18d34d80837700 (diff) | |
parent | 48cd9d9444d673f825a3e5d8faa43fc1ad6f3d6e (diff) | |
download | nextcloud-server-33cf4708d5a4d683766ae70a67138e1cac934850.tar.gz nextcloud-server-33cf4708d5a4d683766ae70a67138e1cac934850.zip |
Merge pull request #5411 from owncloud/ocs_share_api_cleanup
filter duplicates directly in the sql query
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/api.php | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php index d92d30156cb..84e90c71681 100644 --- a/apps/files_sharing/lib/api.php +++ b/apps/files_sharing/lib/api.php @@ -130,27 +130,18 @@ class Api { private static function addReshares($shares, $itemSource) { // if there are no shares than there are also no reshares - if (count($shares) > 0) { - $ids = array(); - $firstShare = reset($shares); + $firstShare = reset($shares); + if ($firstShare) { $path = $firstShare['path']; - foreach ($shares as $share) { - $ids[] = $share['id']; - } } else { return $shares; } $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path` , `permissions`, `stime`, `expiration`, `token`, `storage`, `mail_send`, `mail_send`'; - $getReshares = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` WHERE `*PREFIX*share`.`file_source` = ? AND `*PREFIX*share`.`item_type` IN (\'file\', \'folder\')'); - $reshares = $getReshares->execute(array($itemSource))->fetchAll(); + $getReshares = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` WHERE `*PREFIX*share`.`file_source` = ? AND `*PREFIX*share`.`item_type` IN (\'file\', \'folder\') AND `uid_owner` != ?'); + $reshares = $getReshares->execute(array($itemSource, \OCP\User::getUser()))->fetchAll(); foreach ($reshares as $key => $reshare) { - // remove reshares we already have in the shares array. - if (in_array($reshare['id'], $ids)) { - unset($reshares[$key]); - continue; - } if (isset($reshare['share_with']) && $reshare['share_with'] !== '') { $reshares[$key]['share_with_displayname'] = \OCP\User::getDisplayName($reshare['share_with']); } |