From 4b08783946c8b2b1e731b3193e581b59bbbb15f5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Aug 2015 17:24:54 +0200 Subject: [PATCH] Use SearchResultSorter --- apps/files_sharing/api/sharees.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/apps/files_sharing/api/sharees.php b/apps/files_sharing/api/sharees.php index 7a3555e0a5..120df126a7 100644 --- a/apps/files_sharing/api/sharees.php +++ b/apps/files_sharing/api/sharees.php @@ -210,21 +210,10 @@ class Sharees { // Sort sharees - usort($sharees, function($a, $b) { - $res = strcmp($a['label'], $b['label']); - - // If labels are equal sort by share type - if ($res === 0) { - $res = $a['value']['shareType'] - $b['value']['shareType']; - } - - // If sharetype is equal compare shareWith - if ($res === 0) { - $res = strcmp($a['value']['shareWith'], $b['value']['shareWith']); - } - - return $res; - }); + $sorter = new \OC\Share\SearchResultSorter($search, + 'label', + \OC::$server->getLogger()); + usort($sharees, array($sorter, 'sort')); //Pagination $start = ($page - 1) * $per_page; @@ -239,7 +228,6 @@ class Sharees { $response->setItemsPerPage($per_page); // TODO add other link rels - if ($tot > $end) { $url = $this->urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/sharees?') . 'search=' . $search .