Completed
Pull Request — master (#1234)
by Blizzz
33:32 queued 09:32
created
settings/templates/users/part.grouplist.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,33 +28,33 @@
 block discarded – undo
28 28
 	</li>
29 29
 
30 30
 	<!-- The Admin Group -->
31
-	<?php foreach($_["adminGroup"] as $adminGroup): ?>
32
-		<li data-gid="admin" data-usercount="<?php if($adminGroup['usercount'] > 0) { p($adminGroup['usercount']); } ?>" class="isgroup">
31
+	<?php foreach ($_["adminGroup"] as $adminGroup): ?>
32
+		<li data-gid="admin" data-usercount="<?php if ($adminGroup['usercount'] > 0) { p($adminGroup['usercount']); } ?>" class="isgroup">
33 33
 			<a href="#"><span class="groupname"><?php p($l->t('Admins')); ?></span></a>
34 34
 			<span class="utils">
35
-				<span class="usercount"><?php if($adminGroup['usercount'] > 0) { p($adminGroup['usercount']); } ?></span>
35
+				<span class="usercount"><?php if ($adminGroup['usercount'] > 0) { p($adminGroup['usercount']); } ?></span>
36 36
 			</span>
37 37
 		</li>
38 38
 	<?php endforeach; ?>
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
 		<span class="utils">
45
-			<span class="usercount"><?php if($disabledUsersGroup['usercount'] > 0) { p($disabledUsersGroup['usercount']); } ?></span>
45
+			<span class="usercount"><?php if ($disabledUsersGroup['usercount'] > 0) { p($disabledUsersGroup['usercount']); } ?></span>
46 46
 		</span>
47 47
 	</li>
48 48
 
49 49
 	<!--List of Groups-->
50
-	<?php foreach($_["groups"] as $group): ?>
50
+	<?php foreach ($_["groups"] as $group): ?>
51 51
 		<li data-gid="<?php p($group['name']) ?>" data-usercount="<?php p($group['usercount']) ?>" class="isgroup">
52 52
 			<a href="#" class="dorename">
53 53
 				<span class="groupname"><?php p($group['name']); ?></span>
54 54
 			</a>
55 55
 			<span class="utils">
56
-				<span class="usercount"><?php if($group['usercount'] > 0) { p($group['usercount']); } ?></span>
57
-				<?php if($_['isAdmin']): ?>
56
+				<span class="usercount"><?php if ($group['usercount'] > 0) { p($group['usercount']); } ?></span>
57
+				<?php if ($_['isAdmin']): ?>
58 58
 				<a href="#" class="action delete" original-title="<?php p($l->t('Delete'))?>">
59 59
 					<img src="<?php print_unescaped(image_path('core', 'actions/delete.svg')) ?>" />
60 60
 				</a>
Please login to merge, or discard this patch.
lib/private/User/Manager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	public function __construct(IConfig $config) {
76 76
 		$this->config = $config;
77 77
 		$cachedUsers = &$this->cachedUsers;
78
-		$this->listen('\OC\User', 'postDelete', function ($user) use (&$cachedUsers) {
78
+		$this->listen('\OC\User', 'postDelete', function($user) use (&$cachedUsers) {
79 79
 			/** @var \OC\User\User $user */
80 80
 			unset($cachedUsers[$user->getUID()]);
81 81
 		});
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		$result = $this->checkPasswordNoLogging($loginName, $password);
189 189
 
190 190
 		if ($result === false) {
191
-			\OC::$server->getLogger()->warning('Login failed: \''. $loginName .'\' (Remote IP: \''. \OC::$server->getRequest()->getRemoteAddress(). '\')', ['app' => 'core']);
191
+			\OC::$server->getLogger()->warning('Login failed: \''.$loginName.'\' (Remote IP: \''.\OC::$server->getRequest()->getRemoteAddress().'\')', ['app' => 'core']);
192 192
 		}
193 193
 
194 194
 		return $result;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 			}
238 238
 		}
239 239
 
240
-		uasort($users, function ($a, $b) {
240
+		uasort($users, function($a, $b) {
241 241
 			/**
242 242
 			 * @var \OC\User\User $a
243 243
 			 * @var \OC\User\User $b
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 			}
267 267
 		}
268 268
 
269
-		usort($users, function ($a, $b) {
269
+		usort($users, function($a, $b) {
270 270
 			/**
271 271
 			 * @var \OC\User\User $a
272 272
 			 * @var \OC\User\User $b
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 		foreach ($this->backends as $backend) {
341 341
 			if ($backend->implementsActions(Backend::COUNT_USERS)) {
342 342
 				$backendUsers = $backend->countUsers();
343
-				if($backendUsers !== false) {
344
-					if($backend instanceof IUserBackend) {
343
+				if ($backendUsers !== false) {
344
+					if ($backend instanceof IUserBackend) {
345 345
 						$name = $backend->getBackendName();
346 346
 					} else {
347 347
 						$name = get_class($backend);
348 348
 					}
349
-					if(isset($userCountStatistics[$name])) {
349
+					if (isset($userCountStatistics[$name])) {
350 350
 						$userCountStatistics[$name] += $backendUsers;
351 351
 					} else {
352 352
 						$userCountStatistics[$name] = $backendUsers;
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 
409 409
 		$query = $queryBuilder->execute();
410 410
 
411
-		$result = (int)$query->fetchColumn();
411
+		$result = (int) $query->fetchColumn();
412 412
 		$query->closeCursor();
413 413
 
414 414
 		return $result;
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 
431 431
 		$query = $queryBuilder->execute();
432 432
 
433
-		$result = (int)$query->fetchColumn();
433
+		$result = (int) $query->fetchColumn();
434 434
 		$query->closeCursor();
435 435
 
436 436
 		return $result;
Please login to merge, or discard this patch.
settings/users.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 list($adminGroup, $groups) = $groupsInfo->get();
74 74
 
75 75
 $recoveryAdminEnabled = OC_App::isEnabled('encryption') &&
76
-					    $config->getAppValue( 'encryption', 'recoveryAdminEnabled', null );
76
+					    $config->getAppValue('encryption', 'recoveryAdminEnabled', null);
77 77
 
78
-if($isAdmin) {
78
+if ($isAdmin) {
79 79
 	$subAdmins = \OC::$server->getGroupManager()->getSubAdmin()->getAllSubAdmins();
80 80
 	// New class returns IUser[] so convert back
81 81
 	$result = [];
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 		];
87 87
 	}
88 88
 	$subAdmins = $result;
89
-}else{
89
+} else {
90 90
 	/* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
91 91
 	$gids = array();
92
-	foreach($groups as $group) {
92
+	foreach ($groups as $group) {
93 93
 		if (isset($group['id'])) {
94 94
 			$gids[] = $group['id'];
95 95
 		}
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
 ];
106 106
 
107 107
 // load preset quotas
108
-$quotaPreset=$config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
109
-$quotaPreset=explode(',', $quotaPreset);
110
-foreach($quotaPreset as &$preset) {
111
-	$preset=trim($preset);
108
+$quotaPreset = $config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
109
+$quotaPreset = explode(',', $quotaPreset);
110
+foreach ($quotaPreset as &$preset) {
111
+	$preset = trim($preset);
112 112
 }
113
-$quotaPreset=array_diff($quotaPreset, array('default', 'none'));
113
+$quotaPreset = array_diff($quotaPreset, array('default', 'none'));
114 114
 
115
-$defaultQuota=$config->getAppValue('files', 'default_quota', 'none');
116
-$defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false
117
-	&& array_search($defaultQuota, array('none', 'default'))===false;
115
+$defaultQuota = $config->getAppValue('files', 'default_quota', 'none');
116
+$defaultQuotaIsUserDefined = array_search($defaultQuota, $quotaPreset) === false
117
+	&& array_search($defaultQuota, array('none', 'default')) === false;
118 118
 
119 119
 \OC::$server->getEventDispatcher()->dispatch('OC\Settings\Users::loadAdditionalScripts');
120 120
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 $tmpl->assign('sortGroups', $sortGroupsBy);
124 124
 $tmpl->assign('adminGroup', $adminGroup);
125 125
 $tmpl->assign('disabledUsersGroup', $disabledUsersGroup);
126
-$tmpl->assign('isAdmin', (int)$isAdmin);
126
+$tmpl->assign('isAdmin', (int) $isAdmin);
127 127
 $tmpl->assign('subadmins', $subAdmins);
128 128
 $tmpl->assign('numofgroups', count($groups) + count($adminGroup));
129 129
 $tmpl->assign('quota_preset', $quotaPreset);
Please login to merge, or discard this patch.
settings/Controller/UsersController.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
 		// check for encryption state - TODO see formatUserForIndex
135 135
 		$this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption');
136
-		if($this->isEncryptionAppEnabled) {
136
+		if ($this->isEncryptionAppEnabled) {
137 137
 			// putting this directly in empty is possible in PHP 5.5+
138 138
 			$result = $config->getAppValue('encryption', 'recoveryAdminEnabled', 0);
139 139
 			$this->isRestoreEnabled = !empty($result);
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		}
174 174
 
175 175
 		$subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user);
176
-		foreach($subAdminGroups as $key => $subAdminGroup) {
176
+		foreach ($subAdminGroups as $key => $subAdminGroup) {
177 177
 			$subAdminGroups[$key] = $subAdminGroup->getGID();
178 178
 		}
179 179
 
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	 */
232 232
 	public function index($offset = 0, $limit = 10, $gid = '', $pattern = '', $backend = '') {
233 233
 		// Remove backends
234
-		if(!empty($backend)) {
234
+		if (!empty($backend)) {
235 235
 			$activeBackends = $this->userManager->getBackends();
236 236
 			$this->userManager->clearBackends();
237
-			foreach($activeBackends as $singleActiveBackend) {
238
-				if($backend === get_class($singleActiveBackend)) {
237
+			foreach ($activeBackends as $singleActiveBackend) {
238
+				if ($backend === get_class($singleActiveBackend)) {
239 239
 					$this->userManager->registerBackend($singleActiveBackend);
240 240
 					break;
241 241
 				}
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 
245 245
 		$users = [];
246 246
 		if ($this->isAdmin) {
247
-			if($gid !== '' && $gid !== '_disabledUsers') {
247
+			if ($gid !== '' && $gid !== '_disabledUsers') {
248 248
 				$batch = $this->getUsersForUID($this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset));
249 249
 			} else {
250 250
 				$batch = $this->userManager->search($pattern, $limit, $offset);
251 251
 			}
252 252
 
253 253
 			foreach ($batch as $user) {
254
-				if( ($gid !== '_disabledUsers' && $user->isEnabled()) ||
254
+				if (($gid !== '_disabledUsers' && $user->isEnabled()) ||
255 255
 					($gid === '_disabledUsers' && !$user->isEnabled())
256 256
 				) {
257 257
 					$users[] = $this->formatUserForIndex($user);
@@ -268,17 +268,17 @@  discard block
 block discarded – undo
268 268
 			$subAdminOfGroups = $gids;
269 269
 
270 270
 			// Set the $gid parameter to an empty value if the subadmin has no rights to access a specific group
271
-			if($gid !== '' && $gid !== '_disabledUsers' && !in_array($gid, $subAdminOfGroups)) {
271
+			if ($gid !== '' && $gid !== '_disabledUsers' && !in_array($gid, $subAdminOfGroups)) {
272 272
 				$gid = '';
273 273
 			}
274 274
 
275 275
 			// Batch all groups the user is subadmin of when a group is specified
276 276
 			$batch = [];
277
-			if($gid === '') {
278
-				foreach($subAdminOfGroups as $group) {
277
+			if ($gid === '') {
278
+				foreach ($subAdminOfGroups as $group) {
279 279
 					$groupUsers = $this->groupManager->displayNamesInGroup($group, $pattern, $limit, $offset);
280 280
 
281
-					foreach($groupUsers as $uid => $displayName) {
281
+					foreach ($groupUsers as $uid => $displayName) {
282 282
 						$batch[$uid] = $displayName;
283 283
 					}
284 284
 				}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 					$this->groupManager->getUserGroupIds($user),
294 294
 					$subAdminOfGroups
295 295
 				));
296
-				if( ($gid !== '_disabledUsers' && $user->isEnabled()) ||
296
+				if (($gid !== '_disabledUsers' && $user->isEnabled()) ||
297 297
 					($gid === '_disabledUsers' && !$user->isEnabled())
298 298
 				) {
299 299
 					$users[] = $this->formatUserForIndex($user, $userGroups);
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 	 * @param string $email
315 315
 	 * @return DataResponse
316 316
 	 */
317
-	public function create($username, $password, array $groups=[], $email='') {
318
-		if($email !== '' && !$this->mailer->validateMailAddress($email)) {
317
+	public function create($username, $password, array $groups = [], $email = '') {
318
+		if ($email !== '' && !$this->mailer->validateMailAddress($email)) {
319 319
 			return new DataResponse(
320 320
 				[
321
-					'message' => (string)$this->l10n->t('Invalid mail address')
321
+					'message' => (string) $this->l10n->t('Invalid mail address')
322 322
 				],
323 323
 				Http::STATUS_UNPROCESSABLE_ENTITY
324 324
 			);
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 			if (!empty($groups)) {
331 331
 				foreach ($groups as $key => $group) {
332 332
 					$groupObject = $this->groupManager->get($group);
333
-					if($groupObject === null) {
333
+					if ($groupObject === null) {
334 334
 						unset($groups[$key]);
335 335
 						continue;
336 336
 					}
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 		if ($this->userManager->userExists($username)) {
355 355
 			return new DataResponse(
356 356
 				[
357
-					'message' => (string)$this->l10n->t('A user with that name already exists.')
357
+					'message' => (string) $this->l10n->t('A user with that name already exists.')
358 358
 				],
359 359
 				Http::STATUS_CONFLICT
360 360
 			);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 			if ($email === '') {
366 366
 				return new DataResponse(
367 367
 					[
368
-						'message' => (string)$this->l10n->t('To send a password link to the user an email address is required.')
368
+						'message' => (string) $this->l10n->t('To send a password link to the user an email address is required.')
369 369
 					],
370 370
 					Http::STATUS_UNPROCESSABLE_ENTITY
371 371
 				);
@@ -390,12 +390,12 @@  discard block
 block discarded – undo
390 390
 			);
391 391
 		}
392 392
 
393
-		if($user instanceof IUser) {
394
-			if($groups !== null) {
395
-				foreach($groups as $groupName) {
393
+		if ($user instanceof IUser) {
394
+			if ($groups !== null) {
395
+				foreach ($groups as $groupName) {
396 396
 					$group = $this->groupManager->get($groupName);
397 397
 
398
-					if(empty($group)) {
398
+					if (empty($group)) {
399 399
 						$group = $this->groupManager->createGroup($groupName);
400 400
 					}
401 401
 					$group->addUser($user);
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
 			/**
405 405
 			 * Send new user mail only if a mail is set
406 406
 			 */
407
-			if($email !== '') {
407
+			if ($email !== '') {
408 408
 				$user->setEMailAddress($email);
409 409
 				try {
410 410
 					$emailTemplate = $this->newUserMailHelper->generateTemplate($user, $generatePasswordResetToken);
411 411
 					$this->newUserMailHelper->sendMail($user, $emailTemplate);
412
-				} catch(\Exception $e) {
413
-					$this->log->error("Can't send new user mail to $email: " . $e->getMessage(), ['app' => 'settings']);
412
+				} catch (\Exception $e) {
413
+					$this->log->error("Can't send new user mail to $email: ".$e->getMessage(), ['app' => 'settings']);
414 414
 				}
415 415
 			}
416 416
 			// fetch users groups
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 		$userId = $this->userSession->getUser()->getUID();
443 443
 		$user = $this->userManager->get($id);
444 444
 
445
-		if($userId === $id) {
445
+		if ($userId === $id) {
446 446
 			return new DataResponse(
447 447
 				[
448 448
 					'status' => 'error',
@@ -454,20 +454,20 @@  discard block
 block discarded – undo
454 454
 			);
455 455
 		}
456 456
 
457
-		if(!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) {
457
+		if (!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) {
458 458
 			return new DataResponse(
459 459
 				[
460 460
 					'status' => 'error',
461 461
 					'data' => [
462
-						'message' => (string)$this->l10n->t('Authentication error')
462
+						'message' => (string) $this->l10n->t('Authentication error')
463 463
 					]
464 464
 				],
465 465
 				Http::STATUS_FORBIDDEN
466 466
 			);
467 467
 		}
468 468
 
469
-		if($user) {
470
-			if($user->delete()) {
469
+		if ($user) {
470
+			if ($user->delete()) {
471 471
 				return new DataResponse(
472 472
 					[
473 473
 						'status' => 'success',
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			[
485 485
 				'status' => 'error',
486 486
 				'data' => [
487
-					'message' => (string)$this->l10n->t('Unable to delete user.')
487
+					'message' => (string) $this->l10n->t('Unable to delete user.')
488 488
 				]
489 489
 			],
490 490
 			Http::STATUS_FORBIDDEN
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
 	 * @return DataResponse
500 500
 	 */
501 501
 	public function setEnabled($id, $enabled) {
502
-		$enabled = (bool)$enabled;
503
-		if($enabled) {
502
+		$enabled = (bool) $enabled;
503
+		if ($enabled) {
504 504
 			$errorMsgGeneral = (string) $this->l10n->t('Error while enabling user.');
505 505
 		} else {
506 506
 			$errorMsgGeneral = (string) $this->l10n->t('Error while disabling user.');
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 			);
521 521
 		}
522 522
 
523
-		if($user) {
523
+		if ($user) {
524 524
 			if (!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) {
525 525
 				return new DataResponse(
526 526
 					[
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 
712 712
 			$uniqueUsers = [];
713 713
 			foreach ($groups as $group) {
714
-				foreach($group->getUsers() as $uid => $displayName) {
714
+				foreach ($group->getUsers() as $uid => $displayName) {
715 715
 					$uniqueUsers[$uid] = true;
716 716
 				}
717 717
 			}
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 			);
813 813
 		}
814 814
 
815
-		if($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) {
815
+		if ($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) {
816 816
 			return new DataResponse(
817 817
 				[
818 818
 					'status' => 'error',
Please login to merge, or discard this patch.