@@ -153,17 +153,17 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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,15 +239,15 @@ discard block |
||
| 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); |
| 246 | 246 | |
| 247 | 247 | //Avatar |
| 248 | 248 | $attrs = array('jpegphoto', 'thumbnailphoto'); |
| 249 | - foreach ($attrs as $attr) { |
|
| 250 | - if(isset($ldapEntry[$attr])) { |
|
| 249 | + foreach ($attrs as $attr) { |
|
| 250 | + if (isset($ldapEntry[$attr])) { |
|
| 251 | 251 | $this->avatarImage = $ldapEntry[$attr][0]; |
| 252 | 252 | // the call to the method that saves the avatar in the file |
| 253 | 253 | // system must be postponed after the login. It is to ensure |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @throws \Exception |
| 283 | 283 | */ |
| 284 | 284 | public function getHomePath($valueFromLDAP = null) { |
| 285 | - $path = (string)$valueFromLDAP; |
|
| 285 | + $path = (string) $valueFromLDAP; |
|
| 286 | 286 | $attr = null; |
| 287 | 287 | |
| 288 | 288 | if (is_null($valueFromLDAP) |
@@ -300,12 +300,12 @@ discard block |
||
| 300 | 300 | if ($path !== '') { |
| 301 | 301 | //if attribute's value is an absolute path take this, otherwise append it to data dir |
| 302 | 302 | //check for / at the beginning or pattern c:\ resp. c:/ |
| 303 | - if( '/' !== $path[0] |
|
| 303 | + if ('/' !== $path[0] |
|
| 304 | 304 | && !(3 < strlen($path) && ctype_alpha($path[0]) |
| 305 | 305 | && $path[1] === ':' && ('\\' === $path[2] || '/' === $path[2])) |
| 306 | 306 | ) { |
| 307 | 307 | $path = $this->config->getSystemValue('datadirectory', |
| 308 | - \OC::$SERVERROOT.'/data' ) . '/' . $path; |
|
| 308 | + \OC::$SERVERROOT.'/data').'/'.$path; |
|
| 309 | 309 | } |
| 310 | 310 | //we need it to store it in the DB as well in case a user gets |
| 311 | 311 | //deleted so we can clean up afterwards |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | return $path; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if( !is_null($attr) |
|
| 318 | + if (!is_null($attr) |
|
| 319 | 319 | && $this->config->getAppValue('user_ldap', 'enforce_home_folder_naming_rule', true) |
| 320 | 320 | ) { |
| 321 | 321 | // a naming rule attribute is defined, but it doesn't exist for that LDAP user |
| 322 | - throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: ' . $this->getUsername()); |
|
| 322 | + throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: '.$this->getUsername()); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | //false will apply default behaviour as defined and done by OC_User |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | public function getMemberOfGroups() { |
| 331 | 331 | $cacheKey = 'getMemberOf'.$this->getUsername(); |
| 332 | 332 | $memberOfGroups = $this->connection->getFromCache($cacheKey); |
| 333 | - if(!is_null($memberOfGroups)) { |
|
| 333 | + if (!is_null($memberOfGroups)) { |
|
| 334 | 334 | return $memberOfGroups; |
| 335 | 335 | } |
| 336 | 336 | $groupDNs = $this->access->readAttribute($this->getDN(), 'memberOf'); |
@@ -343,15 +343,15 @@ discard block |
||
| 343 | 343 | * @return string data (provided by LDAP) | false |
| 344 | 344 | */ |
| 345 | 345 | public function getAvatarImage() { |
| 346 | - if(!is_null($this->avatarImage)) { |
|
| 346 | + if (!is_null($this->avatarImage)) { |
|
| 347 | 347 | return $this->avatarImage; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | $this->avatarImage = false; |
| 351 | 351 | $attributes = array('jpegPhoto', 'thumbnailPhoto'); |
| 352 | - foreach($attributes as $attribute) { |
|
| 352 | + foreach ($attributes as $attribute) { |
|
| 353 | 353 | $result = $this->access->readAttribute($this->dn, $attribute); |
| 354 | - if($result !== false && is_array($result) && isset($result[0])) { |
|
| 354 | + if ($result !== false && is_array($result) && isset($result[0])) { |
|
| 355 | 355 | $this->avatarImage = $result[0]; |
| 356 | 356 | break; |
| 357 | 357 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | $lastChecked = $this->config->getUserValue($this->uid, 'user_ldap', |
| 389 | 389 | self::USER_PREFKEY_LASTREFRESH, 0); |
| 390 | 390 | |
| 391 | - if((time() - (int)$lastChecked) < (int)$this->config->getAppValue('user_ldap', 'updateAttributesInterval', 86400)) { |
|
| 391 | + if ((time() - (int) $lastChecked) < (int) $this->config->getAppValue('user_ldap', 'updateAttributesInterval', 86400)) { |
|
| 392 | 392 | return false; |
| 393 | 393 | } |
| 394 | 394 | return true; |
@@ -413,9 +413,9 @@ discard block |
||
| 413 | 413 | * @returns string the effective display name |
| 414 | 414 | */ |
| 415 | 415 | public function composeAndStoreDisplayName($displayName, $displayName2 = '') { |
| 416 | - $displayName2 = (string)$displayName2; |
|
| 417 | - if($displayName2 !== '') { |
|
| 418 | - $displayName .= ' (' . $displayName2 . ')'; |
|
| 416 | + $displayName2 = (string) $displayName2; |
|
| 417 | + if ($displayName2 !== '') { |
|
| 418 | + $displayName .= ' ('.$displayName2.')'; |
|
| 419 | 419 | } |
| 420 | 420 | $this->store('displayName', $displayName); |
| 421 | 421 | return $displayName; |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | * @return bool |
| 438 | 438 | */ |
| 439 | 439 | private function wasRefreshed($feature) { |
| 440 | - if(isset($this->refreshedFeatures[$feature])) { |
|
| 440 | + if (isset($this->refreshedFeatures[$feature])) { |
|
| 441 | 441 | return true; |
| 442 | 442 | } |
| 443 | 443 | $this->refreshedFeatures[$feature] = 1; |
@@ -450,23 +450,23 @@ discard block |
||
| 450 | 450 | * @return null |
| 451 | 451 | */ |
| 452 | 452 | public function updateEmail($valueFromLDAP = null) { |
| 453 | - if($this->wasRefreshed('email')) { |
|
| 453 | + if ($this->wasRefreshed('email')) { |
|
| 454 | 454 | return; |
| 455 | 455 | } |
| 456 | - $email = (string)$valueFromLDAP; |
|
| 457 | - if(is_null($valueFromLDAP)) { |
|
| 456 | + $email = (string) $valueFromLDAP; |
|
| 457 | + if (is_null($valueFromLDAP)) { |
|
| 458 | 458 | $emailAttribute = $this->connection->ldapEmailAttribute; |
| 459 | 459 | if ($emailAttribute !== '') { |
| 460 | 460 | $aEmail = $this->access->readAttribute($this->dn, $emailAttribute); |
| 461 | - if(is_array($aEmail) && (count($aEmail) > 0)) { |
|
| 462 | - $email = (string)$aEmail[0]; |
|
| 461 | + if (is_array($aEmail) && (count($aEmail) > 0)) { |
|
| 462 | + $email = (string) $aEmail[0]; |
|
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | if ($email !== '') { |
| 467 | 467 | $user = $this->userManager->get($this->uid); |
| 468 | 468 | if (!is_null($user)) { |
| 469 | - $currentEmail = (string)$user->getEMailAddress(); |
|
| 469 | + $currentEmail = (string) $user->getEMailAddress(); |
|
| 470 | 470 | if ($currentEmail !== $email) { |
| 471 | 471 | $user->setEMailAddress($email); |
| 472 | 472 | } |
@@ -495,35 +495,35 @@ discard block |
||
| 495 | 495 | * @return null |
| 496 | 496 | */ |
| 497 | 497 | public function updateQuota($valueFromLDAP = null) { |
| 498 | - if($this->wasRefreshed('quota')) { |
|
| 498 | + if ($this->wasRefreshed('quota')) { |
|
| 499 | 499 | return; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | $quotaAttribute = $this->connection->ldapQuotaAttribute; |
| 503 | 503 | $defaultQuota = $this->connection->ldapQuotaDefault; |
| 504 | - if($quotaAttribute === '' && $defaultQuota === '') { |
|
| 504 | + if ($quotaAttribute === '' && $defaultQuota === '') { |
|
| 505 | 505 | return; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | $quota = false; |
| 509 | - if(is_null($valueFromLDAP) && $quotaAttribute !== '') { |
|
| 509 | + if (is_null($valueFromLDAP) && $quotaAttribute !== '') { |
|
| 510 | 510 | $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute); |
| 511 | - if($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) { |
|
| 511 | + if ($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) { |
|
| 512 | 512 | $quota = $aQuota[0]; |
| 513 | - } else if(is_array($aQuota) && isset($aQuota[0])) { |
|
| 514 | - $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::DEBUG); |
|
| 513 | + } else if (is_array($aQuota) && isset($aQuota[0])) { |
|
| 514 | + $this->log->log('no suitable LDAP quota found for user '.$this->uid.': ['.$aQuota[0].']', ILogger::DEBUG); |
|
| 515 | 515 | } |
| 516 | 516 | } else if ($this->verifyQuotaValue($valueFromLDAP)) { |
| 517 | 517 | $quota = $valueFromLDAP; |
| 518 | 518 | } else { |
| 519 | - $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::DEBUG); |
|
| 519 | + $this->log->log('no suitable LDAP quota found for user '.$this->uid.': ['.$valueFromLDAP.']', ILogger::DEBUG); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | if ($quota === false && $this->verifyQuotaValue($defaultQuota)) { |
| 523 | 523 | // quota not found using the LDAP attribute (or not parseable). Try the default quota |
| 524 | 524 | $quota = $defaultQuota; |
| 525 | - } else if($quota === false) { |
|
| 526 | - $this->log->log('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::DEBUG); |
|
| 525 | + } else if ($quota === false) { |
|
| 526 | + $this->log->log('no suitable default quota found for user '.$this->uid.': ['.$defaultQuota.']', ILogger::DEBUG); |
|
| 527 | 527 | return; |
| 528 | 528 | } |
| 529 | 529 | |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | if ($targetUser instanceof IUser) { |
| 532 | 532 | $targetUser->setQuota($quota); |
| 533 | 533 | } else { |
| 534 | - $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::INFO); |
|
| 534 | + $this->log->log('trying to set a quota for user '.$this->uid.' but the user is missing', ILogger::INFO); |
|
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | * @param array $params |
| 546 | 546 | */ |
| 547 | 547 | public function updateAvatarPostLogin($params) { |
| 548 | - if(isset($params['uid']) && $params['uid'] === $this->getUsername()) { |
|
| 548 | + if (isset($params['uid']) && $params['uid'] === $this->getUsername()) { |
|
| 549 | 549 | $this->updateAvatar(); |
| 550 | 550 | } |
| 551 | 551 | } |
@@ -555,11 +555,11 @@ discard block |
||
| 555 | 555 | * @return null |
| 556 | 556 | */ |
| 557 | 557 | public function updateAvatar() { |
| 558 | - if($this->wasRefreshed('avatar')) { |
|
| 558 | + if ($this->wasRefreshed('avatar')) { |
|
| 559 | 559 | return; |
| 560 | 560 | } |
| 561 | 561 | $avatarImage = $this->getAvatarImage(); |
| 562 | - if($avatarImage === false) { |
|
| 562 | + if ($avatarImage === false) { |
|
| 563 | 563 | //not set, nothing left to do; |
| 564 | 564 | return; |
| 565 | 565 | } |
@@ -572,18 +572,18 @@ discard block |
||
| 572 | 572 | * @return null |
| 573 | 573 | */ |
| 574 | 574 | private function setOwnCloudAvatar() { |
| 575 | - if(!$this->image->valid()) { |
|
| 575 | + if (!$this->image->valid()) { |
|
| 576 | 576 | $this->log->log('jpegPhoto data invalid for '.$this->dn, ILogger::ERROR); |
| 577 | 577 | return; |
| 578 | 578 | } |
| 579 | 579 | //make sure it is a square and not bigger than 128x128 |
| 580 | 580 | $size = min(array($this->image->width(), $this->image->height(), 128)); |
| 581 | - if(!$this->image->centerCrop($size)) { |
|
| 581 | + if (!$this->image->centerCrop($size)) { |
|
| 582 | 582 | $this->log->log('croping image for avatar failed for '.$this->dn, ILogger::ERROR); |
| 583 | 583 | return; |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - if(!$this->fs->isLoaded()) { |
|
| 586 | + if (!$this->fs->isLoaded()) { |
|
| 587 | 587 | $this->fs->setup($this->uid); |
| 588 | 588 | } |
| 589 | 589 | |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | $avatar->set($this->image); |
| 593 | 593 | } catch (\Exception $e) { |
| 594 | 594 | \OC::$server->getLogger()->logException($e, [ |
| 595 | - 'message' => 'Could not set avatar for ' . $this->dn, |
|
| 595 | + 'message' => 'Could not set avatar for '.$this->dn, |
|
| 596 | 596 | 'level' => ILogger::INFO, |
| 597 | 597 | 'app' => 'user_ldap', |
| 598 | 598 | ]); |
@@ -606,18 +606,18 @@ discard block |
||
| 606 | 606 | */ |
| 607 | 607 | public function handlePasswordExpiry($params) { |
| 608 | 608 | $ppolicyDN = $this->connection->ldapDefaultPPolicyDN; |
| 609 | - if (empty($ppolicyDN) || ((int)$this->connection->turnOnPasswordChange !== 1)) { |
|
| 610 | - return;//password expiry handling disabled |
|
| 609 | + if (empty($ppolicyDN) || ((int) $this->connection->turnOnPasswordChange !== 1)) { |
|
| 610 | + return; //password expiry handling disabled |
|
| 611 | 611 | } |
| 612 | 612 | $uid = $params['uid']; |
| 613 | - if(isset($uid) && $uid === $this->getUsername()) { |
|
| 613 | + if (isset($uid) && $uid === $this->getUsername()) { |
|
| 614 | 614 | //retrieve relevant user attributes |
| 615 | 615 | $result = $this->access->search('objectclass=*', array($this->dn), ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']); |
| 616 | 616 | |
| 617 | - if(array_key_exists('pwdpolicysubentry', $result[0])) { |
|
| 617 | + if (array_key_exists('pwdpolicysubentry', $result[0])) { |
|
| 618 | 618 | $pwdPolicySubentry = $result[0]['pwdpolicysubentry']; |
| 619 | - if($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)){ |
|
| 620 | - $ppolicyDN = $pwdPolicySubentry[0];//custom ppolicy DN |
|
| 619 | + if ($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)) { |
|
| 620 | + $ppolicyDN = $pwdPolicySubentry[0]; //custom ppolicy DN |
|
| 621 | 621 | } |
| 622 | 622 | } |
| 623 | 623 | |
@@ -626,9 +626,9 @@ discard block |
||
| 626 | 626 | $pwdChangedTime = array_key_exists('pwdchangedtime', $result[0]) ? $result[0]['pwdchangedtime'] : null; |
| 627 | 627 | |
| 628 | 628 | //retrieve relevant password policy attributes |
| 629 | - $cacheKey = 'ppolicyAttributes' . $ppolicyDN; |
|
| 629 | + $cacheKey = 'ppolicyAttributes'.$ppolicyDN; |
|
| 630 | 630 | $result = $this->connection->getFromCache($cacheKey); |
| 631 | - if(is_null($result)) { |
|
| 631 | + if (is_null($result)) { |
|
| 632 | 632 | $result = $this->access->search('objectclass=*', array($ppolicyDN), ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']); |
| 633 | 633 | $this->connection->writeToCache($cacheKey, $result); |
| 634 | 634 | } |
@@ -639,10 +639,10 @@ discard block |
||
| 639 | 639 | |
| 640 | 640 | //handle grace login |
| 641 | 641 | $pwdGraceUseTimeCount = count($pwdGraceUseTime); |
| 642 | - if($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login? |
|
| 643 | - if($pwdGraceAuthNLimit |
|
| 642 | + if ($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login? |
|
| 643 | + if ($pwdGraceAuthNLimit |
|
| 644 | 644 | && (count($pwdGraceAuthNLimit) > 0) |
| 645 | - &&($pwdGraceUseTimeCount < (int)$pwdGraceAuthNLimit[0])) { //at least one more grace login available? |
|
| 645 | + &&($pwdGraceUseTimeCount < (int) $pwdGraceAuthNLimit[0])) { //at least one more grace login available? |
|
| 646 | 646 | $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); |
| 647 | 647 | header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( |
| 648 | 648 | 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid))); |
@@ -653,24 +653,24 @@ discard block |
||
| 653 | 653 | exit(); |
| 654 | 654 | } |
| 655 | 655 | //handle pwdReset attribute |
| 656 | - if($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password |
|
| 656 | + if ($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password |
|
| 657 | 657 | $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); |
| 658 | 658 | header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( |
| 659 | 659 | 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid))); |
| 660 | 660 | exit(); |
| 661 | 661 | } |
| 662 | 662 | //handle password expiry warning |
| 663 | - if($pwdChangedTime && (count($pwdChangedTime) > 0)) { |
|
| 664 | - if($pwdMaxAge && (count($pwdMaxAge) > 0) |
|
| 663 | + if ($pwdChangedTime && (count($pwdChangedTime) > 0)) { |
|
| 664 | + if ($pwdMaxAge && (count($pwdMaxAge) > 0) |
|
| 665 | 665 | && $pwdExpireWarning && (count($pwdExpireWarning) > 0)) { |
| 666 | - $pwdMaxAgeInt = (int)$pwdMaxAge[0]; |
|
| 667 | - $pwdExpireWarningInt = (int)$pwdExpireWarning[0]; |
|
| 668 | - if($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0){ |
|
| 666 | + $pwdMaxAgeInt = (int) $pwdMaxAge[0]; |
|
| 667 | + $pwdExpireWarningInt = (int) $pwdExpireWarning[0]; |
|
| 668 | + if ($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0) { |
|
| 669 | 669 | $pwdChangedTimeDt = \DateTime::createFromFormat('YmdHisZ', $pwdChangedTime[0]); |
| 670 | 670 | $pwdChangedTimeDt->add(new \DateInterval('PT'.$pwdMaxAgeInt.'S')); |
| 671 | 671 | $currentDateTime = new \DateTime(); |
| 672 | 672 | $secondsToExpiry = $pwdChangedTimeDt->getTimestamp() - $currentDateTime->getTimestamp(); |
| 673 | - if($secondsToExpiry <= $pwdExpireWarningInt) { |
|
| 673 | + if ($secondsToExpiry <= $pwdExpireWarningInt) { |
|
| 674 | 674 | //remove last password expiry warning if any |
| 675 | 675 | $notification = $this->notificationManager->createNotification(); |
| 676 | 676 | $notification->setApp('user_ldap') |