summaryrefslogtreecommitdiffstats
path: root/core/Command/User/Disable.php
diff options
context:
space:
mode:
authorThomas Müller <DeepDiver1975@users.noreply.github.com>2016-05-03 15:22:41 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-05-03 15:22:41 +0200
commit4b2544925f7f51d7e5cb1329166451f4fbd9e6bf (patch)
treece9a58e2532ec0301dc7e0c266f8256eb79826f9 /core/Command/User/Disable.php
parentdf2eb96cc40893f60a1b63abbe585c448e0a6d9f (diff)
parent661ab1a8c51ec251c44f76c7d58484ff14003336 (diff)
downloadnextcloud-server-4b2544925f7f51d7e5cb1329166451f4fbd9e6bf.tar.gz
nextcloud-server-4b2544925f7f51d7e5cb1329166451f4fbd9e6bf.zip
Merge pull request #23844 from owncloud/disable-user
Add occ commands to enable and disable a user + a disabled user can n…
Diffstat (limited to 'core/Command/User/Disable.php')
-rw-r--r--core/Command/User/Disable.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/core/Command/User/Disable.php b/core/Command/User/Disable.php
new file mode 100644
index 00000000000..018f11190d6
--- /dev/null
+++ b/core/Command/User/Disable.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @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/>
+ *
+ */
+
+namespace OC\Core\Command\User;
+
+use OCP\IUser;
+use OCP\IUserManager;
+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 Disable extends Command {
+ /** @var IUserManager */
+ protected $userManager;
+
+ /**
+ * @param IUserManager $userManager
+ */
+ public function __construct(IUserManager $userManager) {
+ $this->userManager = $userManager;
+ parent::__construct();
+ }
+
+ protected function configure() {
+ $this
+ ->setName('user:disable')
+ ->setDescription('disables the specified user')
+ ->addArgument(
+ 'uid',
+ InputArgument::REQUIRED,
+ 'the username'
+ );
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $user = $this->userManager->get($input->getArgument('uid'));
+ if (is_null($user)) {
+ $output->writeln('<error>User does not exist</error>');
+ return;
+ }
+
+ $user->setEnabled(false);
+ $output->writeln('<info>The specified user is disabled</info>');
+ }
+}