From d2285113a891fa2e34f4615c4b30490098577649 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 Jan 2016 16:08:18 +0100 Subject: [PATCH 1/3] Make sure to list "group enabled" apps as enabled also when they are not enabled for the current user --- core/command/app/listapps.php | 20 ++++++++++++++++---- core/register_command.php | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/core/command/app/listapps.php b/core/command/app/listapps.php index 504944dd707..d7546b3c0c7 100644 --- a/core/command/app/listapps.php +++ b/core/command/app/listapps.php @@ -25,11 +25,24 @@ namespace OC\Core\Command\App; use OC\Core\Command\Base; +use OCP\App\IAppManager; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class ListApps extends Base { + + /** @var IAppManager */ + protected $manager; + + /** + * @param IAppManager $manager + */ + public function __construct(IAppManager $manager) { + parent::__construct(); + $this->manager = $manager; + } + protected function configure() { parent::configure(); @@ -47,10 +60,9 @@ class ListApps extends Base { protected function execute(InputInterface $input, OutputInterface $output) { if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false'){ - $shouldFilterShipped = true; $shippedFilter = $input->getOption('shipped') === 'true'; } else { - $shouldFilterShipped = false; + $shippedFilter = null; } $apps = \OC_App::getAllApps(); @@ -59,10 +71,10 @@ class ListApps extends Base { //sort enabled apps above disabled apps foreach ($apps as $app) { - if ($shouldFilterShipped && \OC_App::isShipped($app) !== $shippedFilter){ + if ($shippedFilter !== null && \OC_App::isShipped($app) !== $shippedFilter){ continue; } - if (\OC_App::isEnabled($app)) { + if ($this->manager->isInstalled($app)) { $enabledApps[] = $app; } else { $disabledApps[] = $app; diff --git a/core/register_command.php b/core/register_command.php index a7dd7414790..42e2d29ecea 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -47,7 +47,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) { $application->add(new OC\Core\Command\App\Disable()); $application->add(new OC\Core\Command\App\Enable()); $application->add(new OC\Core\Command\App\GetPath()); - $application->add(new OC\Core\Command\App\ListApps()); + $application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager())); $application->add(new OC\Core\Command\Background\Cron(\OC::$server->getConfig())); $application->add(new OC\Core\Command\Background\WebCron(\OC::$server->getConfig())); From 78a02d1b2f60fb04827673d1b5d6ccde2880157f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 Jan 2016 16:09:34 +0100 Subject: [PATCH 2/3] Make it possible to disable apps via the console, which are not enabled for the current user --- core/command/app/disable.php | 17 +++++++++++++++-- core/register_command.php | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/core/command/app/disable.php b/core/command/app/disable.php index b5e776d7e03..b3157faf32e 100644 --- a/core/command/app/disable.php +++ b/core/command/app/disable.php @@ -23,12 +23,25 @@ namespace OC\Core\Command\App; +use OCP\App\IAppManager; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Disable extends Command { + + /** @var IAppManager */ + protected $manager; + + /** + * @param IAppManager $manager + */ + public function __construct(IAppManager $manager) { + parent::__construct(); + $this->manager = $manager; + } + protected function configure() { $this ->setName('app:disable') @@ -42,9 +55,9 @@ class Disable extends Command { protected function execute(InputInterface $input, OutputInterface $output) { $appId = $input->getArgument('app-id'); - if (\OC_App::isEnabled($appId)) { + if ($this->manager->isInstalled($appId)) { try { - \OC_App::disable($appId); + $this->manager->disableApp($appId); $output->writeln($appId . ' disabled'); } catch(\Exception $e) { $output->writeln($e->getMessage()); diff --git a/core/register_command.php b/core/register_command.php index 42e2d29ecea..d167bec2638 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -44,7 +44,7 @@ $application->add(new \OC\Core\Command\Integrity\SignCore( )); if (\OC::$server->getConfig()->getSystemValue('installed', false)) { - $application->add(new OC\Core\Command\App\Disable()); + $application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager())); $application->add(new OC\Core\Command\App\Enable()); $application->add(new OC\Core\Command\App\GetPath()); $application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager())); From 56184f799eca847397e4bc20d562fd2f3bcbe7e1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 Jan 2016 16:10:17 +0100 Subject: [PATCH 3/3] Make it possible to enable apps for groups only via occ --- core/command/app/enable.php | 41 ++++++++++++++++++++++++++++++++----- core/register_command.php | 2 +- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/core/command/app/enable.php b/core/command/app/enable.php index d50b1c4773e..4315972bae2 100644 --- a/core/command/app/enable.php +++ b/core/command/app/enable.php @@ -23,12 +23,26 @@ namespace OC\Core\Command\App; +use OCP\App\IAppManager; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Enable extends Command { + + /** @var IAppManager */ + protected $manager; + + /** + * @param IAppManager $manager + */ + public function __construct(IAppManager $manager) { + parent::__construct(); + $this->manager = $manager; + } + protected function configure() { $this ->setName('app:enable') @@ -37,19 +51,36 @@ class Enable extends Command { 'app-id', InputArgument::REQUIRED, 'enable the specified app' - ); + ) + ->addOption( + 'groups', + 'g', + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'enable the app only for a list of groups' + ) + ; } protected function execute(InputInterface $input, OutputInterface $output) { $appId = $input->getArgument('app-id'); - if (\OC_App::isEnabled($appId)) { - $output->writeln($appId . ' is already enabled'); - } else if (!\OC_App::getAppPath($appId)) { + + if (!\OC_App::getAppPath($appId)) { $output->writeln($appId . ' not found'); return 1; - } else { + } + + $groups = $input->getOption('groups'); + if ($this->manager->isInstalled($appId) && empty($groups)) { + $output->writeln($appId . ' is already enabled'); + } + + if (empty($groups)) { \OC_App::enable($appId); $output->writeln($appId . ' enabled'); + } else { + \OC_App::enable($appId, $groups); + $output->writeln($appId . ' enabled for groups: ' . implode(', ', $groups)); } + return 0; } } diff --git a/core/register_command.php b/core/register_command.php index d167bec2638..e43994530b9 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -45,7 +45,7 @@ $application->add(new \OC\Core\Command\Integrity\SignCore( if (\OC::$server->getConfig()->getSystemValue('installed', false)) { $application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager())); - $application->add(new OC\Core\Command\App\Enable()); + $application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager())); $application->add(new OC\Core\Command\App\GetPath()); $application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager()));