From 0efd6d995037bc34de714024f137fecdbdc50a69 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Thu, 15 Sep 2022 08:15:25 -0100 Subject: set defaultEnabled in shipped.json Signed-off-by: Maxence Lange --- lib/private/App/AppManager.php | 22 ++++++++++++++++++++-- lib/private/Installer.php | 3 +-- lib/public/App/IAppManager.php | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index f154bd854ad..6d2fe51d0ed 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -13,6 +13,7 @@ * @author Julius Haertl * @author Julius Härtl * @author Lukas Reschke + * @author Maxence Lange * @author Morris Jobke * @author Robin Appelman * @author Roeland Jago Douma @@ -91,8 +92,8 @@ class AppManager implements IAppManager { /** @var string[] */ private $shippedApps; - /** @var string[] */ - private $alwaysEnabled; + private array $alwaysEnabled = []; + private array $defaultEnabled = []; /** @var array */ private $appInfos = []; @@ -574,6 +575,7 @@ class AppManager implements IAppManager { $content = json_decode(file_get_contents($shippedJson), true); $this->shippedApps = $content['shippedApps']; $this->alwaysEnabled = $content['alwaysEnabled']; + $this->defaultEnabled = $content['defaultEnabled']; } } @@ -584,4 +586,20 @@ class AppManager implements IAppManager { $this->loadShippedJson(); return $this->alwaysEnabled; } + + /** + * @inheritdoc + */ + public function isDefaultEnabled(string $appId): bool { + return (in_array($appId, $this->getDefaultEnabledApps())); + } + + /** + * @inheritdoc + */ + public function getDefaultEnabledApps():array { + $this->loadShippedJson(); + + return $this->defaultEnabled; + } } diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 86d933b6fbd..43c3db7c3fd 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -545,8 +545,7 @@ class Installer { if ($filename[0] !== '.' and is_dir($app_dir['path']."/$filename")) { if (file_exists($app_dir['path']."/$filename/appinfo/info.xml")) { if ($config->getAppValue($filename, "installed_version", null) === null) { - $info = OC_App::getAppInfo($filename); - $enabled = isset($info['default_enable']); + $enabled = $appManager->isDefaultEnabled($filename); if (($enabled || in_array($filename, $appManager->getAlwaysEnabledApps())) && $config->getAppValue($filename, 'enabled') !== 'no') { if ($softErrors) { diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index e0b5c049290..ef8a7b8d9f0 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -83,6 +83,17 @@ interface IAppManager { */ public function isInstalled($appId); + /** + * Check if an app is enabled by default + * + * Notice: This actually checks if the app should be enabled by default + * and not if currently installed/enabled + * + * @param string $appId + * @since 25.0.0 + */ + public function isDefaultEnabled(string $appId):bool; + /** * Enable an app for every user * @@ -178,6 +189,12 @@ interface IAppManager { */ public function getAlwaysEnabledApps(); + /** + * @return string[] app IDs + * @since 25.0.0 + */ + public function getDefaultEnabledApps(): array; + /** * @param \OCP\IGroup $group * @return String[] -- cgit v1.2.3