Completed
Push — master ( fde08a...208e38 )
by Blizzz
17:49
created
settings/Controller/GroupsController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
 	 * @return DataResponse
102 102
 	 */
103 103
 	public function create($id) {
104
-		if($this->groupManager->groupExists($id)) {
104
+		if ($this->groupManager->groupExists($id)) {
105 105
 			return new DataResponse(
106 106
 				array(
107
-					'message' => (string)$this->l10n->t('Group already exists.')
107
+					'message' => (string) $this->l10n->t('Group already exists.')
108 108
 				),
109 109
 				Http::STATUS_CONFLICT
110 110
 			);
111 111
 		}
112 112
 		$group = $this->groupManager->createGroup($id);
113
-		if($group instanceof IGroup) {
113
+		if ($group instanceof IGroup) {
114 114
 			return new DataResponse(['groupname' => $group->getDisplayName()], Http::STATUS_CREATED);
115 115
 		}
116 116
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			array(
119 119
 				'status' => 'error',
120 120
 				'data' => array(
121
-					'message' => (string)$this->l10n->t('Unable to add group.')
121
+					'message' => (string) $this->l10n->t('Unable to add group.')
122 122
 				)
123 123
 			),
124 124
 			Http::STATUS_FORBIDDEN
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			array(
148 148
 				'status' => 'error',
149 149
 				'data' => array(
150
-					'message' => (string)$this->l10n->t('Unable to delete group.')
150
+					'message' => (string) $this->l10n->t('Unable to delete group.')
151 151
 				),
152 152
 			),
153 153
 			Http::STATUS_FORBIDDEN
Please login to merge, or discard this patch.
settings/templates/users/part.grouplist.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	</li>
27 27
 
28 28
 	<!-- The Admin Group -->
29
-	<?php foreach($_["adminGroup"] as $adminGroup): ?>
30
-		<li data-gid="admin" data-usercount="<?php if($adminGroup['usercount'] > 0) { p($adminGroup['usercount']); } ?>" class="isgroup">
29
+	<?php foreach ($_["adminGroup"] as $adminGroup): ?>
30
+		<li data-gid="admin" data-usercount="<?php if ($adminGroup['usercount'] > 0) { p($adminGroup['usercount']); } ?>" class="isgroup">
31 31
 			<a href="#"><span class="groupname"><?php p($l->t('Admins')); ?></span></a>
32 32
 			<div class="app-navigation-entry-utils">
33 33
 				<ul>
34
-					<li class="app-navigation-entry-utils-counter"><?php if($adminGroup['usercount'] > 0) { p($adminGroup['usercount']); } ?></li>
34
+					<li class="app-navigation-entry-utils-counter"><?php if ($adminGroup['usercount'] > 0) { p($adminGroup['usercount']); } ?></li>
35 35
 				</ul>
36 36
 			</div>
37 37
 		</li>
@@ -39,25 +39,25 @@  discard block
 block discarded – undo
39 39
 
40 40
 	<!-- Disabled Users -->
41 41
 	<?php $disabledUsersGroup = $_["disabledUsersGroup"] ?>
42
-	<li data-gid="_disabledUsers" data-usercount="<?php if($disabledUsersGroup['usercount'] > 0) { p($disabledUsersGroup['usercount']); } ?>" class="isgroup">
42
+	<li data-gid="_disabledUsers" data-usercount="<?php if ($disabledUsersGroup['usercount'] > 0) { p($disabledUsersGroup['usercount']); } ?>" class="isgroup">
43 43
 		<a href="#"><span class="groupname"><?php p($l->t('Disabled')); ?></span></a>
44 44
 		<div class="app-navigation-entry-utils">
45 45
 			<ul>
46
-				<li class="app-navigation-entry-utils-counter"><?php if($disabledUsersGroup['usercount'] > 0) { p($disabledUsersGroup['usercount']); } ?></li>
46
+				<li class="app-navigation-entry-utils-counter"><?php if ($disabledUsersGroup['usercount'] > 0) { p($disabledUsersGroup['usercount']); } ?></li>
47 47
 			</ul>
48 48
 		</div>
49 49
 	</li>
50 50
 
51 51
 	<!--List of Groups-->
52
-	<?php foreach($_["groups"] as $group): ?>
52
+	<?php foreach ($_["groups"] as $group): ?>
53 53
 		<li data-gid="<?php p($group['id']) ?>" data-usercount="<?php p($group['usercount']) ?>" class="isgroup">
54 54
 			<a href="#" class="dorename">
55 55
 				<span class="groupname"><?php p($group['name']); ?></span>
56 56
 			</a>
57 57
 			<div class="app-navigation-entry-utils">
58 58
 				<ul>
59
-					<li class="app-navigation-entry-utils-counter"><?php if($group['usercount'] > 0) { p($group['usercount']); } ?></li>
60
-				 	<?php if($_['isAdmin']): ?>
59
+					<li class="app-navigation-entry-utils-counter"><?php if ($group['usercount'] > 0) { p($group['usercount']); } ?></li>
60
+				 	<?php if ($_['isAdmin']): ?>
61 61
 				 		<li class="app-navigation-entry-utils-menu-button delete">
62 62
 							<button class="icon-delete"></button>
63 63
 						</li>
Please login to merge, or discard this patch.
settings/templates/users/main.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 style('settings', 'settings');
20 20
 
21 21
 $userlistParams = array();
22
-$allGroups=array();
23
-foreach($_["adminGroup"] as $group) {
22
+$allGroups = array();
23
+foreach ($_["adminGroup"] as $group) {
24 24
 	$allGroups[$group['id']] = array('displayName' => $group['name']);
25 25
 }
26
-foreach($_["groups"] as $group) {
26
+foreach ($_["groups"] as $group) {
27 27
 	$allGroups[$group['id']] = array('displayName' => $group['name']);
28 28
 }
29 29
 $userlistParams['subadmingroups'] = $allGroups;
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	<?php print_unescaped($this->inc('users/part.grouplist')); ?>
41 41
 	<div id="app-settings">
42 42
 		<div id="app-settings-header">
43
-			<button class="settings-button" tabindex="0" data-apps-slide-toggle="#app-settings-content"><?php p($l->t('Settings'));?></button>
43
+			<button class="settings-button" tabindex="0" data-apps-slide-toggle="#app-settings-content"><?php p($l->t('Settings')); ?></button>
44 44
 		</div>
45 45
 		<div id="app-settings-content">
46 46
 			<?php print_unescaped($this->inc('users/part.setquota')); ?>
Please login to merge, or discard this patch.
lib/private/SubAdmin.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 			->execute();
121 121
 
122 122
 		$groups = [];
123
-		while($row = $result->fetch()) {
123
+		while ($row = $result->fetch()) {
124 124
 			$group = $this->groupManager->get($row['gid']);
125
-			if(!is_null($group)) {
125
+			if (!is_null($group)) {
126 126
 				$groups[$group->getGID()] = $group;
127 127
 			}
128 128
 		}
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 			->execute();
157 157
 
158 158
 		$users = [];
159
-		while($row = $result->fetch()) {
159
+		while ($row = $result->fetch()) {
160 160
 			$user = $this->userManager->get($row['uid']);
161
-			if(!is_null($user)) {
161
+			if (!is_null($user)) {
162 162
 				$users[] = $user;
163 163
 			}
164 164
 		}
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 			->execute();
180 180
 
181 181
 		$subadmins = [];
182
-		while($row = $result->fetch()) {
182
+		while ($row = $result->fetch()) {
183 183
 			$user = $this->userManager->get($row['uid']);
184 184
 			$group = $this->groupManager->get($row['gid']);
185
-			if(!is_null($user) && !is_null($group)) {
185
+			if (!is_null($user) && !is_null($group)) {
186 186
 				$subadmins[] = [
187 187
 					'user'  => $user,
188 188
 					'group' => $group
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 			->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
213 213
 			->execute();
214 214
 
215
-		$fetch =  $result->fetch();
215
+		$fetch = $result->fetch();
216 216
 		$result->closeCursor();
217 217
 		$result = !empty($fetch) ? true : false;
218 218
 
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
 	 * @return bool
252 252
 	 */
253 253
 	public function isUserAccessible($subadmin, $user) {
254
-		if(!$this->isSubAdmin($subadmin)) {
254
+		if (!$this->isSubAdmin($subadmin)) {
255 255
 			return false;
256 256
 		}
257
-		if($this->groupManager->isAdmin($user->getUID())) {
257
+		if ($this->groupManager->isAdmin($user->getUID())) {
258 258
 			return false;
259 259
 		}
260 260
 		$accessibleGroups = $this->getSubAdminsGroups($subadmin);
261
-		foreach($accessibleGroups as $accessibleGroup) {
262
-			if($accessibleGroup->inGroup($user)) {
261
+		foreach ($accessibleGroups as $accessibleGroup) {
262
+			if ($accessibleGroup->inGroup($user)) {
263 263
 				return true;
264 264
 			}
265 265
 		}
Please login to merge, or discard this patch.
apps/provisioning_api/lib/Controller/UsersController.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * @copyright Copyright (c) 2016, ownCloud, Inc.
5 5
  *
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		// Admin? Or SubAdmin?
132 132
 		$uid = $user->getUID();
133 133
 		$subAdminManager = $this->groupManager->getSubAdmin();
134
-		if($this->groupManager->isAdmin($uid)){
134
+		if ($this->groupManager->isAdmin($uid)) {
135 135
 			$users = $this->userManager->search($search, $limit, $offset);
136 136
 		} else if ($subAdminManager->isSubAdmin($user)) {
137 137
 			$subAdminOfGroups = $subAdminManager->getSubAdminsGroups($user);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 				$subAdminOfGroups[$key] = $group->getGID();
140 140
 			}
141 141
 
142
-			if($offset === null) {
142
+			if ($offset === null) {
143 143
 				$offset = 0;
144 144
 			}
145 145
 
@@ -173,37 +173,37 @@  discard block
 block discarded – undo
173 173
 		$isAdmin = $this->groupManager->isAdmin($user->getUID());
174 174
 		$subAdminManager = $this->groupManager->getSubAdmin();
175 175
 
176
-		if($this->userManager->userExists($userid)) {
176
+		if ($this->userManager->userExists($userid)) {
177 177
 			$this->logger->error('Failed addUser attempt: User already exists.', ['app' => 'ocs_api']);
178 178
 			throw new OCSException('User already exists', 102);
179 179
 		}
180 180
 
181
-		if($groups !== []) {
181
+		if ($groups !== []) {
182 182
 			foreach ($groups as $group) {
183
-				if(!$this->groupManager->groupExists($group)) {
183
+				if (!$this->groupManager->groupExists($group)) {
184 184
 					throw new OCSException('group '.$group.' does not exist', 104);
185 185
 				}
186
-				if(!$isAdmin && !$subAdminManager->isSubAdminofGroup($user, $this->groupManager->get($group))) {
187
-					throw new OCSException('insufficient privileges for group '. $group, 105);
186
+				if (!$isAdmin && !$subAdminManager->isSubAdminofGroup($user, $this->groupManager->get($group))) {
187
+					throw new OCSException('insufficient privileges for group '.$group, 105);
188 188
 				}
189 189
 			}
190 190
 		} else {
191
-			if(!$isAdmin) {
191
+			if (!$isAdmin) {
192 192
 				throw new OCSException('no group specified (required for subadmins)', 106);
193 193
 			}
194 194
 		}
195 195
 
196 196
 		try {
197 197
 			$newUser = $this->userManager->createUser($userid, $password);
198
-			$this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']);
198
+			$this->logger->info('Successful addUser call with userid: '.$userid, ['app' => 'ocs_api']);
199 199
 
200 200
 			foreach ($groups as $group) {
201 201
 				$this->groupManager->get($group)->addUser($newUser);
202
-				$this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']);
202
+				$this->logger->info('Added userid '.$userid.' to group '.$group, ['app' => 'ocs_api']);
203 203
 			}
204 204
 
205 205
 			return new DataResponse();
206
-		} catch (HintException $e ) {
206
+		} catch (HintException $e) {
207 207
 			$this->logger->logException($e, [
208 208
 				'message' => 'Failed addUser attempt with hint exception.',
209 209
 				'level' => \OCP\Util::WARN,
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	public function getCurrentUser(): DataResponse {
248 248
 		$user = $this->userSession->getUser();
249 249
 		if ($user) {
250
-			$data =  $this->getUserData($user->getUID());
250
+			$data = $this->getUserData($user->getUID());
251 251
 			// rename "displayname" to "display-name" only for this call to keep
252 252
 			// the API stable.
253 253
 			$data['display-name'] = $data['displayname'];
@@ -273,17 +273,17 @@  discard block
 block discarded – undo
273 273
 
274 274
 		// Check if the target user exists
275 275
 		$targetUserObject = $this->userManager->get($userId);
276
-		if($targetUserObject === null) {
276
+		if ($targetUserObject === null) {
277 277
 			throw new OCSException('The requested user could not be found', \OCP\API::RESPOND_NOT_FOUND);
278 278
 		}
279 279
 
280 280
 		// Admin? Or SubAdmin?
281
-		if($this->groupManager->isAdmin($currentLoggedInUser->getUID())
281
+		if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())
282 282
 			|| $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) {
283 283
 			$data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true');
284 284
 		} else {
285 285
 			// Check they are looking up themselves
286
-			if($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) {
286
+			if ($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) {
287 287
 				throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
288 288
 			}
289 289
 		}
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 		$currentLoggedInUser = $this->userSession->getUser();
355 355
 
356 356
 		$targetUser = $this->userManager->get($userId);
357
-		if($targetUser === null) {
357
+		if ($targetUser === null) {
358 358
 			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
359 359
 		}
360 360
 
361 361
 		$permittedFields = [];
362
-		if($targetUser->getUID() === $currentLoggedInUser->getUID()) {
362
+		if ($targetUser->getUID() === $currentLoggedInUser->getUID()) {
363 363
 			// Editing self (display, email)
364 364
 			if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) {
365 365
 				$permittedFields[] = 'display';
@@ -385,13 +385,13 @@  discard block
 block discarded – undo
385 385
 			}
386 386
 
387 387
 			// If admin they can edit their own quota
388
-			if($this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
388
+			if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
389 389
 				$permittedFields[] = 'quota';
390 390
 			}
391 391
 		} else {
392 392
 			// Check if admin / subadmin
393 393
 			$subAdminManager = $this->groupManager->getSubAdmin();
394
-			if($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
394
+			if ($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
395 395
 			|| $this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
396 396
 				// They have permissions over the user
397 397
 				$permittedFields[] = 'display';
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 			}
411 411
 		}
412 412
 		// Check if permitted to edit this field
413
-		if(!in_array($key, $permittedFields)) {
413
+		if (!in_array($key, $permittedFields)) {
414 414
 			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
415 415
 		}
416 416
 		// Process the edit
417
-		switch($key) {
417
+		switch ($key) {
418 418
 			case 'display':
419 419
 			case AccountManager::PROPERTY_DISPLAYNAME:
420 420
 				$targetUser->setDisplayName($value);
421 421
 				break;
422 422
 			case 'quota':
423 423
 				$quota = $value;
424
-				if($quota !== 'none' && $quota !== 'default') {
424
+				if ($quota !== 'none' && $quota !== 'default') {
425 425
 					if (is_numeric($quota)) {
426 426
 						$quota = (float) $quota;
427 427
 					} else {
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
 					if ($quota === false) {
431 431
 						throw new OCSException('Invalid quota value '.$value, 103);
432 432
 					}
433
-					if($quota === 0) {
433
+					if ($quota === 0) {
434 434
 						$quota = 'default';
435
-					}else if($quota === -1) {
435
+					} else if ($quota === -1) {
436 436
 						$quota = 'none';
437 437
 					} else {
438 438
 						$quota = \OCP\Util::humanFileSize($quota);
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 				$this->config->setUserValue($targetUser->getUID(), 'core', 'lang', $value);
452 452
 				break;
453 453
 			case AccountManager::PROPERTY_EMAIL:
454
-				if(filter_var($value, FILTER_VALIDATE_EMAIL)) {
454
+				if (filter_var($value, FILTER_VALIDATE_EMAIL)) {
455 455
 					$targetUser->setEMailAddress($value);
456 456
 				} else {
457 457
 					throw new OCSException('', 102);
@@ -486,18 +486,18 @@  discard block
 block discarded – undo
486 486
 
487 487
 		$targetUser = $this->userManager->get($userId);
488 488
 
489
-		if($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) {
489
+		if ($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) {
490 490
 			throw new OCSException('', 101);
491 491
 		}
492 492
 
493 493
 		// If not permitted
494 494
 		$subAdminManager = $this->groupManager->getSubAdmin();
495
-		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
495
+		if (!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
496 496
 			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
497 497
 		}
498 498
 
499 499
 		// Go ahead with the delete
500
-		if($targetUser->delete()) {
500
+		if ($targetUser->delete()) {
501 501
 			return new DataResponse();
502 502
 		} else {
503 503
 			throw new OCSException('', 101);
@@ -540,13 +540,13 @@  discard block
 block discarded – undo
540 540
 		$currentLoggedInUser = $this->userSession->getUser();
541 541
 
542 542
 		$targetUser = $this->userManager->get($userId);
543
-		if($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) {
543
+		if ($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) {
544 544
 			throw new OCSException('', 101);
545 545
 		}
546 546
 
547 547
 		// If not permitted
548 548
 		$subAdminManager = $this->groupManager->getSubAdmin();
549
-		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
549
+		if (!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
550 550
 			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
551 551
 		}
552 552
 
@@ -567,11 +567,11 @@  discard block
 block discarded – undo
567 567
 		$loggedInUser = $this->userSession->getUser();
568 568
 
569 569
 		$targetUser = $this->userManager->get($userId);
570
-		if($targetUser === null) {
570
+		if ($targetUser === null) {
571 571
 			throw new OCSException('', \OCP\API::RESPOND_NOT_FOUND);
572 572
 		}
573 573
 
574
-		if($targetUser->getUID() === $loggedInUser->getUID() || $this->groupManager->isAdmin($loggedInUser->getUID())) {
574
+		if ($targetUser->getUID() === $loggedInUser->getUID() || $this->groupManager->isAdmin($loggedInUser->getUID())) {
575 575
 			// Self lookup or admin lookup
576 576
 			return new DataResponse([
577 577
 				'groups' => $this->groupManager->getUserGroupIds($targetUser)
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 			$subAdminManager = $this->groupManager->getSubAdmin();
581 581
 
582 582
 			// Looking up someone else
583
-			if($subAdminManager->isUserAccessible($loggedInUser, $targetUser)) {
583
+			if ($subAdminManager->isUserAccessible($loggedInUser, $targetUser)) {
584 584
 				// Return the group that the method caller is subadmin of for the user in question
585 585
 				/** @var IGroup[] $getSubAdminsGroups */
586 586
 				$getSubAdminsGroups = $subAdminManager->getSubAdminsGroups($loggedInUser);
@@ -610,16 +610,16 @@  discard block
 block discarded – undo
610 610
 	 * @throws OCSException
611 611
 	 */
612 612
 	public function addToGroup(string $userId, string $groupid = ''): DataResponse {
613
-		if($groupid === '') {
613
+		if ($groupid === '') {
614 614
 			throw new OCSException('', 101);
615 615
 		}
616 616
 
617 617
 		$group = $this->groupManager->get($groupid);
618 618
 		$targetUser = $this->userManager->get($userId);
619
-		if($group === null) {
619
+		if ($group === null) {
620 620
 			throw new OCSException('', 102);
621 621
 		}
622
-		if($targetUser === null) {
622
+		if ($targetUser === null) {
623 623
 			throw new OCSException('', 103);
624 624
 		}
625 625
 
@@ -647,17 +647,17 @@  discard block
 block discarded – undo
647 647
 	public function removeFromGroup(string $userId, string $groupid): DataResponse {
648 648
 		$loggedInUser = $this->userSession->getUser();
649 649
 
650
-		if($groupid === null || trim($groupid) === '') {
650
+		if ($groupid === null || trim($groupid) === '') {
651 651
 			throw new OCSException('', 101);
652 652
 		}
653 653
 
654 654
 		$group = $this->groupManager->get($groupid);
655
-		if($group === null) {
655
+		if ($group === null) {
656 656
 			throw new OCSException('', 102);
657 657
 		}
658 658
 
659 659
 		$targetUser = $this->userManager->get($userId);
660
-		if($targetUser === null) {
660
+		if ($targetUser === null) {
661 661
 			throw new OCSException('', 103);
662 662
 		}
663 663
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		} else if (!$this->groupManager->isAdmin($loggedInUser->getUID())) {
682 682
 			/** @var IGroup[] $subAdminGroups */
683 683
 			$subAdminGroups = $subAdminManager->getSubAdminsGroups($loggedInUser);
684
-			$subAdminGroups = array_map(function (IGroup $subAdminGroup) {
684
+			$subAdminGroups = array_map(function(IGroup $subAdminGroup) {
685 685
 				return $subAdminGroup->getGID();
686 686
 			}, $subAdminGroups);
687 687
 			$userGroups = $this->groupManager->getUserGroupIds($targetUser);
@@ -713,15 +713,15 @@  discard block
 block discarded – undo
713 713
 		$user = $this->userManager->get($userId);
714 714
 
715 715
 		// Check if the user exists
716
-		if($user === null) {
716
+		if ($user === null) {
717 717
 			throw new OCSException('User does not exist', 101);
718 718
 		}
719 719
 		// Check if group exists
720
-		if($group === null) {
721
-			throw new OCSException('Group does not exist',  102);
720
+		if ($group === null) {
721
+			throw new OCSException('Group does not exist', 102);
722 722
 		}
723 723
 		// Check if trying to make subadmin of admin group
724
-		if($group->getGID() === 'admin') {
724
+		if ($group->getGID() === 'admin') {
725 725
 			throw new OCSException('Cannot create subadmins for admin group', 103);
726 726
 		}
727 727
 
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 			return new DataResponse();
733 733
 		}
734 734
 		// Go
735
-		if($subAdminManager->createSubAdmin($user, $group)) {
735
+		if ($subAdminManager->createSubAdmin($user, $group)) {
736 736
 			return new DataResponse();
737 737
 		} else {
738 738
 			throw new OCSException('Unknown error occurred', 103);
@@ -755,20 +755,20 @@  discard block
 block discarded – undo
755 755
 		$subAdminManager = $this->groupManager->getSubAdmin();
756 756
 
757 757
 		// Check if the user exists
758
-		if($user === null) {
758
+		if ($user === null) {
759 759
 			throw new OCSException('User does not exist', 101);
760 760
 		}
761 761
 		// Check if the group exists
762
-		if($group === null) {
762
+		if ($group === null) {
763 763
 			throw new OCSException('Group does not exist', 101);
764 764
 		}
765 765
 		// Check if they are a subadmin of this said group
766
-		if(!$subAdminManager->isSubAdminOfGroup($user, $group)) {
766
+		if (!$subAdminManager->isSubAdminOfGroup($user, $group)) {
767 767
 			throw new OCSException('User is not a subadmin of this group', 102);
768 768
 		}
769 769
 
770 770
 		// Go
771
-		if($subAdminManager->deleteSubAdmin($user, $group)) {
771
+		if ($subAdminManager->deleteSubAdmin($user, $group)) {
772 772
 			return new DataResponse();
773 773
 		} else {
774 774
 			throw new OCSException('Unknown error occurred', 103);
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 	public function getUserSubAdminGroups(string $userId): DataResponse {
786 786
 		$user = $this->userManager->get($userId);
787 787
 		// Check if the user exists
788
-		if($user === null) {
788
+		if ($user === null) {
789 789
 			throw new OCSException('User does not exist', 101);
790 790
 		}
791 791
 
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 			$groups[] = $group->getGID();
797 797
 		}
798 798
 
799
-		if(!$groups) {
799
+		if (!$groups) {
800 800
 			throw new OCSException('Unknown error occurred', 102);
801 801
 		} else {
802 802
 			return new DataResponse($groups);
@@ -840,13 +840,13 @@  discard block
 block discarded – undo
840 840
 		$currentLoggedInUser = $this->userSession->getUser();
841 841
 
842 842
 		$targetUser = $this->userManager->get($userId);
843
-		if($targetUser === null) {
843
+		if ($targetUser === null) {
844 844
 			throw new OCSException('', \OCP\API::RESPOND_NOT_FOUND);
845 845
 		}
846 846
 
847 847
 		// Check if admin / subadmin
848 848
 		$subAdminManager = $this->groupManager->getSubAdmin();
849
-		if(!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
849
+		if (!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
850 850
 			&& !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
851 851
 			// No rights
852 852
 			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 			$this->newUserMailHelper->setL10N($l10n);
869 869
 			$emailTemplate = $this->newUserMailHelper->generateTemplate($targetUser, false);
870 870
 			$this->newUserMailHelper->sendMail($targetUser, $emailTemplate);
871
-		} catch(\Exception $e) {
871
+		} catch (\Exception $e) {
872 872
 			$this->logger->logException($e, [
873 873
 				'message' => "Can't send new user mail to $email",
874 874
 				'level' => \OCP\Util::ERROR,
Please login to merge, or discard this patch.