diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2019-12-16 12:34:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-16 12:34:27 +0100 |
commit | faf58e4cacf6475110e32c7e5c8f37971b641b1a (patch) | |
tree | 8d9e184401c781e1b4c95d2b369e17ef0b448f61 /lib | |
parent | 85ef2bf94429d37ad4c76860b8d9028505b3bf13 (diff) | |
parent | 3eee359d7ffd6219f6a2ab8cca18a13118552842 (diff) | |
download | nextcloud-server-faf58e4cacf6475110e32c7e5c8f37971b641b1a.tar.gz nextcloud-server-faf58e4cacf6475110e32c7e5c8f37971b641b1a.zip |
Merge pull request #17018 from nextcloud/feature/noid/allow-to-force-enable-via-cli
Allow to force enable apps via CLI
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppManager.php | 29 | ||||
-rw-r--r-- | lib/private/Installer.php | 5 | ||||
-rw-r--r-- | lib/private/Server.php | 1 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 6 |
4 files changed, 35 insertions, 6 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) diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 2ad1fb36af7..d583dd20761 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -94,10 +94,11 @@ class Installer { * Installs an app that is located in one of the app folders already * * @param string $appId App to install + * @param bool $forceEnable * @throws \Exception * @return string app ID */ - public function installApp($appId) { + public function installApp(string $appId, bool $forceEnable = false): string { $app = \OC_App::findAppInDirectories($appId); if($app === false) { throw new \Exception('App not found in any app directory'); @@ -117,7 +118,7 @@ class Installer { } $ignoreMaxApps = $this->config->getSystemValue('app_install_overwrite', []); - $ignoreMax = in_array($appId, $ignoreMaxApps); + $ignoreMax = $forceEnable || in_array($appId, $ignoreMaxApps, true); $version = implode('.', \OCP\Util::getVersion()); if (!\OC_App::isAppCompatible($version, $info, $ignoreMax)) { diff --git a/lib/private/Server.php b/lib/private/Server.php index 0cc3b24992e..6b030a77a85 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -798,6 +798,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(AppManager::class, function (Server $c) { return new \OC\App\AppManager( $c->getUserSession(), + $c->getConfig(), $c->query(\OC\AppConfig::class), $c->getGroupManager(), $c->getMemCacheFactory(), diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 918c7597448..4cf8da586e1 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -86,10 +86,11 @@ interface IAppManager { * Enable an app for every user * * @param string $appId + * @param bool $forceEnable * @throws AppPathNotFoundException * @since 8.0.0 */ - public function enableApp($appId); + public function enableApp(string $appId, bool $forceEnable = false): void; /** * Whether a list of types contains a protected app type @@ -105,10 +106,11 @@ interface IAppManager { * * @param string $appId * @param \OCP\IGroup[] $groups + * @param bool $forceEnable * @throws \Exception * @since 8.0.0 */ - public function enableAppForGroups($appId, $groups); + public function enableAppForGroups(string $appId, array $groups, bool $forceEnable = false): void; /** * Disable an app for every user |