summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-10-18 10:23:34 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-10-18 10:23:34 +0200
commit48cd9d9444d673f825a3e5d8faa43fc1ad6f3d6e (patch)
tree5c49c66943039c894436a455665f14b327bd5abc /apps
parent76be7cd1ac54a8f4a5707c7a50eee106383aa51d (diff)
downloadnextcloud-server-48cd9d9444d673f825a3e5d8faa43fc1ad6f3d6e.tar.gz
nextcloud-server-48cd9d9444d673f825a3e5d8faa43fc1ad6f3d6e.zip
filter duplicates directly in the sql query
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/api.php17
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']);
}