singleuser.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @author Morris Jobke <hey@morrisjobke.de>
  4. * @author Robin Appelman <icewind@owncloud.com>
  5. *
  6. * @copyright Copyright (c) 2015, ownCloud, Inc.
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OC\Core\Command\Maintenance;
  23. use Symfony\Component\Console\Command\Command;
  24. use Symfony\Component\Console\Input\InputInterface;
  25. use Symfony\Component\Console\Input\InputOption;
  26. use Symfony\Component\Console\Output\OutputInterface;
  27. use OCP\IConfig;
  28. class SingleUser extends Command {
  29. /** @var IConfig */
  30. protected $config;
  31. /**
  32. * @param IConfig $config
  33. */
  34. public function __construct(IConfig $config) {
  35. $this->config = $config;
  36. parent::__construct();
  37. }
  38. protected function configure() {
  39. $this
  40. ->setName('maintenance:singleuser')
  41. ->setDescription('set single user mode')
  42. ->addOption(
  43. 'on',
  44. null,
  45. InputOption::VALUE_NONE,
  46. 'enable single user mode'
  47. )
  48. ->addOption(
  49. 'off',
  50. null,
  51. InputOption::VALUE_NONE,
  52. 'disable single user mode'
  53. );
  54. }
  55. protected function execute(InputInterface $input, OutputInterface $output) {
  56. if ($input->getOption('on')) {
  57. $this->config->setSystemValue('singleuser', true);
  58. $output->writeln('Single user mode enabled');
  59. } elseif ($input->getOption('off')) {
  60. $this->config->setSystemValue('singleuser', false);
  61. $output->writeln('Single user mode disabled');
  62. } else {
  63. if ($this->config->getSystemValue('singleuser', false)) {
  64. $output->writeln('Single user mode is currently enabled');
  65. } else {
  66. $output->writeln('Single user mode is currently disabled');
  67. }
  68. }
  69. }
  70. }