diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/App/AppManager.php | 63 | ||||
-rw-r--r-- | lib/private/Console/Application.php | 2 | ||||
-rw-r--r-- | lib/private/Migration/MetadataManager.php | 4 | ||||
-rw-r--r-- | lib/private/NavigationManager.php | 2 | ||||
-rw-r--r-- | lib/private/Server.php | 4 | ||||
-rw-r--r-- | lib/private/TaskProcessing/Manager.php | 2 | ||||
-rw-r--r-- | lib/private/Template/JSConfigHelper.php | 2 | ||||
-rw-r--r-- | lib/private/Updater.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/OC_App.php | 2 |
9 files changed, 48 insertions, 35 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index b6f7f9b13b7..84dde3be712 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -45,7 +45,7 @@ class AppManager implements IAppManager { ]; /** @var string[] $appId => $enabled */ - private array $installedAppsCache = []; + private array $enabledAppsCache = []; /** @var string[]|null */ private ?array $shippedApps = null; @@ -129,10 +129,12 @@ class AppManager implements IAppManager { } /** - * @return string[] $appId => $enabled + * For all enabled apps, return the value of their 'enabled' config key. + * + * @return array<string,string> appId => enabled (may be 'yes', or a json encoded list of group ids) */ - private function getInstalledAppsValues(): array { - if (!$this->installedAppsCache) { + private function getEnabledAppsValues(): array { + if (!$this->enabledAppsCache) { $values = $this->getAppConfig()->getValues(false, 'enabled'); $alwaysEnabledApps = $this->getAlwaysEnabledApps(); @@ -140,21 +142,30 @@ class AppManager implements IAppManager { $values[$appId] = 'yes'; } - $this->installedAppsCache = array_filter($values, function ($value) { + $this->enabledAppsCache = array_filter($values, function ($value) { return $value !== 'no'; }); - ksort($this->installedAppsCache); + ksort($this->enabledAppsCache); } - return $this->installedAppsCache; + return $this->enabledAppsCache; } /** - * List all installed apps + * Deprecated alias * * @return string[] */ public function getInstalledApps() { - return array_keys($this->getInstalledAppsValues()); + return $this->getEnabledApps(); + } + + /** + * List all enabled apps, either for everyone or for some groups + * + * @return list<string> + */ + public function getEnabledApps(): array { + return array_keys($this->getEnabledAppsValues()); } /** @@ -195,7 +206,7 @@ class AppManager implements IAppManager { * @return string[] */ public function getEnabledAppsForUser(IUser $user) { - $apps = $this->getInstalledAppsValues(); + $apps = $this->getEnabledAppsValues(); $appsForUser = array_filter($apps, function ($enabled) use ($user) { return $this->checkAppForUser($enabled, $user); }); @@ -203,7 +214,7 @@ class AppManager implements IAppManager { } public function getEnabledAppsForGroup(IGroup $group): array { - $apps = $this->getInstalledAppsValues(); + $apps = $this->getEnabledAppsValues(); $appsForGroups = array_filter($apps, function ($enabled) use ($group) { return $this->checkAppForGroups($enabled, $group); }); @@ -303,7 +314,7 @@ class AppManager implements IAppManager { } public function getAppRestriction(string $appId): array { - $values = $this->getInstalledAppsValues(); + $values = $this->getEnabledAppsValues(); if (!isset($values[$appId])) { return []; @@ -329,9 +340,9 @@ class AppManager implements IAppManager { if ($user === null) { $user = $this->userSession->getUser(); } - $installedApps = $this->getInstalledAppsValues(); - if (isset($installedApps[$appId])) { - return $this->checkAppForUser($installedApps[$appId], $user); + $enabledAppsValues = $this->getEnabledAppsValues(); + if (isset($enabledAppsValues[$appId])) { + return $this->checkAppForUser($enabledAppsValues[$appId], $user); } else { return false; } @@ -395,12 +406,14 @@ class AppManager implements IAppManager { * Notice: This actually checks if the app is enabled and not only if it is installed. * * @param string $appId - * @param IGroup[]|String[] $groups - * @return bool */ - public function isInstalled($appId) { - $installedApps = $this->getInstalledAppsValues(); - return isset($installedApps[$appId]); + public function isInstalled($appId): bool { + return $this->isEnabledForAnyone($appId); + } + + public function isEnabledForAnyone(string $appId): bool { + $enabledAppsValues = $this->getEnabledAppsValues(); + return isset($enabledAppsValues[$appId]); } /** @@ -582,7 +595,7 @@ class AppManager implements IAppManager { $this->overwriteNextcloudRequirement($appId); } - $this->installedAppsCache[$appId] = 'yes'; + $this->enabledAppsCache[$appId] = 'yes'; $this->getAppConfig()->setValue($appId, 'enabled', 'yes'); $this->dispatcher->dispatchTyped(new AppEnableEvent($appId)); $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent( @@ -636,7 +649,7 @@ class AppManager implements IAppManager { : $group; }, $groups); - $this->installedAppsCache[$appId] = json_encode($groupIds); + $this->enabledAppsCache[$appId] = json_encode($groupIds); $this->getAppConfig()->setValue($appId, 'enabled', json_encode($groupIds)); $this->dispatcher->dispatchTyped(new AppEnableEvent($appId, $groupIds)); $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, new ManagerEvent( @@ -665,7 +678,7 @@ class AppManager implements IAppManager { $this->autoDisabledApps[$appId] = $previousSetting; } - unset($this->installedAppsCache[$appId]); + unset($this->enabledAppsCache[$appId]); $this->getAppConfig()->setValue($appId, 'enabled', 'no'); // run uninstall steps @@ -726,7 +739,7 @@ class AppManager implements IAppManager { */ public function getAppsNeedingUpgrade($version) { $appsToUpgrade = []; - $apps = $this->getInstalledApps(); + $apps = $this->getEnabledApps(); foreach ($apps as $appId) { $appInfo = $this->getAppInfo($appId); $appDbVersion = $this->getAppConfig()->getValue($appId, 'installed_version'); @@ -808,7 +821,7 @@ class AppManager implements IAppManager { * @internal */ public function getIncompatibleApps(string $version): array { - $apps = $this->getInstalledApps(); + $apps = $this->getEnabledApps(); $incompatibleApps = []; foreach ($apps as $appId) { $info = $this->getAppInfo($appId); diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index 70bbab10621..f896c0abebe 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -88,7 +88,7 @@ class Application { $this->writeMaintenanceModeInfo($input, $output); } else { $this->appManager->loadApps(); - foreach ($this->appManager->getInstalledApps() as $app) { + foreach ($this->appManager->getEnabledApps() as $app) { try { $appPath = $this->appManager->getAppPath($app); } catch (AppPathNotFoundException) { diff --git a/lib/private/Migration/MetadataManager.php b/lib/private/Migration/MetadataManager.php index fac9127a123..f4cb95342b4 100644 --- a/lib/private/Migration/MetadataManager.php +++ b/lib/private/Migration/MetadataManager.php @@ -73,7 +73,7 @@ class MetadataManager { ): array { $appsAttributes = []; foreach (array_keys($metadata['apps']) as $appId) { - if ($filterKnownMigrations && !$this->appManager->isInstalled($appId)) { + if ($filterKnownMigrations && !$this->appManager->isEnabledForAnyone($appId)) { continue; // if not interested and app is not installed } @@ -97,7 +97,7 @@ class MetadataManager { * @since 30.0.0 */ public function getUnsupportedApps(array $metadata): array { - return array_values(array_diff($this->appManager->getInstalledApps(), array_keys($metadata['apps']))); + return array_values(array_diff($this->appManager->getEnabledApps(), array_keys($metadata['apps']))); } /** diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index 4bcd78b7fcf..83d26c7ca63 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -328,7 +328,7 @@ class NavigationManager implements INavigationManager { $apps = $this->appManager->getEnabledAppsForUser($user); $this->customAppOrder = json_decode($this->config->getUserValue($user->getUID(), 'core', 'apporder', '[]'), true, flags:JSON_THROW_ON_ERROR); } else { - $apps = $this->appManager->getInstalledApps(); + $apps = $this->appManager->getEnabledApps(); $this->customAppOrder = []; } diff --git a/lib/private/Server.php b/lib/private/Server.php index be9d7595e42..968d469aa74 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -837,7 +837,7 @@ class Server extends ServerContainer implements IServerContainer { $busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus'); if ($busClass) { [$app, $class] = explode('::', $busClass, 2); - if ($c->get(IAppManager::class)->isInstalled($app)) { + if ($c->get(IAppManager::class)->isEnabledForUser($app)) { \OC_App::loadApp($app); return $c->get($class); } else { @@ -1046,7 +1046,7 @@ class Server extends ServerContainer implements IServerContainer { $classExists = false; } - if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { + if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isEnabledForAnyone('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { $backgroundService = new BackgroundService( $c->get(IRootFolder::class), $c->getAppDataDir('theming'), diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index 0c8d2414448..07e643ab004 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -1396,7 +1396,7 @@ class Manager implements IManager { $this->logger->warning('Task processing AppAPI webhook failed for task ' . $task->getId() . '. Invalid method: ' . $method); } [, $exAppId, $httpMethod] = $parsedMethod; - if (!$this->appManager->isInstalled('app_api')) { + if (!$this->appManager->isEnabledForAnyone('app_api')) { $this->logger->warning('Task processing AppAPI webhook failed for task ' . $task->getId() . '. AppAPI is disabled or not installed.'); return; } diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index ae887db09d5..5743d2965d2 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -78,7 +78,7 @@ class JSConfigHelper { $apps_paths = []; if ($this->currentUser === null) { - $apps = $this->appManager->getInstalledApps(); + $apps = $this->appManager->getEnabledApps(); } else { $apps = $this->appManager->getEnabledAppsForUser($this->currentUser); } diff --git a/lib/private/Updater.php b/lib/private/Updater.php index c4631f2c7d3..7707a310d99 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -242,7 +242,7 @@ class Updater extends BasicEmitter { $appManager = \OC::$server->getAppManager(); // upgrade appstore apps - $this->upgradeAppStoreApps($appManager->getInstalledApps()); + $this->upgradeAppStoreApps($appManager->getEnabledApps()); $autoDisabledApps = $appManager->getAutoDisabledApps(); if (!empty($autoDisabledApps)) { $this->upgradeAppStoreApps(array_keys($autoDisabledApps), $autoDisabledApps); diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index 544938b6ff9..7fee946b776 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -185,7 +185,7 @@ class OC_App { } if (is_null($user)) { - $apps = $appManager->getInstalledApps(); + $apps = $appManager->getEnabledApps(); } else { $apps = $appManager->getEnabledAppsForUser($user); } |