diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2022-09-15 12:15:25 +0300 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2022-09-15 12:15:33 +0300 |
commit | 0efd6d995037bc34de714024f137fecdbdc50a69 (patch) | |
tree | fd187d0751321f586affd2152f3f170af0ab1fdc /lib | |
parent | 4c1f06170e1f7256bdc0791c40359c5ab6ad5eda (diff) |
set defaultEnabled in shipped.json
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppManager.php | 22 | ||||
-rw-r--r-- | lib/private/Installer.php | 3 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 17 |
3 files changed, 38 insertions, 4 deletions
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 <jus@bitgrid.net> * @author Julius Härtl <jus@bitgrid.net> * @author Lukas Reschke <lukas@statuscode.ch> + * @author Maxence Lange <maxence@artificial-owl.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -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 @@ -84,6 +84,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 * * @param string $appId @@ -179,6 +190,12 @@ interface IAppManager { public function getAlwaysEnabledApps(); /** + * @return string[] app IDs + * @since 25.0.0 + */ + public function getDefaultEnabledApps(): array; + + /** * @param \OCP\IGroup $group * @return String[] * @since 17.0.0 |