summaryrefslogtreecommitdiffstats
path: root/core/command/app
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2016-01-14 16:10:17 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2016-01-19 14:29:12 +0100
commit56184f799eca847397e4bc20d562fd2f3bcbe7e1 (patch)
tree7200590d6bb3964c1f6edfa62be1f952a64946e3 /core/command/app
parent78a02d1b2f60fb04827673d1b5d6ccde2880157f (diff)
downloadnextcloud-server-56184f799eca847397e4bc20d562fd2f3bcbe7e1.tar.gz
nextcloud-server-56184f799eca847397e4bc20d562fd2f3bcbe7e1.zip
Make it possible to enable apps for groups only via occ
Diffstat (limited to 'core/command/app')
-rw-r--r--core/command/app/enable.php41
1 files changed, 36 insertions, 5 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;
}
}