From 5a5bcccd0d612bbb23214777d33a6439b75ffb53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BCller?= <thomas.mueller@tmit.eu>
Date: Fri, 16 Oct 2015 16:38:43 +0200
Subject: [PATCH] Don't show apps which are always enabled in the app manager

---
 lib/private/app.php            |  6 ++----
 lib/private/app/appmanager.php | 17 ++++++++++++-----
 lib/public/app/iappmanager.php |  6 ++++++
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/lib/private/app.php b/lib/private/app.php
index a95019ac02..d7e62dfd85 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -768,12 +768,9 @@ class OC_App {
 					if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
 
 						$apps[] = $file;
-
 					}
-
 				}
 			}
-
 		}
 
 		return $apps;
@@ -793,7 +790,8 @@ class OC_App {
 		//TODO which apps do we want to blacklist and how do we integrate
 		// blacklisting with the multi apps folder feature?
 
-		$blacklist = array('files'); //we don't want to show configuration for these
+		//we don't want to show configuration for these
+		$blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps();
 		$appList = array();
 		$l = \OC::$server->getL10N('core');
 
diff --git a/lib/private/app/appmanager.php b/lib/private/app/appmanager.php
index a121b8ab86..5a932b7dc3 100644
--- a/lib/private/app/appmanager.php
+++ b/lib/private/app/appmanager.php
@@ -136,9 +136,6 @@ class AppManager implements IAppManager {
 	 * @return bool
 	 */
 	private function checkAppForUser($enabled, $user) {
-		if ($this->isAlwaysEnabled($enabled)) {
-			return true;
-		}
 		if ($enabled === 'yes') {
 			return true;
 		} elseif (is_null($user)) {
@@ -284,14 +281,17 @@ class AppManager implements IAppManager {
 		return $incompatibleApps;
 	}
 
+	/**
+	 * @inheritdoc
+	 */
 	public function isShipped($appId) {
 		$this->loadShippedJson();
 		return in_array($appId, $this->shippedApps);
 	}
 
 	private function isAlwaysEnabled($appId) {
-		$this->loadShippedJson();
-		return in_array($appId, $this->alwaysEnabled);
+		$alwaysEnabled = $this->getAlwaysEnabledApps();
+		return in_array($appId, $alwaysEnabled);
 	}
 
 	private function loadShippedJson() {
@@ -310,4 +310,11 @@ class AppManager implements IAppManager {
 		}
 	}
 
+	/**
+	 * @inheritdoc
+	 */
+	public function getAlwaysEnabledApps() {
+		$this->loadShippedJson();
+		return $this->alwaysEnabled;
+	}
 }
diff --git a/lib/public/app/iappmanager.php b/lib/public/app/iappmanager.php
index afbd64d281..09b6bd3f2b 100644
--- a/lib/public/app/iappmanager.php
+++ b/lib/public/app/iappmanager.php
@@ -105,4 +105,10 @@ interface IAppManager {
 	 * @since 9.0.0
 	 */
 	public function isShipped($appId);
+
+	/**
+	 * @return string[]
+	 * @since 9.0.0
+	 */
+	public function getAlwaysEnabledApps();
 }
-- 
GitLab