|
|
|
|
@ -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,12 +142,12 @@ 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -163,7 +165,7 @@ class AppManager implements IAppManager {
|
|
|
|
|
* @return list<string>
|
|
|
|
|
*/
|
|
|
|
|
public function getEnabledApps(): array {
|
|
|
|
|
return array_keys($this->getInstalledAppsValues());
|
|
|
|
|
return array_keys($this->getEnabledAppsValues());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -204,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);
|
|
|
|
|
});
|
|
|
|
|
@ -212,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);
|
|
|
|
|
});
|
|
|
|
|
@ -312,7 +314,7 @@ class AppManager implements IAppManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getAppRestriction(string $appId): array {
|
|
|
|
|
$values = $this->getInstalledAppsValues();
|
|
|
|
|
$values = $this->getEnabledAppsValues();
|
|
|
|
|
|
|
|
|
|
if (!isset($values[$appId])) {
|
|
|
|
|
return [];
|
|
|
|
|
@ -338,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;
|
|
|
|
|
}
|
|
|
|
|
@ -410,8 +412,8 @@ class AppManager implements IAppManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isEnabledForAnyone(string $appId): bool {
|
|
|
|
|
$installedApps = $this->getInstalledAppsValues();
|
|
|
|
|
return isset($installedApps[$appId]);
|
|
|
|
|
$enabledAppsValues = $this->getEnabledAppsValues();
|
|
|
|
|
return isset($enabledAppsValues[$appId]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -593,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(
|
|
|
|
|
@ -647,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(
|
|
|
|
|
@ -676,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
|
|
|
|
|
@ -737,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');
|
|
|
|
|
@ -819,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);
|
|
|
|
|
|