diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-09-15 23:03:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-15 23:03:12 +0300 |
commit | d39f047af210245adcd877baee090f6cc4a8f40c (patch) | |
tree | 455476f636c1002c22d321cb0341ec28ce127fdc /lib | |
parent | 0023a1066be72789a3785e30b78fc4d99dcd2403 (diff) | |
parent | 1998ac7b06e8845719db5cd276db59ac053bbcd2 (diff) |
Merge pull request #34072 from nextcloud/enh/noid/default-enabled-2
set defaultEnabled in shipped.json
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..f7c9d848099 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 should be enabled by default + * + * Notice: This actually checks if the app should be enabled by default + * and not if currently installed/enabled + * + * @param string $appId ID of the app + * @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 |