summaryrefslogtreecommitdiffstats
path: root/lib/private/app.php
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2013-10-14 10:54:38 +0200
committerFrank Karlitschek <frank@owncloud.org>2013-10-14 10:54:38 +0200
commitf06df170cb287009ece7098ff2a28a7af2a0b545 (patch)
tree09b85235958b4af33a6ab3c06412689806147369 /lib/private/app.php
parentf3336f8877771e53d303f6f939f0005fa9692b7a (diff)
downloadnextcloud-server-f06df170cb287009ece7098ff2a28a7af2a0b545.tar.gz
nextcloud-server-f06df170cb287009ece7098ff2a28a7af2a0b545.zip
finally fix the app sorting
Diffstat (limited to 'lib/private/app.php')
-rw-r--r--lib/private/app.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/private/app.php b/lib/private/app.php
index b4a71992178..920906d8836 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -752,10 +752,43 @@ class OC_App{
} else {
$combinedApps = $appList;
}
+ // bring the apps into the right order with a custom sort funtion
+ usort($combinedApps,'\OC_App::customSort');
+
return $combinedApps;
}
/**
+ * @brief: Internal custom sort funtion to bring the app into the right order. Should only be called by listAllApps
+ * @return array
+ */
+ private static function customSort($a, $b) {
+
+ // prio 1: active
+ if ($a['active'] != $b['active']) {
+ return $b['active'] - $a['active'];
+ }
+
+ // prio 2: shipped
+ if ($a['shipped'] != $b['shipped']) {
+ $atemp = ($a['shipped']==true ? 1 : 0);
+ $btemp = ($b['shipped']==true ? 1 : 0);
+ return ($btemp - $atemp);
+ }
+
+ // prio 3: recommended
+ if ($a['internalclass'] != $b['internalclass']) {
+ $atemp = ($a['internalclass']=='recommendedapp' ? 1 : 0);
+ $btemp = ($b['internalclass']=='recommendedapp' ? 1 : 0);
+ return ($btemp - $atemp);
+ }
+
+ // prio 4: alphabetical
+ return strcmp($a['name'], $b['name']);
+
+ }
+
+ /**
* @brief: get a list of all apps on apps.owncloud.com
* @return array, multi-dimensional array of apps.
* Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description