diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-08-09 20:47:49 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-08-26 11:54:24 +0200 |
commit | 8a5c1e6d4d63b2efc2c3e8acca98043973295863 (patch) | |
tree | 7dc6d1edbdc8e186a82d7f77a9567031645a93e0 /apps/files_sharing/api/sharees.php | |
parent | 98301210a9172e6b0a44bcaf43b4ecf4b31f938e (diff) | |
download | nextcloud-server-8a5c1e6d4d63b2efc2c3e8acca98043973295863.tar.gz nextcloud-server-8a5c1e6d4d63b2efc2c3e8acca98043973295863.zip |
Sort sharees
To ensure that pagination is working properly we need to make sure the
shares are always in the same order.
Sorting is first done by label (catches most instances)
If there is a user and a group with the same label we sort by shareType
If there are multiple users with the same label we sort those by
shareWith
Diffstat (limited to 'apps/files_sharing/api/sharees.php')
-rw-r--r-- | apps/files_sharing/api/sharees.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/apps/files_sharing/api/sharees.php b/apps/files_sharing/api/sharees.php index 83acdd086c3..8146c98b01a 100644 --- a/apps/files_sharing/api/sharees.php +++ b/apps/files_sharing/api/sharees.php @@ -205,6 +205,24 @@ class Sharees { $sharees = array_merge($sharees, $this->getRemote($search)); } + + // 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; + }); + //Pagination $start = ($page - 1) * $per_page; $end = $page * $per_page; |