Completed
Push — master ( af20f1...8ccb99 )
by Morris
78:09 queued 53:18
created
apps/user_ldap/lib/User/Manager.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param $uid
142 142
 	 */
143 143
 	public function invalidate($uid) {
144
-		if(!isset($this->usersByUid[$uid])) {
144
+		if (!isset($this->usersByUid[$uid])) {
145 145
 			return;
146 146
 		}
147 147
 		$dn = $this->usersByUid[$uid]->getDN();
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @return null
156 156
 	 */
157 157
 	private function checkAccess() {
158
-		if(is_null($this->access)) {
158
+		if (is_null($this->access)) {
159 159
 			throw new \Exception('LDAP Access instance must be set first');
160 160
 		}
161 161
 	}
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
 			$this->access->getConnection()->ldapUserDisplayName,
178 178
 			$this->access->getConnection()->ldapUserDisplayName2,
179 179
 		);
180
-		foreach($possible as $attr) {
181
-			if(!is_null($attr)) {
180
+		foreach ($possible as $attr) {
181
+			if (!is_null($attr)) {
182 182
 				$attributes[] = $attr;
183 183
 			}
184 184
 		}
185 185
 
186 186
 		$homeRule = $this->access->getConnection()->homeFolderNamingRule;
187
-		if(strpos($homeRule, 'attr:') === 0) {
187
+		if (strpos($homeRule, 'attr:') === 0) {
188 188
 			$attributes[] = substr($homeRule, strlen('attr:'));
189 189
 		}
190 190
 
191
-		if(!$minimal) {
191
+		if (!$minimal) {
192 192
 			// attributes that are not really important but may come with big
193 193
 			// payload.
194 194
 			$attributes = array_merge(
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	public function isDeletedUser($id) {
209 209
 		$isDeleted = $this->ocConfig->getUserValue(
210 210
 			$id, 'user_ldap', 'isDeleted', 0);
211
-		return (int)$isDeleted === 1;
211
+		return (int) $isDeleted === 1;
212 212
 	}
213 213
 
214 214
 	/**
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	 */
232 232
 	protected function createInstancyByUserName($id) {
233 233
 		//most likely a uid. Check whether it is a deleted user
234
-		if($this->isDeletedUser($id)) {
234
+		if ($this->isDeletedUser($id)) {
235 235
 			return $this->getDeletedUser($id);
236 236
 		}
237 237
 		$dn = $this->access->username2dn($id);
238
-		if($dn !== false) {
238
+		if ($dn !== false) {
239 239
 			return $this->createAndCache($dn, $id);
240 240
 		}
241 241
 		return null;
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
 	 */
250 250
 	public function get($id) {
251 251
 		$this->checkAccess();
252
-		if(isset($this->usersByDN[$id])) {
252
+		if (isset($this->usersByDN[$id])) {
253 253
 			return $this->usersByDN[$id];
254
-		} else if(isset($this->usersByUid[$id])) {
254
+		} else if (isset($this->usersByUid[$id])) {
255 255
 			return $this->usersByUid[$id];
256 256
 		}
257 257
 
258
-		if($this->access->stringResemblesDN($id) ) {
258
+		if ($this->access->stringResemblesDN($id)) {
259 259
 			$uid = $this->access->dn2username($id);
260
-			if($uid !== false) {
260
+			if ($uid !== false) {
261 261
 				return $this->createAndCache($id, $uid);
262 262
 			}
263 263
 		}
Please login to merge, or discard this patch.
apps/user_ldap/lib/User/User.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
 	 * @return null
154 154
 	 */
155 155
 	public function update() {
156
-		if(is_null($this->dn)) {
156
+		if (is_null($this->dn)) {
157 157
 			return null;
158 158
 		}
159 159
 
160 160
 		$hasLoggedIn = $this->config->getUserValue($this->uid, 'user_ldap',
161 161
 				self::USER_PREFKEY_FIRSTLOGIN, 0);
162 162
 
163
-		if($this->needsRefresh()) {
163
+		if ($this->needsRefresh()) {
164 164
 			$this->updateEmail();
165 165
 			$this->updateQuota();
166
-			if($hasLoggedIn !== 0) {
166
+			if ($hasLoggedIn !== 0) {
167 167
 				//we do not need to try it, when the user has not been logged in
168 168
 				//before, because the file system will not be ready.
169 169
 				$this->updateAvatar();
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		$this->markRefreshTime();
183 183
 		//Quota
184 184
 		$attr = strtolower($this->connection->ldapQuotaAttribute);
185
-		if(isset($ldapEntry[$attr])) {
185
+		if (isset($ldapEntry[$attr])) {
186 186
 			$this->updateQuota($ldapEntry[$attr][0]);
187 187
 		} else {
188 188
 			if ($this->connection->ldapQuotaDefault !== '') {
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
 		//displayName
195 195
 		$displayName = $displayName2 = '';
196 196
 		$attr = strtolower($this->connection->ldapUserDisplayName);
197
-		if(isset($ldapEntry[$attr])) {
198
-			$displayName = (string)$ldapEntry[$attr][0];
197
+		if (isset($ldapEntry[$attr])) {
198
+			$displayName = (string) $ldapEntry[$attr][0];
199 199
 		}
200 200
 		$attr = strtolower($this->connection->ldapUserDisplayName2);
201
-		if(isset($ldapEntry[$attr])) {
202
-			$displayName2 = (string)$ldapEntry[$attr][0];
201
+		if (isset($ldapEntry[$attr])) {
202
+			$displayName2 = (string) $ldapEntry[$attr][0];
203 203
 		}
204 204
 		if ($displayName !== '') {
205 205
 			$this->composeAndStoreDisplayName($displayName);
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
 		//email must be stored after displayname, because it would cause a user
216 216
 		//change event that will trigger fetching the display name again
217 217
 		$attr = strtolower($this->connection->ldapEmailAttribute);
218
-		if(isset($ldapEntry[$attr])) {
218
+		if (isset($ldapEntry[$attr])) {
219 219
 			$this->updateEmail($ldapEntry[$attr][0]);
220 220
 		}
221 221
 		unset($attr);
222 222
 
223 223
 		// LDAP Username, needed for s2s sharing
224
-		if(isset($ldapEntry['uid'])) {
224
+		if (isset($ldapEntry['uid'])) {
225 225
 			$this->storeLDAPUserName($ldapEntry['uid'][0]);
226
-		} else if(isset($ldapEntry['samaccountname'])) {
226
+		} else if (isset($ldapEntry['samaccountname'])) {
227 227
 			$this->storeLDAPUserName($ldapEntry['samaccountname'][0]);
228 228
 		}
229 229
 
230 230
 		//homePath
231
-		if(strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) {
231
+		if (strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) {
232 232
 			$attr = strtolower(substr($this->connection->homeFolderNamingRule, strlen('attr:')));
233
-			if(isset($ldapEntry[$attr])) {
233
+			if (isset($ldapEntry[$attr])) {
234 234
 				$this->access->cacheUserHome(
235 235
 					$this->getUsername(), $this->getHomePath($ldapEntry[$attr][0]));
236 236
 			}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		//memberOf groups
240 240
 		$cacheKey = 'getMemberOf'.$this->getUsername();
241 241
 		$groups = false;
242
-		if(isset($ldapEntry['memberof'])) {
242
+		if (isset($ldapEntry['memberof'])) {
243 243
 			$groups = $ldapEntry['memberof'];
244 244
 		}
245 245
 		$this->connection->writeToCache($cacheKey, $groups);
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 		/** @var Connection $connection */
249 249
 		$connection = $this->access->getConnection();
250 250
 		$attributes = $connection->resolveRule('avatar');
251
-		foreach ($attributes as $attribute)  {
252
-			if(isset($ldapEntry[$attribute])) {
251
+		foreach ($attributes as $attribute) {
252
+			if (isset($ldapEntry[$attribute])) {
253 253
 				$this->avatarImage = $ldapEntry[$attribute][0];
254 254
 				// the call to the method that saves the avatar in the file
255 255
 				// system must be postponed after the login. It is to ensure
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @throws \Exception
285 285
 	 */
286 286
 	public function getHomePath($valueFromLDAP = null) {
287
-		$path = (string)$valueFromLDAP;
287
+		$path = (string) $valueFromLDAP;
288 288
 		$attr = null;
289 289
 
290 290
 		if (is_null($valueFromLDAP)
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
 		if ($path !== '') {
303 303
 			//if attribute's value is an absolute path take this, otherwise append it to data dir
304 304
 			//check for / at the beginning or pattern c:\ resp. c:/
305
-			if(   '/' !== $path[0]
305
+			if ('/' !== $path[0]
306 306
 			   && !(3 < strlen($path) && ctype_alpha($path[0])
307 307
 			       && $path[1] === ':' && ('\\' === $path[2] || '/' === $path[2]))
308 308
 			) {
309 309
 				$path = $this->config->getSystemValue('datadirectory',
310
-						\OC::$SERVERROOT.'/data' ) . '/' . $path;
310
+						\OC::$SERVERROOT.'/data').'/'.$path;
311 311
 			}
312 312
 			//we need it to store it in the DB as well in case a user gets
313 313
 			//deleted so we can clean up afterwards
@@ -317,11 +317,11 @@  discard block
 block discarded – undo
317 317
 			return $path;
318 318
 		}
319 319
 
320
-		if(    !is_null($attr)
320
+		if (!is_null($attr)
321 321
 			&& $this->config->getAppValue('user_ldap', 'enforce_home_folder_naming_rule', true)
322 322
 		) {
323 323
 			// a naming rule attribute is defined, but it doesn't exist for that LDAP user
324
-			throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: ' . $this->getUsername());
324
+			throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: '.$this->getUsername());
325 325
 		}
326 326
 
327 327
 		//false will apply default behaviour as defined and done by OC_User
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	public function getMemberOfGroups() {
333 333
 		$cacheKey = 'getMemberOf'.$this->getUsername();
334 334
 		$memberOfGroups = $this->connection->getFromCache($cacheKey);
335
-		if(!is_null($memberOfGroups)) {
335
+		if (!is_null($memberOfGroups)) {
336 336
 			return $memberOfGroups;
337 337
 		}
338 338
 		$groupDNs = $this->access->readAttribute($this->getDN(), 'memberOf');
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 * @return string data (provided by LDAP) | false
346 346
 	 */
347 347
 	public function getAvatarImage() {
348
-		if(!is_null($this->avatarImage)) {
348
+		if (!is_null($this->avatarImage)) {
349 349
 			return $this->avatarImage;
350 350
 		}
351 351
 
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 		/** @var Connection $connection */
354 354
 		$connection = $this->access->getConnection();
355 355
 		$attributes = $connection->resolveRule('avatar');
356
-		foreach($attributes as $attribute) {
356
+		foreach ($attributes as $attribute) {
357 357
 			$result = $this->access->readAttribute($this->dn, $attribute);
358
-			if($result !== false && is_array($result) && isset($result[0])) {
358
+			if ($result !== false && is_array($result) && isset($result[0])) {
359 359
 				$this->avatarImage = $result[0];
360 360
 				break;
361 361
 			}
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 		$lastChecked = $this->config->getUserValue($this->uid, 'user_ldap',
393 393
 			self::USER_PREFKEY_LASTREFRESH, 0);
394 394
 
395
-		if((time() - (int)$lastChecked) < (int)$this->config->getAppValue('user_ldap', 'updateAttributesInterval', 86400)) {
395
+		if ((time() - (int) $lastChecked) < (int) $this->config->getAppValue('user_ldap', 'updateAttributesInterval', 86400)) {
396 396
 			return false;
397 397
 		}
398 398
 		return  true;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 	 * @returns string the effective display name
418 418
 	 */
419 419
 	public function composeAndStoreDisplayName($displayName, $displayName2 = '') {
420
-		$displayName2 = (string)$displayName2;
421
-		if($displayName2 !== '') {
422
-			$displayName .= ' (' . $displayName2 . ')';
420
+		$displayName2 = (string) $displayName2;
421
+		if ($displayName2 !== '') {
422
+			$displayName .= ' ('.$displayName2.')';
423 423
 		}
424 424
 		$this->store('displayName', $displayName);
425 425
 		return $displayName;
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 	 * @return bool
442 442
 	 */
443 443
 	private function wasRefreshed($feature) {
444
-		if(isset($this->refreshedFeatures[$feature])) {
444
+		if (isset($this->refreshedFeatures[$feature])) {
445 445
 			return true;
446 446
 		}
447 447
 		$this->refreshedFeatures[$feature] = 1;
@@ -454,23 +454,23 @@  discard block
 block discarded – undo
454 454
 	 * @return null
455 455
 	 */
456 456
 	public function updateEmail($valueFromLDAP = null) {
457
-		if($this->wasRefreshed('email')) {
457
+		if ($this->wasRefreshed('email')) {
458 458
 			return;
459 459
 		}
460
-		$email = (string)$valueFromLDAP;
461
-		if(is_null($valueFromLDAP)) {
460
+		$email = (string) $valueFromLDAP;
461
+		if (is_null($valueFromLDAP)) {
462 462
 			$emailAttribute = $this->connection->ldapEmailAttribute;
463 463
 			if ($emailAttribute !== '') {
464 464
 				$aEmail = $this->access->readAttribute($this->dn, $emailAttribute);
465
-				if(is_array($aEmail) && (count($aEmail) > 0)) {
466
-					$email = (string)$aEmail[0];
465
+				if (is_array($aEmail) && (count($aEmail) > 0)) {
466
+					$email = (string) $aEmail[0];
467 467
 				}
468 468
 			}
469 469
 		}
470 470
 		if ($email !== '') {
471 471
 			$user = $this->userManager->get($this->uid);
472 472
 			if (!is_null($user)) {
473
-				$currentEmail = (string)$user->getEMailAddress();
473
+				$currentEmail = (string) $user->getEMailAddress();
474 474
 				if ($currentEmail !== $email) {
475 475
 					$user->setEMailAddress($email);
476 476
 				}
@@ -499,35 +499,35 @@  discard block
 block discarded – undo
499 499
 	 * @return null
500 500
 	 */
501 501
 	public function updateQuota($valueFromLDAP = null) {
502
-		if($this->wasRefreshed('quota')) {
502
+		if ($this->wasRefreshed('quota')) {
503 503
 			return;
504 504
 		}
505 505
 
506 506
 		$quotaAttribute = $this->connection->ldapQuotaAttribute;
507 507
 		$defaultQuota = $this->connection->ldapQuotaDefault;
508
-		if($quotaAttribute === '' && $defaultQuota === '') {
508
+		if ($quotaAttribute === '' && $defaultQuota === '') {
509 509
 			return;
510 510
 		}
511 511
 
512 512
 		$quota = false;
513
-		if(is_null($valueFromLDAP) && $quotaAttribute !== '') {
513
+		if (is_null($valueFromLDAP) && $quotaAttribute !== '') {
514 514
 			$aQuota = $this->access->readAttribute($this->dn, $quotaAttribute);
515
-			if($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) {
515
+			if ($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) {
516 516
 				$quota = $aQuota[0];
517
-			} else if(is_array($aQuota) && isset($aQuota[0])) {
518
-				$this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::DEBUG);
517
+			} else if (is_array($aQuota) && isset($aQuota[0])) {
518
+				$this->log->log('no suitable LDAP quota found for user '.$this->uid.': ['.$aQuota[0].']', ILogger::DEBUG);
519 519
 			}
520 520
 		} else if ($this->verifyQuotaValue($valueFromLDAP)) {
521 521
 			$quota = $valueFromLDAP;
522 522
 		} else {
523
-			$this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::DEBUG);
523
+			$this->log->log('no suitable LDAP quota found for user '.$this->uid.': ['.$valueFromLDAP.']', ILogger::DEBUG);
524 524
 		}
525 525
 
526 526
 		if ($quota === false && $this->verifyQuotaValue($defaultQuota)) {
527 527
 			// quota not found using the LDAP attribute (or not parseable). Try the default quota
528 528
 			$quota = $defaultQuota;
529
-		} else if($quota === false) {
530
-			$this->log->log('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::DEBUG);
529
+		} else if ($quota === false) {
530
+			$this->log->log('no suitable default quota found for user '.$this->uid.': ['.$defaultQuota.']', ILogger::DEBUG);
531 531
 			return;
532 532
 		}
533 533
 
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 		if ($targetUser instanceof IUser) {
536 536
 			$targetUser->setQuota($quota);
537 537
 		} else {
538
-			$this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::INFO);
538
+			$this->log->log('trying to set a quota for user '.$this->uid.' but the user is missing', ILogger::INFO);
539 539
 		}
540 540
 	}
541 541
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 	 * @param array $params
550 550
 	 */
551 551
 	public function updateAvatarPostLogin($params) {
552
-		if(isset($params['uid']) && $params['uid'] === $this->getUsername()) {
552
+		if (isset($params['uid']) && $params['uid'] === $this->getUsername()) {
553 553
 			$this->updateAvatar();
554 554
 		}
555 555
 	}
@@ -559,15 +559,15 @@  discard block
 block discarded – undo
559 559
 	 * @return bool
560 560
 	 */
561 561
 	public function updateAvatar($force = false) {
562
-		if(!$force && $this->wasRefreshed('avatar')) {
562
+		if (!$force && $this->wasRefreshed('avatar')) {
563 563
 			return false;
564 564
 		}
565 565
 		$avatarImage = $this->getAvatarImage();
566
-		if($avatarImage === false) {
566
+		if ($avatarImage === false) {
567 567
 			//not set, nothing left to do;
568 568
 			return false;
569 569
 		}
570
-		if(!$this->image->loadFromBase64(base64_encode($avatarImage))) {
570
+		if (!$this->image->loadFromBase64(base64_encode($avatarImage))) {
571 571
 			return false;
572 572
 		}
573 573
 		return $this->setOwnCloudAvatar();
@@ -578,18 +578,18 @@  discard block
 block discarded – undo
578 578
 	 * @return bool
579 579
 	 */
580 580
 	private function setOwnCloudAvatar() {
581
-		if(!$this->image->valid()) {
581
+		if (!$this->image->valid()) {
582 582
 			$this->log->log('avatar image data from LDAP invalid for '.$this->dn, ILogger::ERROR);
583 583
 			return false;
584 584
 		}
585 585
 		//make sure it is a square and not bigger than 128x128
586 586
 		$size = min(array($this->image->width(), $this->image->height(), 128));
587
-		if(!$this->image->centerCrop($size)) {
587
+		if (!$this->image->centerCrop($size)) {
588 588
 			$this->log->log('croping image for avatar failed for '.$this->dn, ILogger::ERROR);
589 589
 			return false;
590 590
 		}
591 591
 
592
-		if(!$this->fs->isLoaded()) {
592
+		if (!$this->fs->isLoaded()) {
593 593
 			$this->fs->setup($this->uid);
594 594
 		}
595 595
 
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 			return true;
600 600
 		} catch (\Exception $e) {
601 601
 			\OC::$server->getLogger()->logException($e, [
602
-				'message' => 'Could not set avatar for ' . $this->dn,
602
+				'message' => 'Could not set avatar for '.$this->dn,
603 603
 				'level' => ILogger::INFO,
604 604
 				'app' => 'user_ldap',
605 605
 			]);
@@ -614,18 +614,18 @@  discard block
 block discarded – undo
614 614
 	 */
615 615
 	public function handlePasswordExpiry($params) {
616 616
 		$ppolicyDN = $this->connection->ldapDefaultPPolicyDN;
617
-		if (empty($ppolicyDN) || ((int)$this->connection->turnOnPasswordChange !== 1)) {
618
-			return;//password expiry handling disabled
617
+		if (empty($ppolicyDN) || ((int) $this->connection->turnOnPasswordChange !== 1)) {
618
+			return; //password expiry handling disabled
619 619
 		}
620 620
 		$uid = $params['uid'];
621
-		if(isset($uid) && $uid === $this->getUsername()) {
621
+		if (isset($uid) && $uid === $this->getUsername()) {
622 622
 			//retrieve relevant user attributes
623 623
 			$result = $this->access->search('objectclass=*', array($this->dn), ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']);
624 624
 			
625
-			if(array_key_exists('pwdpolicysubentry', $result[0])) {
625
+			if (array_key_exists('pwdpolicysubentry', $result[0])) {
626 626
 				$pwdPolicySubentry = $result[0]['pwdpolicysubentry'];
627
-				if($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)){
628
-					$ppolicyDN = $pwdPolicySubentry[0];//custom ppolicy DN
627
+				if ($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)) {
628
+					$ppolicyDN = $pwdPolicySubentry[0]; //custom ppolicy DN
629 629
 				}
630 630
 			}
631 631
 			
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 			$pwdChangedTime = array_key_exists('pwdchangedtime', $result[0]) ? $result[0]['pwdchangedtime'] : null;
635 635
 			
636 636
 			//retrieve relevant password policy attributes
637
-			$cacheKey = 'ppolicyAttributes' . $ppolicyDN;
637
+			$cacheKey = 'ppolicyAttributes'.$ppolicyDN;
638 638
 			$result = $this->connection->getFromCache($cacheKey);
639
-			if(is_null($result)) {
639
+			if (is_null($result)) {
640 640
 				$result = $this->access->search('objectclass=*', array($ppolicyDN), ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']);
641 641
 				$this->connection->writeToCache($cacheKey, $result);
642 642
 			}
@@ -647,10 +647,10 @@  discard block
 block discarded – undo
647 647
 			
648 648
 			//handle grace login
649 649
 			$pwdGraceUseTimeCount = count($pwdGraceUseTime);
650
-			if($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login?
651
-				if($pwdGraceAuthNLimit 
650
+			if ($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login?
651
+				if ($pwdGraceAuthNLimit 
652 652
 					&& (count($pwdGraceAuthNLimit) > 0)
653
-					&&($pwdGraceUseTimeCount < (int)$pwdGraceAuthNLimit[0])) { //at least one more grace login available?
653
+					&&($pwdGraceUseTimeCount < (int) $pwdGraceAuthNLimit[0])) { //at least one more grace login available?
654 654
 					$this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true');
655 655
 					header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute(
656 656
 					'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid)));
@@ -661,24 +661,24 @@  discard block
 block discarded – undo
661 661
 				exit();
662 662
 			}
663 663
 			//handle pwdReset attribute
664
-			if($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password
664
+			if ($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password
665 665
 				$this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true');
666 666
 				header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute(
667 667
 				'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid)));
668 668
 				exit();
669 669
 			}
670 670
 			//handle password expiry warning
671
-			if($pwdChangedTime && (count($pwdChangedTime) > 0)) {
672
-				if($pwdMaxAge && (count($pwdMaxAge) > 0)
671
+			if ($pwdChangedTime && (count($pwdChangedTime) > 0)) {
672
+				if ($pwdMaxAge && (count($pwdMaxAge) > 0)
673 673
 					&& $pwdExpireWarning && (count($pwdExpireWarning) > 0)) {
674
-					$pwdMaxAgeInt = (int)$pwdMaxAge[0];
675
-					$pwdExpireWarningInt = (int)$pwdExpireWarning[0];
676
-					if($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0){
674
+					$pwdMaxAgeInt = (int) $pwdMaxAge[0];
675
+					$pwdExpireWarningInt = (int) $pwdExpireWarning[0];
676
+					if ($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0) {
677 677
 						$pwdChangedTimeDt = \DateTime::createFromFormat('YmdHisZ', $pwdChangedTime[0]);
678 678
 						$pwdChangedTimeDt->add(new \DateInterval('PT'.$pwdMaxAgeInt.'S'));
679 679
 						$currentDateTime = new \DateTime();
680 680
 						$secondsToExpiry = $pwdChangedTimeDt->getTimestamp() - $currentDateTime->getTimestamp();
681
-						if($secondsToExpiry <= $pwdExpireWarningInt) {
681
+						if ($secondsToExpiry <= $pwdExpireWarningInt) {
682 682
 							//remove last password expiry warning if any
683 683
 							$notification = $this->notificationManager->createNotification();
684 684
 							$notification->setApp('user_ldap')
Please login to merge, or discard this patch.
apps/user_ldap/lib/Configuration.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function __construct($configPrefix, $autoRead = true) {
117 117
 		$this->configPrefix = $configPrefix;
118
-		if($autoRead) {
118
+		if ($autoRead) {
119 119
 			$this->readConfiguration();
120 120
 		}
121 121
 	}
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * @return mixed|null
126 126
 	 */
127 127
 	public function __get($name) {
128
-		if(isset($this->config[$name])) {
128
+		if (isset($this->config[$name])) {
129 129
 			return $this->config[$name];
130 130
 		}
131 131
 		return null;
@@ -156,22 +156,22 @@  discard block
 block discarded – undo
156 156
 	 * @return false|null
157 157
 	 */
158 158
 	public function setConfiguration($config, &$applied = null) {
159
-		if(!is_array($config)) {
159
+		if (!is_array($config)) {
160 160
 			return false;
161 161
 		}
162 162
 
163 163
 		$cta = $this->getConfigTranslationArray();
164
-		foreach($config as $inputKey => $val) {
165
-			if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
164
+		foreach ($config as $inputKey => $val) {
165
+			if (strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
166 166
 				$key = $cta[$inputKey];
167
-			} elseif(array_key_exists($inputKey, $this->config)) {
167
+			} elseif (array_key_exists($inputKey, $this->config)) {
168 168
 				$key = $inputKey;
169 169
 			} else {
170 170
 				continue;
171 171
 			}
172 172
 
173 173
 			$setMethod = 'setValue';
174
-			switch($key) {
174
+			switch ($key) {
175 175
 				case 'ldapAgentPassword':
176 176
 					$setMethod = 'setRawValue';
177 177
 					break;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 					break;
196 196
 			}
197 197
 			$this->$setMethod($key, $val);
198
-			if(is_array($applied)) {
198
+			if (is_array($applied)) {
199 199
 				$applied[] = $inputKey;
200 200
 				// storing key as index avoids duplication, and as value for simplicity
201 201
 			}
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
 	}
206 206
 
207 207
 	public function readConfiguration() {
208
-		if(!$this->configRead && !is_null($this->configPrefix)) {
208
+		if (!$this->configRead && !is_null($this->configPrefix)) {
209 209
 			$cta = array_flip($this->getConfigTranslationArray());
210
-			foreach($this->config as $key => $val) {
211
-				if(!isset($cta[$key])) {
210
+			foreach ($this->config as $key => $val) {
211
+				if (!isset($cta[$key])) {
212 212
 					//some are determined
213 213
 					continue;
214 214
 				}
215 215
 				$dbKey = $cta[$key];
216
-				switch($key) {
216
+				switch ($key) {
217 217
 					case 'ldapBase':
218 218
 					case 'ldapBaseUsers':
219 219
 					case 'ldapBaseGroups':
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	public function saveConfiguration() {
258 258
 		$cta = array_flip($this->getConfigTranslationArray());
259
-		foreach($this->unsavedChanges as $key) {
259
+		foreach ($this->unsavedChanges as $key) {
260 260
 			$value = $this->config[$key];
261 261
 			switch ($key) {
262 262
 				case 'ldapAgentPassword':
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 				case 'ldapGroupFilterObjectclass':
273 273
 				case 'ldapGroupFilterGroups':
274 274
 				case 'ldapLoginFilterAttributes':
275
-					if(is_array($value)) {
275
+					if (is_array($value)) {
276 276
 						$value = implode("\n", $value);
277 277
 					}
278 278
 					break;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 				case 'ldapUuidGroupAttribute':
284 284
 					continue 2;
285 285
 			}
286
-			if(is_null($value)) {
286
+			if (is_null($value)) {
287 287
 				$value = '';
288 288
 			}
289 289
 			$this->saveValue($cta[$key], $value);
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 */
299 299
 	protected function getMultiLine($varName) {
300 300
 		$value = $this->getValue($varName);
301
-		if(empty($value)) {
301
+		if (empty($value)) {
302 302
 			$value = '';
303 303
 		} else {
304 304
 			$value = preg_split('/\r\n|\r|\n/', $value);
@@ -314,21 +314,21 @@  discard block
 block discarded – undo
314 314
 	 * @param array|string $value to set
315 315
 	 */
316 316
 	protected function setMultiLine($varName, $value) {
317
-		if(empty($value)) {
317
+		if (empty($value)) {
318 318
 			$value = '';
319 319
 		} else if (!is_array($value)) {
320 320
 			$value = preg_split('/\r\n|\r|\n|;/', $value);
321
-			if($value === false) {
321
+			if ($value === false) {
322 322
 				$value = '';
323 323
 			}
324 324
 		}
325 325
 
326
-		if(!is_array($value)) {
326
+		if (!is_array($value)) {
327 327
 			$finalValue = trim($value);
328 328
 		} else {
329 329
 			$finalValue = [];
330
-			foreach($value as $key => $val) {
331
-				if(is_string($val)) {
330
+			foreach ($value as $key => $val) {
331
+				if (is_string($val)) {
332 332
 					$val = trim($val);
333 333
 					if ($val !== '') {
334 334
 						//accidental line breaks are not wanted and can cause
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	 */
376 376
 	protected function getValue($varName) {
377 377
 		static $defaults;
378
-		if(is_null($defaults)) {
378
+		if (is_null($defaults)) {
379 379
 			$defaults = $this->getDefaults();
380 380
 		}
381 381
 		return \OC::$server->getConfig()->getAppValue('user_ldap',
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	 * @param mixed $value to set
391 391
 	 */
392 392
 	protected function setValue($varName, $value) {
393
-		if(is_string($value)) {
393
+		if (is_string($value)) {
394 394
 			$value = trim($value);
395 395
 		}
396 396
 		$this->config[$varName] = $value;
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 			'ldap_experienced_admin'            => 'ldapExperiencedAdmin',
540 540
 			'ldap_dynamic_group_member_url'     => 'ldapDynamicGroupMemberURL',
541 541
 			'ldap_default_ppolicy_dn'           => 'ldapDefaultPPolicyDN',
542
-			'ldapIgnoreNamingRules'             => 'ldapIgnoreNamingRules',	// sysconfig
542
+			'ldapIgnoreNamingRules'             => 'ldapIgnoreNamingRules', // sysconfig
543 543
 		);
544 544
 		return $array;
545 545
 	}
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 	 * @throws \RuntimeException
551 551
 	 */
552 552
 	public function resolveRule($rule) {
553
-		if($rule === 'avatar') {
553
+		if ($rule === 'avatar') {
554 554
 			return $this->getAvatarAttributes();
555 555
 		}
556 556
 		throw new \RuntimeException('Invalid rule');
@@ -560,17 +560,17 @@  discard block
 block discarded – undo
560 560
 		$value = $this->ldapUserAvatarRule ?: self::AVATAR_PREFIX_DEFAULT;
561 561
 		$defaultAttributes = ['jpegphoto', 'thumbnailphoto'];
562 562
 
563
-		if($value === self::AVATAR_PREFIX_NONE) {
563
+		if ($value === self::AVATAR_PREFIX_NONE) {
564 564
 			return [];
565 565
 		}
566
-		if(strpos($value, self::AVATAR_PREFIX_DATA_ATTRIBUTE) === 0) {
566
+		if (strpos($value, self::AVATAR_PREFIX_DATA_ATTRIBUTE) === 0) {
567 567
 			$attribute = trim(substr($value, strlen(self::AVATAR_PREFIX_DATA_ATTRIBUTE)));
568
-			if($attribute === '') {
568
+			if ($attribute === '') {
569 569
 				return $defaultAttributes;
570 570
 			}
571 571
 			return [strtolower($attribute)];
572 572
 		}
573
-		if($value !== self::AVATAR_PREFIX_DEFAULT) {
573
+		if ($value !== self::AVATAR_PREFIX_DEFAULT) {
574 574
 			\OC::$server->getLogger()->warning('Invalid config value to ldapUserAvatarRule; falling back to default.');
575 575
 		}
576 576
 		return $defaultAttributes;
Please login to merge, or discard this patch.
apps/user_ldap/lib/User_LDAP.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
 			return $this->userPluginManager->canChangeAvatar($uid);
104 104
 		}
105 105
 
106
-		if(!$this->implementsActions(Backend::PROVIDE_AVATAR)) {
106
+		if (!$this->implementsActions(Backend::PROVIDE_AVATAR)) {
107 107
 			return true;
108 108
 		}
109 109
 
110 110
 		$user = $this->access->userManager->get($uid);
111
-		if(!$user instanceof User) {
111
+		if (!$user instanceof User) {
112 112
 			return false;
113 113
 		}
114 114
 		$imageData = $user->getAvatarImage();
115
-		if($imageData === false) {
115
+		if ($imageData === false) {
116 116
 			return true;
117 117
 		}
118 118
 		return !$user->updateAvatar(true);
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 	public function loginName2UserName($loginName) {
128 128
 		$cacheKey = 'loginName2UserName-'.$loginName;
129 129
 		$username = $this->access->connection->getFromCache($cacheKey);
130
-		if(!is_null($username)) {
130
+		if (!is_null($username)) {
131 131
 			return $username;
132 132
 		}
133 133
 
134 134
 		try {
135 135
 			$ldapRecord = $this->getLDAPUserByLoginName($loginName);
136 136
 			$user = $this->access->userManager->get($ldapRecord['dn'][0]);
137
-			if($user instanceof OfflineUser) {
137
+			if ($user instanceof OfflineUser) {
138 138
 				// this path is not really possible, however get() is documented
139 139
 				// to return User or OfflineUser so we are very defensive here.
140 140
 				$this->access->connection->writeToCache($cacheKey, false);
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 		//find out dn of the user name
171 171
 		$attrs = $this->access->userManager->getAttributes();
172 172
 		$users = $this->access->fetchUsersByLoginName($loginName, $attrs);
173
-		if(count($users) < 1) {
174
-			throw new NotOnLDAP('No user available for the given login name on ' .
175
-				$this->access->connection->ldapHost . ':' . $this->access->connection->ldapPort);
173
+		if (count($users) < 1) {
174
+			throw new NotOnLDAP('No user available for the given login name on '.
175
+				$this->access->connection->ldapHost.':'.$this->access->connection->ldapPort);
176 176
 		}
177 177
 		return $users[0];
178 178
 	}
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 	public function checkPassword($uid, $password) {
188 188
 		try {
189 189
 			$ldapRecord = $this->getLDAPUserByLoginName($uid);
190
-		} catch(NotOnLDAP $e) {
191
-			if($this->ocConfig->getSystemValue('loglevel', ILogger::WARN) === ILogger::DEBUG) {
190
+		} catch (NotOnLDAP $e) {
191
+			if ($this->ocConfig->getSystemValue('loglevel', ILogger::WARN) === ILogger::DEBUG) {
192 192
 				\OC::$server->getLogger()->logException($e, ['app' => 'user_ldap']);
193 193
 			}
194 194
 			return false;
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 		$dn = $ldapRecord['dn'][0];
197 197
 		$user = $this->access->userManager->get($dn);
198 198
 
199
-		if(!$user instanceof User) {
199
+		if (!$user instanceof User) {
200 200
 			Util::writeLog('user_ldap',
201
-				'LDAP Login: Could not get user object for DN ' . $dn .
201
+				'LDAP Login: Could not get user object for DN '.$dn.
202 202
 				'. Maybe the LDAP entry has no set display name attribute?',
203 203
 				ILogger::WARN);
204 204
 			return false;
205 205
 		}
206
-		if($user->getUsername() !== false) {
206
+		if ($user->getUsername() !== false) {
207 207
 			//are the credentials OK?
208
-			if(!$this->access->areCredentialsValid($dn, $password)) {
208
+			if (!$this->access->areCredentialsValid($dn, $password)) {
209 209
 				return false;
210 210
 			}
211 211
 
@@ -232,14 +232,14 @@  discard block
 block discarded – undo
232 232
 
233 233
 		$user = $this->access->userManager->get($uid);
234 234
 
235
-		if(!$user instanceof User) {
236
-			throw new \Exception('LDAP setPassword: Could not get user object for uid ' . $uid .
235
+		if (!$user instanceof User) {
236
+			throw new \Exception('LDAP setPassword: Could not get user object for uid '.$uid.
237 237
 				'. Maybe the LDAP entry has no set display name attribute?');
238 238
 		}
239
-		if($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) {
239
+		if ($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) {
240 240
 			$ldapDefaultPPolicyDN = $this->access->connection->ldapDefaultPPolicyDN;
241 241
 			$turnOnPasswordChange = $this->access->connection->turnOnPasswordChange;
242
-			if (!empty($ldapDefaultPPolicyDN) && ((int)$turnOnPasswordChange === 1)) {
242
+			if (!empty($ldapDefaultPPolicyDN) && ((int) $turnOnPasswordChange === 1)) {
243 243
 				//remove last password expiry warning if any
244 244
 				$notification = $this->notificationManager->createNotification();
245 245
 				$notification->setApp('user_ldap')
@@ -268,18 +268,18 @@  discard block
 block discarded – undo
268 268
 
269 269
 		//check if users are cached, if so return
270 270
 		$ldap_users = $this->access->connection->getFromCache($cachekey);
271
-		if(!is_null($ldap_users)) {
271
+		if (!is_null($ldap_users)) {
272 272
 			return $ldap_users;
273 273
 		}
274 274
 
275 275
 		// if we'd pass -1 to LDAP search, we'd end up in a Protocol
276 276
 		// error. With a limit of 0, we get 0 results. So we pass null.
277
-		if($limit <= 0) {
277
+		if ($limit <= 0) {
278 278
 			$limit = null;
279 279
 		}
280 280
 		$filter = $this->access->combineFilterWithAnd(array(
281 281
 			$this->access->connection->ldapUserFilter,
282
-			$this->access->connection->ldapUserDisplayName . '=*',
282
+			$this->access->connection->ldapUserDisplayName.'=*',
283 283
 			$this->access->getFilterPartForUserSearch($search)
284 284
 		));
285 285
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			$this->access->userManager->getAttributes(true),
293 293
 			$limit, $offset);
294 294
 		$ldap_users = $this->access->nextcloudUserNames($ldap_users);
295
-		Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', ILogger::DEBUG);
295
+		Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users).' Users found', ILogger::DEBUG);
296 296
 
297 297
 		$this->access->connection->writeToCache($cachekey, $ldap_users);
298 298
 		return $ldap_users;
@@ -308,19 +308,19 @@  discard block
 block discarded – undo
308 308
 	 * @throws \OC\ServerNotAvailableException
309 309
 	 */
310 310
 	public function userExistsOnLDAP($user) {
311
-		if(is_string($user)) {
311
+		if (is_string($user)) {
312 312
 			$user = $this->access->userManager->get($user);
313 313
 		}
314
-		if(is_null($user)) {
314
+		if (is_null($user)) {
315 315
 			return false;
316 316
 		}
317 317
 
318 318
 		$dn = $user->getDN();
319 319
 		//check if user really still exists by reading its entry
320
-		if(!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) {
320
+		if (!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) {
321 321
 			$lcr = $this->access->connection->getConnectionResource();
322
-			if(is_null($lcr)) {
323
-				throw new \Exception('No LDAP Connection to server ' . $this->access->connection->ldapHost);
322
+			if (is_null($lcr)) {
323
+				throw new \Exception('No LDAP Connection to server '.$this->access->connection->ldapHost);
324 324
 			}
325 325
 
326 326
 			try {
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 			}
343 343
 		}
344 344
 
345
-		if($user instanceof OfflineUser) {
345
+		if ($user instanceof OfflineUser) {
346 346
 			$user->unmark();
347 347
 		}
348 348
 
@@ -357,18 +357,18 @@  discard block
 block discarded – undo
357 357
 	 */
358 358
 	public function userExists($uid) {
359 359
 		$userExists = $this->access->connection->getFromCache('userExists'.$uid);
360
-		if(!is_null($userExists)) {
361
-			return (bool)$userExists;
360
+		if (!is_null($userExists)) {
361
+			return (bool) $userExists;
362 362
 		}
363 363
 		//getting dn, if false the user does not exist. If dn, he may be mapped only, requires more checking.
364 364
 		$user = $this->access->userManager->get($uid);
365 365
 
366
-		if(is_null($user)) {
366
+		if (is_null($user)) {
367 367
 			Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '.
368 368
 				$this->access->connection->ldapHost, ILogger::DEBUG);
369 369
 			$this->access->connection->writeToCache('userExists'.$uid, false);
370 370
 			return false;
371
-		} else if($user instanceof OfflineUser) {
371
+		} else if ($user instanceof OfflineUser) {
372 372
 			//express check for users marked as deleted. Returning true is
373 373
 			//necessary for cleanup
374 374
 			return true;
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 
377 377
 		$result = $this->userExistsOnLDAP($user);
378 378
 		$this->access->connection->writeToCache('userExists'.$uid, $result);
379
-		if($result === true) {
379
+		if ($result === true) {
380 380
 			$user->update();
381 381
 		}
382 382
 		return $result;
@@ -394,13 +394,13 @@  discard block
 block discarded – undo
394 394
 		}
395 395
 
396 396
 		$marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0);
397
-		if((int)$marked === 0) {
397
+		if ((int) $marked === 0) {
398 398
 			\OC::$server->getLogger()->notice(
399
-				'User '.$uid . ' is not marked as deleted, not cleaning up.',
399
+				'User '.$uid.' is not marked as deleted, not cleaning up.',
400 400
 				array('app' => 'user_ldap'));
401 401
 			return false;
402 402
 		}
403
-		\OC::$server->getLogger()->info('Cleaning up after user ' . $uid,
403
+		\OC::$server->getLogger()->info('Cleaning up after user '.$uid,
404 404
 			array('app' => 'user_ldap'));
405 405
 
406 406
 		$this->access->getUserMapper()->unmap($uid); // we don't emit unassign signals here, since it is implicit to delete signals fired from core
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	 */
419 419
 	public function getHome($uid) {
420 420
 		// user Exists check required as it is not done in user proxy!
421
-		if(!$this->userExists($uid)) {
421
+		if (!$this->userExists($uid)) {
422 422
 			return false;
423 423
 		}
424 424
 
@@ -428,22 +428,22 @@  discard block
 block discarded – undo
428 428
 
429 429
 		$cacheKey = 'getHome'.$uid;
430 430
 		$path = $this->access->connection->getFromCache($cacheKey);
431
-		if(!is_null($path)) {
431
+		if (!is_null($path)) {
432 432
 			return $path;
433 433
 		}
434 434
 
435 435
 		// early return path if it is a deleted user
436 436
 		$user = $this->access->userManager->get($uid);
437
-		if($user instanceof OfflineUser) {
438
-			if($this->currentUserInDeletionProcess !== null
437
+		if ($user instanceof OfflineUser) {
438
+			if ($this->currentUserInDeletionProcess !== null
439 439
 				&& $this->currentUserInDeletionProcess === $user->getOCName()
440 440
 			) {
441 441
 				return $user->getHomePath();
442 442
 			} else {
443
-				throw new NoUserException($uid . ' is not a valid user anymore');
443
+				throw new NoUserException($uid.' is not a valid user anymore');
444 444
 			}
445 445
 		} else if ($user === null) {
446
-			throw new NoUserException($uid . ' is not a valid user anymore');
446
+			throw new NoUserException($uid.' is not a valid user anymore');
447 447
 		}
448 448
 
449 449
 		$path = $user->getHomePath();
@@ -462,12 +462,12 @@  discard block
 block discarded – undo
462 462
 			return $this->userPluginManager->getDisplayName($uid);
463 463
 		}
464 464
 
465
-		if(!$this->userExists($uid)) {
465
+		if (!$this->userExists($uid)) {
466 466
 			return false;
467 467
 		}
468 468
 
469 469
 		$cacheKey = 'getDisplayName'.$uid;
470
-		if(!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) {
470
+		if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) {
471 471
 			return $displayName;
472 472
 		}
473 473
 
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 			$this->access->username2dn($uid),
485 485
 			$this->access->connection->ldapUserDisplayName);
486 486
 
487
-		if($displayName && (count($displayName) > 0)) {
487
+		if ($displayName && (count($displayName) > 0)) {
488 488
 			$displayName = $displayName[0];
489 489
 
490
-			if (is_array($displayName2)){
490
+			if (is_array($displayName2)) {
491 491
 				$displayName2 = count($displayName2) > 0 ? $displayName2[0] : '';
492 492
 			}
493 493
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 	 */
530 530
 	public function getDisplayNames($search = '', $limit = null, $offset = null) {
531 531
 		$cacheKey = 'getDisplayNames-'.$search.'-'.$limit.'-'.$offset;
532
-		if(!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) {
532
+		if (!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) {
533 533
 			return $displayNames;
534 534
 		}
535 535
 
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
 	* compared with \OC\User\Backend::CREATE_USER etc.
552 552
 	*/
553 553
 	public function implementsActions($actions) {
554
-		return (bool)((Backend::CHECK_PASSWORD
554
+		return (bool) ((Backend::CHECK_PASSWORD
555 555
 			| Backend::GET_HOME
556 556
 			| Backend::GET_DISPLAYNAME
557 557
 			| (($this->access->connection->ldapUserAvatarRule !== 'none') ? Backend::PROVIDE_AVATAR : 0)
558 558
 			| Backend::COUNT_USERS
559
-			| (((int)$this->access->connection->turnOnPasswordChange === 1)? Backend::SET_PASSWORD :0)
559
+			| (((int) $this->access->connection->turnOnPasswordChange === 1) ? Backend::SET_PASSWORD : 0)
560 560
 			| $this->userPluginManager->getImplementedActions())
561 561
 			& $actions);
562 562
 	}
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 
581 581
 		$filter = $this->access->getFilterForUserCount();
582 582
 		$cacheKey = 'countUsers-'.$filter;
583
-		if(!is_null($entries = $this->access->connection->getFromCache($cacheKey))) {
583
+		if (!is_null($entries = $this->access->connection->getFromCache($cacheKey))) {
584 584
 			return $entries;
585 585
 		}
586 586
 		$entries = $this->access->countUsers($filter);
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 	 * Backend name to be shown in user management
593 593
 	 * @return string the name of the backend to be shown
594 594
 	 */
595
-	public function getBackendName(){
595
+	public function getBackendName() {
596 596
 		return 'LDAP';
597 597
 	}
598 598
 	
Please login to merge, or discard this patch.