Passed
Push — master ( ebedbf...47a21f )
by Joas
12:46 queued 18s
created
apps/files_external/lib/Command/Import.php 1 patch
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -41,187 +41,187 @@
 block discarded – undo
41 41
 use Symfony\Component\Console\Output\OutputInterface;
42 42
 
43 43
 class Import extends Base {
44
-	/**
45
-	 * @var GlobalStoragesService
46
-	 */
47
-	private $globalService;
48
-
49
-	/**
50
-	 * @var UserStoragesService
51
-	 */
52
-	private $userService;
53
-
54
-	/**
55
-	 * @var IUserSession
56
-	 */
57
-	private $userSession;
58
-
59
-	/**
60
-	 * @var IUserManager
61
-	 */
62
-	private $userManager;
63
-
64
-	/** @var ImportLegacyStoragesService */
65
-	private $importLegacyStorageService;
66
-
67
-	/** @var BackendService */
68
-	private $backendService;
69
-
70
-	public function __construct(GlobalStoragesService $globalService,
71
-						 UserStoragesService $userService,
72
-						 IUserSession $userSession,
73
-						 IUserManager $userManager,
74
-						 ImportLegacyStoragesService $importLegacyStorageService,
75
-						 BackendService $backendService
76
-	) {
77
-		parent::__construct();
78
-		$this->globalService = $globalService;
79
-		$this->userService = $userService;
80
-		$this->userSession = $userSession;
81
-		$this->userManager = $userManager;
82
-		$this->importLegacyStorageService = $importLegacyStorageService;
83
-		$this->backendService = $backendService;
84
-	}
85
-
86
-	protected function configure() {
87
-		$this
88
-			->setName('files_external:import')
89
-			->setDescription('Import mount configurations')
90
-			->addOption(
91
-				'user',
92
-				'',
93
-				InputOption::VALUE_OPTIONAL,
94
-				'user to add the mount configurations for, if not set the mount will be added as system mount'
95
-			)
96
-			->addArgument(
97
-				'path',
98
-				InputArgument::REQUIRED,
99
-				'path to a json file containing the mounts to import, use "-" to read from stdin'
100
-			)
101
-			->addOption(
102
-				'dry',
103
-				'',
104
-				InputOption::VALUE_NONE,
105
-				'Don\'t save the imported mounts, only list the new mounts'
106
-			);
107
-		parent::configure();
108
-	}
109
-
110
-	protected function execute(InputInterface $input, OutputInterface $output): int {
111
-		$user = $input->getOption('user');
112
-		$path = $input->getArgument('path');
113
-		if ($path === '-') {
114
-			$json = file_get_contents('php://stdin');
115
-		} else {
116
-			if (!file_exists($path)) {
117
-				$output->writeln('<error>File not found: ' . $path . '</error>');
118
-				return 1;
119
-			}
120
-			$json = file_get_contents($path);
121
-		}
122
-		if (!is_string($json) || strlen($json) < 2) {
123
-			$output->writeln('<error>Error while reading json</error>');
124
-			return 1;
125
-		}
126
-		$data = json_decode($json, true);
127
-		if (!is_array($data)) {
128
-			$output->writeln('<error>Error while parsing json</error>');
129
-			return 1;
130
-		}
131
-
132
-		$isLegacy = isset($data['user']) || isset($data['group']);
133
-		if ($isLegacy) {
134
-			$this->importLegacyStorageService->setData($data);
135
-			$mounts = $this->importLegacyStorageService->getAllStorages();
136
-			foreach ($mounts as $mount) {
137
-				if ($mount->getBackendOption('password') === false) {
138
-					$output->writeln('<error>Failed to decrypt password</error>');
139
-					return 1;
140
-				}
141
-			}
142
-		} else {
143
-			if (!isset($data[0])) { //normalize to an array of mounts
144
-				$data = [$data];
145
-			}
146
-			$mounts = array_map([$this, 'parseData'], $data);
147
-		}
148
-
149
-		if ($user) {
150
-			// ensure applicables are correct for personal mounts
151
-			foreach ($mounts as $mount) {
152
-				$mount->setApplicableGroups([]);
153
-				$mount->setApplicableUsers([$user]);
154
-			}
155
-		}
156
-
157
-		$storageService = $this->getStorageService($user);
158
-
159
-		$existingMounts = $storageService->getAllStorages();
160
-
161
-		foreach ($mounts as $mount) {
162
-			foreach ($existingMounts as $existingMount) {
163
-				if (
164
-					$existingMount->getMountPoint() === $mount->getMountPoint() &&
165
-					$existingMount->getApplicableGroups() === $mount->getApplicableGroups() &&
166
-					$existingMount->getApplicableUsers() === $mount->getApplicableUsers() &&
167
-					$existingMount->getBackendOptions() === $mount->getBackendOptions()
168
-				) {
169
-					$output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>");
170
-					return 1;
171
-				}
172
-			}
173
-		}
174
-
175
-		if ($input->getOption('dry')) {
176
-			if (count($mounts) === 0) {
177
-				$output->writeln('<error>No mounts to be imported</error>');
178
-				return 1;
179
-			}
180
-			$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
181
-			$listInput = new ArrayInput([], $listCommand->getDefinition());
182
-			$listInput->setOption('output', $input->getOption('output'));
183
-			$listInput->setOption('show-password', true);
184
-			$listCommand->listMounts($user, $mounts, $listInput, $output);
185
-		} else {
186
-			foreach ($mounts as $mount) {
187
-				$storageService->addStorage($mount);
188
-			}
189
-		}
190
-		return 0;
191
-	}
192
-
193
-	private function parseData(array $data) {
194
-		$mount = new StorageConfig($data['mount_id']);
195
-		$mount->setMountPoint($data['mount_point']);
196
-		$mount->setBackend($this->getBackendByClass($data['storage']));
197
-		$authBackend = $this->backendService->getAuthMechanism($data['authentication_type']);
198
-		$mount->setAuthMechanism($authBackend);
199
-		$mount->setBackendOptions($data['configuration']);
200
-		$mount->setMountOptions($data['options']);
201
-		$mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []);
202
-		$mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []);
203
-		return $mount;
204
-	}
205
-
206
-	private function getBackendByClass($className) {
207
-		$backends = $this->backendService->getBackends();
208
-		foreach ($backends as $backend) {
209
-			if ($backend->getStorageClass() === $className) {
210
-				return $backend;
211
-			}
212
-		}
213
-	}
214
-
215
-	protected function getStorageService($userId) {
216
-		if (!empty($userId)) {
217
-			$user = $this->userManager->get($userId);
218
-			if (is_null($user)) {
219
-				throw new NoUserException("user $userId not found");
220
-			}
221
-			$this->userSession->setUser($user);
222
-			return $this->userService;
223
-		} else {
224
-			return $this->globalService;
225
-		}
226
-	}
44
+    /**
45
+     * @var GlobalStoragesService
46
+     */
47
+    private $globalService;
48
+
49
+    /**
50
+     * @var UserStoragesService
51
+     */
52
+    private $userService;
53
+
54
+    /**
55
+     * @var IUserSession
56
+     */
57
+    private $userSession;
58
+
59
+    /**
60
+     * @var IUserManager
61
+     */
62
+    private $userManager;
63
+
64
+    /** @var ImportLegacyStoragesService */
65
+    private $importLegacyStorageService;
66
+
67
+    /** @var BackendService */
68
+    private $backendService;
69
+
70
+    public function __construct(GlobalStoragesService $globalService,
71
+                            UserStoragesService $userService,
72
+                            IUserSession $userSession,
73
+                            IUserManager $userManager,
74
+                            ImportLegacyStoragesService $importLegacyStorageService,
75
+                            BackendService $backendService
76
+    ) {
77
+        parent::__construct();
78
+        $this->globalService = $globalService;
79
+        $this->userService = $userService;
80
+        $this->userSession = $userSession;
81
+        $this->userManager = $userManager;
82
+        $this->importLegacyStorageService = $importLegacyStorageService;
83
+        $this->backendService = $backendService;
84
+    }
85
+
86
+    protected function configure() {
87
+        $this
88
+            ->setName('files_external:import')
89
+            ->setDescription('Import mount configurations')
90
+            ->addOption(
91
+                'user',
92
+                '',
93
+                InputOption::VALUE_OPTIONAL,
94
+                'user to add the mount configurations for, if not set the mount will be added as system mount'
95
+            )
96
+            ->addArgument(
97
+                'path',
98
+                InputArgument::REQUIRED,
99
+                'path to a json file containing the mounts to import, use "-" to read from stdin'
100
+            )
101
+            ->addOption(
102
+                'dry',
103
+                '',
104
+                InputOption::VALUE_NONE,
105
+                'Don\'t save the imported mounts, only list the new mounts'
106
+            );
107
+        parent::configure();
108
+    }
109
+
110
+    protected function execute(InputInterface $input, OutputInterface $output): int {
111
+        $user = $input->getOption('user');
112
+        $path = $input->getArgument('path');
113
+        if ($path === '-') {
114
+            $json = file_get_contents('php://stdin');
115
+        } else {
116
+            if (!file_exists($path)) {
117
+                $output->writeln('<error>File not found: ' . $path . '</error>');
118
+                return 1;
119
+            }
120
+            $json = file_get_contents($path);
121
+        }
122
+        if (!is_string($json) || strlen($json) < 2) {
123
+            $output->writeln('<error>Error while reading json</error>');
124
+            return 1;
125
+        }
126
+        $data = json_decode($json, true);
127
+        if (!is_array($data)) {
128
+            $output->writeln('<error>Error while parsing json</error>');
129
+            return 1;
130
+        }
131
+
132
+        $isLegacy = isset($data['user']) || isset($data['group']);
133
+        if ($isLegacy) {
134
+            $this->importLegacyStorageService->setData($data);
135
+            $mounts = $this->importLegacyStorageService->getAllStorages();
136
+            foreach ($mounts as $mount) {
137
+                if ($mount->getBackendOption('password') === false) {
138
+                    $output->writeln('<error>Failed to decrypt password</error>');
139
+                    return 1;
140
+                }
141
+            }
142
+        } else {
143
+            if (!isset($data[0])) { //normalize to an array of mounts
144
+                $data = [$data];
145
+            }
146
+            $mounts = array_map([$this, 'parseData'], $data);
147
+        }
148
+
149
+        if ($user) {
150
+            // ensure applicables are correct for personal mounts
151
+            foreach ($mounts as $mount) {
152
+                $mount->setApplicableGroups([]);
153
+                $mount->setApplicableUsers([$user]);
154
+            }
155
+        }
156
+
157
+        $storageService = $this->getStorageService($user);
158
+
159
+        $existingMounts = $storageService->getAllStorages();
160
+
161
+        foreach ($mounts as $mount) {
162
+            foreach ($existingMounts as $existingMount) {
163
+                if (
164
+                    $existingMount->getMountPoint() === $mount->getMountPoint() &&
165
+                    $existingMount->getApplicableGroups() === $mount->getApplicableGroups() &&
166
+                    $existingMount->getApplicableUsers() === $mount->getApplicableUsers() &&
167
+                    $existingMount->getBackendOptions() === $mount->getBackendOptions()
168
+                ) {
169
+                    $output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>");
170
+                    return 1;
171
+                }
172
+            }
173
+        }
174
+
175
+        if ($input->getOption('dry')) {
176
+            if (count($mounts) === 0) {
177
+                $output->writeln('<error>No mounts to be imported</error>');
178
+                return 1;
179
+            }
180
+            $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
181
+            $listInput = new ArrayInput([], $listCommand->getDefinition());
182
+            $listInput->setOption('output', $input->getOption('output'));
183
+            $listInput->setOption('show-password', true);
184
+            $listCommand->listMounts($user, $mounts, $listInput, $output);
185
+        } else {
186
+            foreach ($mounts as $mount) {
187
+                $storageService->addStorage($mount);
188
+            }
189
+        }
190
+        return 0;
191
+    }
192
+
193
+    private function parseData(array $data) {
194
+        $mount = new StorageConfig($data['mount_id']);
195
+        $mount->setMountPoint($data['mount_point']);
196
+        $mount->setBackend($this->getBackendByClass($data['storage']));
197
+        $authBackend = $this->backendService->getAuthMechanism($data['authentication_type']);
198
+        $mount->setAuthMechanism($authBackend);
199
+        $mount->setBackendOptions($data['configuration']);
200
+        $mount->setMountOptions($data['options']);
201
+        $mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []);
202
+        $mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []);
203
+        return $mount;
204
+    }
205
+
206
+    private function getBackendByClass($className) {
207
+        $backends = $this->backendService->getBackends();
208
+        foreach ($backends as $backend) {
209
+            if ($backend->getStorageClass() === $className) {
210
+                return $backend;
211
+            }
212
+        }
213
+    }
214
+
215
+    protected function getStorageService($userId) {
216
+        if (!empty($userId)) {
217
+            $user = $this->userManager->get($userId);
218
+            if (is_null($user)) {
219
+                throw new NoUserException("user $userId not found");
220
+            }
221
+            $this->userSession->setUser($user);
222
+            return $this->userService;
223
+        } else {
224
+            return $this->globalService;
225
+        }
226
+    }
227 227
 }
Please login to merge, or discard this patch.
apps/encryption/lib/Command/RecoverUser.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -36,77 +36,77 @@
 block discarded – undo
36 36
 
37 37
 class RecoverUser extends Command {
38 38
 
39
-	/** @var Util */
40
-	protected $util;
41
-
42
-	/** @var IUserManager */
43
-	protected $userManager;
44
-
45
-	/** @var  QuestionHelper */
46
-	protected $questionHelper;
47
-
48
-	/**
49
-	 * @param Util $util
50
-	 * @param IConfig $config
51
-	 * @param IUserManager $userManager
52
-	 * @param QuestionHelper $questionHelper
53
-	 */
54
-	public function __construct(Util $util,
55
-								IConfig $config,
56
-								IUserManager $userManager,
57
-								QuestionHelper $questionHelper) {
58
-		$this->util = $util;
59
-		$this->questionHelper = $questionHelper;
60
-		$this->userManager = $userManager;
61
-		parent::__construct();
62
-	}
63
-
64
-	protected function configure() {
65
-		$this
66
-			->setName('encryption:recover-user')
67
-			->setDescription('Recover user data in case of password lost. This only works if the user enabled the recovery key.');
68
-
69
-		$this->addArgument(
70
-			'user',
71
-			InputArgument::REQUIRED,
72
-			'user which should be recovered'
73
-		);
74
-	}
75
-
76
-	protected function execute(InputInterface $input, OutputInterface $output): int {
77
-		$isMasterKeyEnabled = $this->util->isMasterKeyEnabled();
78
-
79
-		if ($isMasterKeyEnabled) {
80
-			$output->writeln('You use the master key, no individual user recovery needed.');
81
-			return 0;
82
-		}
83
-
84
-		$uid = $input->getArgument('user');
85
-		$userExists = $this->userManager->userExists($uid);
86
-		if ($userExists === false) {
87
-			$output->writeln('User "' . $uid . '" unknown.');
88
-			return 1;
89
-		}
90
-
91
-		$recoveryKeyEnabled = $this->util->isRecoveryEnabledForUser($uid);
92
-		if ($recoveryKeyEnabled === false) {
93
-			$output->writeln('Recovery key is not enabled for: ' . $uid);
94
-			return 1;
95
-		}
96
-
97
-		$question = new Question('Please enter the recovery key password: ');
98
-		$question->setHidden(true);
99
-		$question->setHiddenFallback(false);
100
-		$recoveryPassword = $this->questionHelper->ask($input, $output, $question);
101
-
102
-		$question = new Question('Please enter the new login password for the user: ');
103
-		$question->setHidden(true);
104
-		$question->setHiddenFallback(false);
105
-		$newLoginPassword = $this->questionHelper->ask($input, $output, $question);
106
-
107
-		$output->write('Start to recover users files... This can take some time...');
108
-		$this->userManager->get($uid)->setPassword($newLoginPassword, $recoveryPassword);
109
-		$output->writeln('Done.');
110
-		return 0;
111
-	}
39
+    /** @var Util */
40
+    protected $util;
41
+
42
+    /** @var IUserManager */
43
+    protected $userManager;
44
+
45
+    /** @var  QuestionHelper */
46
+    protected $questionHelper;
47
+
48
+    /**
49
+     * @param Util $util
50
+     * @param IConfig $config
51
+     * @param IUserManager $userManager
52
+     * @param QuestionHelper $questionHelper
53
+     */
54
+    public function __construct(Util $util,
55
+                                IConfig $config,
56
+                                IUserManager $userManager,
57
+                                QuestionHelper $questionHelper) {
58
+        $this->util = $util;
59
+        $this->questionHelper = $questionHelper;
60
+        $this->userManager = $userManager;
61
+        parent::__construct();
62
+    }
63
+
64
+    protected function configure() {
65
+        $this
66
+            ->setName('encryption:recover-user')
67
+            ->setDescription('Recover user data in case of password lost. This only works if the user enabled the recovery key.');
68
+
69
+        $this->addArgument(
70
+            'user',
71
+            InputArgument::REQUIRED,
72
+            'user which should be recovered'
73
+        );
74
+    }
75
+
76
+    protected function execute(InputInterface $input, OutputInterface $output): int {
77
+        $isMasterKeyEnabled = $this->util->isMasterKeyEnabled();
78
+
79
+        if ($isMasterKeyEnabled) {
80
+            $output->writeln('You use the master key, no individual user recovery needed.');
81
+            return 0;
82
+        }
83
+
84
+        $uid = $input->getArgument('user');
85
+        $userExists = $this->userManager->userExists($uid);
86
+        if ($userExists === false) {
87
+            $output->writeln('User "' . $uid . '" unknown.');
88
+            return 1;
89
+        }
90
+
91
+        $recoveryKeyEnabled = $this->util->isRecoveryEnabledForUser($uid);
92
+        if ($recoveryKeyEnabled === false) {
93
+            $output->writeln('Recovery key is not enabled for: ' . $uid);
94
+            return 1;
95
+        }
96
+
97
+        $question = new Question('Please enter the recovery key password: ');
98
+        $question->setHidden(true);
99
+        $question->setHiddenFallback(false);
100
+        $recoveryPassword = $this->questionHelper->ask($input, $output, $question);
101
+
102
+        $question = new Question('Please enter the new login password for the user: ');
103
+        $question->setHidden(true);
104
+        $question->setHiddenFallback(false);
105
+        $newLoginPassword = $this->questionHelper->ask($input, $output, $question);
106
+
107
+        $output->write('Start to recover users files... This can take some time...');
108
+        $this->userManager->get($uid)->setPassword($newLoginPassword, $recoveryPassword);
109
+        $output->writeln('Done.');
110
+        return 0;
111
+    }
112 112
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,13 +84,13 @@
 block discarded – undo
84 84
 		$uid = $input->getArgument('user');
85 85
 		$userExists = $this->userManager->userExists($uid);
86 86
 		if ($userExists === false) {
87
-			$output->writeln('User "' . $uid . '" unknown.');
87
+			$output->writeln('User "'.$uid.'" unknown.');
88 88
 			return 1;
89 89
 		}
90 90
 
91 91
 		$recoveryKeyEnabled = $this->util->isRecoveryEnabledForUser($uid);
92 92
 		if ($recoveryKeyEnabled === false) {
93
-			$output->writeln('Recovery key is not enabled for: ' . $uid);
93
+			$output->writeln('Recovery key is not enabled for: '.$uid);
94 94
 			return 1;
95 95
 		}
96 96
 
Please login to merge, or discard this patch.
apps/encryption/lib/Command/EnableMasterKey.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -33,52 +33,52 @@
 block discarded – undo
33 33
 
34 34
 class EnableMasterKey extends Command {
35 35
 
36
-	/** @var Util */
37
-	protected $util;
36
+    /** @var Util */
37
+    protected $util;
38 38
 
39
-	/** @var IConfig */
40
-	protected $config;
39
+    /** @var IConfig */
40
+    protected $config;
41 41
 
42
-	/** @var  QuestionHelper */
43
-	protected $questionHelper;
42
+    /** @var  QuestionHelper */
43
+    protected $questionHelper;
44 44
 
45
-	/**
46
-	 * @param Util $util
47
-	 * @param IConfig $config
48
-	 * @param QuestionHelper $questionHelper
49
-	 */
50
-	public function __construct(Util $util,
51
-								IConfig $config,
52
-								QuestionHelper $questionHelper) {
53
-		$this->util = $util;
54
-		$this->config = $config;
55
-		$this->questionHelper = $questionHelper;
56
-		parent::__construct();
57
-	}
45
+    /**
46
+     * @param Util $util
47
+     * @param IConfig $config
48
+     * @param QuestionHelper $questionHelper
49
+     */
50
+    public function __construct(Util $util,
51
+                                IConfig $config,
52
+                                QuestionHelper $questionHelper) {
53
+        $this->util = $util;
54
+        $this->config = $config;
55
+        $this->questionHelper = $questionHelper;
56
+        parent::__construct();
57
+    }
58 58
 
59
-	protected function configure() {
60
-		$this
61
-			->setName('encryption:enable-master-key')
62
-			->setDescription('Enable the master key. Only available for fresh installations with no existing encrypted data! There is also no way to disable it again.');
63
-	}
59
+    protected function configure() {
60
+        $this
61
+            ->setName('encryption:enable-master-key')
62
+            ->setDescription('Enable the master key. Only available for fresh installations with no existing encrypted data! There is also no way to disable it again.');
63
+    }
64 64
 
65
-	protected function execute(InputInterface $input, OutputInterface $output): int {
66
-		$isAlreadyEnabled = $this->util->isMasterKeyEnabled();
65
+    protected function execute(InputInterface $input, OutputInterface $output): int {
66
+        $isAlreadyEnabled = $this->util->isMasterKeyEnabled();
67 67
 
68
-		if ($isAlreadyEnabled) {
69
-			$output->writeln('Master key already enabled');
70
-		} else {
71
-			$question = new ConfirmationQuestion(
72
-				'Warning: Only available for fresh installations with no existing encrypted data! '
73
-			. 'There is also no way to disable it again. Do you want to continue? (y/n) ', false);
74
-			if ($this->questionHelper->ask($input, $output, $question)) {
75
-				$this->config->setAppValue('encryption', 'useMasterKey', '1');
76
-				$output->writeln('Master key successfully enabled.');
77
-			} else {
78
-				$output->writeln('aborted.');
79
-				return 1;
80
-			}
81
-		}
82
-		return 0;
83
-	}
68
+        if ($isAlreadyEnabled) {
69
+            $output->writeln('Master key already enabled');
70
+        } else {
71
+            $question = new ConfirmationQuestion(
72
+                'Warning: Only available for fresh installations with no existing encrypted data! '
73
+            . 'There is also no way to disable it again. Do you want to continue? (y/n) ', false);
74
+            if ($this->questionHelper->ask($input, $output, $question)) {
75
+                $this->config->setAppValue('encryption', 'useMasterKey', '1');
76
+                $output->writeln('Master key successfully enabled.');
77
+            } else {
78
+                $output->writeln('aborted.');
79
+                return 1;
80
+            }
81
+        }
82
+        return 0;
83
+    }
84 84
 }
Please login to merge, or discard this patch.
apps/encryption/lib/Command/DisableMasterKey.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -34,55 +34,55 @@
 block discarded – undo
34 34
 
35 35
 class DisableMasterKey extends Command {
36 36
 
37
-	/** @var Util */
38
-	protected $util;
37
+    /** @var Util */
38
+    protected $util;
39 39
 
40
-	/** @var IConfig */
41
-	protected $config;
40
+    /** @var IConfig */
41
+    protected $config;
42 42
 
43
-	/** @var  QuestionHelper */
44
-	protected $questionHelper;
43
+    /** @var  QuestionHelper */
44
+    protected $questionHelper;
45 45
 
46
-	/**
47
-	 * @param Util $util
48
-	 * @param IConfig $config
49
-	 * @param QuestionHelper $questionHelper
50
-	 */
51
-	public function __construct(Util $util,
52
-								IConfig $config,
53
-								QuestionHelper $questionHelper) {
54
-		$this->util = $util;
55
-		$this->config = $config;
56
-		$this->questionHelper = $questionHelper;
57
-		parent::__construct();
58
-	}
46
+    /**
47
+     * @param Util $util
48
+     * @param IConfig $config
49
+     * @param QuestionHelper $questionHelper
50
+     */
51
+    public function __construct(Util $util,
52
+                                IConfig $config,
53
+                                QuestionHelper $questionHelper) {
54
+        $this->util = $util;
55
+        $this->config = $config;
56
+        $this->questionHelper = $questionHelper;
57
+        parent::__construct();
58
+    }
59 59
 
60
-	protected function configure() {
61
-		$this
62
-			->setName('encryption:disable-master-key')
63
-			->setDescription('Disable the master key and use per-user keys instead. Only available for fresh installations with no existing encrypted data! There is no way to enable it again.');
64
-	}
60
+    protected function configure() {
61
+        $this
62
+            ->setName('encryption:disable-master-key')
63
+            ->setDescription('Disable the master key and use per-user keys instead. Only available for fresh installations with no existing encrypted data! There is no way to enable it again.');
64
+    }
65 65
 
66
-	protected function execute(InputInterface $input, OutputInterface $output): int {
67
-		$isMasterKeyEnabled = $this->util->isMasterKeyEnabled();
66
+    protected function execute(InputInterface $input, OutputInterface $output): int {
67
+        $isMasterKeyEnabled = $this->util->isMasterKeyEnabled();
68 68
 
69
-		if (!$isMasterKeyEnabled) {
70
-			$output->writeln('Master key already disabled');
71
-		} else {
72
-			$question = new ConfirmationQuestion(
73
-				'Warning: Only perform this operation for a fresh installations with no existing encrypted data! '
74
-				. 'There is no way to enable the master key again. '
75
-				. 'We strongly recommend to keep the master key, it provides significant performance improvements '
76
-				. 'and is easier to handle for both, users and administrators. '
77
-				. 'Do you really want to switch to per-user keys? (y/n) ', false);
78
-			if ($this->questionHelper->ask($input, $output, $question)) {
79
-				$this->config->setAppValue('encryption', 'useMasterKey', '0');
80
-				$output->writeln('Master key successfully disabled.');
81
-			} else {
82
-				$output->writeln('aborted.');
83
-				return 1;
84
-			}
85
-		}
86
-		return 0;
87
-	}
69
+        if (!$isMasterKeyEnabled) {
70
+            $output->writeln('Master key already disabled');
71
+        } else {
72
+            $question = new ConfirmationQuestion(
73
+                'Warning: Only perform this operation for a fresh installations with no existing encrypted data! '
74
+                . 'There is no way to enable the master key again. '
75
+                . 'We strongly recommend to keep the master key, it provides significant performance improvements '
76
+                . 'and is easier to handle for both, users and administrators. '
77
+                . 'Do you really want to switch to per-user keys? (y/n) ', false);
78
+            if ($this->questionHelper->ask($input, $output, $question)) {
79
+                $this->config->setAppValue('encryption', 'useMasterKey', '0');
80
+                $output->writeln('Master key successfully disabled.');
81
+            } else {
82
+                $output->writeln('aborted.');
83
+                return 1;
84
+            }
85
+        }
86
+        return 0;
87
+    }
88 88
 }
Please login to merge, or discard this patch.
apps/dav/lib/Command/SyncSystemAddressBook.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -32,37 +32,37 @@
 block discarded – undo
32 32
 
33 33
 class SyncSystemAddressBook extends Command {
34 34
 
35
-	/** @var SyncService */
36
-	private $syncService;
35
+    /** @var SyncService */
36
+    private $syncService;
37 37
 
38
-	/**
39
-	 * @param SyncService $syncService
40
-	 */
41
-	public function __construct(SyncService $syncService) {
42
-		parent::__construct();
43
-		$this->syncService = $syncService;
44
-	}
38
+    /**
39
+     * @param SyncService $syncService
40
+     */
41
+    public function __construct(SyncService $syncService) {
42
+        parent::__construct();
43
+        $this->syncService = $syncService;
44
+    }
45 45
 
46
-	protected function configure() {
47
-		$this
48
-			->setName('dav:sync-system-addressbook')
49
-			->setDescription('Synchronizes users to the system addressbook');
50
-	}
46
+    protected function configure() {
47
+        $this
48
+            ->setName('dav:sync-system-addressbook')
49
+            ->setDescription('Synchronizes users to the system addressbook');
50
+    }
51 51
 
52
-	/**
53
-	 * @param InputInterface $input
54
-	 * @param OutputInterface $output
55
-	 */
56
-	protected function execute(InputInterface $input, OutputInterface $output): int {
57
-		$output->writeln('Syncing users ...');
58
-		$progress = new ProgressBar($output);
59
-		$progress->start();
60
-		$this->syncService->syncInstance(function () use ($progress) {
61
-			$progress->advance();
62
-		});
52
+    /**
53
+     * @param InputInterface $input
54
+     * @param OutputInterface $output
55
+     */
56
+    protected function execute(InputInterface $input, OutputInterface $output): int {
57
+        $output->writeln('Syncing users ...');
58
+        $progress = new ProgressBar($output);
59
+        $progress->start();
60
+        $this->syncService->syncInstance(function () use ($progress) {
61
+            $progress->advance();
62
+        });
63 63
 
64
-		$progress->finish();
65
-		$output->writeln('');
66
-		return 0;
67
-	}
64
+        $progress->finish();
65
+        $output->writeln('');
66
+        return 0;
67
+    }
68 68
 }
Please login to merge, or discard this patch.
apps/dav/lib/Command/RemoveInvalidShares.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -38,50 +38,50 @@
 block discarded – undo
38 38
  */
39 39
 class RemoveInvalidShares extends Command {
40 40
 
41
-	/** @var IDBConnection */
42
-	private $connection;
43
-	/** @var Principal */
44
-	private $principalBackend;
41
+    /** @var IDBConnection */
42
+    private $connection;
43
+    /** @var Principal */
44
+    private $principalBackend;
45 45
 
46
-	public function __construct(IDBConnection $connection,
47
-								Principal $principalBackend) {
48
-		parent::__construct();
46
+    public function __construct(IDBConnection $connection,
47
+                                Principal $principalBackend) {
48
+        parent::__construct();
49 49
 
50
-		$this->connection = $connection;
51
-		$this->principalBackend = $principalBackend;
52
-	}
50
+        $this->connection = $connection;
51
+        $this->principalBackend = $principalBackend;
52
+    }
53 53
 
54
-	protected function configure() {
55
-		$this
56
-			->setName('dav:remove-invalid-shares')
57
-			->setDescription('Remove invalid dav shares');
58
-	}
54
+    protected function configure() {
55
+        $this
56
+            ->setName('dav:remove-invalid-shares')
57
+            ->setDescription('Remove invalid dav shares');
58
+    }
59 59
 
60
-	protected function execute(InputInterface $input, OutputInterface $output): int {
61
-		$query = $this->connection->getQueryBuilder();
62
-		$result = $query->selectDistinct('principaluri')
63
-			->from('dav_shares')
64
-			->execute();
60
+    protected function execute(InputInterface $input, OutputInterface $output): int {
61
+        $query = $this->connection->getQueryBuilder();
62
+        $result = $query->selectDistinct('principaluri')
63
+            ->from('dav_shares')
64
+            ->execute();
65 65
 
66
-		while ($row = $result->fetch()) {
67
-			$principaluri = $row['principaluri'];
68
-			$p = $this->principalBackend->getPrincipalByPath($principaluri);
69
-			if ($p === null) {
70
-				$this->deleteSharesForPrincipal($principaluri);
71
-			}
72
-		}
66
+        while ($row = $result->fetch()) {
67
+            $principaluri = $row['principaluri'];
68
+            $p = $this->principalBackend->getPrincipalByPath($principaluri);
69
+            if ($p === null) {
70
+                $this->deleteSharesForPrincipal($principaluri);
71
+            }
72
+        }
73 73
 
74
-		$result->closeCursor();
75
-		return 0;
76
-	}
74
+        $result->closeCursor();
75
+        return 0;
76
+    }
77 77
 
78
-	/**
79
-	 * @param string $principaluri
80
-	 */
81
-	private function deleteSharesForPrincipal($principaluri) {
82
-		$delete = $this->connection->getQueryBuilder();
83
-		$delete->delete('dav_shares')
84
-			->where($delete->expr()->eq('principaluri', $delete->createNamedParameter($principaluri)));
85
-		$delete->execute();
86
-	}
78
+    /**
79
+     * @param string $principaluri
80
+     */
81
+    private function deleteSharesForPrincipal($principaluri) {
82
+        $delete = $this->connection->getQueryBuilder();
83
+        $delete->delete('dav_shares')
84
+            ->where($delete->expr()->eq('principaluri', $delete->createNamedParameter($principaluri)));
85
+        $delete->execute();
86
+    }
87 87
 }
Please login to merge, or discard this patch.
apps/dav/lib/Command/SendEventReminders.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -37,50 +37,50 @@
 block discarded – undo
37 37
  */
38 38
 class SendEventReminders extends Command {
39 39
 
40
-	/** @var ReminderService */
41
-	protected $reminderService;
40
+    /** @var ReminderService */
41
+    protected $reminderService;
42 42
 
43
-	/** @var IConfig */
44
-	protected $config;
43
+    /** @var IConfig */
44
+    protected $config;
45 45
 
46
-	/**
47
-	 * @param ReminderService $reminderService
48
-	 * @param IConfig $config
49
-	 */
50
-	public function __construct(ReminderService $reminderService,
51
-								IConfig $config) {
52
-		parent::__construct();
53
-		$this->reminderService = $reminderService;
54
-		$this->config = $config;
55
-	}
46
+    /**
47
+     * @param ReminderService $reminderService
48
+     * @param IConfig $config
49
+     */
50
+    public function __construct(ReminderService $reminderService,
51
+                                IConfig $config) {
52
+        parent::__construct();
53
+        $this->reminderService = $reminderService;
54
+        $this->config = $config;
55
+    }
56 56
 
57
-	/**
58
-	 * @inheritDoc
59
-	 */
60
-	protected function configure():void {
61
-		$this
62
-			->setName('dav:send-event-reminders')
63
-			->setDescription('Sends event reminders');
64
-	}
57
+    /**
58
+     * @inheritDoc
59
+     */
60
+    protected function configure():void {
61
+        $this
62
+            ->setName('dav:send-event-reminders')
63
+            ->setDescription('Sends event reminders');
64
+    }
65 65
 
66
-	/**
67
-	 * @param InputInterface $input
68
-	 * @param OutputInterface $output
69
-	 */
70
-	protected function execute(InputInterface $input, OutputInterface $output): int {
71
-		if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
72
-			$output->writeln('<error>Sending event reminders disabled!</error>');
73
-			$output->writeln('<info>Please run "php occ config:app:set dav sendEventReminders --value yes"');
74
-			return 1;
75
-		}
66
+    /**
67
+     * @param InputInterface $input
68
+     * @param OutputInterface $output
69
+     */
70
+    protected function execute(InputInterface $input, OutputInterface $output): int {
71
+        if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
72
+            $output->writeln('<error>Sending event reminders disabled!</error>');
73
+            $output->writeln('<info>Please run "php occ config:app:set dav sendEventReminders --value yes"');
74
+            return 1;
75
+        }
76 76
 
77
-		if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'occ') {
78
-			$output->writeln('<error>Sending event reminders mode set to background-job!</error>');
79
-			$output->writeln('<info>Please run "php occ config:app:set dav sendEventRemindersMode --value occ"');
80
-			return 1;
81
-		}
77
+        if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'occ') {
78
+            $output->writeln('<error>Sending event reminders mode set to background-job!</error>');
79
+            $output->writeln('<info>Please run "php occ config:app:set dav sendEventRemindersMode --value occ"');
80
+            return 1;
81
+        }
82 82
 
83
-		$this->reminderService->processReminders();
84
-		return 0;
85
-	}
83
+        $this->reminderService->processReminders();
84
+        return 0;
85
+    }
86 86
 }
Please login to merge, or discard this patch.
apps/dav/lib/Command/CreateCalendar.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -40,60 +40,60 @@
 block discarded – undo
40 40
 
41 41
 class CreateCalendar extends Command {
42 42
 
43
-	/** @var IUserManager */
44
-	protected $userManager;
43
+    /** @var IUserManager */
44
+    protected $userManager;
45 45
 
46
-	/** @var IGroupManager $groupManager */
47
-	private $groupManager;
46
+    /** @var IGroupManager $groupManager */
47
+    private $groupManager;
48 48
 
49
-	/** @var \OCP\IDBConnection */
50
-	protected $dbConnection;
49
+    /** @var \OCP\IDBConnection */
50
+    protected $dbConnection;
51 51
 
52
-	/**
53
-	 * @param IUserManager $userManager
54
-	 * @param IGroupManager $groupManager
55
-	 * @param IDBConnection $dbConnection
56
-	 */
57
-	public function __construct(IUserManager $userManager, IGroupManager $groupManager, IDBConnection $dbConnection) {
58
-		parent::__construct();
59
-		$this->userManager = $userManager;
60
-		$this->groupManager = $groupManager;
61
-		$this->dbConnection = $dbConnection;
62
-	}
52
+    /**
53
+     * @param IUserManager $userManager
54
+     * @param IGroupManager $groupManager
55
+     * @param IDBConnection $dbConnection
56
+     */
57
+    public function __construct(IUserManager $userManager, IGroupManager $groupManager, IDBConnection $dbConnection) {
58
+        parent::__construct();
59
+        $this->userManager = $userManager;
60
+        $this->groupManager = $groupManager;
61
+        $this->dbConnection = $dbConnection;
62
+    }
63 63
 
64
-	protected function configure() {
65
-		$this
66
-			->setName('dav:create-calendar')
67
-			->setDescription('Create a dav calendar')
68
-			->addArgument('user',
69
-				InputArgument::REQUIRED,
70
-				'User for whom the calendar will be created')
71
-			->addArgument('name',
72
-				InputArgument::REQUIRED,
73
-				'Name of the calendar');
74
-	}
64
+    protected function configure() {
65
+        $this
66
+            ->setName('dav:create-calendar')
67
+            ->setDescription('Create a dav calendar')
68
+            ->addArgument('user',
69
+                InputArgument::REQUIRED,
70
+                'User for whom the calendar will be created')
71
+            ->addArgument('name',
72
+                InputArgument::REQUIRED,
73
+                'Name of the calendar');
74
+    }
75 75
 
76
-	protected function execute(InputInterface $input, OutputInterface $output): int {
77
-		$user = $input->getArgument('user');
78
-		if (!$this->userManager->userExists($user)) {
79
-			throw new \InvalidArgumentException("User <$user> in unknown.");
80
-		}
81
-		$principalBackend = new Principal(
82
-			$this->userManager,
83
-			$this->groupManager,
84
-			\OC::$server->getShareManager(),
85
-			\OC::$server->getUserSession(),
86
-			\OC::$server->getAppManager(),
87
-			\OC::$server->query(ProxyMapper::class),
88
-			\OC::$server->getConfig()
89
-		);
90
-		$random = \OC::$server->getSecureRandom();
91
-		$logger = \OC::$server->getLogger();
92
-		$dispatcher = \OC::$server->getEventDispatcher();
76
+    protected function execute(InputInterface $input, OutputInterface $output): int {
77
+        $user = $input->getArgument('user');
78
+        if (!$this->userManager->userExists($user)) {
79
+            throw new \InvalidArgumentException("User <$user> in unknown.");
80
+        }
81
+        $principalBackend = new Principal(
82
+            $this->userManager,
83
+            $this->groupManager,
84
+            \OC::$server->getShareManager(),
85
+            \OC::$server->getUserSession(),
86
+            \OC::$server->getAppManager(),
87
+            \OC::$server->query(ProxyMapper::class),
88
+            \OC::$server->getConfig()
89
+        );
90
+        $random = \OC::$server->getSecureRandom();
91
+        $logger = \OC::$server->getLogger();
92
+        $dispatcher = \OC::$server->getEventDispatcher();
93 93
 
94
-		$name = $input->getArgument('name');
95
-		$caldav = new CalDavBackend($this->dbConnection, $principalBackend, $this->userManager, $this->groupManager, $random, $logger, $dispatcher);
96
-		$caldav->createCalendar("principals/users/$user", $name, []);
97
-		return 0;
98
-	}
94
+        $name = $input->getArgument('name');
95
+        $caldav = new CalDavBackend($this->dbConnection, $principalBackend, $this->userManager, $this->groupManager, $random, $logger, $dispatcher);
96
+        $caldav->createCalendar("principals/users/$user", $name, []);
97
+        return 0;
98
+    }
99 99
 }
Please login to merge, or discard this patch.
apps/dav/lib/Command/ListCalendars.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -37,70 +37,70 @@
 block discarded – undo
37 37
 
38 38
 class ListCalendars extends Command {
39 39
 
40
-	/** @var IUserManager */
41
-	protected $userManager;
40
+    /** @var IUserManager */
41
+    protected $userManager;
42 42
 
43
-	/** @var CalDavBackend */
44
-	private $caldav;
43
+    /** @var CalDavBackend */
44
+    private $caldav;
45 45
 
46
-	/**
47
-	 * @param IUserManager $userManager
48
-	 * @param CalDavBackend $caldav
49
-	 */
50
-	public function __construct(IUserManager $userManager, CalDavBackend $caldav) {
51
-		parent::__construct();
52
-		$this->userManager = $userManager;
53
-		$this->caldav = $caldav;
54
-	}
46
+    /**
47
+     * @param IUserManager $userManager
48
+     * @param CalDavBackend $caldav
49
+     */
50
+    public function __construct(IUserManager $userManager, CalDavBackend $caldav) {
51
+        parent::__construct();
52
+        $this->userManager = $userManager;
53
+        $this->caldav = $caldav;
54
+    }
55 55
 
56
-	protected function configure() {
57
-		$this
58
-			->setName('dav:list-calendars')
59
-			->setDescription('List all calendars of a user')
60
-			->addArgument('uid',
61
-				InputArgument::REQUIRED,
62
-				'User for whom all calendars will be listed');
63
-	}
56
+    protected function configure() {
57
+        $this
58
+            ->setName('dav:list-calendars')
59
+            ->setDescription('List all calendars of a user')
60
+            ->addArgument('uid',
61
+                InputArgument::REQUIRED,
62
+                'User for whom all calendars will be listed');
63
+    }
64 64
 
65
-	protected function execute(InputInterface $input, OutputInterface $output): int {
66
-		$user = $input->getArgument('uid');
67
-		if (!$this->userManager->userExists($user)) {
68
-			throw new \InvalidArgumentException("User <$user> is unknown.");
69
-		}
65
+    protected function execute(InputInterface $input, OutputInterface $output): int {
66
+        $user = $input->getArgument('uid');
67
+        if (!$this->userManager->userExists($user)) {
68
+            throw new \InvalidArgumentException("User <$user> is unknown.");
69
+        }
70 70
 
71
-		$calendars = $this->caldav->getCalendarsForUser("principals/users/$user");
71
+        $calendars = $this->caldav->getCalendarsForUser("principals/users/$user");
72 72
 
73
-		$calendarTableData = [];
74
-		foreach ($calendars as $calendar) {
75
-			// skip birthday calendar
76
-			if ($calendar['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI) {
77
-				continue;
78
-			}
73
+        $calendarTableData = [];
74
+        foreach ($calendars as $calendar) {
75
+            // skip birthday calendar
76
+            if ($calendar['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI) {
77
+                continue;
78
+            }
79 79
 
80
-			$readOnly = false;
81
-			$readOnlyIndex = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
82
-			if (isset($calendar[$readOnlyIndex])) {
83
-				$readOnly = $calendar[$readOnlyIndex];
84
-			}
80
+            $readOnly = false;
81
+            $readOnlyIndex = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
82
+            if (isset($calendar[$readOnlyIndex])) {
83
+                $readOnly = $calendar[$readOnlyIndex];
84
+            }
85 85
 
86
-			$calendarTableData[] = [
87
-				$calendar['uri'],
88
-				$calendar['{DAV:}displayname'],
89
-				$calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'],
90
-				$calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'],
91
-				$readOnly ? ' x ' : ' ✓ ',
92
-			];
93
-		}
86
+            $calendarTableData[] = [
87
+                $calendar['uri'],
88
+                $calendar['{DAV:}displayname'],
89
+                $calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'],
90
+                $calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'],
91
+                $readOnly ? ' x ' : ' ✓ ',
92
+            ];
93
+        }
94 94
 
95
-		if (count($calendarTableData) > 0) {
96
-			$table = new Table($output);
97
-			$table->setHeaders(['uri', 'displayname', 'owner\'s userid', 'owner\'s displayname', 'writable'])
98
-				->setRows($calendarTableData);
95
+        if (count($calendarTableData) > 0) {
96
+            $table = new Table($output);
97
+            $table->setHeaders(['uri', 'displayname', 'owner\'s userid', 'owner\'s displayname', 'writable'])
98
+                ->setRows($calendarTableData);
99 99
 
100
-			$table->render();
101
-		} else {
102
-			$output->writeln("<info>User <$user> has no calendars</info>");
103
-		}
104
-		return 0;
105
-	}
100
+            $table->render();
101
+        } else {
102
+            $output->writeln("<info>User <$user> has no calendars</info>");
103
+        }
104
+        return 0;
105
+    }
106 106
 }
Please login to merge, or discard this patch.