@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | return $this->userPluginManager->canChangeAvatar($uid); |
103 | 103 | } |
104 | 104 | |
105 | - if(!$this->implementsActions(Backend::PROVIDE_AVATAR)) { |
|
105 | + if (!$this->implementsActions(Backend::PROVIDE_AVATAR)) { |
|
106 | 106 | return true; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $user = $this->access->userManager->get($uid); |
110 | - if(!$user instanceof User) { |
|
110 | + if (!$user instanceof User) { |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | $imageData = $user->getAvatarImage(); |
114 | - if($imageData === false) { |
|
114 | + if ($imageData === false) { |
|
115 | 115 | return true; |
116 | 116 | } |
117 | 117 | return !$user->updateAvatar(true); |
@@ -126,14 +126,14 @@ discard block |
||
126 | 126 | public function loginName2UserName($loginName) { |
127 | 127 | $cacheKey = 'loginName2UserName-'.$loginName; |
128 | 128 | $username = $this->access->connection->getFromCache($cacheKey); |
129 | - if(!is_null($username)) { |
|
129 | + if (!is_null($username)) { |
|
130 | 130 | return $username; |
131 | 131 | } |
132 | 132 | |
133 | 133 | try { |
134 | 134 | $ldapRecord = $this->getLDAPUserByLoginName($loginName); |
135 | 135 | $user = $this->access->userManager->get($ldapRecord['dn'][0]); |
136 | - if($user instanceof OfflineUser) { |
|
136 | + if ($user instanceof OfflineUser) { |
|
137 | 137 | // this path is not really possible, however get() is documented |
138 | 138 | // to return User or OfflineUser so we are very defensive here. |
139 | 139 | $this->access->connection->writeToCache($cacheKey, false); |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | //find out dn of the user name |
170 | 170 | $attrs = $this->access->userManager->getAttributes(); |
171 | 171 | $users = $this->access->fetchUsersByLoginName($loginName, $attrs); |
172 | - if(count($users) < 1) { |
|
173 | - throw new NotOnLDAP('No user available for the given login name on ' . |
|
174 | - $this->access->connection->ldapHost . ':' . $this->access->connection->ldapPort); |
|
172 | + if (count($users) < 1) { |
|
173 | + throw new NotOnLDAP('No user available for the given login name on '. |
|
174 | + $this->access->connection->ldapHost.':'.$this->access->connection->ldapPort); |
|
175 | 175 | } |
176 | 176 | return $users[0]; |
177 | 177 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | public function checkPassword($uid, $password) { |
187 | 187 | try { |
188 | 188 | $ldapRecord = $this->getLDAPUserByLoginName($uid); |
189 | - } catch(NotOnLDAP $e) { |
|
190 | - if($this->ocConfig->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) { |
|
189 | + } catch (NotOnLDAP $e) { |
|
190 | + if ($this->ocConfig->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) { |
|
191 | 191 | \OC::$server->getLogger()->logException($e, ['app' => 'user_ldap']); |
192 | 192 | } |
193 | 193 | return false; |
@@ -195,16 +195,16 @@ discard block |
||
195 | 195 | $dn = $ldapRecord['dn'][0]; |
196 | 196 | $user = $this->access->userManager->get($dn); |
197 | 197 | |
198 | - if(!$user instanceof User) { |
|
198 | + if (!$user instanceof User) { |
|
199 | 199 | Util::writeLog('user_ldap', |
200 | - 'LDAP Login: Could not get user object for DN ' . $dn . |
|
200 | + 'LDAP Login: Could not get user object for DN '.$dn. |
|
201 | 201 | '. Maybe the LDAP entry has no set display name attribute?', |
202 | 202 | Util::WARN); |
203 | 203 | return false; |
204 | 204 | } |
205 | - if($user->getUsername() !== false) { |
|
205 | + if ($user->getUsername() !== false) { |
|
206 | 206 | //are the credentials OK? |
207 | - if(!$this->access->areCredentialsValid($dn, $password)) { |
|
207 | + if (!$this->access->areCredentialsValid($dn, $password)) { |
|
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | |
232 | 232 | $user = $this->access->userManager->get($uid); |
233 | 233 | |
234 | - if(!$user instanceof User) { |
|
235 | - throw new \Exception('LDAP setPassword: Could not get user object for uid ' . $uid . |
|
234 | + if (!$user instanceof User) { |
|
235 | + throw new \Exception('LDAP setPassword: Could not get user object for uid '.$uid. |
|
236 | 236 | '. Maybe the LDAP entry has no set display name attribute?'); |
237 | 237 | } |
238 | - if($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) { |
|
238 | + if ($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) { |
|
239 | 239 | $ldapDefaultPPolicyDN = $this->access->connection->ldapDefaultPPolicyDN; |
240 | 240 | $turnOnPasswordChange = $this->access->connection->turnOnPasswordChange; |
241 | 241 | if (!empty($ldapDefaultPPolicyDN) && (intval($turnOnPasswordChange) === 1)) { |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | |
268 | 268 | //check if users are cached, if so return |
269 | 269 | $ldap_users = $this->access->connection->getFromCache($cachekey); |
270 | - if(!is_null($ldap_users)) { |
|
270 | + if (!is_null($ldap_users)) { |
|
271 | 271 | return $ldap_users; |
272 | 272 | } |
273 | 273 | |
274 | 274 | // if we'd pass -1 to LDAP search, we'd end up in a Protocol |
275 | 275 | // error. With a limit of 0, we get 0 results. So we pass null. |
276 | - if($limit <= 0) { |
|
276 | + if ($limit <= 0) { |
|
277 | 277 | $limit = null; |
278 | 278 | } |
279 | 279 | $filter = $this->access->combineFilterWithAnd(array( |
280 | 280 | $this->access->connection->ldapUserFilter, |
281 | - $this->access->connection->ldapUserDisplayName . '=*', |
|
281 | + $this->access->connection->ldapUserDisplayName.'=*', |
|
282 | 282 | $this->access->getFilterPartForUserSearch($search) |
283 | 283 | )); |
284 | 284 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $this->access->userManager->getAttributes(true), |
292 | 292 | $limit, $offset); |
293 | 293 | $ldap_users = $this->access->nextcloudUserNames($ldap_users); |
294 | - Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', Util::DEBUG); |
|
294 | + Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users).' Users found', Util::DEBUG); |
|
295 | 295 | |
296 | 296 | $this->access->connection->writeToCache($cachekey, $ldap_users); |
297 | 297 | return $ldap_users; |
@@ -307,16 +307,16 @@ discard block |
||
307 | 307 | * @throws \OC\ServerNotAvailableException |
308 | 308 | */ |
309 | 309 | public function userExistsOnLDAP($user) { |
310 | - if(is_string($user)) { |
|
310 | + if (is_string($user)) { |
|
311 | 311 | $user = $this->access->userManager->get($user); |
312 | 312 | } |
313 | - if(is_null($user)) { |
|
313 | + if (is_null($user)) { |
|
314 | 314 | return false; |
315 | 315 | } |
316 | 316 | |
317 | 317 | $dn = $user->getDN(); |
318 | 318 | //check if user really still exists by reading its entry |
319 | - if(!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) { |
|
319 | + if (!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) { |
|
320 | 320 | try { |
321 | 321 | $uuid = $this->access->getUserMapper()->getUUIDByDN($dn); |
322 | 322 | if (!$uuid) { |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | - if($user instanceof OfflineUser) { |
|
339 | + if ($user instanceof OfflineUser) { |
|
340 | 340 | $user->unmark(); |
341 | 341 | } |
342 | 342 | |
@@ -351,18 +351,18 @@ discard block |
||
351 | 351 | */ |
352 | 352 | public function userExists($uid) { |
353 | 353 | $userExists = $this->access->connection->getFromCache('userExists'.$uid); |
354 | - if(!is_null($userExists)) { |
|
355 | - return (bool)$userExists; |
|
354 | + if (!is_null($userExists)) { |
|
355 | + return (bool) $userExists; |
|
356 | 356 | } |
357 | 357 | //getting dn, if false the user does not exist. If dn, he may be mapped only, requires more checking. |
358 | 358 | $user = $this->access->userManager->get($uid); |
359 | 359 | |
360 | - if(is_null($user)) { |
|
360 | + if (is_null($user)) { |
|
361 | 361 | Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '. |
362 | 362 | $this->access->connection->ldapHost, Util::DEBUG); |
363 | 363 | $this->access->connection->writeToCache('userExists'.$uid, false); |
364 | 364 | return false; |
365 | - } else if($user instanceof OfflineUser) { |
|
365 | + } else if ($user instanceof OfflineUser) { |
|
366 | 366 | //express check for users marked as deleted. Returning true is |
367 | 367 | //necessary for cleanup |
368 | 368 | return true; |
@@ -385,13 +385,13 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | $marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0); |
388 | - if(intval($marked) === 0) { |
|
388 | + if (intval($marked) === 0) { |
|
389 | 389 | \OC::$server->getLogger()->notice( |
390 | - 'User '.$uid . ' is not marked as deleted, not cleaning up.', |
|
390 | + 'User '.$uid.' is not marked as deleted, not cleaning up.', |
|
391 | 391 | array('app' => 'user_ldap')); |
392 | 392 | return false; |
393 | 393 | } |
394 | - \OC::$server->getLogger()->info('Cleaning up after user ' . $uid, |
|
394 | + \OC::$server->getLogger()->info('Cleaning up after user '.$uid, |
|
395 | 395 | array('app' => 'user_ldap')); |
396 | 396 | |
397 | 397 | $this->access->getUserMapper()->unmap($uid); |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | */ |
410 | 410 | public function getHome($uid) { |
411 | 411 | // user Exists check required as it is not done in user proxy! |
412 | - if(!$this->userExists($uid)) { |
|
412 | + if (!$this->userExists($uid)) { |
|
413 | 413 | return false; |
414 | 414 | } |
415 | 415 | |
@@ -419,22 +419,22 @@ discard block |
||
419 | 419 | |
420 | 420 | $cacheKey = 'getHome'.$uid; |
421 | 421 | $path = $this->access->connection->getFromCache($cacheKey); |
422 | - if(!is_null($path)) { |
|
422 | + if (!is_null($path)) { |
|
423 | 423 | return $path; |
424 | 424 | } |
425 | 425 | |
426 | 426 | // early return path if it is a deleted user |
427 | 427 | $user = $this->access->userManager->get($uid); |
428 | - if($user instanceof OfflineUser) { |
|
429 | - if($this->currentUserInDeletionProcess !== null |
|
428 | + if ($user instanceof OfflineUser) { |
|
429 | + if ($this->currentUserInDeletionProcess !== null |
|
430 | 430 | && $this->currentUserInDeletionProcess === $user->getOCName() |
431 | 431 | ) { |
432 | 432 | return $user->getHomePath(); |
433 | 433 | } else { |
434 | - throw new NoUserException($uid . ' is not a valid user anymore'); |
|
434 | + throw new NoUserException($uid.' is not a valid user anymore'); |
|
435 | 435 | } |
436 | 436 | } else if ($user === null) { |
437 | - throw new NoUserException($uid . ' is not a valid user anymore'); |
|
437 | + throw new NoUserException($uid.' is not a valid user anymore'); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | $path = $user->getHomePath(); |
@@ -453,12 +453,12 @@ discard block |
||
453 | 453 | return $this->userPluginManager->getDisplayName($uid); |
454 | 454 | } |
455 | 455 | |
456 | - if(!$this->userExists($uid)) { |
|
456 | + if (!$this->userExists($uid)) { |
|
457 | 457 | return false; |
458 | 458 | } |
459 | 459 | |
460 | 460 | $cacheKey = 'getDisplayName'.$uid; |
461 | - if(!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
|
461 | + if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
|
462 | 462 | return $displayName; |
463 | 463 | } |
464 | 464 | |
@@ -475,10 +475,10 @@ discard block |
||
475 | 475 | $this->access->username2dn($uid), |
476 | 476 | $this->access->connection->ldapUserDisplayName); |
477 | 477 | |
478 | - if($displayName && (count($displayName) > 0)) { |
|
478 | + if ($displayName && (count($displayName) > 0)) { |
|
479 | 479 | $displayName = $displayName[0]; |
480 | 480 | |
481 | - if (is_array($displayName2)){ |
|
481 | + if (is_array($displayName2)) { |
|
482 | 482 | $displayName2 = count($displayName2) > 0 ? $displayName2[0] : ''; |
483 | 483 | } |
484 | 484 | |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | */ |
521 | 521 | public function getDisplayNames($search = '', $limit = null, $offset = null) { |
522 | 522 | $cacheKey = 'getDisplayNames-'.$search.'-'.$limit.'-'.$offset; |
523 | - if(!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) { |
|
523 | + if (!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) { |
|
524 | 524 | return $displayNames; |
525 | 525 | } |
526 | 526 | |
@@ -542,12 +542,12 @@ discard block |
||
542 | 542 | * compared with \OC\User\Backend::CREATE_USER etc. |
543 | 543 | */ |
544 | 544 | public function implementsActions($actions) { |
545 | - return (bool)((Backend::CHECK_PASSWORD |
|
545 | + return (bool) ((Backend::CHECK_PASSWORD |
|
546 | 546 | | Backend::GET_HOME |
547 | 547 | | Backend::GET_DISPLAYNAME |
548 | 548 | | (($this->access->connection->ldapUserAvatarRule !== 'none') ? Backend::PROVIDE_AVATAR : 0) |
549 | 549 | | Backend::COUNT_USERS |
550 | - | ((intval($this->access->connection->turnOnPasswordChange) === 1)?(Backend::SET_PASSWORD):0) |
|
550 | + | ((intval($this->access->connection->turnOnPasswordChange) === 1) ? (Backend::SET_PASSWORD) : 0) |
|
551 | 551 | | $this->userPluginManager->getImplementedActions()) |
552 | 552 | & $actions); |
553 | 553 | } |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | |
572 | 572 | $filter = $this->access->getFilterForUserCount(); |
573 | 573 | $cacheKey = 'countUsers-'.$filter; |
574 | - if(!is_null($entries = $this->access->connection->getFromCache($cacheKey))) { |
|
574 | + if (!is_null($entries = $this->access->connection->getFromCache($cacheKey))) { |
|
575 | 575 | return $entries; |
576 | 576 | } |
577 | 577 | $entries = $this->access->countUsers($filter); |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | * Backend name to be shown in user management |
584 | 584 | * @return string the name of the backend to be shown |
585 | 585 | */ |
586 | - public function getBackendName(){ |
|
586 | + public function getBackendName() { |
|
587 | 587 | return 'LDAP'; |
588 | 588 | } |
589 | 589 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param array $params |
71 | 71 | */ |
72 | 72 | public function change(array $params) { |
73 | - switch($params['feature']) { |
|
73 | + switch ($params['feature']) { |
|
74 | 74 | case 'enabled': |
75 | 75 | $this->log( |
76 | 76 | $params['value'] === 'true' ? 'User enabled: "%s"' : 'User disabled: "%s"', |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param IUser $user |
99 | 99 | */ |
100 | 100 | public function setPassword(IUser $user) { |
101 | - if($user->getBackendClassName() === 'Database') { |
|
101 | + if ($user->getBackendClassName() === 'Database') { |
|
102 | 102 | $this->log( |
103 | 103 | 'Password of user "%s" has been changed', |
104 | 104 | [ |