summaryrefslogtreecommitdiffstats
path: root/settings/Controller/AppSettingsController.php
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2017-10-03 14:56:41 +0200
committerJulius Härtl <jus@bitgrid.net>2017-10-10 12:34:37 +0200
commit8d1b32e59788633dc6ab77e736a72f00625a389d (patch)
tree5bd0a1d386863d15c9b84e654580e8515e5739d4 /settings/Controller/AppSettingsController.php
parent968d4f6396e30321a4f05f867edd581ba50c9e81 (diff)
downloadnextcloud-server-8d1b32e59788633dc6ab77e736a72f00625a389d.tar.gz
nextcloud-server-8d1b32e59788633dc6ab77e736a72f00625a389d.zip
App management: add update section
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'settings/Controller/AppSettingsController.php')
-rw-r--r--settings/Controller/AppSettingsController.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/settings/Controller/AppSettingsController.php b/settings/Controller/AppSettingsController.php
index ac77b2e7dd6..da59461e5fa 100644
--- a/settings/Controller/AppSettingsController.php
+++ b/settings/Controller/AppSettingsController.php
@@ -52,6 +52,7 @@ class AppSettingsController extends Controller {
const CAT_DISABLED = 1;
const CAT_ALL_INSTALLED = 2;
const CAT_APP_BUNDLES = 3;
+ const CAT_UPDATES = 4;
/** @var \OCP\IL10N */
private $l10n;
@@ -130,8 +131,10 @@ class AppSettingsController extends Controller {
private function getAllCategories() {
$currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2);
+ $updateCount = count($this->getAppsWithUpdates());
$formattedCategories = [
['id' => self::CAT_ALL_INSTALLED, 'ident' => 'installed', 'displayName' => (string)$this->l10n->t('Your apps')],
+ ['id' => self::CAT_UPDATES, 'ident' => 'updates', 'displayName' => (string)$this->l10n->t('Updates'), 'counter' => $updateCount],
['id' => self::CAT_ENABLED, 'ident' => 'enabled', 'displayName' => (string)$this->l10n->t('Enabled apps')],
['id' => self::CAT_DISABLED, 'ident' => 'disabled', 'displayName' => (string)$this->l10n->t('Disabled apps')],
['id' => self::CAT_APP_BUNDLES, 'ident' => 'app-bundles', 'displayName' => (string)$this->l10n->t('App bundles')],
@@ -273,6 +276,28 @@ class AppSettingsController extends Controller {
return $formattedApps;
}
+ private function getAppsWithUpdates() {
+ $appClass = new \OC_App();
+ $apps = $appClass->listAllApps();
+ foreach($apps as $key => $app) {
+ $newVersion = \OC\Installer::isUpdateAvailable($app['id'], $this->appFetcher);
+ if($newVersion !== false) {
+ $apps[$key]['update'] = $newVersion;
+ } else {
+ unset($apps[$key]);
+ }
+ }
+ usort($apps, function ($a, $b) {
+ $a = (string)$a['name'];
+ $b = (string)$b['name'];
+ if ($a === $b) {
+ return 0;
+ }
+ return ($a < $b) ? -1 : 1;
+ });
+ return $apps;
+ }
+
/**
* Get all available apps in a category
*
@@ -301,6 +326,10 @@ class AppSettingsController extends Controller {
return ($a < $b) ? -1 : 1;
});
break;
+ // updates
+ case 'updates':
+ $apps = $this->getAppsWithUpdates();
+ break;
// enabled apps
case 'enabled':
$apps = $appClass->listAllApps();