Completed
Push — master ( fafc07...340ea1 )
by
unknown
42:03
created
apps/settings/lib/Listener/AppPasswordCreatedActivityListener.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
 		try {
66 66
 			$this->activityManager->publish($activity);
67 67
 		} catch (BadMethodCallException $e) {
68
-			$this->logger->warning('Could not publish activity: ' . $e->getMessage(), [
68
+			$this->logger->warning('Could not publish activity: '.$e->getMessage(), [
69 69
 				'exception' => $e
70 70
 			]);
71 71
 		}
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -21,32 +21,32 @@
 block discarded – undo
21 21
  * @template-implements IEventListener<\OC\Authentication\Events\AppPasswordCreatedEvent>
22 22
  */
23 23
 class AppPasswordCreatedActivityListener implements IEventListener {
24
-	public function __construct(
25
-		private IActivityManager $activityManager,
26
-		private IUserSession $userSession,
27
-		private LoggerInterface $logger,
28
-	) {
29
-	}
24
+    public function __construct(
25
+        private IActivityManager $activityManager,
26
+        private IUserSession $userSession,
27
+        private LoggerInterface $logger,
28
+    ) {
29
+    }
30 30
 
31
-	public function handle(Event $event): void {
32
-		if (!($event instanceof AppPasswordCreatedEvent)) {
33
-			return;
34
-		}
31
+    public function handle(Event $event): void {
32
+        if (!($event instanceof AppPasswordCreatedEvent)) {
33
+            return;
34
+        }
35 35
 
36
-		$activity = $this->activityManager->generateEvent();
37
-		$activity->setApp('settings')
38
-			->setType('security')
39
-			->setAffectedUser($event->getToken()->getUID())
40
-			->setAuthor($this->userSession->getUser() ? $this->userSession->getUser()->getUID() : '')
41
-			->setSubject(Provider::APP_TOKEN_CREATED, ['name' => $event->getToken()->getName()])
42
-			->setObject('app_token', $event->getToken()->getId());
36
+        $activity = $this->activityManager->generateEvent();
37
+        $activity->setApp('settings')
38
+            ->setType('security')
39
+            ->setAffectedUser($event->getToken()->getUID())
40
+            ->setAuthor($this->userSession->getUser() ? $this->userSession->getUser()->getUID() : '')
41
+            ->setSubject(Provider::APP_TOKEN_CREATED, ['name' => $event->getToken()->getName()])
42
+            ->setObject('app_token', $event->getToken()->getId());
43 43
 
44
-		try {
45
-			$this->activityManager->publish($activity);
46
-		} catch (BadMethodCallException $e) {
47
-			$this->logger->warning('Could not publish activity: ' . $e->getMessage(), [
48
-				'exception' => $e
49
-			]);
50
-		}
51
-	}
44
+        try {
45
+            $this->activityManager->publish($activity);
46
+        } catch (BadMethodCallException $e) {
47
+            $this->logger->warning('Could not publish activity: ' . $e->getMessage(), [
48
+                'exception' => $e
49
+            ]);
50
+        }
51
+    }
52 52
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Service/DBConfigService.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		$stmt->closeCursor();
141 141
 
142 142
 		foreach ($result as $row) {
143
-			if ((int)$row['count'] > 1) {
143
+			if ((int) $row['count'] > 1) {
144 144
 				$this->removeApplicable($row['mount_id'], $applicableType, $applicableId);
145 145
 			} else {
146 146
 				$this->removeMount($row['mount_id']);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function getAdminMountsForMultiple($type, array $values) {
216 216
 		$builder = $this->connection->getQueryBuilder();
217
-		$params = array_map(function ($value) use ($builder) {
217
+		$params = array_map(function($value) use ($builder) {
218 218
 			return $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR);
219 219
 		}, $values);
220 220
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 		}
413 413
 		$uniqueMounts = array_values($uniqueMounts);
414 414
 
415
-		$mountIds = array_map(function ($mount) {
415
+		$mountIds = array_map(function($mount) {
416 416
 			return $mount['mount_id'];
417 417
 		}, $uniqueMounts);
418 418
 		$mountIds = array_values(array_unique($mountIds));
@@ -421,9 +421,9 @@  discard block
 block discarded – undo
421 421
 		$config = $this->getConfigForMounts($mountIds);
422 422
 		$options = $this->getOptionsForMounts($mountIds);
423 423
 
424
-		return array_map(function ($mount, $applicable, $config, $options) {
425
-			$mount['type'] = (int)$mount['type'];
426
-			$mount['priority'] = (int)$mount['priority'];
424
+		return array_map(function($mount, $applicable, $config, $options) {
425
+			$mount['type'] = (int) $mount['type'];
426
+			$mount['priority'] = (int) $mount['priority'];
427 427
 			$mount['applicable'] = $applicable;
428 428
 			$mount['config'] = $config;
429 429
 			$mount['options'] = $options;
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		}
446 446
 		$builder = $this->connection->getQueryBuilder();
447 447
 		$fields[] = 'mount_id';
448
-		$placeHolders = array_map(function ($id) use ($builder) {
448
+		$placeHolders = array_map(function($id) use ($builder) {
449 449
 			return $builder->createPositionalParameter($id, IQueryBuilder::PARAM_INT);
450 450
 		}, $mountIds);
451 451
 		$query = $builder->select($fields)
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 		}
463 463
 		foreach ($rows as $row) {
464 464
 			if (isset($row['type'])) {
465
-				$row['type'] = (int)$row['type'];
465
+				$row['type'] = (int) $row['type'];
466 466
 			}
467 467
 			$result[$row['mount_id']][] = $row;
468 468
 		}
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 	public function getOptionsForMounts($mountIds) {
494 494
 		$mountOptions = $this->selectForMounts('external_options', ['key', 'value'], $mountIds);
495 495
 		$optionsMap = array_map([$this, 'createKeyValueMap'], $mountOptions);
496
-		return array_map(function (array $options) {
497
-			return array_map(function ($option) {
496
+		return array_map(function(array $options) {
497
+			return array_map(function($option) {
498 498
 				return json_decode($option);
499 499
 			}, $options);
500 500
 		}, $optionsMap);
@@ -505,16 +505,16 @@  discard block
 block discarded – undo
505 505
 	 * @return array ['key1' => $value1, ...]
506 506
 	 */
507 507
 	private function createKeyValueMap(array $keyValuePairs) {
508
-		$decryptedPairts = array_map(function ($pair) {
508
+		$decryptedPairts = array_map(function($pair) {
509 509
 			if ($pair['key'] === 'password') {
510 510
 				$pair['value'] = $this->decryptValue($pair['value']);
511 511
 			}
512 512
 			return $pair;
513 513
 		}, $keyValuePairs);
514
-		$keys = array_map(function ($pair) {
514
+		$keys = array_map(function($pair) {
515 515
 			return $pair['key'];
516 516
 		}, $decryptedPairts);
517
-		$values = array_map(function ($pair) {
517
+		$values = array_map(function($pair) {
518 518
 			return $pair['value'];
519 519
 		}, $decryptedPairts);
520 520
 
Please login to merge, or discard this patch.
Indentation   +504 added lines, -504 removed lines patch added patch discarded remove patch
@@ -17,508 +17,508 @@
 block discarded – undo
17 17
  * Stores the mount config in the database
18 18
  */
19 19
 class DBConfigService {
20
-	public const MOUNT_TYPE_ADMIN = 1;
21
-	public const MOUNT_TYPE_PERSONAL = 2;
22
-	/** @deprecated use MOUNT_TYPE_PERSONAL (full uppercase) instead */
23
-	public const MOUNT_TYPE_PERSONAl = 2;
24
-
25
-	public const APPLICABLE_TYPE_GLOBAL = 1;
26
-	public const APPLICABLE_TYPE_GROUP = 2;
27
-	public const APPLICABLE_TYPE_USER = 3;
28
-
29
-	public function __construct(
30
-		private IDBConnection $connection,
31
-		private ICrypto $crypto,
32
-	) {
33
-	}
34
-
35
-	public function getMountById(int $mountId): ?array {
36
-		$builder = $this->connection->getQueryBuilder();
37
-		$query = $builder->select(['mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'type'])
38
-			->from('external_mounts', 'm')
39
-			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
40
-		$mounts = $this->getMountsFromQuery($query);
41
-		if (count($mounts) > 0) {
42
-			return $mounts[0];
43
-		} else {
44
-			return null;
45
-		}
46
-	}
47
-
48
-	/**
49
-	 * Get all configured mounts
50
-	 *
51
-	 * @return array
52
-	 */
53
-	public function getAllMounts() {
54
-		$builder = $this->connection->getQueryBuilder();
55
-		$query = $builder->select(['mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'type'])
56
-			->from('external_mounts');
57
-		return $this->getMountsFromQuery($query);
58
-	}
59
-
60
-	public function getMountsForUser($userId, $groupIds) {
61
-		$builder = $this->connection->getQueryBuilder();
62
-		$query = $builder->select(['m.mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'm.type'])
63
-			->from('external_mounts', 'm')
64
-			->innerJoin('m', 'external_applicable', 'a', $builder->expr()->eq('m.mount_id', 'a.mount_id'))
65
-			->where($builder->expr()->orX(
66
-				$builder->expr()->andX( // global mounts
67
-					$builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_GLOBAL, IQueryBuilder::PARAM_INT)),
68
-					$builder->expr()->isNull('a.value'),
69
-				),
70
-				$builder->expr()->andX( // mounts for user
71
-					$builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_USER, IQueryBuilder::PARAM_INT)),
72
-					$builder->expr()->eq('a.value', $builder->createNamedParameter($userId)),
73
-				),
74
-				$builder->expr()->andX( // mounts for group
75
-					$builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_GROUP, IQueryBuilder::PARAM_INT)),
76
-					$builder->expr()->in('a.value', $builder->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY)),
77
-				),
78
-			));
79
-
80
-		return $this->getMountsFromQuery($query);
81
-	}
82
-
83
-	public function modifyMountsOnUserDelete(string $uid): void {
84
-		$this->modifyMountsOnDelete($uid, self::APPLICABLE_TYPE_USER);
85
-	}
86
-
87
-	public function modifyMountsOnGroupDelete(string $gid): void {
88
-		$this->modifyMountsOnDelete($gid, self::APPLICABLE_TYPE_GROUP);
89
-	}
90
-
91
-	protected function modifyMountsOnDelete(string $applicableId, int $applicableType): void {
92
-		$builder = $this->connection->getQueryBuilder();
93
-		$query = $builder->select(['a.mount_id', $builder->func()->count('a.mount_id', 'count')])
94
-			->from('external_applicable', 'a')
95
-			->leftJoin('a', 'external_applicable', 'b', $builder->expr()->eq('a.mount_id', 'b.mount_id'))
96
-			->where($builder->expr()->andX(
97
-				$builder->expr()->eq('b.type', $builder->createNamedParameter($applicableType, IQueryBuilder::PARAM_INT)),
98
-				$builder->expr()->eq('b.value', $builder->createNamedParameter($applicableId)),
99
-			),
100
-			)
101
-			->groupBy(['a.mount_id']);
102
-		$stmt = $query->executeQuery();
103
-		$result = $stmt->fetchAll();
104
-		$stmt->closeCursor();
105
-
106
-		foreach ($result as $row) {
107
-			if ((int)$row['count'] > 1) {
108
-				$this->removeApplicable($row['mount_id'], $applicableType, $applicableId);
109
-			} else {
110
-				$this->removeMount($row['mount_id']);
111
-			}
112
-		}
113
-	}
114
-
115
-	/**
116
-	 * Get admin defined mounts
117
-	 *
118
-	 * @return array
119
-	 */
120
-	public function getAdminMounts() {
121
-		$builder = $this->connection->getQueryBuilder();
122
-		$query = $builder->select(['mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'type'])
123
-			->from('external_mounts')
124
-			->where($builder->expr()->eq('type', $builder->expr()->literal(self::MOUNT_TYPE_ADMIN, IQueryBuilder::PARAM_INT)));
125
-		return $this->getMountsFromQuery($query);
126
-	}
127
-
128
-	protected function getForQuery(IQueryBuilder $builder, $type, $value) {
129
-		$query = $builder->select(['m.mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'm.type'])
130
-			->from('external_mounts', 'm')
131
-			->innerJoin('m', 'external_applicable', 'a', $builder->expr()->eq('m.mount_id', 'a.mount_id'))
132
-			->where($builder->expr()->eq('a.type', $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT)));
133
-
134
-		if (is_null($value)) {
135
-			$query = $query->andWhere($builder->expr()->isNull('a.value'));
136
-		} else {
137
-			$query = $query->andWhere($builder->expr()->eq('a.value', $builder->createNamedParameter($value)));
138
-		}
139
-
140
-		return $query;
141
-	}
142
-
143
-	/**
144
-	 * Get mounts by applicable
145
-	 *
146
-	 * @param int $type any of the self::APPLICABLE_TYPE_ constants
147
-	 * @param string|null $value user_id, group_id or null for global mounts
148
-	 * @return array
149
-	 */
150
-	public function getMountsFor($type, $value) {
151
-		$builder = $this->connection->getQueryBuilder();
152
-		$query = $this->getForQuery($builder, $type, $value);
153
-
154
-		return $this->getMountsFromQuery($query);
155
-	}
156
-
157
-	/**
158
-	 * Get admin defined mounts by applicable
159
-	 *
160
-	 * @param int $type any of the self::APPLICABLE_TYPE_ constants
161
-	 * @param string|null $value user_id, group_id or null for global mounts
162
-	 * @return array
163
-	 */
164
-	public function getAdminMountsFor($type, $value) {
165
-		$builder = $this->connection->getQueryBuilder();
166
-		$query = $this->getForQuery($builder, $type, $value);
167
-		$query->andWhere($builder->expr()->eq('m.type', $builder->expr()->literal(self::MOUNT_TYPE_ADMIN, IQueryBuilder::PARAM_INT)));
168
-
169
-		return $this->getMountsFromQuery($query);
170
-	}
171
-
172
-	/**
173
-	 * Get admin defined mounts for multiple applicable
174
-	 *
175
-	 * @param int $type any of the self::APPLICABLE_TYPE_ constants
176
-	 * @param string[] $values user_ids or group_ids
177
-	 * @return array
178
-	 */
179
-	public function getAdminMountsForMultiple($type, array $values) {
180
-		$builder = $this->connection->getQueryBuilder();
181
-		$params = array_map(function ($value) use ($builder) {
182
-			return $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR);
183
-		}, $values);
184
-
185
-		$query = $builder->select(['m.mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'm.type'])
186
-			->from('external_mounts', 'm')
187
-			->innerJoin('m', 'external_applicable', 'a', $builder->expr()->eq('m.mount_id', 'a.mount_id'))
188
-			->where($builder->expr()->eq('a.type', $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT)))
189
-			->andWhere($builder->expr()->in('a.value', $params));
190
-		$query->andWhere($builder->expr()->eq('m.type', $builder->expr()->literal(self::MOUNT_TYPE_ADMIN, IQueryBuilder::PARAM_INT)));
191
-
192
-		return $this->getMountsFromQuery($query);
193
-	}
194
-
195
-	/**
196
-	 * Get user defined mounts by applicable
197
-	 *
198
-	 * @param int $type any of the self::APPLICABLE_TYPE_ constants
199
-	 * @param string|null $value user_id, group_id or null for global mounts
200
-	 * @return array
201
-	 */
202
-	public function getUserMountsFor($type, $value) {
203
-		$builder = $this->connection->getQueryBuilder();
204
-		$query = $this->getForQuery($builder, $type, $value);
205
-		$query->andWhere($builder->expr()->eq('m.type', $builder->expr()->literal(self::MOUNT_TYPE_PERSONAL, IQueryBuilder::PARAM_INT)));
206
-
207
-		return $this->getMountsFromQuery($query);
208
-	}
209
-
210
-	/**
211
-	 * Add a mount to the database
212
-	 *
213
-	 * @param string $mountPoint
214
-	 * @param string $storageBackend
215
-	 * @param string $authBackend
216
-	 * @param int $priority
217
-	 * @param int $type self::MOUNT_TYPE_ADMIN or self::MOUNT_TYPE_PERSONAL
218
-	 * @return int the id of the new mount
219
-	 */
220
-	public function addMount($mountPoint, $storageBackend, $authBackend, $priority, $type) {
221
-		if (!$priority) {
222
-			$priority = 100;
223
-		}
224
-		$builder = $this->connection->getQueryBuilder();
225
-		$query = $builder->insert('external_mounts')
226
-			->values([
227
-				'mount_point' => $builder->createNamedParameter($mountPoint, IQueryBuilder::PARAM_STR),
228
-				'storage_backend' => $builder->createNamedParameter($storageBackend, IQueryBuilder::PARAM_STR),
229
-				'auth_backend' => $builder->createNamedParameter($authBackend, IQueryBuilder::PARAM_STR),
230
-				'priority' => $builder->createNamedParameter($priority, IQueryBuilder::PARAM_INT),
231
-				'type' => $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT),
232
-			]);
233
-		$query->executeStatement();
234
-		return $query->getLastInsertId();
235
-	}
236
-
237
-	/**
238
-	 * Remove a mount from the database
239
-	 *
240
-	 * @param int $mountId
241
-	 */
242
-	public function removeMount($mountId) {
243
-		$builder = $this->connection->getQueryBuilder();
244
-		$query = $builder->delete('external_mounts')
245
-			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
246
-		$query->executeStatement();
247
-
248
-		$builder = $this->connection->getQueryBuilder();
249
-		$query = $builder->delete('external_applicable')
250
-			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
251
-		$query->executeStatement();
252
-
253
-		$builder = $this->connection->getQueryBuilder();
254
-		$query = $builder->delete('external_config')
255
-			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
256
-		$query->executeStatement();
257
-
258
-		$builder = $this->connection->getQueryBuilder();
259
-		$query = $builder->delete('external_options')
260
-			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
261
-		$query->executeStatement();
262
-	}
263
-
264
-	/**
265
-	 * @param int $mountId
266
-	 * @param string $newMountPoint
267
-	 */
268
-	public function setMountPoint($mountId, $newMountPoint) {
269
-		$builder = $this->connection->getQueryBuilder();
270
-
271
-		$query = $builder->update('external_mounts')
272
-			->set('mount_point', $builder->createNamedParameter($newMountPoint))
273
-			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
274
-
275
-		$query->executeStatement();
276
-	}
277
-
278
-	/**
279
-	 * @param int $mountId
280
-	 * @param string $newAuthBackend
281
-	 */
282
-	public function setAuthBackend($mountId, $newAuthBackend) {
283
-		$builder = $this->connection->getQueryBuilder();
284
-
285
-		$query = $builder->update('external_mounts')
286
-			->set('auth_backend', $builder->createNamedParameter($newAuthBackend))
287
-			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
288
-
289
-		$query->executeStatement();
290
-	}
291
-
292
-	/**
293
-	 * @param int $mountId
294
-	 * @param string $key
295
-	 * @param string $value
296
-	 */
297
-	public function setConfig($mountId, $key, $value) {
298
-		if ($key === 'password') {
299
-			$value = $this->encryptValue($value);
300
-		}
301
-
302
-		try {
303
-			$builder = $this->connection->getQueryBuilder();
304
-			$builder->insert('external_config')
305
-				->setValue('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))
306
-				->setValue('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR))
307
-				->setValue('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR))
308
-				->executeStatement();
309
-		} catch (Exception $e) {
310
-			if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
311
-				throw $e;
312
-			}
313
-			$builder = $this->connection->getQueryBuilder();
314
-			$query = $builder->update('external_config')
315
-				->set('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR))
316
-				->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)))
317
-				->andWhere($builder->expr()->eq('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR)));
318
-			$query->executeStatement();
319
-		}
320
-	}
321
-
322
-	/**
323
-	 * @param int $mountId
324
-	 * @param string $key
325
-	 * @param string $value
326
-	 */
327
-	public function setOption($mountId, $key, $value) {
328
-		try {
329
-			$builder = $this->connection->getQueryBuilder();
330
-			$builder->insert('external_options')
331
-				->setValue('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))
332
-				->setValue('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR))
333
-				->setValue('value', $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR))
334
-				->executeStatement();
335
-		} catch (Exception $e) {
336
-			if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
337
-				throw $e;
338
-			}
339
-			$builder = $this->connection->getQueryBuilder();
340
-			$query = $builder->update('external_options')
341
-				->set('value', $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR))
342
-				->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)))
343
-				->andWhere($builder->expr()->eq('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR)));
344
-			$query->executeStatement();
345
-		}
346
-	}
347
-
348
-	public function addApplicable($mountId, $type, $value) {
349
-		try {
350
-			$builder = $this->connection->getQueryBuilder();
351
-			$builder->insert('external_applicable')
352
-				->setValue('mount_id', $builder->createNamedParameter($mountId))
353
-				->setValue('type', $builder->createNamedParameter($type))
354
-				->setValue('value', $builder->createNamedParameter($value))
355
-				->executeStatement();
356
-		} catch (Exception $e) {
357
-			// applicable exists already
358
-			if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
359
-				throw $e;
360
-			}
361
-		}
362
-	}
363
-
364
-	public function removeApplicable($mountId, $type, $value) {
365
-		$builder = $this->connection->getQueryBuilder();
366
-		$query = $builder->delete('external_applicable')
367
-			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)))
368
-			->andWhere($builder->expr()->eq('type', $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT)));
369
-
370
-		if (is_null($value)) {
371
-			$query = $query->andWhere($builder->expr()->isNull('value'));
372
-		} else {
373
-			$query = $query->andWhere($builder->expr()->eq('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR)));
374
-		}
375
-
376
-		$query->executeStatement();
377
-	}
378
-
379
-	private function getMountsFromQuery(IQueryBuilder $query) {
380
-		$result = $query->executeQuery();
381
-		$mounts = $result->fetchAll();
382
-		$uniqueMounts = [];
383
-		foreach ($mounts as $mount) {
384
-			$id = $mount['mount_id'];
385
-			if (!isset($uniqueMounts[$id])) {
386
-				$uniqueMounts[$id] = $mount;
387
-			}
388
-		}
389
-		$uniqueMounts = array_values($uniqueMounts);
390
-
391
-		$mountIds = array_map(function ($mount) {
392
-			return $mount['mount_id'];
393
-		}, $uniqueMounts);
394
-		$mountIds = array_values(array_unique($mountIds));
395
-
396
-		$applicable = $this->getApplicableForMounts($mountIds);
397
-		$config = $this->getConfigForMounts($mountIds);
398
-		$options = $this->getOptionsForMounts($mountIds);
399
-
400
-		return array_map(function ($mount, $applicable, $config, $options) {
401
-			$mount['type'] = (int)$mount['type'];
402
-			$mount['priority'] = (int)$mount['priority'];
403
-			$mount['applicable'] = $applicable;
404
-			$mount['config'] = $config;
405
-			$mount['options'] = $options;
406
-			return $mount;
407
-		}, $uniqueMounts, $applicable, $config, $options);
408
-	}
409
-
410
-	/**
411
-	 * Get mount options from a table grouped by mount id
412
-	 *
413
-	 * @param string $table
414
-	 * @param string[] $fields
415
-	 * @param int[] $mountIds
416
-	 * @return array [$mountId => [['field1' => $value1, ...], ...], ...]
417
-	 */
418
-	private function selectForMounts($table, array $fields, array $mountIds) {
419
-		if (count($mountIds) === 0) {
420
-			return [];
421
-		}
422
-		$builder = $this->connection->getQueryBuilder();
423
-		$fields[] = 'mount_id';
424
-		$placeHolders = array_map(function ($id) use ($builder) {
425
-			return $builder->createPositionalParameter($id, IQueryBuilder::PARAM_INT);
426
-		}, $mountIds);
427
-		$query = $builder->select($fields)
428
-			->from($table)
429
-			->where($builder->expr()->in('mount_id', $placeHolders));
430
-
431
-		$result = $query->executeQuery();
432
-		$rows = $result->fetchAll();
433
-		$result->closeCursor();
434
-
435
-		$result = [];
436
-		foreach ($mountIds as $mountId) {
437
-			$result[$mountId] = [];
438
-		}
439
-		foreach ($rows as $row) {
440
-			if (isset($row['type'])) {
441
-				$row['type'] = (int)$row['type'];
442
-			}
443
-			$result[$row['mount_id']][] = $row;
444
-		}
445
-		return $result;
446
-	}
447
-
448
-	/**
449
-	 * @param int[] $mountIds
450
-	 * @return array [$id => [['type' => $type, 'value' => $value], ...], ...]
451
-	 */
452
-	public function getApplicableForMounts($mountIds) {
453
-		return $this->selectForMounts('external_applicable', ['type', 'value'], $mountIds);
454
-	}
455
-
456
-	/**
457
-	 * @param int[] $mountIds
458
-	 * @return array [$id => ['key1' => $value1, ...], ...]
459
-	 */
460
-	public function getConfigForMounts($mountIds) {
461
-		$mountConfigs = $this->selectForMounts('external_config', ['key', 'value'], $mountIds);
462
-		return array_map([$this, 'createKeyValueMap'], $mountConfigs);
463
-	}
464
-
465
-	/**
466
-	 * @param int[] $mountIds
467
-	 * @return array [$id => ['key1' => $value1, ...], ...]
468
-	 */
469
-	public function getOptionsForMounts($mountIds) {
470
-		$mountOptions = $this->selectForMounts('external_options', ['key', 'value'], $mountIds);
471
-		$optionsMap = array_map([$this, 'createKeyValueMap'], $mountOptions);
472
-		return array_map(function (array $options) {
473
-			return array_map(function ($option) {
474
-				return json_decode($option);
475
-			}, $options);
476
-		}, $optionsMap);
477
-	}
478
-
479
-	/**
480
-	 * @param array $keyValuePairs [['key'=>$key, 'value=>$value], ...]
481
-	 * @return array ['key1' => $value1, ...]
482
-	 */
483
-	private function createKeyValueMap(array $keyValuePairs) {
484
-		$decryptedPairts = array_map(function ($pair) {
485
-			if ($pair['key'] === 'password') {
486
-				$pair['value'] = $this->decryptValue($pair['value']);
487
-			}
488
-			return $pair;
489
-		}, $keyValuePairs);
490
-		$keys = array_map(function ($pair) {
491
-			return $pair['key'];
492
-		}, $decryptedPairts);
493
-		$values = array_map(function ($pair) {
494
-			return $pair['value'];
495
-		}, $decryptedPairts);
496
-
497
-		return array_combine($keys, $values);
498
-	}
499
-
500
-	private function encryptValue($value) {
501
-		return $this->crypto->encrypt($value);
502
-	}
503
-
504
-	private function decryptValue($value) {
505
-		try {
506
-			return $this->crypto->decrypt($value);
507
-		} catch (\Exception $e) {
508
-			return $value;
509
-		}
510
-	}
511
-
512
-	/**
513
-	 * Check if any mountpoint is configured that overwrite the home folder
514
-	 */
515
-	public function hasHomeFolderOverwriteMount(): bool {
516
-		$builder = $this->connection->getQueryBuilder();
517
-		$query = $builder->select('mount_id')
518
-			->from('external_mounts')
519
-			->where($builder->expr()->eq('mount_point', $builder->createNamedParameter('/')))
520
-			->setMaxResults(1);
521
-		$result = $query->executeQuery();
522
-		return count($result->fetchAll()) > 0;
523
-	}
20
+    public const MOUNT_TYPE_ADMIN = 1;
21
+    public const MOUNT_TYPE_PERSONAL = 2;
22
+    /** @deprecated use MOUNT_TYPE_PERSONAL (full uppercase) instead */
23
+    public const MOUNT_TYPE_PERSONAl = 2;
24
+
25
+    public const APPLICABLE_TYPE_GLOBAL = 1;
26
+    public const APPLICABLE_TYPE_GROUP = 2;
27
+    public const APPLICABLE_TYPE_USER = 3;
28
+
29
+    public function __construct(
30
+        private IDBConnection $connection,
31
+        private ICrypto $crypto,
32
+    ) {
33
+    }
34
+
35
+    public function getMountById(int $mountId): ?array {
36
+        $builder = $this->connection->getQueryBuilder();
37
+        $query = $builder->select(['mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'type'])
38
+            ->from('external_mounts', 'm')
39
+            ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
40
+        $mounts = $this->getMountsFromQuery($query);
41
+        if (count($mounts) > 0) {
42
+            return $mounts[0];
43
+        } else {
44
+            return null;
45
+        }
46
+    }
47
+
48
+    /**
49
+     * Get all configured mounts
50
+     *
51
+     * @return array
52
+     */
53
+    public function getAllMounts() {
54
+        $builder = $this->connection->getQueryBuilder();
55
+        $query = $builder->select(['mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'type'])
56
+            ->from('external_mounts');
57
+        return $this->getMountsFromQuery($query);
58
+    }
59
+
60
+    public function getMountsForUser($userId, $groupIds) {
61
+        $builder = $this->connection->getQueryBuilder();
62
+        $query = $builder->select(['m.mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'm.type'])
63
+            ->from('external_mounts', 'm')
64
+            ->innerJoin('m', 'external_applicable', 'a', $builder->expr()->eq('m.mount_id', 'a.mount_id'))
65
+            ->where($builder->expr()->orX(
66
+                $builder->expr()->andX( // global mounts
67
+                    $builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_GLOBAL, IQueryBuilder::PARAM_INT)),
68
+                    $builder->expr()->isNull('a.value'),
69
+                ),
70
+                $builder->expr()->andX( // mounts for user
71
+                    $builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_USER, IQueryBuilder::PARAM_INT)),
72
+                    $builder->expr()->eq('a.value', $builder->createNamedParameter($userId)),
73
+                ),
74
+                $builder->expr()->andX( // mounts for group
75
+                    $builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_GROUP, IQueryBuilder::PARAM_INT)),
76
+                    $builder->expr()->in('a.value', $builder->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY)),
77
+                ),
78
+            ));
79
+
80
+        return $this->getMountsFromQuery($query);
81
+    }
82
+
83
+    public function modifyMountsOnUserDelete(string $uid): void {
84
+        $this->modifyMountsOnDelete($uid, self::APPLICABLE_TYPE_USER);
85
+    }
86
+
87
+    public function modifyMountsOnGroupDelete(string $gid): void {
88
+        $this->modifyMountsOnDelete($gid, self::APPLICABLE_TYPE_GROUP);
89
+    }
90
+
91
+    protected function modifyMountsOnDelete(string $applicableId, int $applicableType): void {
92
+        $builder = $this->connection->getQueryBuilder();
93
+        $query = $builder->select(['a.mount_id', $builder->func()->count('a.mount_id', 'count')])
94
+            ->from('external_applicable', 'a')
95
+            ->leftJoin('a', 'external_applicable', 'b', $builder->expr()->eq('a.mount_id', 'b.mount_id'))
96
+            ->where($builder->expr()->andX(
97
+                $builder->expr()->eq('b.type', $builder->createNamedParameter($applicableType, IQueryBuilder::PARAM_INT)),
98
+                $builder->expr()->eq('b.value', $builder->createNamedParameter($applicableId)),
99
+            ),
100
+            )
101
+            ->groupBy(['a.mount_id']);
102
+        $stmt = $query->executeQuery();
103
+        $result = $stmt->fetchAll();
104
+        $stmt->closeCursor();
105
+
106
+        foreach ($result as $row) {
107
+            if ((int)$row['count'] > 1) {
108
+                $this->removeApplicable($row['mount_id'], $applicableType, $applicableId);
109
+            } else {
110
+                $this->removeMount($row['mount_id']);
111
+            }
112
+        }
113
+    }
114
+
115
+    /**
116
+     * Get admin defined mounts
117
+     *
118
+     * @return array
119
+     */
120
+    public function getAdminMounts() {
121
+        $builder = $this->connection->getQueryBuilder();
122
+        $query = $builder->select(['mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'type'])
123
+            ->from('external_mounts')
124
+            ->where($builder->expr()->eq('type', $builder->expr()->literal(self::MOUNT_TYPE_ADMIN, IQueryBuilder::PARAM_INT)));
125
+        return $this->getMountsFromQuery($query);
126
+    }
127
+
128
+    protected function getForQuery(IQueryBuilder $builder, $type, $value) {
129
+        $query = $builder->select(['m.mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'm.type'])
130
+            ->from('external_mounts', 'm')
131
+            ->innerJoin('m', 'external_applicable', 'a', $builder->expr()->eq('m.mount_id', 'a.mount_id'))
132
+            ->where($builder->expr()->eq('a.type', $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT)));
133
+
134
+        if (is_null($value)) {
135
+            $query = $query->andWhere($builder->expr()->isNull('a.value'));
136
+        } else {
137
+            $query = $query->andWhere($builder->expr()->eq('a.value', $builder->createNamedParameter($value)));
138
+        }
139
+
140
+        return $query;
141
+    }
142
+
143
+    /**
144
+     * Get mounts by applicable
145
+     *
146
+     * @param int $type any of the self::APPLICABLE_TYPE_ constants
147
+     * @param string|null $value user_id, group_id or null for global mounts
148
+     * @return array
149
+     */
150
+    public function getMountsFor($type, $value) {
151
+        $builder = $this->connection->getQueryBuilder();
152
+        $query = $this->getForQuery($builder, $type, $value);
153
+
154
+        return $this->getMountsFromQuery($query);
155
+    }
156
+
157
+    /**
158
+     * Get admin defined mounts by applicable
159
+     *
160
+     * @param int $type any of the self::APPLICABLE_TYPE_ constants
161
+     * @param string|null $value user_id, group_id or null for global mounts
162
+     * @return array
163
+     */
164
+    public function getAdminMountsFor($type, $value) {
165
+        $builder = $this->connection->getQueryBuilder();
166
+        $query = $this->getForQuery($builder, $type, $value);
167
+        $query->andWhere($builder->expr()->eq('m.type', $builder->expr()->literal(self::MOUNT_TYPE_ADMIN, IQueryBuilder::PARAM_INT)));
168
+
169
+        return $this->getMountsFromQuery($query);
170
+    }
171
+
172
+    /**
173
+     * Get admin defined mounts for multiple applicable
174
+     *
175
+     * @param int $type any of the self::APPLICABLE_TYPE_ constants
176
+     * @param string[] $values user_ids or group_ids
177
+     * @return array
178
+     */
179
+    public function getAdminMountsForMultiple($type, array $values) {
180
+        $builder = $this->connection->getQueryBuilder();
181
+        $params = array_map(function ($value) use ($builder) {
182
+            return $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR);
183
+        }, $values);
184
+
185
+        $query = $builder->select(['m.mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'm.type'])
186
+            ->from('external_mounts', 'm')
187
+            ->innerJoin('m', 'external_applicable', 'a', $builder->expr()->eq('m.mount_id', 'a.mount_id'))
188
+            ->where($builder->expr()->eq('a.type', $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT)))
189
+            ->andWhere($builder->expr()->in('a.value', $params));
190
+        $query->andWhere($builder->expr()->eq('m.type', $builder->expr()->literal(self::MOUNT_TYPE_ADMIN, IQueryBuilder::PARAM_INT)));
191
+
192
+        return $this->getMountsFromQuery($query);
193
+    }
194
+
195
+    /**
196
+     * Get user defined mounts by applicable
197
+     *
198
+     * @param int $type any of the self::APPLICABLE_TYPE_ constants
199
+     * @param string|null $value user_id, group_id or null for global mounts
200
+     * @return array
201
+     */
202
+    public function getUserMountsFor($type, $value) {
203
+        $builder = $this->connection->getQueryBuilder();
204
+        $query = $this->getForQuery($builder, $type, $value);
205
+        $query->andWhere($builder->expr()->eq('m.type', $builder->expr()->literal(self::MOUNT_TYPE_PERSONAL, IQueryBuilder::PARAM_INT)));
206
+
207
+        return $this->getMountsFromQuery($query);
208
+    }
209
+
210
+    /**
211
+     * Add a mount to the database
212
+     *
213
+     * @param string $mountPoint
214
+     * @param string $storageBackend
215
+     * @param string $authBackend
216
+     * @param int $priority
217
+     * @param int $type self::MOUNT_TYPE_ADMIN or self::MOUNT_TYPE_PERSONAL
218
+     * @return int the id of the new mount
219
+     */
220
+    public function addMount($mountPoint, $storageBackend, $authBackend, $priority, $type) {
221
+        if (!$priority) {
222
+            $priority = 100;
223
+        }
224
+        $builder = $this->connection->getQueryBuilder();
225
+        $query = $builder->insert('external_mounts')
226
+            ->values([
227
+                'mount_point' => $builder->createNamedParameter($mountPoint, IQueryBuilder::PARAM_STR),
228
+                'storage_backend' => $builder->createNamedParameter($storageBackend, IQueryBuilder::PARAM_STR),
229
+                'auth_backend' => $builder->createNamedParameter($authBackend, IQueryBuilder::PARAM_STR),
230
+                'priority' => $builder->createNamedParameter($priority, IQueryBuilder::PARAM_INT),
231
+                'type' => $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT),
232
+            ]);
233
+        $query->executeStatement();
234
+        return $query->getLastInsertId();
235
+    }
236
+
237
+    /**
238
+     * Remove a mount from the database
239
+     *
240
+     * @param int $mountId
241
+     */
242
+    public function removeMount($mountId) {
243
+        $builder = $this->connection->getQueryBuilder();
244
+        $query = $builder->delete('external_mounts')
245
+            ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
246
+        $query->executeStatement();
247
+
248
+        $builder = $this->connection->getQueryBuilder();
249
+        $query = $builder->delete('external_applicable')
250
+            ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
251
+        $query->executeStatement();
252
+
253
+        $builder = $this->connection->getQueryBuilder();
254
+        $query = $builder->delete('external_config')
255
+            ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
256
+        $query->executeStatement();
257
+
258
+        $builder = $this->connection->getQueryBuilder();
259
+        $query = $builder->delete('external_options')
260
+            ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
261
+        $query->executeStatement();
262
+    }
263
+
264
+    /**
265
+     * @param int $mountId
266
+     * @param string $newMountPoint
267
+     */
268
+    public function setMountPoint($mountId, $newMountPoint) {
269
+        $builder = $this->connection->getQueryBuilder();
270
+
271
+        $query = $builder->update('external_mounts')
272
+            ->set('mount_point', $builder->createNamedParameter($newMountPoint))
273
+            ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
274
+
275
+        $query->executeStatement();
276
+    }
277
+
278
+    /**
279
+     * @param int $mountId
280
+     * @param string $newAuthBackend
281
+     */
282
+    public function setAuthBackend($mountId, $newAuthBackend) {
283
+        $builder = $this->connection->getQueryBuilder();
284
+
285
+        $query = $builder->update('external_mounts')
286
+            ->set('auth_backend', $builder->createNamedParameter($newAuthBackend))
287
+            ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
288
+
289
+        $query->executeStatement();
290
+    }
291
+
292
+    /**
293
+     * @param int $mountId
294
+     * @param string $key
295
+     * @param string $value
296
+     */
297
+    public function setConfig($mountId, $key, $value) {
298
+        if ($key === 'password') {
299
+            $value = $this->encryptValue($value);
300
+        }
301
+
302
+        try {
303
+            $builder = $this->connection->getQueryBuilder();
304
+            $builder->insert('external_config')
305
+                ->setValue('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))
306
+                ->setValue('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR))
307
+                ->setValue('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR))
308
+                ->executeStatement();
309
+        } catch (Exception $e) {
310
+            if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
311
+                throw $e;
312
+            }
313
+            $builder = $this->connection->getQueryBuilder();
314
+            $query = $builder->update('external_config')
315
+                ->set('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR))
316
+                ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)))
317
+                ->andWhere($builder->expr()->eq('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR)));
318
+            $query->executeStatement();
319
+        }
320
+    }
321
+
322
+    /**
323
+     * @param int $mountId
324
+     * @param string $key
325
+     * @param string $value
326
+     */
327
+    public function setOption($mountId, $key, $value) {
328
+        try {
329
+            $builder = $this->connection->getQueryBuilder();
330
+            $builder->insert('external_options')
331
+                ->setValue('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))
332
+                ->setValue('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR))
333
+                ->setValue('value', $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR))
334
+                ->executeStatement();
335
+        } catch (Exception $e) {
336
+            if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
337
+                throw $e;
338
+            }
339
+            $builder = $this->connection->getQueryBuilder();
340
+            $query = $builder->update('external_options')
341
+                ->set('value', $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR))
342
+                ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)))
343
+                ->andWhere($builder->expr()->eq('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR)));
344
+            $query->executeStatement();
345
+        }
346
+    }
347
+
348
+    public function addApplicable($mountId, $type, $value) {
349
+        try {
350
+            $builder = $this->connection->getQueryBuilder();
351
+            $builder->insert('external_applicable')
352
+                ->setValue('mount_id', $builder->createNamedParameter($mountId))
353
+                ->setValue('type', $builder->createNamedParameter($type))
354
+                ->setValue('value', $builder->createNamedParameter($value))
355
+                ->executeStatement();
356
+        } catch (Exception $e) {
357
+            // applicable exists already
358
+            if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
359
+                throw $e;
360
+            }
361
+        }
362
+    }
363
+
364
+    public function removeApplicable($mountId, $type, $value) {
365
+        $builder = $this->connection->getQueryBuilder();
366
+        $query = $builder->delete('external_applicable')
367
+            ->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)))
368
+            ->andWhere($builder->expr()->eq('type', $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT)));
369
+
370
+        if (is_null($value)) {
371
+            $query = $query->andWhere($builder->expr()->isNull('value'));
372
+        } else {
373
+            $query = $query->andWhere($builder->expr()->eq('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR)));
374
+        }
375
+
376
+        $query->executeStatement();
377
+    }
378
+
379
+    private function getMountsFromQuery(IQueryBuilder $query) {
380
+        $result = $query->executeQuery();
381
+        $mounts = $result->fetchAll();
382
+        $uniqueMounts = [];
383
+        foreach ($mounts as $mount) {
384
+            $id = $mount['mount_id'];
385
+            if (!isset($uniqueMounts[$id])) {
386
+                $uniqueMounts[$id] = $mount;
387
+            }
388
+        }
389
+        $uniqueMounts = array_values($uniqueMounts);
390
+
391
+        $mountIds = array_map(function ($mount) {
392
+            return $mount['mount_id'];
393
+        }, $uniqueMounts);
394
+        $mountIds = array_values(array_unique($mountIds));
395
+
396
+        $applicable = $this->getApplicableForMounts($mountIds);
397
+        $config = $this->getConfigForMounts($mountIds);
398
+        $options = $this->getOptionsForMounts($mountIds);
399
+
400
+        return array_map(function ($mount, $applicable, $config, $options) {
401
+            $mount['type'] = (int)$mount['type'];
402
+            $mount['priority'] = (int)$mount['priority'];
403
+            $mount['applicable'] = $applicable;
404
+            $mount['config'] = $config;
405
+            $mount['options'] = $options;
406
+            return $mount;
407
+        }, $uniqueMounts, $applicable, $config, $options);
408
+    }
409
+
410
+    /**
411
+     * Get mount options from a table grouped by mount id
412
+     *
413
+     * @param string $table
414
+     * @param string[] $fields
415
+     * @param int[] $mountIds
416
+     * @return array [$mountId => [['field1' => $value1, ...], ...], ...]
417
+     */
418
+    private function selectForMounts($table, array $fields, array $mountIds) {
419
+        if (count($mountIds) === 0) {
420
+            return [];
421
+        }
422
+        $builder = $this->connection->getQueryBuilder();
423
+        $fields[] = 'mount_id';
424
+        $placeHolders = array_map(function ($id) use ($builder) {
425
+            return $builder->createPositionalParameter($id, IQueryBuilder::PARAM_INT);
426
+        }, $mountIds);
427
+        $query = $builder->select($fields)
428
+            ->from($table)
429
+            ->where($builder->expr()->in('mount_id', $placeHolders));
430
+
431
+        $result = $query->executeQuery();
432
+        $rows = $result->fetchAll();
433
+        $result->closeCursor();
434
+
435
+        $result = [];
436
+        foreach ($mountIds as $mountId) {
437
+            $result[$mountId] = [];
438
+        }
439
+        foreach ($rows as $row) {
440
+            if (isset($row['type'])) {
441
+                $row['type'] = (int)$row['type'];
442
+            }
443
+            $result[$row['mount_id']][] = $row;
444
+        }
445
+        return $result;
446
+    }
447
+
448
+    /**
449
+     * @param int[] $mountIds
450
+     * @return array [$id => [['type' => $type, 'value' => $value], ...], ...]
451
+     */
452
+    public function getApplicableForMounts($mountIds) {
453
+        return $this->selectForMounts('external_applicable', ['type', 'value'], $mountIds);
454
+    }
455
+
456
+    /**
457
+     * @param int[] $mountIds
458
+     * @return array [$id => ['key1' => $value1, ...], ...]
459
+     */
460
+    public function getConfigForMounts($mountIds) {
461
+        $mountConfigs = $this->selectForMounts('external_config', ['key', 'value'], $mountIds);
462
+        return array_map([$this, 'createKeyValueMap'], $mountConfigs);
463
+    }
464
+
465
+    /**
466
+     * @param int[] $mountIds
467
+     * @return array [$id => ['key1' => $value1, ...], ...]
468
+     */
469
+    public function getOptionsForMounts($mountIds) {
470
+        $mountOptions = $this->selectForMounts('external_options', ['key', 'value'], $mountIds);
471
+        $optionsMap = array_map([$this, 'createKeyValueMap'], $mountOptions);
472
+        return array_map(function (array $options) {
473
+            return array_map(function ($option) {
474
+                return json_decode($option);
475
+            }, $options);
476
+        }, $optionsMap);
477
+    }
478
+
479
+    /**
480
+     * @param array $keyValuePairs [['key'=>$key, 'value=>$value], ...]
481
+     * @return array ['key1' => $value1, ...]
482
+     */
483
+    private function createKeyValueMap(array $keyValuePairs) {
484
+        $decryptedPairts = array_map(function ($pair) {
485
+            if ($pair['key'] === 'password') {
486
+                $pair['value'] = $this->decryptValue($pair['value']);
487
+            }
488
+            return $pair;
489
+        }, $keyValuePairs);
490
+        $keys = array_map(function ($pair) {
491
+            return $pair['key'];
492
+        }, $decryptedPairts);
493
+        $values = array_map(function ($pair) {
494
+            return $pair['value'];
495
+        }, $decryptedPairts);
496
+
497
+        return array_combine($keys, $values);
498
+    }
499
+
500
+    private function encryptValue($value) {
501
+        return $this->crypto->encrypt($value);
502
+    }
503
+
504
+    private function decryptValue($value) {
505
+        try {
506
+            return $this->crypto->decrypt($value);
507
+        } catch (\Exception $e) {
508
+            return $value;
509
+        }
510
+    }
511
+
512
+    /**
513
+     * Check if any mountpoint is configured that overwrite the home folder
514
+     */
515
+    public function hasHomeFolderOverwriteMount(): bool {
516
+        $builder = $this->connection->getQueryBuilder();
517
+        $query = $builder->select('mount_id')
518
+            ->from('external_mounts')
519
+            ->where($builder->expr()->eq('mount_point', $builder->createNamedParameter('/')))
520
+            ->setMaxResults(1);
521
+        $result = $query->executeQuery();
522
+        return count($result->fetchAll()) > 0;
523
+    }
524 524
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Settings/Personal.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
 use OCP\WorkflowEngine\IManager;
29 29
 
30 30
 class Personal extends ASettings {
31
-	public function getScope(): int {
32
-		return IManager::SCOPE_USER;
33
-	}
31
+    public function getScope(): int {
32
+        return IManager::SCOPE_USER;
33
+    }
34 34
 
35
-	public function getSection(): ?string {
36
-		return $this->manager->isUserScopeEnabled() ? 'workflow' : null;
37
-	}
35
+    public function getSection(): ?string {
36
+        return $this->manager->isUserScopeEnabled() ? 'workflow' : null;
37
+    }
38 38
 }
Please login to merge, or discard this patch.
lib/public/DB/QueryBuilder/ICompositeExpression.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -29,39 +29,39 @@
 block discarded – undo
29 29
  * @since 8.2.0
30 30
  */
31 31
 interface ICompositeExpression {
32
-	/**
33
-	 * Adds multiple parts to composite expression.
34
-	 *
35
-	 * @param array $parts
36
-	 *
37
-	 * @return ICompositeExpression
38
-	 * @since 8.2.0
39
-	 */
40
-	public function addMultiple(array $parts = []): ICompositeExpression;
32
+    /**
33
+     * Adds multiple parts to composite expression.
34
+     *
35
+     * @param array $parts
36
+     *
37
+     * @return ICompositeExpression
38
+     * @since 8.2.0
39
+     */
40
+    public function addMultiple(array $parts = []): ICompositeExpression;
41 41
 
42
-	/**
43
-	 * Adds an expression to composite expression.
44
-	 *
45
-	 * @param mixed $part
46
-	 *
47
-	 * @return ICompositeExpression
48
-	 * @since 8.2.0
49
-	 */
50
-	public function add($part): ICompositeExpression;
42
+    /**
43
+     * Adds an expression to composite expression.
44
+     *
45
+     * @param mixed $part
46
+     *
47
+     * @return ICompositeExpression
48
+     * @since 8.2.0
49
+     */
50
+    public function add($part): ICompositeExpression;
51 51
 
52
-	/**
53
-	 * Retrieves the amount of expressions on composite expression.
54
-	 *
55
-	 * @return integer
56
-	 * @since 8.2.0
57
-	 */
58
-	public function count(): int;
52
+    /**
53
+     * Retrieves the amount of expressions on composite expression.
54
+     *
55
+     * @return integer
56
+     * @since 8.2.0
57
+     */
58
+    public function count(): int;
59 59
 
60
-	/**
61
-	 * Returns the type of this composite expression (AND/OR).
62
-	 *
63
-	 * @return string
64
-	 * @since 8.2.0
65
-	 */
66
-	public function getType(): string;
60
+    /**
61
+     * Returns the type of this composite expression (AND/OR).
62
+     *
63
+     * @return string
64
+     * @since 8.2.0
65
+     */
66
+    public function getType(): string;
67 67
 }
Please login to merge, or discard this patch.
core/Command/Group/Info.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 		$gid = $input->getArgument('groupid');
68 68
 		$group = $this->groupManager->get($gid);
69 69
 		if (!$group instanceof IGroup) {
70
-			$output->writeln('<error>Group "' . $gid . '" does not exist.</error>');
70
+			$output->writeln('<error>Group "'.$gid.'" does not exist.</error>');
71 71
 			return 1;
72 72
 		} else {
73 73
 			$groupOutput = [
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -35,56 +35,56 @@
 block discarded – undo
35 35
 use Symfony\Component\Console\Output\OutputInterface;
36 36
 
37 37
 class Info extends Base {
38
-	public function __construct(
39
-		protected IGroupManager $groupManager,
40
-	) {
41
-		parent::__construct();
42
-	}
38
+    public function __construct(
39
+        protected IGroupManager $groupManager,
40
+    ) {
41
+        parent::__construct();
42
+    }
43 43
 
44
-	protected function configure() {
45
-		$this
46
-			->setName('group:info')
47
-			->setDescription('Show information about a group')
48
-			->addArgument(
49
-				'groupid',
50
-				InputArgument::REQUIRED,
51
-				'Group id'
52
-			)->addOption(
53
-				'output',
54
-				null,
55
-				InputOption::VALUE_OPTIONAL,
56
-				'Output format (plain, json or json_pretty, default is plain)',
57
-				$this->defaultOutputFormat
58
-			);
59
-	}
44
+    protected function configure() {
45
+        $this
46
+            ->setName('group:info')
47
+            ->setDescription('Show information about a group')
48
+            ->addArgument(
49
+                'groupid',
50
+                InputArgument::REQUIRED,
51
+                'Group id'
52
+            )->addOption(
53
+                'output',
54
+                null,
55
+                InputOption::VALUE_OPTIONAL,
56
+                'Output format (plain, json or json_pretty, default is plain)',
57
+                $this->defaultOutputFormat
58
+            );
59
+    }
60 60
 
61
-	protected function execute(InputInterface $input, OutputInterface $output): int {
62
-		$gid = $input->getArgument('groupid');
63
-		$group = $this->groupManager->get($gid);
64
-		if (!$group instanceof IGroup) {
65
-			$output->writeln('<error>Group "' . $gid . '" does not exist.</error>');
66
-			return 1;
67
-		} else {
68
-			$groupOutput = [
69
-				'groupID' => $gid,
70
-				'displayName' => $group->getDisplayName(),
71
-				'backends' => $group->getBackendNames(),
72
-			];
61
+    protected function execute(InputInterface $input, OutputInterface $output): int {
62
+        $gid = $input->getArgument('groupid');
63
+        $group = $this->groupManager->get($gid);
64
+        if (!$group instanceof IGroup) {
65
+            $output->writeln('<error>Group "' . $gid . '" does not exist.</error>');
66
+            return 1;
67
+        } else {
68
+            $groupOutput = [
69
+                'groupID' => $gid,
70
+                'displayName' => $group->getDisplayName(),
71
+                'backends' => $group->getBackendNames(),
72
+            ];
73 73
 
74
-			$this->writeArrayInOutputFormat($input, $output, $groupOutput);
75
-			return 0;
76
-		}
77
-	}
74
+            $this->writeArrayInOutputFormat($input, $output, $groupOutput);
75
+            return 0;
76
+        }
77
+    }
78 78
 
79
-	/**
80
-	 * @param string $argumentName
81
-	 * @param CompletionContext $context
82
-	 * @return string[]
83
-	 */
84
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
85
-		if ($argumentName === 'groupid') {
86
-			return array_map(static fn (IGroup $group) => $group->getGID(), $this->groupManager->search($context->getCurrentWord()));
87
-		}
88
-		return [];
89
-	}
79
+    /**
80
+     * @param string $argumentName
81
+     * @param CompletionContext $context
82
+     * @return string[]
83
+     */
84
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
85
+        if ($argumentName === 'groupid') {
86
+            return array_map(static fn (IGroup $group) => $group->getGID(), $this->groupManager->search($context->getCurrentWord()));
87
+        }
88
+        return [];
89
+    }
90 90
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/Entry.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * sort the actions by priority and name
118 118
 	 */
119 119
 	private function sortActions(): void {
120
-		usort($this->actions, function (IAction $action1, IAction $action2) {
120
+		usort($this->actions, function(IAction $action1, IAction $action2) {
121 121
 			$prio1 = $action1->getPriority();
122 122
 			$prio2 = $action2->getPriority();
123 123
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public function jsonSerialize(): array {
156 156
 		$topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null;
157
-		$otherActions = array_map(function (IAction $action) {
157
+		$otherActions = array_map(function(IAction $action) {
158 158
 			return $action->jsonSerialize();
159 159
 		}, array_slice($this->actions, 1));
160 160
 
Please login to merge, or discard this patch.
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -14,170 +14,170 @@
 block discarded – undo
14 14
 use function array_merge;
15 15
 
16 16
 class Entry implements IEntry {
17
-	public const PROPERTY_STATUS_MESSAGE_TIMESTAMP = 'statusMessageTimestamp';
18
-
19
-	/** @var string|int|null */
20
-	private $id = null;
21
-
22
-	private string $fullName = '';
23
-
24
-	/** @var string[] */
25
-	private array $emailAddresses = [];
26
-
27
-	private ?string $avatar = null;
28
-
29
-	private ?string $profileTitle = null;
30
-
31
-	private ?string $profileUrl = null;
32
-
33
-	/** @var IAction[] */
34
-	private array $actions = [];
35
-
36
-	private array $properties = [];
37
-
38
-	private ?string $status = null;
39
-	private ?string $statusMessage = null;
40
-	private ?int $statusMessageTimestamp = null;
41
-	private ?string $statusIcon = null;
42
-
43
-	public function setId(string $id): void {
44
-		$this->id = $id;
45
-	}
46
-
47
-	public function setFullName(string $displayName): void {
48
-		$this->fullName = $displayName;
49
-	}
50
-
51
-	public function getFullName(): string {
52
-		return $this->fullName;
53
-	}
54
-
55
-	public function addEMailAddress(string $address): void {
56
-		$this->emailAddresses[] = $address;
57
-	}
58
-
59
-	/**
60
-	 * @return string[]
61
-	 */
62
-	public function getEMailAddresses(): array {
63
-		return $this->emailAddresses;
64
-	}
65
-
66
-	public function setAvatar(string $avatar): void {
67
-		$this->avatar = $avatar;
68
-	}
69
-
70
-	public function getAvatar(): ?string {
71
-		return $this->avatar;
72
-	}
73
-
74
-	public function setProfileTitle(string $profileTitle): void {
75
-		$this->profileTitle = $profileTitle;
76
-	}
77
-
78
-	public function getProfileTitle(): ?string {
79
-		return $this->profileTitle;
80
-	}
81
-
82
-	public function setProfileUrl(string $profileUrl): void {
83
-		$this->profileUrl = $profileUrl;
84
-	}
85
-
86
-	public function getProfileUrl(): ?string {
87
-		return $this->profileUrl;
88
-	}
89
-
90
-	public function addAction(IAction $action): void {
91
-		$this->actions[] = $action;
92
-		$this->sortActions();
93
-	}
94
-
95
-	public function setStatus(string $status,
96
-		?string $statusMessage = null,
97
-		?int $statusMessageTimestamp = null,
98
-		?string $icon = null): void {
99
-		$this->status = $status;
100
-		$this->statusMessage = $statusMessage;
101
-		$this->statusMessageTimestamp = $statusMessageTimestamp;
102
-		$this->statusIcon = $icon;
103
-	}
104
-
105
-	/**
106
-	 * @return IAction[]
107
-	 */
108
-	public function getActions(): array {
109
-		return $this->actions;
110
-	}
111
-
112
-	/**
113
-	 * sort the actions by priority and name
114
-	 */
115
-	private function sortActions(): void {
116
-		usort($this->actions, function (IAction $action1, IAction $action2) {
117
-			$prio1 = $action1->getPriority();
118
-			$prio2 = $action2->getPriority();
119
-
120
-			if ($prio1 === $prio2) {
121
-				// Ascending order for same priority
122
-				return strcasecmp($action1->getName(), $action2->getName());
123
-			}
124
-
125
-			// Descending order when priority differs
126
-			return $prio2 - $prio1;
127
-		});
128
-	}
129
-
130
-	public function setProperty(string $propertyName, mixed $value) {
131
-		$this->properties[$propertyName] = $value;
132
-	}
133
-
134
-	/**
135
-	 * @param array $properties key-value array containing additional properties
136
-	 */
137
-	public function setProperties(array $properties): void {
138
-		$this->properties = array_merge($this->properties, $properties);
139
-	}
140
-
141
-	public function getProperty(string $key): mixed {
142
-		if (!isset($this->properties[$key])) {
143
-			return null;
144
-		}
145
-		return $this->properties[$key];
146
-	}
147
-
148
-	/**
149
-	 * @return array{id: int|string|null, fullName: string, avatar: string|null, topAction: mixed, actions: array, lastMessage: '', emailAddresses: string[], profileTitle: string|null, profileUrl: string|null, status: string|null, statusMessage: null|string, statusMessageTimestamp: null|int, statusIcon: null|string, isUser: bool, uid: mixed}
150
-	 */
151
-	public function jsonSerialize(): array {
152
-		$topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null;
153
-		$otherActions = array_map(function (IAction $action) {
154
-			return $action->jsonSerialize();
155
-		}, array_slice($this->actions, 1));
156
-
157
-		return [
158
-			'id' => $this->id,
159
-			'fullName' => $this->fullName,
160
-			'avatar' => $this->getAvatar(),
161
-			'topAction' => $topAction,
162
-			'actions' => $otherActions,
163
-			'lastMessage' => '',
164
-			'emailAddresses' => $this->getEMailAddresses(),
165
-			'profileTitle' => $this->profileTitle,
166
-			'profileUrl' => $this->profileUrl,
167
-			'status' => $this->status,
168
-			'statusMessage' => $this->statusMessage,
169
-			'statusMessageTimestamp' => $this->statusMessageTimestamp,
170
-			'statusIcon' => $this->statusIcon,
171
-			'isUser' => $this->getProperty('isUser') === true,
172
-			'uid' => $this->getProperty('UID'),
173
-		];
174
-	}
175
-
176
-	public function getStatusMessage(): ?string {
177
-		return $this->statusMessage;
178
-	}
179
-
180
-	public function getStatusMessageTimestamp(): ?int {
181
-		return $this->statusMessageTimestamp;
182
-	}
17
+    public const PROPERTY_STATUS_MESSAGE_TIMESTAMP = 'statusMessageTimestamp';
18
+
19
+    /** @var string|int|null */
20
+    private $id = null;
21
+
22
+    private string $fullName = '';
23
+
24
+    /** @var string[] */
25
+    private array $emailAddresses = [];
26
+
27
+    private ?string $avatar = null;
28
+
29
+    private ?string $profileTitle = null;
30
+
31
+    private ?string $profileUrl = null;
32
+
33
+    /** @var IAction[] */
34
+    private array $actions = [];
35
+
36
+    private array $properties = [];
37
+
38
+    private ?string $status = null;
39
+    private ?string $statusMessage = null;
40
+    private ?int $statusMessageTimestamp = null;
41
+    private ?string $statusIcon = null;
42
+
43
+    public function setId(string $id): void {
44
+        $this->id = $id;
45
+    }
46
+
47
+    public function setFullName(string $displayName): void {
48
+        $this->fullName = $displayName;
49
+    }
50
+
51
+    public function getFullName(): string {
52
+        return $this->fullName;
53
+    }
54
+
55
+    public function addEMailAddress(string $address): void {
56
+        $this->emailAddresses[] = $address;
57
+    }
58
+
59
+    /**
60
+     * @return string[]
61
+     */
62
+    public function getEMailAddresses(): array {
63
+        return $this->emailAddresses;
64
+    }
65
+
66
+    public function setAvatar(string $avatar): void {
67
+        $this->avatar = $avatar;
68
+    }
69
+
70
+    public function getAvatar(): ?string {
71
+        return $this->avatar;
72
+    }
73
+
74
+    public function setProfileTitle(string $profileTitle): void {
75
+        $this->profileTitle = $profileTitle;
76
+    }
77
+
78
+    public function getProfileTitle(): ?string {
79
+        return $this->profileTitle;
80
+    }
81
+
82
+    public function setProfileUrl(string $profileUrl): void {
83
+        $this->profileUrl = $profileUrl;
84
+    }
85
+
86
+    public function getProfileUrl(): ?string {
87
+        return $this->profileUrl;
88
+    }
89
+
90
+    public function addAction(IAction $action): void {
91
+        $this->actions[] = $action;
92
+        $this->sortActions();
93
+    }
94
+
95
+    public function setStatus(string $status,
96
+        ?string $statusMessage = null,
97
+        ?int $statusMessageTimestamp = null,
98
+        ?string $icon = null): void {
99
+        $this->status = $status;
100
+        $this->statusMessage = $statusMessage;
101
+        $this->statusMessageTimestamp = $statusMessageTimestamp;
102
+        $this->statusIcon = $icon;
103
+    }
104
+
105
+    /**
106
+     * @return IAction[]
107
+     */
108
+    public function getActions(): array {
109
+        return $this->actions;
110
+    }
111
+
112
+    /**
113
+     * sort the actions by priority and name
114
+     */
115
+    private function sortActions(): void {
116
+        usort($this->actions, function (IAction $action1, IAction $action2) {
117
+            $prio1 = $action1->getPriority();
118
+            $prio2 = $action2->getPriority();
119
+
120
+            if ($prio1 === $prio2) {
121
+                // Ascending order for same priority
122
+                return strcasecmp($action1->getName(), $action2->getName());
123
+            }
124
+
125
+            // Descending order when priority differs
126
+            return $prio2 - $prio1;
127
+        });
128
+    }
129
+
130
+    public function setProperty(string $propertyName, mixed $value) {
131
+        $this->properties[$propertyName] = $value;
132
+    }
133
+
134
+    /**
135
+     * @param array $properties key-value array containing additional properties
136
+     */
137
+    public function setProperties(array $properties): void {
138
+        $this->properties = array_merge($this->properties, $properties);
139
+    }
140
+
141
+    public function getProperty(string $key): mixed {
142
+        if (!isset($this->properties[$key])) {
143
+            return null;
144
+        }
145
+        return $this->properties[$key];
146
+    }
147
+
148
+    /**
149
+     * @return array{id: int|string|null, fullName: string, avatar: string|null, topAction: mixed, actions: array, lastMessage: '', emailAddresses: string[], profileTitle: string|null, profileUrl: string|null, status: string|null, statusMessage: null|string, statusMessageTimestamp: null|int, statusIcon: null|string, isUser: bool, uid: mixed}
150
+     */
151
+    public function jsonSerialize(): array {
152
+        $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null;
153
+        $otherActions = array_map(function (IAction $action) {
154
+            return $action->jsonSerialize();
155
+        }, array_slice($this->actions, 1));
156
+
157
+        return [
158
+            'id' => $this->id,
159
+            'fullName' => $this->fullName,
160
+            'avatar' => $this->getAvatar(),
161
+            'topAction' => $topAction,
162
+            'actions' => $otherActions,
163
+            'lastMessage' => '',
164
+            'emailAddresses' => $this->getEMailAddresses(),
165
+            'profileTitle' => $this->profileTitle,
166
+            'profileUrl' => $this->profileUrl,
167
+            'status' => $this->status,
168
+            'statusMessage' => $this->statusMessage,
169
+            'statusMessageTimestamp' => $this->statusMessageTimestamp,
170
+            'statusIcon' => $this->statusIcon,
171
+            'isUser' => $this->getProperty('isUser') === true,
172
+            'uid' => $this->getProperty('UID'),
173
+        ];
174
+    }
175
+
176
+    public function getStatusMessage(): ?string {
177
+        return $this->statusMessage;
178
+    }
179
+
180
+    public function getStatusMessageTimestamp(): ?int {
181
+        return $this->statusMessageTimestamp;
182
+    }
183 183
 }
Please login to merge, or discard this patch.
apps/admin_audit/lib/Actions/Trashbin.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@
 block discarded – undo
29 29
 namespace OCA\AdminAudit\Actions;
30 30
 
31 31
 class Trashbin extends Action {
32
-	public function delete(array $params): void {
33
-		$this->log('File "%s" deleted from trash bin.',
34
-			['path' => $params['path']], ['path']
35
-		);
36
-	}
32
+    public function delete(array $params): void {
33
+        $this->log('File "%s" deleted from trash bin.',
34
+            ['path' => $params['path']], ['path']
35
+        );
36
+    }
37 37
 
38
-	public function restore(array $params): void {
39
-		$this->log('File "%s" restored from trash bin.',
40
-			['path' => $params['filePath']], ['path']
41
-		);
42
-	}
38
+    public function restore(array $params): void {
39
+        $this->log('File "%s" restored from trash bin.',
40
+            ['path' => $params['filePath']], ['path']
41
+        );
42
+    }
43 43
 }
Please login to merge, or discard this patch.
lib/public/Share/Exceptions/AlreadySharedException.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@
 block discarded – undo
29 29
  * @since 22.0.0
30 30
  */
31 31
 class AlreadySharedException extends GenericShareException {
32
-	/** @var IShare */
33
-	private $existingShare;
32
+    /** @var IShare */
33
+    private $existingShare;
34 34
 
35
-	/**
36
-	 * @since 22.0.0
37
-	 */
38
-	public function __construct(string $message, IShare $existingShare) {
39
-		parent::__construct($message);
35
+    /**
36
+     * @since 22.0.0
37
+     */
38
+    public function __construct(string $message, IShare $existingShare) {
39
+        parent::__construct($message);
40 40
 
41
-		$this->existingShare = $existingShare;
42
-	}
41
+        $this->existingShare = $existingShare;
42
+    }
43 43
 
44
-	/**
45
-	 * @since 22.0.0
46
-	 */
47
-	public function getExistingShare(): IShare {
48
-		return $this->existingShare;
49
-	}
44
+    /**
45
+     * @since 22.0.0
46
+     */
47
+    public function getExistingShare(): IShare {
48
+        return $this->existingShare;
49
+    }
50 50
 }
Please login to merge, or discard this patch.
apps/provisioning_api/lib/AppInfo/Application.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	public function register(IRegistrationContext $context): void {
61 61
 		$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
62 62
 
63
-		$context->registerService(NewUserMailHelper::class, function (ContainerInterface $c) {
63
+		$context->registerService(NewUserMailHelper::class, function(ContainerInterface $c) {
64 64
 			return new NewUserMailHelper(
65 65
 				$c->get(Defaults::class),
66 66
 				$c->get(IURLGenerator::class),
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 				Util::getDefaultEmailAddress('no-reply')
74 74
 			);
75 75
 		});
76
-		$context->registerService(ProvisioningApiMiddleware::class, function (ContainerInterface $c) {
76
+		$context->registerService(ProvisioningApiMiddleware::class, function(ContainerInterface $c) {
77 77
 			$user = $c->get(IUserManager::class)->get($c->get('UserId'));
78 78
 			$isAdmin = false;
79 79
 			$isSubAdmin = false;
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -54,48 +54,48 @@
 block discarded – undo
54 54
 use Psr\Container\ContainerInterface;
55 55
 
56 56
 class Application extends App implements IBootstrap {
57
-	public function __construct(array $urlParams = []) {
58
-		parent::__construct('provisioning_api', $urlParams);
59
-	}
57
+    public function __construct(array $urlParams = []) {
58
+        parent::__construct('provisioning_api', $urlParams);
59
+    }
60 60
 
61
-	public function register(IRegistrationContext $context): void {
62
-		$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
61
+    public function register(IRegistrationContext $context): void {
62
+        $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
63 63
 
64
-		$context->registerService(NewUserMailHelper::class, function (ContainerInterface $c) {
65
-			return new NewUserMailHelper(
66
-				$c->get(Defaults::class),
67
-				$c->get(IURLGenerator::class),
68
-				$c->get(IFactory::class),
69
-				$c->get(IMailer::class),
70
-				$c->get(ISecureRandom::class),
71
-				$c->get(ITimeFactory::class),
72
-				$c->get(IConfig::class),
73
-				$c->get(ICrypto::class),
74
-				Util::getDefaultEmailAddress('no-reply')
75
-			);
76
-		});
77
-		$context->registerService(ProvisioningApiMiddleware::class, function (ContainerInterface $c) {
78
-			$user = $c->get(IUserManager::class)->get($c->get('UserId'));
79
-			$isAdmin = false;
80
-			$isSubAdmin = false;
64
+        $context->registerService(NewUserMailHelper::class, function (ContainerInterface $c) {
65
+            return new NewUserMailHelper(
66
+                $c->get(Defaults::class),
67
+                $c->get(IURLGenerator::class),
68
+                $c->get(IFactory::class),
69
+                $c->get(IMailer::class),
70
+                $c->get(ISecureRandom::class),
71
+                $c->get(ITimeFactory::class),
72
+                $c->get(IConfig::class),
73
+                $c->get(ICrypto::class),
74
+                Util::getDefaultEmailAddress('no-reply')
75
+            );
76
+        });
77
+        $context->registerService(ProvisioningApiMiddleware::class, function (ContainerInterface $c) {
78
+            $user = $c->get(IUserManager::class)->get($c->get('UserId'));
79
+            $isAdmin = false;
80
+            $isSubAdmin = false;
81 81
 
82
-			if ($user instanceof IUser) {
83
-				$groupManager = $c->get(IGroupManager::class);
84
-				assert($groupManager instanceof GroupManager);
85
-				$isAdmin = $groupManager->isAdmin($user->getUID());
86
-				$isSubAdmin = $groupManager->getSubAdmin()->isSubAdmin($user);
87
-			}
82
+            if ($user instanceof IUser) {
83
+                $groupManager = $c->get(IGroupManager::class);
84
+                assert($groupManager instanceof GroupManager);
85
+                $isAdmin = $groupManager->isAdmin($user->getUID());
86
+                $isSubAdmin = $groupManager->getSubAdmin()->isSubAdmin($user);
87
+            }
88 88
 
89
-			return new ProvisioningApiMiddleware(
90
-				$c->get(IControllerMethodReflector::class),
91
-				$isAdmin,
92
-				$isSubAdmin
93
-			);
94
-		});
95
-		$context->registerMiddleware(ProvisioningApiMiddleware::class);
96
-		$context->registerCapability(Capabilities::class);
97
-	}
89
+            return new ProvisioningApiMiddleware(
90
+                $c->get(IControllerMethodReflector::class),
91
+                $isAdmin,
92
+                $isSubAdmin
93
+            );
94
+        });
95
+        $context->registerMiddleware(ProvisioningApiMiddleware::class);
96
+        $context->registerCapability(Capabilities::class);
97
+    }
98 98
 
99
-	public function boot(IBootContext $context): void {
100
-	}
99
+    public function boot(IBootContext $context): void {
100
+    }
101 101
 }
Please login to merge, or discard this patch.