diff options
author | Joas Schilling <coding@schilljs.com> | 2019-09-05 12:55:24 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-12-13 13:06:12 +0100 |
commit | 3eee359d7ffd6219f6a2ab8cca18a13118552842 (patch) | |
tree | 94aa2317588ce3864a3d3715330c757f61d25713 /lib/private/App | |
parent | 642606754b133a36d7715b45b243155cbb006f95 (diff) | |
download | nextcloud-server-3eee359d7ffd6219f6a2ab8cca18a13118552842.tar.gz nextcloud-server-3eee359d7ffd6219f6a2ab8cca18a13118552842.zip |
Allow to force enable apps via CLI
Co-authored-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/App')
-rw-r--r-- | lib/private/App/AppManager.php | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 130ea1510c3..937cc511985 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -42,6 +42,7 @@ use OCP\App\AppPathNotFoundException; use OCP\App\IAppManager; use OCP\App\ManagerEvent; use OCP\ICacheFactory; +use OCP\IConfig; use OCP\IGroup; use OCP\IGroupManager; use OCP\ILogger; @@ -66,6 +67,9 @@ class AppManager implements IAppManager { /** @var IUserSession */ private $userSession; + /** @var IConfig */ + private $config; + /** @var AppConfig */ private $appConfig; @@ -101,18 +105,21 @@ class AppManager implements IAppManager { /** * @param IUserSession $userSession + * @param IConfig $config * @param AppConfig $appConfig * @param IGroupManager $groupManager * @param ICacheFactory $memCacheFactory * @param EventDispatcherInterface $dispatcher */ public function __construct(IUserSession $userSession, + IConfig $config, AppConfig $appConfig, IGroupManager $groupManager, ICacheFactory $memCacheFactory, EventDispatcherInterface $dispatcher, ILogger $logger) { $this->userSession = $userSession; + $this->config = $config; $this->appConfig = $appConfig; $this->groupManager = $groupManager; $this->memCacheFactory = $memCacheFactory; @@ -296,16 +303,29 @@ class AppManager implements IAppManager { return isset($installedApps[$appId]); } + public function ignoreNextcloudRequirementForApp(string $appId): void { + $ignoreMaxApps = $this->config->getSystemValue('app_install_overwrite', []); + if (!in_array($appId, $ignoreMaxApps, true)) { + $ignoreMaxApps[] = $appId; + $this->config->setSystemValue('app_install_overwrite', $ignoreMaxApps); + } + } + /** * Enable an app for every user * * @param string $appId + * @param bool $forceEnable * @throws AppPathNotFoundException */ - public function enableApp($appId) { + public function enableApp(string $appId, bool $forceEnable = false): void { // Check if app exists $this->getAppPath($appId); + if ($forceEnable) { + $this->ignoreNextcloudRequirementForApp($appId); + } + $this->installedAppsCache[$appId] = 'yes'; $this->appConfig->setValue($appId, 'enabled', 'yes'); $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent( @@ -334,10 +354,11 @@ class AppManager implements IAppManager { * * @param string $appId * @param \OCP\IGroup[] $groups + * @param bool $forceEnable * @throws \InvalidArgumentException if app can't be enabled for groups * @throws AppPathNotFoundException */ - public function enableAppForGroups($appId, $groups) { + public function enableAppForGroups(string $appId, array $groups, bool $forceEnable = false): void { // Check if app exists $this->getAppPath($appId); @@ -346,6 +367,10 @@ class AppManager implements IAppManager { throw new \InvalidArgumentException("$appId can't be enabled for groups."); } + if ($forceEnable) { + $this->ignoreNextcloudRequirementForApp($appId); + } + $groupIds = array_map(function ($group) { /** @var \OCP\IGroup $group */ return ($group instanceof IGroup) |