diff options
Diffstat (limited to 'core/command')
-rw-r--r-- | core/command/app/disable.php | 17 | ||||
-rw-r--r-- | core/command/app/enable.php | 41 | ||||
-rw-r--r-- | core/command/app/listapps.php | 20 | ||||
-rw-r--r-- | core/command/integrity/signapp.php | 25 | ||||
-rw-r--r-- | core/command/maintenance/mimetype/updatejs.php | 2 |
5 files changed, 86 insertions, 19 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/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/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/command/integrity/signapp.php b/core/command/integrity/signapp.php index a203b9ad1da..53df9619c6d 100644 --- a/core/command/integrity/signapp.php +++ b/core/command/integrity/signapp.php @@ -23,6 +23,7 @@ namespace OC\Core\Command\Integrity; use OC\IntegrityCheck\Checker; use OC\IntegrityCheck\Helpers\FileAccessHelper; +use OCP\IURLGenerator; use phpseclib\Crypt\RSA; use phpseclib\File\X509; use Symfony\Component\Console\Command\Command; @@ -40,23 +41,28 @@ class SignApp extends Command { private $checker; /** @var FileAccessHelper */ private $fileAccessHelper; + /** @var IURLGenerator */ + private $urlGenerator; /** * @param Checker $checker * @param FileAccessHelper $fileAccessHelper + * @param IURLGenerator $urlGenerator */ public function __construct(Checker $checker, - FileAccessHelper $fileAccessHelper) { + FileAccessHelper $fileAccessHelper, + IURLGenerator $urlGenerator) { parent::__construct(null); $this->checker = $checker; $this->fileAccessHelper = $fileAccessHelper; + $this->urlGenerator = $urlGenerator; } protected function configure() { $this ->setName('integrity:sign-app') - ->setDescription('Sign app using a private key.') - ->addOption('appId', null, InputOption::VALUE_REQUIRED, 'Application to sign') + ->setDescription('Signs an app using a private key.') + ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Application to sign') ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing') ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing'); } @@ -65,11 +71,14 @@ class SignApp extends Command { * {@inheritdoc } */ protected function execute(InputInterface $input, OutputInterface $output) { - $appId = $input->getOption('appId'); + $path = $input->getOption('path'); $privateKeyPath = $input->getOption('privateKey'); $keyBundlePath = $input->getOption('certificate'); - if(is_null($appId) || is_null($privateKeyPath) || is_null($keyBundlePath)) { - $output->writeln('--appId, --privateKey and --certificate are required.'); + if(is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) { + $documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity'); + $output->writeln('This command requires the --path, --privateKey and --certificate.'); + $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"'); + $output->writeln('For more information please consult the documentation: '. $documentationUrl); return null; } @@ -91,8 +100,8 @@ class SignApp extends Command { $x509 = new X509(); $x509->loadX509($keyBundle); $x509->setPrivateKey($rsa); - $this->checker->writeAppSignature($appId, $x509, $rsa); + $this->checker->writeAppSignature($path, $x509, $rsa); - $output->writeln('Successfully signed "'.$appId.'"'); + $output->writeln('Successfully signed "'.$path.'"'); } } diff --git a/core/command/maintenance/mimetype/updatejs.php b/core/command/maintenance/mimetype/updatejs.php index e93b563d5fb..8ee06e8cdc9 100644 --- a/core/command/maintenance/mimetype/updatejs.php +++ b/core/command/maintenance/mimetype/updatejs.php @@ -71,6 +71,7 @@ class UpdateJS extends Command { //Remove duplicates $files = array_values(array_unique($files)); + sort($files); // Fetch all themes! $themes = []; @@ -100,6 +101,7 @@ class UpdateJS extends Command { //Remove Duplicates $themes[$theme] = array_values(array_unique($themes[$theme])); + sort($themes[$theme]); } //Generate the JS |