2014-08-21 15:59:13 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Arthur Schiwon <blizzz@owncloud.com>
|
2015-06-25 09:43:55 +00:00
|
|
|
* @author Jens-Christian Fischer <jens-christian.fischer@switch.ch>
|
|
|
|
* @author Joas Schilling <nickvergessen@owncloud.com>
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
|
|
|
*
|
2016-01-12 14:02:16 +00:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
2015-03-26 10:44:34 +00:00
|
|
|
* @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 15:59:13 +00:00
|
|
|
*/
|
2015-02-26 10:37:37 +00:00
|
|
|
|
2014-08-21 15:59:13 +00:00
|
|
|
namespace OC\Core\Command\User;
|
|
|
|
|
2015-04-23 10:32:46 +00:00
|
|
|
use OCP\IUserManager;
|
2014-08-21 15:59:13 +00:00
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
|
|
|
|
class Delete extends Command {
|
2015-04-23 10:32:46 +00:00
|
|
|
/** @var IUserManager */
|
2015-01-07 11:21:28 +00:00
|
|
|
protected $userManager;
|
|
|
|
|
|
|
|
/**
|
2015-04-23 10:32:46 +00:00
|
|
|
* @param IUserManager $userManager
|
2015-01-07 11:21:28 +00:00
|
|
|
*/
|
2015-04-23 10:32:46 +00:00
|
|
|
public function __construct(IUserManager $userManager) {
|
2015-01-07 11:21:28 +00:00
|
|
|
$this->userManager = $userManager;
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
2014-08-21 15:59:13 +00: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 10:32:46 +00:00
|
|
|
$user = $this->userManager->get($input->getArgument('uid'));
|
|
|
|
if (is_null($user)) {
|
2015-04-23 10:40:13 +00:00
|
|
|
$output->writeln('<error>User does not exist</error>');
|
2015-04-23 10:32:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($user->delete()) {
|
2015-04-23 10:40:13 +00:00
|
|
|
$output->writeln('<info>The specified user was deleted</info>');
|
2014-08-21 15:59:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-04-23 10:32:46 +00:00
|
|
|
|
2015-06-11 11:02:47 +00:00
|
|
|
$output->writeln('<error>The specified user could not be deleted. Please check the logs.</error>');
|
2014-08-21 15:59:13 +00:00
|
|
|
}
|
|
|
|
}
|