2014-08-21 19:59:13 +04:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 18:07:57 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
2015-06-25 12:43:55 +03:00
|
|
|
* @author Jens-Christian Fischer <jens-christian.fischer@switch.ch>
|
2016-07-21 18:07:57 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
2014-08-21 19:59:13 +04:00
|
|
|
*/
|
2015-02-26 13:37:37 +03:00
|
|
|
|
2014-08-21 19:59:13 +04:00
|
|
|
namespace OC\Core\Command\User;
|
|
|
|
|
2015-04-23 13:32:46 +03:00
|
|
|
use OCP\IUserManager;
|
2014-08-21 19:59:13 +04:00
|
|
|
use Symfony\Component\Console\Command\Command;
|
2019-11-22 22:52:10 +03:00
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
2014-08-21 19:59:13 +04:00
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
class Delete extends Command {
|
2015-04-23 13:32:46 +03:00
|
|
|
/** @var IUserManager */
|
2015-01-07 14:21:28 +03:00
|
|
|
protected $userManager;
|
|
|
|
|
|
|
|
/**
|
2015-04-23 13:32:46 +03:00
|
|
|
* @param IUserManager $userManager
|
2015-01-07 14:21:28 +03:00
|
|
|
*/
|
2015-04-23 13:32:46 +03:00
|
|
|
public function __construct(IUserManager $userManager) {
|
2015-01-07 14:21:28 +03:00
|
|
|
$this->userManager = $userManager;
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
2014-08-21 19:59:13 +04:00
|
|
|
protected function configure() {
|
|
|
|
$this
|
|
|
|
->setName('user:delete')
|
|
|
|
->setDescription('deletes the specified user')
|
|
|
|
->addArgument(
|
|
|
|
'uid',
|
|
|
|
InputArgument::REQUIRED,
|
|
|
|
'the username'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) {
|
2015-04-23 13:32:46 +03:00
|
|
|
$user = $this->userManager->get($input->getArgument('uid'));
|
|
|
|
if (is_null($user)) {
|
2015-04-23 13:40:13 +03:00
|
|
|
$output->writeln('<error>User does not exist</error>');
|
2015-04-23 13:32:46 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($user->delete()) {
|
2015-04-23 13:40:13 +03:00
|
|
|
$output->writeln('<info>The specified user was deleted</info>');
|
2014-08-21 19:59:13 +04:00
|
|
|
return;
|
|
|
|
}
|
2015-04-23 13:32:46 +03:00
|
|
|
|
2015-06-11 14:02:47 +03:00
|
|
|
$output->writeln('<error>The specified user could not be deleted. Please check the logs.</error>');
|
2014-08-21 19:59:13 +04:00
|
|
|
}
|
|
|
|
}
|