Passed
Push — master ( ebedbf...47a21f )
by Joas
12:46 queued 18s
created
core/Command/Maintenance/DataFingerprint.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -30,26 +30,26 @@
 block discarded – undo
30 30
 
31 31
 class DataFingerprint extends Command {
32 32
 
33
-	/** @var IConfig */
34
-	protected $config;
35
-	/** @var ITimeFactory */
36
-	protected $timeFactory;
33
+    /** @var IConfig */
34
+    protected $config;
35
+    /** @var ITimeFactory */
36
+    protected $timeFactory;
37 37
 
38
-	public function __construct(IConfig $config,
39
-								ITimeFactory $timeFactory) {
40
-		$this->config = $config;
41
-		$this->timeFactory = $timeFactory;
42
-		parent::__construct();
43
-	}
38
+    public function __construct(IConfig $config,
39
+                                ITimeFactory $timeFactory) {
40
+        $this->config = $config;
41
+        $this->timeFactory = $timeFactory;
42
+        parent::__construct();
43
+    }
44 44
 
45
-	protected function configure() {
46
-		$this
47
-			->setName('maintenance:data-fingerprint')
48
-			->setDescription('update the systems data-fingerprint after a backup is restored');
49
-	}
45
+    protected function configure() {
46
+        $this
47
+            ->setName('maintenance:data-fingerprint')
48
+            ->setDescription('update the systems data-fingerprint after a backup is restored');
49
+    }
50 50
 
51
-	protected function execute(InputInterface $input, OutputInterface $output): int {
52
-		$this->config->setSystemValue('data-fingerprint', md5($this->timeFactory->getTime()));
53
-		return 0;
54
-	}
51
+    protected function execute(InputInterface $input, OutputInterface $output): int {
52
+        $this->config->setSystemValue('data-fingerprint', md5($this->timeFactory->getTime()));
53
+        return 0;
54
+    }
55 55
 }
Please login to merge, or discard this patch.
core/Command/Maintenance/UpdateHtaccess.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,19 +30,19 @@
 block discarded – undo
30 30
 use Symfony\Component\Console\Output\OutputInterface;
31 31
 
32 32
 class UpdateHtaccess extends Command {
33
-	protected function configure() {
34
-		$this
35
-			->setName('maintenance:update:htaccess')
36
-			->setDescription('Updates the .htaccess file');
37
-	}
33
+    protected function configure() {
34
+        $this
35
+            ->setName('maintenance:update:htaccess')
36
+            ->setDescription('Updates the .htaccess file');
37
+    }
38 38
 
39
-	protected function execute(InputInterface $input, OutputInterface $output): int {
40
-		if (\OC\Setup::updateHtaccess()) {
41
-			$output->writeln('.htaccess has been updated');
42
-			return 0;
43
-		} else {
44
-			$output->writeln('<error>Error updating .htaccess file, not enough permissions or "overwrite.cli.url" set to an invalid URL?</error>');
45
-			return 1;
46
-		}
47
-	}
39
+    protected function execute(InputInterface $input, OutputInterface $output): int {
40
+        if (\OC\Setup::updateHtaccess()) {
41
+            $output->writeln('.htaccess has been updated');
42
+            return 0;
43
+        } else {
44
+            $output->writeln('<error>Error updating .htaccess file, not enough permissions or "overwrite.cli.url" set to an invalid URL?</error>');
45
+            return 1;
46
+        }
47
+    }
48 48
 }
Please login to merge, or discard this patch.
core/Command/User/Disable.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -30,37 +30,37 @@
 block discarded – undo
30 30
 use Symfony\Component\Console\Output\OutputInterface;
31 31
 
32 32
 class Disable extends Command {
33
-	/** @var IUserManager */
34
-	protected $userManager;
33
+    /** @var IUserManager */
34
+    protected $userManager;
35 35
 
36
-	/**
37
-	 * @param IUserManager $userManager
38
-	 */
39
-	public function __construct(IUserManager $userManager) {
40
-		$this->userManager = $userManager;
41
-		parent::__construct();
42
-	}
36
+    /**
37
+     * @param IUserManager $userManager
38
+     */
39
+    public function __construct(IUserManager $userManager) {
40
+        $this->userManager = $userManager;
41
+        parent::__construct();
42
+    }
43 43
 
44
-	protected function configure() {
45
-		$this
46
-			->setName('user:disable')
47
-			->setDescription('disables the specified user')
48
-			->addArgument(
49
-				'uid',
50
-				InputArgument::REQUIRED,
51
-				'the username'
52
-			);
53
-	}
44
+    protected function configure() {
45
+        $this
46
+            ->setName('user:disable')
47
+            ->setDescription('disables the specified user')
48
+            ->addArgument(
49
+                'uid',
50
+                InputArgument::REQUIRED,
51
+                'the username'
52
+            );
53
+    }
54 54
 
55
-	protected function execute(InputInterface $input, OutputInterface $output): int {
56
-		$user = $this->userManager->get($input->getArgument('uid'));
57
-		if (is_null($user)) {
58
-			$output->writeln('<error>User does not exist</error>');
59
-			return 1;
60
-		}
55
+    protected function execute(InputInterface $input, OutputInterface $output): int {
56
+        $user = $this->userManager->get($input->getArgument('uid'));
57
+        if (is_null($user)) {
58
+            $output->writeln('<error>User does not exist</error>');
59
+            return 1;
60
+        }
61 61
 
62
-		$user->setEnabled(false);
63
-		$output->writeln('<info>The specified user is disabled</info>');
64
-		return 0;
65
-	}
62
+        $user->setEnabled(false);
63
+        $output->writeln('<info>The specified user is disabled</info>');
64
+        return 0;
65
+    }
66 66
 }
Please login to merge, or discard this patch.
core/Command/User/Delete.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -33,41 +33,41 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class Delete extends Command {
36
-	/** @var IUserManager */
37
-	protected $userManager;
36
+    /** @var IUserManager */
37
+    protected $userManager;
38 38
 
39
-	/**
40
-	 * @param IUserManager $userManager
41
-	 */
42
-	public function __construct(IUserManager $userManager) {
43
-		$this->userManager = $userManager;
44
-		parent::__construct();
45
-	}
39
+    /**
40
+     * @param IUserManager $userManager
41
+     */
42
+    public function __construct(IUserManager $userManager) {
43
+        $this->userManager = $userManager;
44
+        parent::__construct();
45
+    }
46 46
 
47
-	protected function configure() {
48
-		$this
49
-			->setName('user:delete')
50
-			->setDescription('deletes the specified user')
51
-			->addArgument(
52
-				'uid',
53
-				InputArgument::REQUIRED,
54
-				'the username'
55
-			);
56
-	}
47
+    protected function configure() {
48
+        $this
49
+            ->setName('user:delete')
50
+            ->setDescription('deletes the specified user')
51
+            ->addArgument(
52
+                'uid',
53
+                InputArgument::REQUIRED,
54
+                'the username'
55
+            );
56
+    }
57 57
 
58
-	protected function execute(InputInterface $input, OutputInterface $output): int {
59
-		$user = $this->userManager->get($input->getArgument('uid'));
60
-		if (is_null($user)) {
61
-			$output->writeln('<error>User does not exist</error>');
62
-			return 0;
63
-		}
58
+    protected function execute(InputInterface $input, OutputInterface $output): int {
59
+        $user = $this->userManager->get($input->getArgument('uid'));
60
+        if (is_null($user)) {
61
+            $output->writeln('<error>User does not exist</error>');
62
+            return 0;
63
+        }
64 64
 
65
-		if ($user->delete()) {
66
-			$output->writeln('<info>The specified user was deleted</info>');
67
-			return 0;
68
-		}
65
+        if ($user->delete()) {
66
+            $output->writeln('<info>The specified user was deleted</info>');
67
+            return 0;
68
+        }
69 69
 
70
-		$output->writeln('<error>The specified user could not be deleted. Please check the logs.</error>');
71
-		return 1;
72
-	}
70
+        $output->writeln('<error>The specified user could not be deleted. Please check the logs.</error>');
71
+        return 1;
72
+    }
73 73
 }
Please login to merge, or discard this patch.
core/Command/User/ListCommand.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -34,88 +34,88 @@
 block discarded – undo
34 34
 
35 35
 class ListCommand extends Base {
36 36
 
37
-	/** @var IUserManager */
38
-	protected $userManager;
37
+    /** @var IUserManager */
38
+    protected $userManager;
39 39
 
40
-	/** @var IGroupManager */
41
-	protected $groupManager;
40
+    /** @var IGroupManager */
41
+    protected $groupManager;
42 42
 
43
-	/**
44
-	 * @param IUserManager $userManager
45
-	 * @param IGroupManager $groupManager
46
-	 */
47
-	public function __construct(IUserManager $userManager,
48
-								IGroupManager $groupManager) {
49
-		$this->userManager = $userManager;
50
-		$this->groupManager = $groupManager;
51
-		parent::__construct();
52
-	}
43
+    /**
44
+     * @param IUserManager $userManager
45
+     * @param IGroupManager $groupManager
46
+     */
47
+    public function __construct(IUserManager $userManager,
48
+                                IGroupManager $groupManager) {
49
+        $this->userManager = $userManager;
50
+        $this->groupManager = $groupManager;
51
+        parent::__construct();
52
+    }
53 53
 
54
-	protected function configure() {
55
-		$this
56
-			->setName('user:list')
57
-			->setDescription('list configured users')
58
-			->addOption(
59
-				'limit',
60
-				'l',
61
-				InputOption::VALUE_OPTIONAL,
62
-				'Number of users to retrieve',
63
-				500
64
-			)->addOption(
65
-				'offset',
66
-				'o',
67
-				InputOption::VALUE_OPTIONAL,
68
-				'Offset for retrieving users',
69
-				0
70
-			)->addOption(
71
-				'output',
72
-				null,
73
-				InputOption::VALUE_OPTIONAL,
74
-				'Output format (plain, json or json_pretty, default is plain)',
75
-				$this->defaultOutputFormat
76
-			)->addOption(
77
-				'info',
78
-				'i',
79
-				InputOption::VALUE_NONE,
80
-				'Show detailed info'
81
-			);
82
-	}
54
+    protected function configure() {
55
+        $this
56
+            ->setName('user:list')
57
+            ->setDescription('list configured users')
58
+            ->addOption(
59
+                'limit',
60
+                'l',
61
+                InputOption::VALUE_OPTIONAL,
62
+                'Number of users to retrieve',
63
+                500
64
+            )->addOption(
65
+                'offset',
66
+                'o',
67
+                InputOption::VALUE_OPTIONAL,
68
+                'Offset for retrieving users',
69
+                0
70
+            )->addOption(
71
+                'output',
72
+                null,
73
+                InputOption::VALUE_OPTIONAL,
74
+                'Output format (plain, json or json_pretty, default is plain)',
75
+                $this->defaultOutputFormat
76
+            )->addOption(
77
+                'info',
78
+                'i',
79
+                InputOption::VALUE_NONE,
80
+                'Show detailed info'
81
+            );
82
+    }
83 83
 
84
-	protected function execute(InputInterface $input, OutputInterface $output): int {
85
-		$users = $this->userManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset'));
84
+    protected function execute(InputInterface $input, OutputInterface $output): int {
85
+        $users = $this->userManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset'));
86 86
 
87
-		$this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users, (bool)$input->getOption('info')));
88
-		return 0;
89
-	}
87
+        $this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users, (bool)$input->getOption('info')));
88
+        return 0;
89
+    }
90 90
 
91
-	/**
92
-	 * @param IUser[] $users
93
-	 * @param bool [$detailed=false]
94
-	 * @return array
95
-	 */
96
-	private function formatUsers(array $users, bool $detailed = false) {
97
-		$keys = array_map(function (IUser $user) {
98
-			return $user->getUID();
99
-		}, $users);
91
+    /**
92
+     * @param IUser[] $users
93
+     * @param bool [$detailed=false]
94
+     * @return array
95
+     */
96
+    private function formatUsers(array $users, bool $detailed = false) {
97
+        $keys = array_map(function (IUser $user) {
98
+            return $user->getUID();
99
+        }, $users);
100 100
 
101
-		$values = array_map(function (IUser $user) use ($detailed) {
102
-			if ($detailed) {
103
-				$groups = $this->groupManager->getUserGroupIds($user);
104
-				return [
105
-					'user_id' => $user->getUID(),
106
-					'display_name' => $user->getDisplayName(),
107
-					'email' => $user->getEMailAddress() ? $user->getEMailAddress() : '',
108
-					'cloud_id' => $user->getCloudId(),
109
-					'enabled' => $user->isEnabled(),
110
-					'groups' => $groups,
111
-					'quota' => $user->getQuota(),
112
-					'last_seen' => date(\DateTime::ATOM, $user->getLastLogin()), // ISO-8601
113
-					'user_directory' => $user->getHome(),
114
-					'backend' => $user->getBackendClassName()
115
-				];
116
-			}
117
-			return $user->getDisplayName();
118
-		}, $users);
119
-		return array_combine($keys, $values);
120
-	}
101
+        $values = array_map(function (IUser $user) use ($detailed) {
102
+            if ($detailed) {
103
+                $groups = $this->groupManager->getUserGroupIds($user);
104
+                return [
105
+                    'user_id' => $user->getUID(),
106
+                    'display_name' => $user->getDisplayName(),
107
+                    'email' => $user->getEMailAddress() ? $user->getEMailAddress() : '',
108
+                    'cloud_id' => $user->getCloudId(),
109
+                    'enabled' => $user->isEnabled(),
110
+                    'groups' => $groups,
111
+                    'quota' => $user->getQuota(),
112
+                    'last_seen' => date(\DateTime::ATOM, $user->getLastLogin()), // ISO-8601
113
+                    'user_directory' => $user->getHome(),
114
+                    'backend' => $user->getBackendClassName()
115
+                ];
116
+            }
117
+            return $user->getDisplayName();
118
+        }, $users);
119
+        return array_combine($keys, $values);
120
+    }
121 121
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	protected function execute(InputInterface $input, OutputInterface $output): int {
85 85
 		$users = $this->userManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset'));
86 86
 
87
-		$this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users, (bool)$input->getOption('info')));
87
+		$this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users, (bool) $input->getOption('info')));
88 88
 		return 0;
89 89
 	}
90 90
 
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 	 * @return array
95 95
 	 */
96 96
 	private function formatUsers(array $users, bool $detailed = false) {
97
-		$keys = array_map(function (IUser $user) {
97
+		$keys = array_map(function(IUser $user) {
98 98
 			return $user->getUID();
99 99
 		}, $users);
100 100
 
101
-		$values = array_map(function (IUser $user) use ($detailed) {
101
+		$values = array_map(function(IUser $user) use ($detailed) {
102 102
 			if ($detailed) {
103 103
 				$groups = $this->groupManager->getUserGroupIds($user);
104 104
 				return [
Please login to merge, or discard this patch.
core/Command/User/LastSeen.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -34,45 +34,45 @@
 block discarded – undo
34 34
 use Symfony\Component\Console\Output\OutputInterface;
35 35
 
36 36
 class LastSeen extends Command {
37
-	/** @var IUserManager */
38
-	protected $userManager;
37
+    /** @var IUserManager */
38
+    protected $userManager;
39 39
 
40
-	/**
41
-	 * @param IUserManager $userManager
42
-	 */
43
-	public function __construct(IUserManager $userManager) {
44
-		$this->userManager = $userManager;
45
-		parent::__construct();
46
-	}
40
+    /**
41
+     * @param IUserManager $userManager
42
+     */
43
+    public function __construct(IUserManager $userManager) {
44
+        $this->userManager = $userManager;
45
+        parent::__construct();
46
+    }
47 47
 
48
-	protected function configure() {
49
-		$this
50
-			->setName('user:lastseen')
51
-			->setDescription('shows when the user was logged in last time')
52
-			->addArgument(
53
-				'uid',
54
-				InputArgument::REQUIRED,
55
-				'the username'
56
-			);
57
-	}
48
+    protected function configure() {
49
+        $this
50
+            ->setName('user:lastseen')
51
+            ->setDescription('shows when the user was logged in last time')
52
+            ->addArgument(
53
+                'uid',
54
+                InputArgument::REQUIRED,
55
+                'the username'
56
+            );
57
+    }
58 58
 
59
-	protected function execute(InputInterface $input, OutputInterface $output): int {
60
-		$user = $this->userManager->get($input->getArgument('uid'));
61
-		if (is_null($user)) {
62
-			$output->writeln('<error>User does not exist</error>');
63
-			return 1;
64
-		}
59
+    protected function execute(InputInterface $input, OutputInterface $output): int {
60
+        $user = $this->userManager->get($input->getArgument('uid'));
61
+        if (is_null($user)) {
62
+            $output->writeln('<error>User does not exist</error>');
63
+            return 1;
64
+        }
65 65
 
66
-		$lastLogin = $user->getLastLogin();
67
-		if ($lastLogin === 0) {
68
-			$output->writeln('User ' . $user->getUID() .
69
-				' has never logged in, yet.');
70
-		} else {
71
-			$date = new \DateTime();
72
-			$date->setTimestamp($lastLogin);
73
-			$output->writeln($user->getUID() .
74
-				'`s last login: ' . $date->format('d.m.Y H:i'));
75
-		}
76
-		return 0;
77
-	}
66
+        $lastLogin = $user->getLastLogin();
67
+        if ($lastLogin === 0) {
68
+            $output->writeln('User ' . $user->getUID() .
69
+                ' has never logged in, yet.');
70
+        } else {
71
+            $date = new \DateTime();
72
+            $date->setTimestamp($lastLogin);
73
+            $output->writeln($user->getUID() .
74
+                '`s last login: ' . $date->format('d.m.Y H:i'));
75
+        }
76
+        return 0;
77
+    }
78 78
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -65,13 +65,13 @@
 block discarded – undo
65 65
 
66 66
 		$lastLogin = $user->getLastLogin();
67 67
 		if ($lastLogin === 0) {
68
-			$output->writeln('User ' . $user->getUID() .
68
+			$output->writeln('User '.$user->getUID().
69 69
 				' has never logged in, yet.');
70 70
 		} else {
71 71
 			$date = new \DateTime();
72 72
 			$date->setTimestamp($lastLogin);
73
-			$output->writeln($user->getUID() .
74
-				'`s last login: ' . $date->format('d.m.Y H:i'));
73
+			$output->writeln($user->getUID().
74
+				'`s last login: '.$date->format('d.m.Y H:i'));
75 75
 		}
76 76
 		return 0;
77 77
 	}
Please login to merge, or discard this patch.
core/Command/User/Setting.php 1 patch
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -36,210 +36,210 @@
 block discarded – undo
36 36
 use Symfony\Component\Console\Output\OutputInterface;
37 37
 
38 38
 class Setting extends Base {
39
-	/** @var IUserManager */
40
-	protected $userManager;
41
-
42
-	/** @var IConfig */
43
-	protected $config;
44
-
45
-	/** @var IDBConnection */
46
-	protected $connection;
47
-
48
-	/**
49
-	 * @param IUserManager $userManager
50
-	 * @param IConfig $config
51
-	 * @param IDBConnection $connection
52
-	 */
53
-	public function __construct(IUserManager $userManager, IConfig $config, IDBConnection $connection) {
54
-		parent::__construct();
55
-		$this->userManager = $userManager;
56
-		$this->config = $config;
57
-		$this->connection = $connection;
58
-	}
59
-
60
-	protected function configure() {
61
-		parent::configure();
62
-		$this
63
-			->setName('user:setting')
64
-			->setDescription('Read and modify user settings')
65
-			->addArgument(
66
-				'uid',
67
-				InputArgument::REQUIRED,
68
-				'User ID used to login'
69
-			)
70
-			->addArgument(
71
-				'app',
72
-				InputArgument::OPTIONAL,
73
-				'Restrict the settings to a given app',
74
-				''
75
-			)
76
-			->addArgument(
77
-				'key',
78
-				InputArgument::OPTIONAL,
79
-				'Setting key to set, get or delete',
80
-				''
81
-			)
82
-			->addOption(
83
-				'ignore-missing-user',
84
-				null,
85
-				InputOption::VALUE_NONE,
86
-				'Use this option to ignore errors when the user does not exist'
87
-			)
88
-
89
-			// Get
90
-			->addOption(
91
-				'default-value',
92
-				null,
93
-				InputOption::VALUE_REQUIRED,
94
-				'(Only applicable on get) If no default value is set and the config does not exist, the command will exit with 1'
95
-			)
96
-
97
-			// Set
98
-			->addArgument(
99
-				'value',
100
-				InputArgument::OPTIONAL,
101
-				'The new value of the setting',
102
-				null
103
-			)
104
-			->addOption(
105
-				'update-only',
106
-				null,
107
-				InputOption::VALUE_NONE,
108
-				'Only updates the value, if it is not set before, it is not being added'
109
-			)
110
-
111
-			// Delete
112
-			->addOption(
113
-				'delete',
114
-				null,
115
-				InputOption::VALUE_NONE,
116
-				'Specify this option to delete the config'
117
-			)
118
-			->addOption(
119
-				'error-if-not-exists',
120
-				null,
121
-				InputOption::VALUE_NONE,
122
-				'Checks whether the setting exists before deleting it'
123
-			)
124
-		;
125
-	}
126
-
127
-	protected function checkInput(InputInterface $input) {
128
-		$uid = $input->getArgument('uid');
129
-		if (!$input->getOption('ignore-missing-user') && !$this->userManager->userExists($uid)) {
130
-			throw new \InvalidArgumentException('The user "' . $uid . '" does not exist.');
131
-		}
132
-
133
-		if ($input->getArgument('key') === '' && $input->hasParameterOption('--default-value')) {
134
-			throw new \InvalidArgumentException('The "default-value" option can only be used when specifying a key.');
135
-		}
136
-
137
-		if ($input->getArgument('key') === '' && $input->getArgument('value') !== null) {
138
-			throw new \InvalidArgumentException('The value argument can only be used when specifying a key.');
139
-		}
140
-		if ($input->getArgument('value') !== null && $input->hasParameterOption('--default-value')) {
141
-			throw new \InvalidArgumentException('The value argument can not be used together with "default-value".');
142
-		}
143
-		if ($input->getOption('update-only') && $input->getArgument('value') === null) {
144
-			throw new \InvalidArgumentException('The "update-only" option can only be used together with "value".');
145
-		}
146
-
147
-		if ($input->getArgument('key') === '' && $input->getOption('delete')) {
148
-			throw new \InvalidArgumentException('The "delete" option can only be used when specifying a key.');
149
-		}
150
-		if ($input->getOption('delete') && $input->hasParameterOption('--default-value')) {
151
-			throw new \InvalidArgumentException('The "delete" option can not be used together with "default-value".');
152
-		}
153
-		if ($input->getOption('delete') && $input->getArgument('value') !== null) {
154
-			throw new \InvalidArgumentException('The "delete" option can not be used together with "value".');
155
-		}
156
-		if ($input->getOption('error-if-not-exists') && !$input->getOption('delete')) {
157
-			throw new \InvalidArgumentException('The "error-if-not-exists" option can only be used together with "delete".');
158
-		}
159
-	}
160
-
161
-	protected function execute(InputInterface $input, OutputInterface $output): int {
162
-		try {
163
-			$this->checkInput($input);
164
-		} catch (\InvalidArgumentException $e) {
165
-			$output->writeln('<error>' . $e->getMessage() . '</error>');
166
-			return 1;
167
-		}
168
-
169
-		$uid = $input->getArgument('uid');
170
-		$app = $input->getArgument('app');
171
-		$key = $input->getArgument('key');
172
-
173
-		if ($key !== '') {
174
-			$value = $this->config->getUserValue($uid, $app, $key, null);
175
-			if ($input->getArgument('value') !== null) {
176
-				if ($input->hasParameterOption('--update-only') && $value === null) {
177
-					$output->writeln('<error>The setting does not exist for user "' . $uid . '".</error>');
178
-					return 1;
179
-				}
180
-
181
-				if ($app === 'settings' && $key === 'email') {
182
-					$user = $this->userManager->get($uid);
183
-					if ($user instanceof IUser) {
184
-						$user->setEMailAddress($input->getArgument('value'));
185
-						return 0;
186
-					}
187
-				}
188
-
189
-				$this->config->setUserValue($uid, $app, $key, $input->getArgument('value'));
190
-				return 0;
191
-			} elseif ($input->hasParameterOption('--delete')) {
192
-				if ($input->hasParameterOption('--error-if-not-exists') && $value === null) {
193
-					$output->writeln('<error>The setting does not exist for user "' . $uid . '".</error>');
194
-					return 1;
195
-				}
196
-
197
-				if ($app === 'settings' && $key === 'email') {
198
-					$user = $this->userManager->get($uid);
199
-					if ($user instanceof IUser) {
200
-						$user->setEMailAddress('');
201
-						return 0;
202
-					}
203
-				}
204
-
205
-				$this->config->deleteUserValue($uid, $app, $key);
206
-				return 0;
207
-			} elseif ($value !== null) {
208
-				$output->writeln($value);
209
-				return 0;
210
-			} else {
211
-				if ($input->hasParameterOption('--default-value')) {
212
-					$output->writeln($input->getOption('default-value'));
213
-					return 0;
214
-				} else {
215
-					$output->writeln('<error>The setting does not exist for user "' . $uid . '".</error>');
216
-					return 1;
217
-				}
218
-			}
219
-		} else {
220
-			$settings = $this->getUserSettings($uid, $app);
221
-			$this->writeArrayInOutputFormat($input, $output, $settings);
222
-			return 0;
223
-		}
224
-	}
225
-
226
-	protected function getUserSettings($uid, $app) {
227
-		$query = $this->connection->getQueryBuilder();
228
-		$query->select('*')
229
-			->from('preferences')
230
-			->where($query->expr()->eq('userid', $query->createNamedParameter($uid)));
231
-
232
-		if ($app !== '') {
233
-			$query->andWhere($query->expr()->eq('appid', $query->createNamedParameter($app)));
234
-		}
235
-
236
-		$result = $query->execute();
237
-		$settings = [];
238
-		while ($row = $result->fetch()) {
239
-			$settings[$row['appid']][$row['configkey']] = $row['configvalue'];
240
-		}
241
-		$result->closeCursor();
242
-
243
-		return $settings;
244
-	}
39
+    /** @var IUserManager */
40
+    protected $userManager;
41
+
42
+    /** @var IConfig */
43
+    protected $config;
44
+
45
+    /** @var IDBConnection */
46
+    protected $connection;
47
+
48
+    /**
49
+     * @param IUserManager $userManager
50
+     * @param IConfig $config
51
+     * @param IDBConnection $connection
52
+     */
53
+    public function __construct(IUserManager $userManager, IConfig $config, IDBConnection $connection) {
54
+        parent::__construct();
55
+        $this->userManager = $userManager;
56
+        $this->config = $config;
57
+        $this->connection = $connection;
58
+    }
59
+
60
+    protected function configure() {
61
+        parent::configure();
62
+        $this
63
+            ->setName('user:setting')
64
+            ->setDescription('Read and modify user settings')
65
+            ->addArgument(
66
+                'uid',
67
+                InputArgument::REQUIRED,
68
+                'User ID used to login'
69
+            )
70
+            ->addArgument(
71
+                'app',
72
+                InputArgument::OPTIONAL,
73
+                'Restrict the settings to a given app',
74
+                ''
75
+            )
76
+            ->addArgument(
77
+                'key',
78
+                InputArgument::OPTIONAL,
79
+                'Setting key to set, get or delete',
80
+                ''
81
+            )
82
+            ->addOption(
83
+                'ignore-missing-user',
84
+                null,
85
+                InputOption::VALUE_NONE,
86
+                'Use this option to ignore errors when the user does not exist'
87
+            )
88
+
89
+            // Get
90
+            ->addOption(
91
+                'default-value',
92
+                null,
93
+                InputOption::VALUE_REQUIRED,
94
+                '(Only applicable on get) If no default value is set and the config does not exist, the command will exit with 1'
95
+            )
96
+
97
+            // Set
98
+            ->addArgument(
99
+                'value',
100
+                InputArgument::OPTIONAL,
101
+                'The new value of the setting',
102
+                null
103
+            )
104
+            ->addOption(
105
+                'update-only',
106
+                null,
107
+                InputOption::VALUE_NONE,
108
+                'Only updates the value, if it is not set before, it is not being added'
109
+            )
110
+
111
+            // Delete
112
+            ->addOption(
113
+                'delete',
114
+                null,
115
+                InputOption::VALUE_NONE,
116
+                'Specify this option to delete the config'
117
+            )
118
+            ->addOption(
119
+                'error-if-not-exists',
120
+                null,
121
+                InputOption::VALUE_NONE,
122
+                'Checks whether the setting exists before deleting it'
123
+            )
124
+        ;
125
+    }
126
+
127
+    protected function checkInput(InputInterface $input) {
128
+        $uid = $input->getArgument('uid');
129
+        if (!$input->getOption('ignore-missing-user') && !$this->userManager->userExists($uid)) {
130
+            throw new \InvalidArgumentException('The user "' . $uid . '" does not exist.');
131
+        }
132
+
133
+        if ($input->getArgument('key') === '' && $input->hasParameterOption('--default-value')) {
134
+            throw new \InvalidArgumentException('The "default-value" option can only be used when specifying a key.');
135
+        }
136
+
137
+        if ($input->getArgument('key') === '' && $input->getArgument('value') !== null) {
138
+            throw new \InvalidArgumentException('The value argument can only be used when specifying a key.');
139
+        }
140
+        if ($input->getArgument('value') !== null && $input->hasParameterOption('--default-value')) {
141
+            throw new \InvalidArgumentException('The value argument can not be used together with "default-value".');
142
+        }
143
+        if ($input->getOption('update-only') && $input->getArgument('value') === null) {
144
+            throw new \InvalidArgumentException('The "update-only" option can only be used together with "value".');
145
+        }
146
+
147
+        if ($input->getArgument('key') === '' && $input->getOption('delete')) {
148
+            throw new \InvalidArgumentException('The "delete" option can only be used when specifying a key.');
149
+        }
150
+        if ($input->getOption('delete') && $input->hasParameterOption('--default-value')) {
151
+            throw new \InvalidArgumentException('The "delete" option can not be used together with "default-value".');
152
+        }
153
+        if ($input->getOption('delete') && $input->getArgument('value') !== null) {
154
+            throw new \InvalidArgumentException('The "delete" option can not be used together with "value".');
155
+        }
156
+        if ($input->getOption('error-if-not-exists') && !$input->getOption('delete')) {
157
+            throw new \InvalidArgumentException('The "error-if-not-exists" option can only be used together with "delete".');
158
+        }
159
+    }
160
+
161
+    protected function execute(InputInterface $input, OutputInterface $output): int {
162
+        try {
163
+            $this->checkInput($input);
164
+        } catch (\InvalidArgumentException $e) {
165
+            $output->writeln('<error>' . $e->getMessage() . '</error>');
166
+            return 1;
167
+        }
168
+
169
+        $uid = $input->getArgument('uid');
170
+        $app = $input->getArgument('app');
171
+        $key = $input->getArgument('key');
172
+
173
+        if ($key !== '') {
174
+            $value = $this->config->getUserValue($uid, $app, $key, null);
175
+            if ($input->getArgument('value') !== null) {
176
+                if ($input->hasParameterOption('--update-only') && $value === null) {
177
+                    $output->writeln('<error>The setting does not exist for user "' . $uid . '".</error>');
178
+                    return 1;
179
+                }
180
+
181
+                if ($app === 'settings' && $key === 'email') {
182
+                    $user = $this->userManager->get($uid);
183
+                    if ($user instanceof IUser) {
184
+                        $user->setEMailAddress($input->getArgument('value'));
185
+                        return 0;
186
+                    }
187
+                }
188
+
189
+                $this->config->setUserValue($uid, $app, $key, $input->getArgument('value'));
190
+                return 0;
191
+            } elseif ($input->hasParameterOption('--delete')) {
192
+                if ($input->hasParameterOption('--error-if-not-exists') && $value === null) {
193
+                    $output->writeln('<error>The setting does not exist for user "' . $uid . '".</error>');
194
+                    return 1;
195
+                }
196
+
197
+                if ($app === 'settings' && $key === 'email') {
198
+                    $user = $this->userManager->get($uid);
199
+                    if ($user instanceof IUser) {
200
+                        $user->setEMailAddress('');
201
+                        return 0;
202
+                    }
203
+                }
204
+
205
+                $this->config->deleteUserValue($uid, $app, $key);
206
+                return 0;
207
+            } elseif ($value !== null) {
208
+                $output->writeln($value);
209
+                return 0;
210
+            } else {
211
+                if ($input->hasParameterOption('--default-value')) {
212
+                    $output->writeln($input->getOption('default-value'));
213
+                    return 0;
214
+                } else {
215
+                    $output->writeln('<error>The setting does not exist for user "' . $uid . '".</error>');
216
+                    return 1;
217
+                }
218
+            }
219
+        } else {
220
+            $settings = $this->getUserSettings($uid, $app);
221
+            $this->writeArrayInOutputFormat($input, $output, $settings);
222
+            return 0;
223
+        }
224
+    }
225
+
226
+    protected function getUserSettings($uid, $app) {
227
+        $query = $this->connection->getQueryBuilder();
228
+        $query->select('*')
229
+            ->from('preferences')
230
+            ->where($query->expr()->eq('userid', $query->createNamedParameter($uid)));
231
+
232
+        if ($app !== '') {
233
+            $query->andWhere($query->expr()->eq('appid', $query->createNamedParameter($app)));
234
+        }
235
+
236
+        $result = $query->execute();
237
+        $settings = [];
238
+        while ($row = $result->fetch()) {
239
+            $settings[$row['appid']][$row['configkey']] = $row['configvalue'];
240
+        }
241
+        $result->closeCursor();
242
+
243
+        return $settings;
244
+    }
245 245
 }
Please login to merge, or discard this patch.
core/Command/User/Add.php 2 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -40,130 +40,130 @@
 block discarded – undo
40 40
 use Symfony\Component\Console\Question\Question;
41 41
 
42 42
 class Add extends Command {
43
-	/** @var \OCP\IUserManager */
44
-	protected $userManager;
45
-
46
-	/** @var \OCP\IGroupManager */
47
-	protected $groupManager;
48
-
49
-	/**
50
-	 * @param IUserManager $userManager
51
-	 * @param IGroupManager $groupManager
52
-	 */
53
-	public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
54
-		parent::__construct();
55
-		$this->userManager = $userManager;
56
-		$this->groupManager = $groupManager;
57
-	}
58
-
59
-	protected function configure() {
60
-		$this
61
-			->setName('user:add')
62
-			->setDescription('adds a user')
63
-			->addArgument(
64
-				'uid',
65
-				InputArgument::REQUIRED,
66
-				'User ID used to login (must only contain a-z, A-Z, 0-9, -, _ and @)'
67
-			)
68
-			->addOption(
69
-				'password-from-env',
70
-				null,
71
-				InputOption::VALUE_NONE,
72
-				'read password from environment variable OC_PASS'
73
-			)
74
-			->addOption(
75
-				'display-name',
76
-				null,
77
-				InputOption::VALUE_OPTIONAL,
78
-				'User name used in the web UI (can contain any characters)'
79
-			)
80
-			->addOption(
81
-				'group',
82
-				'g',
83
-				InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
84
-				'groups the user should be added to (The group will be created if it does not exist)'
85
-			);
86
-	}
87
-
88
-	protected function execute(InputInterface $input, OutputInterface $output): int {
89
-		$uid = $input->getArgument('uid');
90
-		if ($this->userManager->userExists($uid)) {
91
-			$output->writeln('<error>The user "' . $uid . '" already exists.</error>');
92
-			return 1;
93
-		}
94
-
95
-		if ($input->getOption('password-from-env')) {
96
-			$password = getenv('OC_PASS');
97
-			if (!$password) {
98
-				$output->writeln('<error>--password-from-env given, but OC_PASS is empty!</error>');
99
-				return 1;
100
-			}
101
-		} elseif ($input->isInteractive()) {
102
-			/** @var QuestionHelper $helper */
103
-			$helper = $this->getHelper('question');
104
-
105
-			$question = new Question('Enter password: ');
106
-			$question->setHidden(true);
107
-			$password = $helper->ask($input, $output, $question);
108
-
109
-			$question = new Question('Confirm password: ');
110
-			$question->setHidden(true);
111
-			$confirm = $helper->ask($input, $output,$question);
112
-
113
-			if ($password !== $confirm) {
114
-				$output->writeln("<error>Passwords did not match!</error>");
115
-				return 1;
116
-			}
117
-		} else {
118
-			$output->writeln("<error>Interactive input or --password-from-env is needed for entering a password!</error>");
119
-			return 1;
120
-		}
121
-
122
-		try {
123
-			$user = $this->userManager->createUser(
124
-				$input->getArgument('uid'),
125
-				$password
126
-			);
127
-		} catch (\Exception $e) {
128
-			$output->writeln('<error>' . $e->getMessage() . '</error>');
129
-			return 1;
130
-		}
131
-
132
-
133
-		if ($user instanceof IUser) {
134
-			$output->writeln('<info>The user "' . $user->getUID() . '" was created successfully</info>');
135
-		} else {
136
-			$output->writeln('<error>An error occurred while creating the user</error>');
137
-			return 1;
138
-		}
139
-
140
-		if ($input->getOption('display-name')) {
141
-			$user->setDisplayName($input->getOption('display-name'));
142
-			$output->writeln('Display name set to "' . $user->getDisplayName() . '"');
143
-		}
144
-
145
-		$groups = $input->getOption('group');
146
-
147
-		if (!empty($groups)) {
148
-			// Make sure we init the Filesystem for the user, in case we need to
149
-			// init some group shares.
150
-			Filesystem::init($user->getUID(), '');
151
-		}
152
-
153
-		foreach ($groups as $groupName) {
154
-			$group = $this->groupManager->get($groupName);
155
-			if (!$group) {
156
-				$this->groupManager->createGroup($groupName);
157
-				$group = $this->groupManager->get($groupName);
158
-				if ($group instanceof IGroup) {
159
-					$output->writeln('Created group "' . $group->getGID() . '"');
160
-				}
161
-			}
162
-			if ($group instanceof IGroup) {
163
-				$group->addUser($user);
164
-				$output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"');
165
-			}
166
-		}
167
-		return 0;
168
-	}
43
+    /** @var \OCP\IUserManager */
44
+    protected $userManager;
45
+
46
+    /** @var \OCP\IGroupManager */
47
+    protected $groupManager;
48
+
49
+    /**
50
+     * @param IUserManager $userManager
51
+     * @param IGroupManager $groupManager
52
+     */
53
+    public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
54
+        parent::__construct();
55
+        $this->userManager = $userManager;
56
+        $this->groupManager = $groupManager;
57
+    }
58
+
59
+    protected function configure() {
60
+        $this
61
+            ->setName('user:add')
62
+            ->setDescription('adds a user')
63
+            ->addArgument(
64
+                'uid',
65
+                InputArgument::REQUIRED,
66
+                'User ID used to login (must only contain a-z, A-Z, 0-9, -, _ and @)'
67
+            )
68
+            ->addOption(
69
+                'password-from-env',
70
+                null,
71
+                InputOption::VALUE_NONE,
72
+                'read password from environment variable OC_PASS'
73
+            )
74
+            ->addOption(
75
+                'display-name',
76
+                null,
77
+                InputOption::VALUE_OPTIONAL,
78
+                'User name used in the web UI (can contain any characters)'
79
+            )
80
+            ->addOption(
81
+                'group',
82
+                'g',
83
+                InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
84
+                'groups the user should be added to (The group will be created if it does not exist)'
85
+            );
86
+    }
87
+
88
+    protected function execute(InputInterface $input, OutputInterface $output): int {
89
+        $uid = $input->getArgument('uid');
90
+        if ($this->userManager->userExists($uid)) {
91
+            $output->writeln('<error>The user "' . $uid . '" already exists.</error>');
92
+            return 1;
93
+        }
94
+
95
+        if ($input->getOption('password-from-env')) {
96
+            $password = getenv('OC_PASS');
97
+            if (!$password) {
98
+                $output->writeln('<error>--password-from-env given, but OC_PASS is empty!</error>');
99
+                return 1;
100
+            }
101
+        } elseif ($input->isInteractive()) {
102
+            /** @var QuestionHelper $helper */
103
+            $helper = $this->getHelper('question');
104
+
105
+            $question = new Question('Enter password: ');
106
+            $question->setHidden(true);
107
+            $password = $helper->ask($input, $output, $question);
108
+
109
+            $question = new Question('Confirm password: ');
110
+            $question->setHidden(true);
111
+            $confirm = $helper->ask($input, $output,$question);
112
+
113
+            if ($password !== $confirm) {
114
+                $output->writeln("<error>Passwords did not match!</error>");
115
+                return 1;
116
+            }
117
+        } else {
118
+            $output->writeln("<error>Interactive input or --password-from-env is needed for entering a password!</error>");
119
+            return 1;
120
+        }
121
+
122
+        try {
123
+            $user = $this->userManager->createUser(
124
+                $input->getArgument('uid'),
125
+                $password
126
+            );
127
+        } catch (\Exception $e) {
128
+            $output->writeln('<error>' . $e->getMessage() . '</error>');
129
+            return 1;
130
+        }
131
+
132
+
133
+        if ($user instanceof IUser) {
134
+            $output->writeln('<info>The user "' . $user->getUID() . '" was created successfully</info>');
135
+        } else {
136
+            $output->writeln('<error>An error occurred while creating the user</error>');
137
+            return 1;
138
+        }
139
+
140
+        if ($input->getOption('display-name')) {
141
+            $user->setDisplayName($input->getOption('display-name'));
142
+            $output->writeln('Display name set to "' . $user->getDisplayName() . '"');
143
+        }
144
+
145
+        $groups = $input->getOption('group');
146
+
147
+        if (!empty($groups)) {
148
+            // Make sure we init the Filesystem for the user, in case we need to
149
+            // init some group shares.
150
+            Filesystem::init($user->getUID(), '');
151
+        }
152
+
153
+        foreach ($groups as $groupName) {
154
+            $group = $this->groupManager->get($groupName);
155
+            if (!$group) {
156
+                $this->groupManager->createGroup($groupName);
157
+                $group = $this->groupManager->get($groupName);
158
+                if ($group instanceof IGroup) {
159
+                    $output->writeln('Created group "' . $group->getGID() . '"');
160
+                }
161
+            }
162
+            if ($group instanceof IGroup) {
163
+                $group->addUser($user);
164
+                $output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"');
165
+            }
166
+        }
167
+        return 0;
168
+    }
169 169
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	protected function execute(InputInterface $input, OutputInterface $output): int {
89 89
 		$uid = $input->getArgument('uid');
90 90
 		if ($this->userManager->userExists($uid)) {
91
-			$output->writeln('<error>The user "' . $uid . '" already exists.</error>');
91
+			$output->writeln('<error>The user "'.$uid.'" already exists.</error>');
92 92
 			return 1;
93 93
 		}
94 94
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
 			$question = new Question('Confirm password: ');
110 110
 			$question->setHidden(true);
111
-			$confirm = $helper->ask($input, $output,$question);
111
+			$confirm = $helper->ask($input, $output, $question);
112 112
 
113 113
 			if ($password !== $confirm) {
114 114
 				$output->writeln("<error>Passwords did not match!</error>");
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 				$password
126 126
 			);
127 127
 		} catch (\Exception $e) {
128
-			$output->writeln('<error>' . $e->getMessage() . '</error>');
128
+			$output->writeln('<error>'.$e->getMessage().'</error>');
129 129
 			return 1;
130 130
 		}
131 131
 
132 132
 
133 133
 		if ($user instanceof IUser) {
134
-			$output->writeln('<info>The user "' . $user->getUID() . '" was created successfully</info>');
134
+			$output->writeln('<info>The user "'.$user->getUID().'" was created successfully</info>');
135 135
 		} else {
136 136
 			$output->writeln('<error>An error occurred while creating the user</error>');
137 137
 			return 1;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 		if ($input->getOption('display-name')) {
141 141
 			$user->setDisplayName($input->getOption('display-name'));
142
-			$output->writeln('Display name set to "' . $user->getDisplayName() . '"');
142
+			$output->writeln('Display name set to "'.$user->getDisplayName().'"');
143 143
 		}
144 144
 
145 145
 		$groups = $input->getOption('group');
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
 				$this->groupManager->createGroup($groupName);
157 157
 				$group = $this->groupManager->get($groupName);
158 158
 				if ($group instanceof IGroup) {
159
-					$output->writeln('Created group "' . $group->getGID() . '"');
159
+					$output->writeln('Created group "'.$group->getGID().'"');
160 160
 				}
161 161
 			}
162 162
 			if ($group instanceof IGroup) {
163 163
 				$group->addUser($user);
164
-				$output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"');
164
+				$output->writeln('User "'.$user->getUID().'" added to group "'.$group->getGID().'"');
165 165
 			}
166 166
 		}
167 167
 		return 0;
Please login to merge, or discard this patch.
core/Command/User/Info.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -33,58 +33,58 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class Info extends Base {
36
-	/** @var IUserManager */
37
-	protected $userManager;
38
-	/** @var IGroupManager */
39
-	protected $groupManager;
36
+    /** @var IUserManager */
37
+    protected $userManager;
38
+    /** @var IGroupManager */
39
+    protected $groupManager;
40 40
 
41
-	/**
42
-	 * @param IUserManager $userManager
43
-	 * @param IGroupManager $groupManager
44
-	 */
45
-	public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
46
-		$this->userManager = $userManager;
47
-		$this->groupManager = $groupManager;
48
-		parent::__construct();
49
-	}
41
+    /**
42
+     * @param IUserManager $userManager
43
+     * @param IGroupManager $groupManager
44
+     */
45
+    public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
46
+        $this->userManager = $userManager;
47
+        $this->groupManager = $groupManager;
48
+        parent::__construct();
49
+    }
50 50
 
51
-	protected function configure() {
52
-		$this
53
-			->setName('user:info')
54
-			->setDescription('show user info')
55
-			->addArgument(
56
-				'user',
57
-				InputArgument::REQUIRED,
58
-				'user to show'
59
-			)->addOption(
60
-				'output',
61
-				null,
62
-				InputOption::VALUE_OPTIONAL,
63
-				'Output format (plain, json or json_pretty, default is plain)',
64
-				$this->defaultOutputFormat
65
-			);
66
-	}
51
+    protected function configure() {
52
+        $this
53
+            ->setName('user:info')
54
+            ->setDescription('show user info')
55
+            ->addArgument(
56
+                'user',
57
+                InputArgument::REQUIRED,
58
+                'user to show'
59
+            )->addOption(
60
+                'output',
61
+                null,
62
+                InputOption::VALUE_OPTIONAL,
63
+                'Output format (plain, json or json_pretty, default is plain)',
64
+                $this->defaultOutputFormat
65
+            );
66
+    }
67 67
 
68
-	protected function execute(InputInterface $input, OutputInterface $output): int {
69
-		$user = $this->userManager->get($input->getArgument('user'));
70
-		if (is_null($user)) {
71
-			$output->writeln('<error>user not found</error>');
72
-			return 1;
73
-		}
74
-		$groups = $this->groupManager->getUserGroupIds($user);
75
-		$data = [
76
-			'user_id' => $user->getUID(),
77
-			'display_name' => $user->getDisplayName(),
78
-			'email' => $user->getEMailAddress() ? $user->getEMailAddress() : '',
79
-			'cloud_id' => $user->getCloudId(),
80
-			'enabled' => $user->isEnabled(),
81
-			'groups' => $groups,
82
-			'quota' => $user->getQuota(),
83
-			'last_seen' => date(\DateTime::ATOM, $user->getLastLogin()), // ISO-8601
84
-			'user_directory' => $user->getHome(),
85
-			'backend' => $user->getBackendClassName()
86
-		];
87
-		$this->writeArrayInOutputFormat($input, $output, $data);
88
-		return 0;
89
-	}
68
+    protected function execute(InputInterface $input, OutputInterface $output): int {
69
+        $user = $this->userManager->get($input->getArgument('user'));
70
+        if (is_null($user)) {
71
+            $output->writeln('<error>user not found</error>');
72
+            return 1;
73
+        }
74
+        $groups = $this->groupManager->getUserGroupIds($user);
75
+        $data = [
76
+            'user_id' => $user->getUID(),
77
+            'display_name' => $user->getDisplayName(),
78
+            'email' => $user->getEMailAddress() ? $user->getEMailAddress() : '',
79
+            'cloud_id' => $user->getCloudId(),
80
+            'enabled' => $user->isEnabled(),
81
+            'groups' => $groups,
82
+            'quota' => $user->getQuota(),
83
+            'last_seen' => date(\DateTime::ATOM, $user->getLastLogin()), // ISO-8601
84
+            'user_directory' => $user->getHome(),
85
+            'backend' => $user->getBackendClassName()
86
+        ];
87
+        $this->writeArrayInOutputFormat($input, $output, $data);
88
+        return 0;
89
+    }
90 90
 }
Please login to merge, or discard this patch.