Make it possible to enable apps for groups only via occ
This commit is contained in:
parent
78a02d1b2f
commit
56184f799e
|
@ -23,12 +23,26 @@
|
||||||
|
|
||||||
namespace OC\Core\Command\App;
|
namespace OC\Core\Command\App;
|
||||||
|
|
||||||
|
use OCP\App\IAppManager;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
class Enable extends Command {
|
class Enable extends Command {
|
||||||
|
|
||||||
|
/** @var IAppManager */
|
||||||
|
protected $manager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param IAppManager $manager
|
||||||
|
*/
|
||||||
|
public function __construct(IAppManager $manager) {
|
||||||
|
parent::__construct();
|
||||||
|
$this->manager = $manager;
|
||||||
|
}
|
||||||
|
|
||||||
protected function configure() {
|
protected function configure() {
|
||||||
$this
|
$this
|
||||||
->setName('app:enable')
|
->setName('app:enable')
|
||||||
|
@ -37,19 +51,36 @@ class Enable extends Command {
|
||||||
'app-id',
|
'app-id',
|
||||||
InputArgument::REQUIRED,
|
InputArgument::REQUIRED,
|
||||||
'enable the specified app'
|
'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) {
|
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||||
$appId = $input->getArgument('app-id');
|
$appId = $input->getArgument('app-id');
|
||||||
if (\OC_App::isEnabled($appId)) {
|
|
||||||
$output->writeln($appId . ' is already enabled');
|
if (!\OC_App::getAppPath($appId)) {
|
||||||
} else if (!\OC_App::getAppPath($appId)) {
|
|
||||||
$output->writeln($appId . ' not found');
|
$output->writeln($appId . ' not found');
|
||||||
return 1;
|
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);
|
\OC_App::enable($appId);
|
||||||
$output->writeln($appId . ' enabled');
|
$output->writeln($appId . ' enabled');
|
||||||
|
} else {
|
||||||
|
\OC_App::enable($appId, $groups);
|
||||||
|
$output->writeln($appId . ' enabled for groups: ' . implode(', ', $groups));
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ $application->add(new \OC\Core\Command\Integrity\SignCore(
|
||||||
|
|
||||||
if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
|
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\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\GetPath());
|
||||||
$application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager()));
|
$application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager()));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue