@@ -103,16 +103,16 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,16 +308,16 @@ discard block |
||
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 | try { |
322 | 322 | $uuid = $this->access->getUserMapper()->getUUIDByDN($dn); |
323 | 323 | if (!$uuid) { |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | - if($user instanceof OfflineUser) { |
|
340 | + if ($user instanceof OfflineUser) { |
|
341 | 341 | $user->unmark(); |
342 | 342 | } |
343 | 343 | |
@@ -352,18 +352,18 @@ discard block |
||
352 | 352 | */ |
353 | 353 | public function userExists($uid) { |
354 | 354 | $userExists = $this->access->connection->getFromCache('userExists'.$uid); |
355 | - if(!is_null($userExists)) { |
|
356 | - return (bool)$userExists; |
|
355 | + if (!is_null($userExists)) { |
|
356 | + return (bool) $userExists; |
|
357 | 357 | } |
358 | 358 | //getting dn, if false the user does not exist. If dn, he may be mapped only, requires more checking. |
359 | 359 | $user = $this->access->userManager->get($uid); |
360 | 360 | |
361 | - if(is_null($user)) { |
|
361 | + if (is_null($user)) { |
|
362 | 362 | Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '. |
363 | 363 | $this->access->connection->ldapHost, ILogger::DEBUG); |
364 | 364 | $this->access->connection->writeToCache('userExists'.$uid, false); |
365 | 365 | return false; |
366 | - } else if($user instanceof OfflineUser) { |
|
366 | + } else if ($user instanceof OfflineUser) { |
|
367 | 367 | //express check for users marked as deleted. Returning true is |
368 | 368 | //necessary for cleanup |
369 | 369 | return true; |
@@ -386,13 +386,13 @@ discard block |
||
386 | 386 | } |
387 | 387 | |
388 | 388 | $marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0); |
389 | - if((int)$marked === 0) { |
|
389 | + if ((int) $marked === 0) { |
|
390 | 390 | \OC::$server->getLogger()->notice( |
391 | - 'User '.$uid . ' is not marked as deleted, not cleaning up.', |
|
391 | + 'User '.$uid.' is not marked as deleted, not cleaning up.', |
|
392 | 392 | array('app' => 'user_ldap')); |
393 | 393 | return false; |
394 | 394 | } |
395 | - \OC::$server->getLogger()->info('Cleaning up after user ' . $uid, |
|
395 | + \OC::$server->getLogger()->info('Cleaning up after user '.$uid, |
|
396 | 396 | array('app' => 'user_ldap')); |
397 | 397 | |
398 | 398 | $this->access->getUserMapper()->unmap($uid); // we don't emit unassign signals here, since it is implicit to delete signals fired from core |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | public function getHome($uid) { |
412 | 412 | // user Exists check required as it is not done in user proxy! |
413 | - if(!$this->userExists($uid)) { |
|
413 | + if (!$this->userExists($uid)) { |
|
414 | 414 | return false; |
415 | 415 | } |
416 | 416 | |
@@ -420,22 +420,22 @@ discard block |
||
420 | 420 | |
421 | 421 | $cacheKey = 'getHome'.$uid; |
422 | 422 | $path = $this->access->connection->getFromCache($cacheKey); |
423 | - if(!is_null($path)) { |
|
423 | + if (!is_null($path)) { |
|
424 | 424 | return $path; |
425 | 425 | } |
426 | 426 | |
427 | 427 | // early return path if it is a deleted user |
428 | 428 | $user = $this->access->userManager->get($uid); |
429 | - if($user instanceof OfflineUser) { |
|
430 | - if($this->currentUserInDeletionProcess !== null |
|
429 | + if ($user instanceof OfflineUser) { |
|
430 | + if ($this->currentUserInDeletionProcess !== null |
|
431 | 431 | && $this->currentUserInDeletionProcess === $user->getOCName() |
432 | 432 | ) { |
433 | 433 | return $user->getHomePath(); |
434 | 434 | } else { |
435 | - throw new NoUserException($uid . ' is not a valid user anymore'); |
|
435 | + throw new NoUserException($uid.' is not a valid user anymore'); |
|
436 | 436 | } |
437 | 437 | } else if ($user === null) { |
438 | - throw new NoUserException($uid . ' is not a valid user anymore'); |
|
438 | + throw new NoUserException($uid.' is not a valid user anymore'); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | $path = $user->getHomePath(); |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | return $this->userPluginManager->getDisplayName($uid); |
455 | 455 | } |
456 | 456 | |
457 | - if(!$this->userExists($uid)) { |
|
457 | + if (!$this->userExists($uid)) { |
|
458 | 458 | return false; |
459 | 459 | } |
460 | 460 | |
461 | 461 | $cacheKey = 'getDisplayName'.$uid; |
462 | - if(!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
|
462 | + if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
|
463 | 463 | return $displayName; |
464 | 464 | } |
465 | 465 | |
@@ -476,10 +476,10 @@ discard block |
||
476 | 476 | $this->access->username2dn($uid), |
477 | 477 | $this->access->connection->ldapUserDisplayName); |
478 | 478 | |
479 | - if($displayName && (count($displayName) > 0)) { |
|
479 | + if ($displayName && (count($displayName) > 0)) { |
|
480 | 480 | $displayName = $displayName[0]; |
481 | 481 | |
482 | - if (is_array($displayName2)){ |
|
482 | + if (is_array($displayName2)) { |
|
483 | 483 | $displayName2 = count($displayName2) > 0 ? $displayName2[0] : ''; |
484 | 484 | } |
485 | 485 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | */ |
522 | 522 | public function getDisplayNames($search = '', $limit = null, $offset = null) { |
523 | 523 | $cacheKey = 'getDisplayNames-'.$search.'-'.$limit.'-'.$offset; |
524 | - if(!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) { |
|
524 | + if (!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) { |
|
525 | 525 | return $displayNames; |
526 | 526 | } |
527 | 527 | |
@@ -543,12 +543,12 @@ discard block |
||
543 | 543 | * compared with \OC\User\Backend::CREATE_USER etc. |
544 | 544 | */ |
545 | 545 | public function implementsActions($actions) { |
546 | - return (bool)((Backend::CHECK_PASSWORD |
|
546 | + return (bool) ((Backend::CHECK_PASSWORD |
|
547 | 547 | | Backend::GET_HOME |
548 | 548 | | Backend::GET_DISPLAYNAME |
549 | 549 | | (($this->access->connection->ldapUserAvatarRule !== 'none') ? Backend::PROVIDE_AVATAR : 0) |
550 | 550 | | Backend::COUNT_USERS |
551 | - | (((int)$this->access->connection->turnOnPasswordChange === 1)? Backend::SET_PASSWORD :0) |
|
551 | + | (((int) $this->access->connection->turnOnPasswordChange === 1) ? Backend::SET_PASSWORD : 0) |
|
552 | 552 | | $this->userPluginManager->getImplementedActions()) |
553 | 553 | & $actions); |
554 | 554 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | $filter = $this->access->getFilterForUserCount(); |
574 | 574 | $cacheKey = 'countUsers-'.$filter; |
575 | - if(!is_null($entries = $this->access->connection->getFromCache($cacheKey))) { |
|
575 | + if (!is_null($entries = $this->access->connection->getFromCache($cacheKey))) { |
|
576 | 576 | return $entries; |
577 | 577 | } |
578 | 578 | $entries = $this->access->countUsers($filter); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * Backend name to be shown in user management |
585 | 585 | * @return string the name of the backend to be shown |
586 | 586 | */ |
587 | - public function getBackendName(){ |
|
587 | + public function getBackendName() { |
|
588 | 588 | return 'LDAP'; |
589 | 589 | } |
590 | 590 |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | public function assign(string $uid) { |
59 | 59 | $this->log( |
60 | 60 | 'UserID assigned: "%s"', |
61 | - [ 'uid' => $uid ], |
|
62 | - [ 'uid' ] |
|
61 | + ['uid' => $uid], |
|
62 | + ['uid'] |
|
63 | 63 | ); |
64 | 64 | } |
65 | 65 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | public function unassign(string $uid) { |
87 | 87 | $this->log( |
88 | 88 | 'UserID unassigned: "%s"', |
89 | - [ 'uid' => $uid ], |
|
90 | - [ 'uid' ] |
|
89 | + ['uid' => $uid], |
|
90 | + ['uid'] |
|
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param array $params |
98 | 98 | */ |
99 | 99 | public function change(array $params) { |
100 | - switch($params['feature']) { |
|
100 | + switch ($params['feature']) { |
|
101 | 101 | case 'enabled': |
102 | 102 | $this->log( |
103 | 103 | $params['value'] === 'true' ? 'User enabled: "%s"' : 'User disabled: "%s"', |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param IUser $user |
126 | 126 | */ |
127 | 127 | public function setPassword(IUser $user) { |
128 | - if($user->getBackendClassName() === 'Database') { |
|
128 | + if ($user->getBackendClassName() === 'Database') { |
|
129 | 129 | $this->log( |
130 | 130 | 'Password of user "%s" has been changed', |
131 | 131 | [ |