1<?php 2/** 3 * @author Thomas Müller <thomas.mueller@tmit.eu> 4 * 5 * @copyright Copyright (c) 2018, ownCloud GmbH 6 * @license AGPL-3.0 7 * 8 * This code is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Affero General Public License, version 3, 10 * as published by the Free Software Foundation. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Affero General Public License for more details. 16 * 17 * You should have received a copy of the GNU Affero General Public License, version 3, 18 * along with this program. If not, see <http://www.gnu.org/licenses/> 19 * 20 */ 21 22namespace OC\Core\Command\User; 23 24use OCP\IUserManager; 25use Symfony\Component\Console\Command\Command; 26use Symfony\Component\Console\Input\InputInterface; 27use Symfony\Component\Console\Output\OutputInterface; 28use Symfony\Component\Console\Input\InputArgument; 29 30class Disable extends Command { 31 /** @var IUserManager */ 32 protected $userManager; 33 34 /** 35 * @param IUserManager $userManager 36 */ 37 public function __construct(IUserManager $userManager) { 38 $this->userManager = $userManager; 39 parent::__construct(); 40 } 41 42 protected function configure() { 43 $this 44 ->setName('user:disable') 45 ->setDescription('Disables the specified user.') 46 ->addArgument( 47 'uid', 48 InputArgument::REQUIRED, 49 'The username.' 50 ); 51 } 52 53 protected function execute(InputInterface $input, OutputInterface $output) { 54 $user = $this->userManager->get($input->getArgument('uid')); 55 if ($user === null) { 56 $output->writeln('<error>User does not exist</error>'); 57 return; 58 } 59 60 $user->setEnabled(false); 61 $output->writeln('<info>The specified user is disabled</info>'); 62 } 63} 64