diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-02-24 10:34:06 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-02-24 10:34:06 +0100 |
commit | da8e34cf7f31ae6b560fabdd9c59179b4e1f4f0a (patch) | |
tree | b9500e58d7810f45e88385f52c7e6207579ffcc6 /settings | |
parent | a320edaca5f90a713ad5e394555bcbddce2cb319 (diff) | |
parent | b40d4c9cbc9fdb3a889d5d2fb8b5e770a8efe0e3 (diff) | |
download | nextcloud-server-da8e34cf7f31ae6b560fabdd9c59179b4e1f4f0a.tar.gz nextcloud-server-da8e34cf7f31ae6b560fabdd9c59179b4e1f4f0a.zip |
Merge pull request #14009 from owncloud/installing-installed-apps-is-stupid
don't allow installation of already installed apps - fixes #14004
Diffstat (limited to 'settings')
-rw-r--r-- | settings/controller/appsettingscontroller.php | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/settings/controller/appsettingscontroller.php b/settings/controller/appsettingscontroller.php index 8be3d61da26..a7f709cc15d 100644 --- a/settings/controller/appsettingscontroller.php +++ b/settings/controller/appsettingscontroller.php @@ -24,6 +24,7 @@ namespace OC\Settings\Controller; use OC\App\DependencyAnalyzer; use OC\App\Platform; +use OC\OCSClient; use \OCP\AppFramework\Controller; use OCP\ICacheFactory; use OCP\IRequest; @@ -74,10 +75,10 @@ class AppSettingsController extends Controller { ['id' => 1, 'displayName' => (string)$this->l10n->t('Not enabled')], ]; - if($this->config->getSystemValue('appstoreenabled', true)) { + if(OCSClient::isAppStoreEnabled()) { $categories[] = ['id' => 2, 'displayName' => (string)$this->l10n->t('Recommended')]; // apps from external repo via OCS - $ocs = \OC_OCSClient::getCategories(); + $ocs = OCSClient::getCategories(); if ($ocs) { foreach($ocs as $k => $v) { $categories[] = array( @@ -106,10 +107,7 @@ class AppSettingsController extends Controller { switch ($category) { // installed apps case 0: - $apps = \OC_App::listAllApps(true); - $apps = array_filter($apps, function ($app) { - return $app['active']; - }); + $apps = $this->getInstalledApps(); usort($apps, function ($a, $b) { $a = (string)$a['name']; $b = (string)$b['name']; @@ -147,7 +145,21 @@ class AppSettingsController extends Controller { } if (!$apps) { $apps = array(); + } else { + // don't list installed apps + $installedApps = $this->getInstalledApps(); + $installedApps = array_map(function ($app) { + if (isset($app['ocsid'])) { + return $app['ocsid']; + } + return $app['id']; + }, $installedApps); + $apps = array_filter($apps, function ($app) use ($installedApps) { + return !in_array($app['id'], $installedApps); + }); } + + // sort by score usort($apps, function ($a, $b) { $a = (int)$a['score']; $b = (int)$b['score']; @@ -189,4 +201,15 @@ class AppSettingsController extends Controller { return ['apps' => $apps, 'status' => 'success']; } + + /** + * @return array + */ + private function getInstalledApps() { + $apps = \OC_App::listAllApps(true); + $apps = array_filter($apps, function ($app) { + return $app['active']; + }); + return $apps; + } } |