diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-02-09 22:48:27 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-02-23 23:16:28 +0100 |
commit | 39d84069337d7d6ddcaed7b1daba37cfeb26dcc7 (patch) | |
tree | fd7bb14caa1845c8444e2eaf3f6784fe19ff0a04 /settings | |
parent | 0cdc2cebbf9551652cc6df0433126bd840169e8a (diff) | |
download | nextcloud-server-39d84069337d7d6ddcaed7b1daba37cfeb26dcc7.tar.gz nextcloud-server-39d84069337d7d6ddcaed7b1daba37cfeb26dcc7.zip |
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; + } } |