@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @return TemplateResponse|RedirectResponse |
86 | 86 | */ |
87 | 87 | public function showRenewPasswordForm($user) { |
88 | - if($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') { |
|
88 | + if ($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') { |
|
89 | 89 | return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm')); |
90 | 90 | } |
91 | 91 | $parameters = []; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return RedirectResponse |
130 | 130 | */ |
131 | 131 | public function tryRenewPassword($user, $oldPassword, $newPassword) { |
132 | - if($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') { |
|
132 | + if ($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') { |
|
133 | 133 | return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm')); |
134 | 134 | } |
135 | 135 | $args = !is_null($user) ? ['user' => $user] : []; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | // we shall not log on RemoteException |
55 | 55 | $server->addPlugin(new ExceptionLoggerPlugin('webdav', \OC::$server->getLogger())); |
56 | 56 | } |
57 | - $server->on('beforeMethod', function () use ($e) { |
|
57 | + $server->on('beforeMethod', function() use ($e) { |
|
58 | 58 | if ($e instanceof RemoteException) { |
59 | 59 | switch ($e->getCode()) { |
60 | 60 | case OC_Response::STATUS_SERVICE_UNAVAILABLE: |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $server->exec(); |
71 | 71 | } else { |
72 | 72 | $statusCode = OC_Response::STATUS_INTERNAL_SERVER_ERROR; |
73 | - if ($e instanceof \OC\ServiceUnavailableException ) { |
|
73 | + if ($e instanceof \OC\ServiceUnavailableException) { |
|
74 | 74 | $statusCode = OC_Response::STATUS_SERVICE_UNAVAILABLE; |
75 | 75 | } |
76 | 76 | if ($e instanceof RemoteException) { |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | return $services[$service]; |
104 | 104 | } |
105 | 105 | |
106 | - return \OC::$server->getConfig()->getAppValue('core', 'remote_' . $service); |
|
106 | + return \OC::$server->getConfig()->getAppValue('core', 'remote_'.$service); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | try { |
110 | - require_once __DIR__ . '/lib/base.php'; |
|
110 | + require_once __DIR__.'/lib/base.php'; |
|
111 | 111 | |
112 | 112 | // All resources served via the DAV endpoint should have the strictest possible |
113 | 113 | // policy. Exempted from this is the SabreDAV browser plugin which overwrites |
@@ -128,18 +128,18 @@ discard block |
||
128 | 128 | if (!$pos = strpos($pathInfo, '/', 1)) { |
129 | 129 | $pos = strlen($pathInfo); |
130 | 130 | } |
131 | - $service=substr($pathInfo, 1, $pos-1); |
|
131 | + $service = substr($pathInfo, 1, $pos - 1); |
|
132 | 132 | |
133 | 133 | $file = resolveService($service); |
134 | 134 | |
135 | - if(is_null($file)) { |
|
135 | + if (is_null($file)) { |
|
136 | 136 | throw new RemoteException('Path not found', OC_Response::STATUS_NOT_FOUND); |
137 | 137 | } |
138 | 138 | |
139 | - $file=ltrim($file, '/'); |
|
139 | + $file = ltrim($file, '/'); |
|
140 | 140 | |
141 | - $parts=explode('/', $file, 2); |
|
142 | - $app=$parts[0]; |
|
141 | + $parts = explode('/', $file, 2); |
|
142 | + $app = $parts[0]; |
|
143 | 143 | |
144 | 144 | // Load all required applications |
145 | 145 | \OC::$REQUESTEDAPP = $app; |
@@ -148,17 +148,17 @@ discard block |
||
148 | 148 | |
149 | 149 | switch ($app) { |
150 | 150 | case 'core': |
151 | - $file = OC::$SERVERROOT .'/'. $file; |
|
151 | + $file = OC::$SERVERROOT.'/'.$file; |
|
152 | 152 | break; |
153 | 153 | default: |
154 | 154 | if (!\OC::$server->getAppManager()->isInstalled($app)) { |
155 | - throw new RemoteException('App not installed: ' . $app); |
|
155 | + throw new RemoteException('App not installed: '.$app); |
|
156 | 156 | } |
157 | 157 | OC_App::loadApp($app); |
158 | - $file = OC_App::getAppPath($app) .'/'. $parts[1]; |
|
158 | + $file = OC_App::getAppPath($app).'/'.$parts[1]; |
|
159 | 159 | break; |
160 | 160 | } |
161 | - $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; |
|
161 | + $baseuri = OC::$WEBROOT.'/remote.php/'.$service.'/'; |
|
162 | 162 | require_once $file; |
163 | 163 | |
164 | 164 | } catch (Exception $ex) { |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | * @return null |
150 | 150 | */ |
151 | 151 | public function update() { |
152 | - if(is_null($this->dn)) { |
|
152 | + if (is_null($this->dn)) { |
|
153 | 153 | return null; |
154 | 154 | } |
155 | 155 | |
156 | 156 | $hasLoggedIn = $this->config->getUserValue($this->uid, 'user_ldap', |
157 | 157 | self::USER_PREFKEY_FIRSTLOGIN, 0); |
158 | 158 | |
159 | - if($this->needsRefresh()) { |
|
159 | + if ($this->needsRefresh()) { |
|
160 | 160 | $this->updateEmail(); |
161 | 161 | $this->updateQuota(); |
162 | - if($hasLoggedIn !== 0) { |
|
162 | + if ($hasLoggedIn !== 0) { |
|
163 | 163 | //we do not need to try it, when the user has not been logged in |
164 | 164 | //before, because the file system will not be ready. |
165 | 165 | $this->updateAvatar(); |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $this->markRefreshTime(); |
179 | 179 | //Quota |
180 | 180 | $attr = strtolower($this->connection->ldapQuotaAttribute); |
181 | - if(isset($ldapEntry[$attr])) { |
|
181 | + if (isset($ldapEntry[$attr])) { |
|
182 | 182 | $this->updateQuota($ldapEntry[$attr][0]); |
183 | 183 | } else { |
184 | 184 | if ($this->connection->ldapQuotaDefault !== '') { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | |
191 | 191 | $attr = strtolower($this->connection->ldapEmailAttribute); |
192 | - if(isset($ldapEntry[$attr])) { |
|
192 | + if (isset($ldapEntry[$attr])) { |
|
193 | 193 | $this->updateEmail($ldapEntry[$attr][0]); |
194 | 194 | } |
195 | 195 | unset($attr); |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | //displayName |
198 | 198 | $displayName = $displayName2 = ''; |
199 | 199 | $attr = strtolower($this->connection->ldapUserDisplayName); |
200 | - if(isset($ldapEntry[$attr])) { |
|
200 | + if (isset($ldapEntry[$attr])) { |
|
201 | 201 | $displayName = strval($ldapEntry[$attr][0]); |
202 | 202 | } |
203 | 203 | $attr = strtolower($this->connection->ldapUserDisplayName2); |
204 | - if(isset($ldapEntry[$attr])) { |
|
204 | + if (isset($ldapEntry[$attr])) { |
|
205 | 205 | $displayName2 = strval($ldapEntry[$attr][0]); |
206 | 206 | } |
207 | 207 | if ($displayName !== '') { |
@@ -215,16 +215,16 @@ discard block |
||
215 | 215 | unset($attr); |
216 | 216 | |
217 | 217 | // LDAP Username, needed for s2s sharing |
218 | - if(isset($ldapEntry['uid'])) { |
|
218 | + if (isset($ldapEntry['uid'])) { |
|
219 | 219 | $this->storeLDAPUserName($ldapEntry['uid'][0]); |
220 | - } else if(isset($ldapEntry['samaccountname'])) { |
|
220 | + } else if (isset($ldapEntry['samaccountname'])) { |
|
221 | 221 | $this->storeLDAPUserName($ldapEntry['samaccountname'][0]); |
222 | 222 | } |
223 | 223 | |
224 | 224 | //homePath |
225 | - if(strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) { |
|
225 | + if (strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) { |
|
226 | 226 | $attr = strtolower(substr($this->connection->homeFolderNamingRule, strlen('attr:'))); |
227 | - if(isset($ldapEntry[$attr])) { |
|
227 | + if (isset($ldapEntry[$attr])) { |
|
228 | 228 | $this->access->cacheUserHome( |
229 | 229 | $this->getUsername(), $this->getHomePath($ldapEntry[$attr][0])); |
230 | 230 | } |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | //memberOf groups |
234 | 234 | $cacheKey = 'getMemberOf'.$this->getUsername(); |
235 | 235 | $groups = false; |
236 | - if(isset($ldapEntry['memberof'])) { |
|
236 | + if (isset($ldapEntry['memberof'])) { |
|
237 | 237 | $groups = $ldapEntry['memberof']; |
238 | 238 | } |
239 | 239 | $this->connection->writeToCache($cacheKey, $groups); |
240 | 240 | |
241 | 241 | //Avatar |
242 | 242 | $attrs = array('jpegphoto', 'thumbnailphoto'); |
243 | - foreach ($attrs as $attr) { |
|
244 | - if(isset($ldapEntry[$attr])) { |
|
243 | + foreach ($attrs as $attr) { |
|
244 | + if (isset($ldapEntry[$attr])) { |
|
245 | 245 | $this->avatarImage = $ldapEntry[$attr][0]; |
246 | 246 | // the call to the method that saves the avatar in the file |
247 | 247 | // system must be postponed after the login. It is to ensure |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | if ($path !== '') { |
295 | 295 | //if attribute's value is an absolute path take this, otherwise append it to data dir |
296 | 296 | //check for / at the beginning or pattern c:\ resp. c:/ |
297 | - if( '/' !== $path[0] |
|
297 | + if ('/' !== $path[0] |
|
298 | 298 | && !(3 < strlen($path) && ctype_alpha($path[0]) |
299 | 299 | && $path[1] === ':' && ('\\' === $path[2] || '/' === $path[2])) |
300 | 300 | ) { |
301 | 301 | $path = $this->config->getSystemValue('datadirectory', |
302 | - \OC::$SERVERROOT.'/data' ) . '/' . $path; |
|
302 | + \OC::$SERVERROOT.'/data').'/'.$path; |
|
303 | 303 | } |
304 | 304 | //we need it to store it in the DB as well in case a user gets |
305 | 305 | //deleted so we can clean up afterwards |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | return $path; |
310 | 310 | } |
311 | 311 | |
312 | - if( !is_null($attr) |
|
312 | + if (!is_null($attr) |
|
313 | 313 | && $this->config->getAppValue('user_ldap', 'enforce_home_folder_naming_rule', true) |
314 | 314 | ) { |
315 | 315 | // a naming rule attribute is defined, but it doesn't exist for that LDAP user |
316 | - throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: ' . $this->getUsername()); |
|
316 | + throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: '.$this->getUsername()); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | //false will apply default behaviour as defined and done by OC_User |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | public function getMemberOfGroups() { |
325 | 325 | $cacheKey = 'getMemberOf'.$this->getUsername(); |
326 | 326 | $memberOfGroups = $this->connection->getFromCache($cacheKey); |
327 | - if(!is_null($memberOfGroups)) { |
|
327 | + if (!is_null($memberOfGroups)) { |
|
328 | 328 | return $memberOfGroups; |
329 | 329 | } |
330 | 330 | $groupDNs = $this->access->readAttribute($this->getDN(), 'memberOf'); |
@@ -337,15 +337,15 @@ discard block |
||
337 | 337 | * @return string data (provided by LDAP) | false |
338 | 338 | */ |
339 | 339 | public function getAvatarImage() { |
340 | - if(!is_null($this->avatarImage)) { |
|
340 | + if (!is_null($this->avatarImage)) { |
|
341 | 341 | return $this->avatarImage; |
342 | 342 | } |
343 | 343 | |
344 | 344 | $this->avatarImage = false; |
345 | 345 | $attributes = array('jpegPhoto', 'thumbnailPhoto'); |
346 | - foreach($attributes as $attribute) { |
|
346 | + foreach ($attributes as $attribute) { |
|
347 | 347 | $result = $this->access->readAttribute($this->dn, $attribute); |
348 | - if($result !== false && is_array($result) && isset($result[0])) { |
|
348 | + if ($result !== false && is_array($result) && isset($result[0])) { |
|
349 | 349 | $this->avatarImage = $result[0]; |
350 | 350 | break; |
351 | 351 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | self::USER_PREFKEY_LASTREFRESH, 0); |
384 | 384 | |
385 | 385 | //TODO make interval configurable |
386 | - if((time() - intval($lastChecked)) < 86400 ) { |
|
386 | + if ((time() - intval($lastChecked)) < 86400) { |
|
387 | 387 | return false; |
388 | 388 | } |
389 | 389 | return true; |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | */ |
410 | 410 | public function composeAndStoreDisplayName($displayName, $displayName2 = '') { |
411 | 411 | $displayName2 = strval($displayName2); |
412 | - if($displayName2 !== '') { |
|
413 | - $displayName .= ' (' . $displayName2 . ')'; |
|
412 | + if ($displayName2 !== '') { |
|
413 | + $displayName .= ' ('.$displayName2.')'; |
|
414 | 414 | } |
415 | 415 | $this->store('displayName', $displayName); |
416 | 416 | return $displayName; |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @return bool |
433 | 433 | */ |
434 | 434 | private function wasRefreshed($feature) { |
435 | - if(isset($this->refreshedFeatures[$feature])) { |
|
435 | + if (isset($this->refreshedFeatures[$feature])) { |
|
436 | 436 | return true; |
437 | 437 | } |
438 | 438 | $this->refreshedFeatures[$feature] = 1; |
@@ -445,15 +445,15 @@ discard block |
||
445 | 445 | * @return null |
446 | 446 | */ |
447 | 447 | public function updateEmail($valueFromLDAP = null) { |
448 | - if($this->wasRefreshed('email')) { |
|
448 | + if ($this->wasRefreshed('email')) { |
|
449 | 449 | return; |
450 | 450 | } |
451 | 451 | $email = strval($valueFromLDAP); |
452 | - if(is_null($valueFromLDAP)) { |
|
452 | + if (is_null($valueFromLDAP)) { |
|
453 | 453 | $emailAttribute = $this->connection->ldapEmailAttribute; |
454 | 454 | if ($emailAttribute !== '') { |
455 | 455 | $aEmail = $this->access->readAttribute($this->dn, $emailAttribute); |
456 | - if(is_array($aEmail) && (count($aEmail) > 0)) { |
|
456 | + if (is_array($aEmail) && (count($aEmail) > 0)) { |
|
457 | 457 | $email = strval($aEmail[0]); |
458 | 458 | } |
459 | 459 | } |
@@ -490,20 +490,20 @@ discard block |
||
490 | 490 | * @return null |
491 | 491 | */ |
492 | 492 | public function updateQuota($valueFromLDAP = null) { |
493 | - if($this->wasRefreshed('quota')) { |
|
493 | + if ($this->wasRefreshed('quota')) { |
|
494 | 494 | return; |
495 | 495 | } |
496 | 496 | |
497 | 497 | $quota = false; |
498 | - if(is_null($valueFromLDAP)) { |
|
498 | + if (is_null($valueFromLDAP)) { |
|
499 | 499 | $quotaAttribute = $this->connection->ldapQuotaAttribute; |
500 | 500 | if ($quotaAttribute !== '') { |
501 | 501 | $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute); |
502 | - if($aQuota && (count($aQuota) > 0)) { |
|
502 | + if ($aQuota && (count($aQuota) > 0)) { |
|
503 | 503 | if ($this->verifyQuotaValue($aQuota[0])) { |
504 | 504 | $quota = $aQuota[0]; |
505 | 505 | } else { |
506 | - $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', \OCP\Util::WARN); |
|
506 | + $this->log->log('not suitable LDAP quota found for user '.$this->uid.': ['.$aQuota[0].']', \OCP\Util::WARN); |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | } |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | if ($this->verifyQuotaValue($valueFromLDAP)) { |
512 | 512 | $quota = $valueFromLDAP; |
513 | 513 | } else { |
514 | - $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', \OCP\Util::WARN); |
|
514 | + $this->log->log('not suitable LDAP quota found for user '.$this->uid.': ['.$valueFromLDAP.']', \OCP\Util::WARN); |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | |
@@ -525,14 +525,14 @@ discard block |
||
525 | 525 | |
526 | 526 | $targetUser = $this->userManager->get($this->uid); |
527 | 527 | if ($targetUser) { |
528 | - if($quota !== false) { |
|
528 | + if ($quota !== false) { |
|
529 | 529 | $targetUser->setQuota($quota); |
530 | 530 | } else { |
531 | - $this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', \OCP\Util::WARN); |
|
531 | + $this->log->log('not suitable default quota found for user '.$this->uid.': ['.$defaultQuota.']', \OCP\Util::WARN); |
|
532 | 532 | $targetUser->setQuota('default'); |
533 | 533 | } |
534 | 534 | } else { |
535 | - $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', \OCP\Util::ERROR); |
|
535 | + $this->log->log('trying to set a quota for user '.$this->uid.' but the user is missing', \OCP\Util::ERROR); |
|
536 | 536 | } |
537 | 537 | } |
538 | 538 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @param array $params |
547 | 547 | */ |
548 | 548 | public function updateAvatarPostLogin($params) { |
549 | - if(isset($params['uid']) && $params['uid'] === $this->getUsername()) { |
|
549 | + if (isset($params['uid']) && $params['uid'] === $this->getUsername()) { |
|
550 | 550 | $this->updateAvatar(); |
551 | 551 | } |
552 | 552 | } |
@@ -556,11 +556,11 @@ discard block |
||
556 | 556 | * @return null |
557 | 557 | */ |
558 | 558 | public function updateAvatar() { |
559 | - if($this->wasRefreshed('avatar')) { |
|
559 | + if ($this->wasRefreshed('avatar')) { |
|
560 | 560 | return; |
561 | 561 | } |
562 | 562 | $avatarImage = $this->getAvatarImage(); |
563 | - if($avatarImage === false) { |
|
563 | + if ($avatarImage === false) { |
|
564 | 564 | //not set, nothing left to do; |
565 | 565 | return; |
566 | 566 | } |
@@ -573,18 +573,18 @@ discard block |
||
573 | 573 | * @return null |
574 | 574 | */ |
575 | 575 | private function setOwnCloudAvatar() { |
576 | - if(!$this->image->valid()) { |
|
576 | + if (!$this->image->valid()) { |
|
577 | 577 | $this->log->log('jpegPhoto data invalid for '.$this->dn, \OCP\Util::ERROR); |
578 | 578 | return; |
579 | 579 | } |
580 | 580 | //make sure it is a square and not bigger than 128x128 |
581 | 581 | $size = min(array($this->image->width(), $this->image->height(), 128)); |
582 | - if(!$this->image->centerCrop($size)) { |
|
582 | + if (!$this->image->centerCrop($size)) { |
|
583 | 583 | $this->log->log('croping image for avatar failed for '.$this->dn, \OCP\Util::ERROR); |
584 | 584 | return; |
585 | 585 | } |
586 | 586 | |
587 | - if(!$this->fs->isLoaded()) { |
|
587 | + if (!$this->fs->isLoaded()) { |
|
588 | 588 | $this->fs->setup($this->uid); |
589 | 589 | } |
590 | 590 | |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | $avatar->set($this->image); |
594 | 594 | } catch (\Exception $e) { |
595 | 595 | \OC::$server->getLogger()->notice( |
596 | - 'Could not set avatar for ' . $this->dn . ', because: ' . $e->getMessage(), |
|
596 | + 'Could not set avatar for '.$this->dn.', because: '.$e->getMessage(), |
|
597 | 597 | ['app' => 'user_ldap']); |
598 | 598 | } |
599 | 599 | } |
@@ -606,17 +606,17 @@ discard block |
||
606 | 606 | public function handlePasswordExpiry($params) { |
607 | 607 | $ppolicyDN = $this->connection->ldapDefaultPPolicyDN; |
608 | 608 | if (empty($ppolicyDN) || (intval($this->connection->turnOnPasswordChange) !== 1)) { |
609 | - return;//password expiry handling disabled |
|
609 | + return; //password expiry handling disabled |
|
610 | 610 | } |
611 | 611 | $uid = $params['uid']; |
612 | - if(isset($uid) && $uid === $this->getUsername()) { |
|
612 | + if (isset($uid) && $uid === $this->getUsername()) { |
|
613 | 613 | //retrieve relevant user attributes |
614 | 614 | $result = $this->access->search('objectclass=*', $this->dn, ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']); |
615 | 615 | |
616 | - if(array_key_exists('pwdpolicysubentry', $result[0])) { |
|
616 | + if (array_key_exists('pwdpolicysubentry', $result[0])) { |
|
617 | 617 | $pwdPolicySubentry = $result[0]['pwdpolicysubentry']; |
618 | - if($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)){ |
|
619 | - $ppolicyDN = $pwdPolicySubentry[0];//custom ppolicy DN |
|
618 | + if ($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)) { |
|
619 | + $ppolicyDN = $pwdPolicySubentry[0]; //custom ppolicy DN |
|
620 | 620 | } |
621 | 621 | } |
622 | 622 | |
@@ -625,9 +625,9 @@ discard block |
||
625 | 625 | $pwdChangedTime = array_key_exists('pwdchangedtime', $result[0]) ? $result[0]['pwdchangedtime'] : null; |
626 | 626 | |
627 | 627 | //retrieve relevant password policy attributes |
628 | - $cacheKey = 'ppolicyAttributes' . $ppolicyDN; |
|
628 | + $cacheKey = 'ppolicyAttributes'.$ppolicyDN; |
|
629 | 629 | $result = $this->connection->getFromCache($cacheKey); |
630 | - if(is_null($result)) { |
|
630 | + if (is_null($result)) { |
|
631 | 631 | $result = $this->access->search('objectclass=*', $ppolicyDN, ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']); |
632 | 632 | $this->connection->writeToCache($cacheKey, $result); |
633 | 633 | } |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | |
639 | 639 | //handle grace login |
640 | 640 | $pwdGraceUseTimeCount = count($pwdGraceUseTime); |
641 | - if($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login? |
|
642 | - if($pwdGraceAuthNLimit |
|
641 | + if ($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login? |
|
642 | + if ($pwdGraceAuthNLimit |
|
643 | 643 | && (count($pwdGraceAuthNLimit) > 0) |
644 | 644 | &&($pwdGraceUseTimeCount < intval($pwdGraceAuthNLimit[0]))) { //at least one more grace login available? |
645 | 645 | $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); |
@@ -652,24 +652,24 @@ discard block |
||
652 | 652 | exit(); |
653 | 653 | } |
654 | 654 | //handle pwdReset attribute |
655 | - if($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password |
|
655 | + if ($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password |
|
656 | 656 | $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); |
657 | 657 | header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( |
658 | 658 | 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid))); |
659 | 659 | exit(); |
660 | 660 | } |
661 | 661 | //handle password expiry warning |
662 | - if($pwdChangedTime && (count($pwdChangedTime) > 0)) { |
|
663 | - if($pwdMaxAge && (count($pwdMaxAge) > 0) |
|
662 | + if ($pwdChangedTime && (count($pwdChangedTime) > 0)) { |
|
663 | + if ($pwdMaxAge && (count($pwdMaxAge) > 0) |
|
664 | 664 | && $pwdExpireWarning && (count($pwdExpireWarning) > 0)) { |
665 | 665 | $pwdMaxAgeInt = intval($pwdMaxAge[0]); |
666 | 666 | $pwdExpireWarningInt = intval($pwdExpireWarning[0]); |
667 | - if($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0){ |
|
667 | + if ($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0) { |
|
668 | 668 | $pwdChangedTimeDt = \DateTime::createFromFormat('YmdHisZ', $pwdChangedTime[0]); |
669 | 669 | $pwdChangedTimeDt->add(new \DateInterval('PT'.$pwdMaxAgeInt.'S')); |
670 | 670 | $currentDateTime = new \DateTime(); |
671 | 671 | $secondsToExpiry = $pwdChangedTimeDt->getTimestamp() - $currentDateTime->getTimestamp(); |
672 | - if($secondsToExpiry <= $pwdExpireWarningInt) { |
|
672 | + if ($secondsToExpiry <= $pwdExpireWarningInt) { |
|
673 | 673 | //remove last password expiry warning if any |
674 | 674 | $notification = $this->notificationManager->createNotification(); |
675 | 675 | $notification->setApp('user_ldap') |
@@ -102,13 +102,13 @@ |
||
102 | 102 | if ($generatePasswordResetToken) { |
103 | 103 | $token = $this->secureRandom->generate( |
104 | 104 | 21, |
105 | - ISecureRandom::CHAR_DIGITS . |
|
106 | - ISecureRandom::CHAR_LOWER . |
|
105 | + ISecureRandom::CHAR_DIGITS. |
|
106 | + ISecureRandom::CHAR_LOWER. |
|
107 | 107 | ISecureRandom::CHAR_UPPER |
108 | 108 | ); |
109 | - $tokenValue = $this->timeFactory->getTime() . ':' . $token; |
|
109 | + $tokenValue = $this->timeFactory->getTime().':'.$token; |
|
110 | 110 | $mailAddress = (null !== $user->getEMailAddress()) ? $user->getEMailAddress() : ''; |
111 | - $encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress . $this->config->getSystemValue('secret')); |
|
111 | + $encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress.$this->config->getSystemValue('secret')); |
|
112 | 112 | $this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue); |
113 | 113 | $link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', ['userId' => $user->getUID(), 'token' => $token]); |
114 | 114 | } else { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param \OCP\IL10N $l10n |
47 | 47 | * @param Defaults $theme |
48 | 48 | */ |
49 | - public function __construct($template, $requestToken, $l10n, $theme ) { |
|
49 | + public function __construct($template, $requestToken, $l10n, $theme) { |
|
50 | 50 | $this->vars = array(); |
51 | 51 | $this->vars['requesttoken'] = $requestToken; |
52 | 52 | $this->l10n = $l10n; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) { |
65 | 65 | // Check if the app is in the app folder or in the root |
66 | - if( file_exists($app_dir.'/templates/' )) { |
|
66 | + if (file_exists($app_dir.'/templates/')) { |
|
67 | 67 | return [ |
68 | 68 | $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/', |
69 | 69 | $app_dir.'/templates/', |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * If the key existed before, it will be overwritten |
100 | 100 | */ |
101 | - public function assign( $key, $value) { |
|
101 | + public function assign($key, $value) { |
|
102 | 102 | $this->vars[$key] = $value; |
103 | 103 | return true; |
104 | 104 | } |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * exists, the value will be appended. It can be accessed via |
114 | 114 | * $_[$key][$position] in the template. |
115 | 115 | */ |
116 | - public function append( $key, $value ) { |
|
117 | - if( array_key_exists( $key, $this->vars )) { |
|
116 | + public function append($key, $value) { |
|
117 | + if (array_key_exists($key, $this->vars)) { |
|
118 | 118 | $this->vars[$key][] = $value; |
119 | 119 | } |
120 | - else{ |
|
121 | - $this->vars[$key] = array( $value ); |
|
120 | + else { |
|
121 | + $this->vars[$key] = array($value); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function printPage() { |
132 | 132 | $data = $this->fetchPage(); |
133 | - if( $data === false ) { |
|
133 | + if ($data === false) { |
|
134 | 134 | return false; |
135 | 135 | } |
136 | - else{ |
|
136 | + else { |
|
137 | 137 | print $data; |
138 | 138 | return true; |
139 | 139 | } |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | $l = $this->l10n; |
167 | 167 | $theme = $this->theme; |
168 | 168 | |
169 | - if( !is_null($additionalParams)) { |
|
170 | - $_ = array_merge( $additionalParams, $this->vars ); |
|
169 | + if (!is_null($additionalParams)) { |
|
170 | + $_ = array_merge($additionalParams, $this->vars); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // Include |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | if ($host === '') { |
134 | 134 | $additionalConnectionParams['dbname'] = $dbName; // use dbname as easy connect name |
135 | 135 | } else { |
136 | - $additionalConnectionParams['dbname'] = '//' . $host . (!empty($port) ? ":{$port}" : "") . '/' . $dbName; |
|
136 | + $additionalConnectionParams['dbname'] = '//'.$host.(!empty($port) ? ":{$port}" : "").'/'.$dbName; |
|
137 | 137 | } |
138 | 138 | unset($additionalConnectionParams['host']); |
139 | 139 | break; |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | $name = $this->config->getValue('dbname', 'owncloud'); |
188 | 188 | |
189 | 189 | if ($this->normalizeType($type) === 'sqlite3') { |
190 | - $dataDir = $this->config->getValue("datadirectory", \OC::$SERVERROOT . '/data'); |
|
191 | - $connectionParams['path'] = $dataDir . '/' . $name . '.db'; |
|
190 | + $dataDir = $this->config->getValue("datadirectory", \OC::$SERVERROOT.'/data'); |
|
191 | + $connectionParams['path'] = $dataDir.'/'.$name.'.db'; |
|
192 | 192 | } else { |
193 | 193 | $host = $this->config->getValue('dbhost', ''); |
194 | 194 | if (strpos($host, ':')) { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | if ($remoteShare) { |
183 | 183 | try { |
184 | 184 | $ownerCloudId = $this->cloudIdManager->getCloudId($remoteShare['owner'], $remoteShare['remote']); |
185 | - $shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time()); |
|
185 | + $shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_'.time()); |
|
186 | 186 | $share->setId($shareId); |
187 | 187 | list($token, $remoteId) = $this->askOwnerToReShare($shareWith, $share, $shareId); |
188 | 188 | // remote share was create successfully if we get a valid token as return |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | $failure = true; |
255 | 255 | } |
256 | 256 | } catch (\Exception $e) { |
257 | - $this->logger->error('Failed to notify remote server of federated share, removing share (' . $e->getMessage() . ')'); |
|
257 | + $this->logger->error('Failed to notify remote server of federated share, removing share ('.$e->getMessage().')'); |
|
258 | 258 | $failure = true; |
259 | 259 | } |
260 | 260 | |
261 | - if($failure) { |
|
261 | + if ($failure) { |
|
262 | 262 | $this->removeShareFromTableById($shareId); |
263 | 263 | $message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable or uses a self-signed certificate.', |
264 | 264 | [$share->getNode()->getName(), $share->getSharedWith()]); |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | ->andWhere($query->expr()->eq('mountpoint', $query->createNamedParameter($share->getTarget()))); |
310 | 310 | $result = $query->execute()->fetchAll(); |
311 | 311 | |
312 | - if (isset($result[0]) && (int)$result[0]['remote_id'] > 0) { |
|
312 | + if (isset($result[0]) && (int) $result[0]['remote_id'] > 0) { |
|
313 | 313 | return $result[0]; |
314 | 314 | } |
315 | 315 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $qb->execute(); |
352 | 352 | $id = $qb->getLastInsertId(); |
353 | 353 | |
354 | - return (int)$id; |
|
354 | + return (int) $id; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -441,14 +441,14 @@ discard block |
||
441 | 441 | public function getRemoteId(IShare $share) { |
442 | 442 | $query = $this->dbConnection->getQueryBuilder(); |
443 | 443 | $query->select('remote_id')->from('federated_reshares') |
444 | - ->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId()))); |
|
444 | + ->where($query->expr()->eq('share_id', $query->createNamedParameter((int) $share->getId()))); |
|
445 | 445 | $data = $query->execute()->fetch(); |
446 | 446 | |
447 | 447 | if (!is_array($data) || !isset($data['remote_id'])) { |
448 | 448 | throw new ShareNotFound(); |
449 | 449 | } |
450 | 450 | |
451 | - return (int)$data['remote_id']; |
|
451 | + return (int) $data['remote_id']; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | ->orderBy('id'); |
480 | 480 | |
481 | 481 | $cursor = $qb->execute(); |
482 | - while($data = $cursor->fetch()) { |
|
482 | + while ($data = $cursor->fetch()) { |
|
483 | 483 | $children[] = $this->createShareObject($data); |
484 | 484 | } |
485 | 485 | $cursor->closeCursor(); |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | ); |
609 | 609 | } |
610 | 610 | |
611 | - $qb->innerJoin('s', 'filecache' ,'f', $qb->expr()->eq('s.file_source', 'f.fileid')); |
|
611 | + $qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')); |
|
612 | 612 | $qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId()))); |
613 | 613 | |
614 | 614 | $qb->orderBy('id'); |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | |
672 | 672 | $cursor = $qb->execute(); |
673 | 673 | $shares = []; |
674 | - while($data = $cursor->fetch()) { |
|
674 | + while ($data = $cursor->fetch()) { |
|
675 | 675 | $shares[] = $this->createShareObject($data); |
676 | 676 | } |
677 | 677 | $cursor->closeCursor(); |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | ->execute(); |
724 | 724 | |
725 | 725 | $shares = []; |
726 | - while($data = $cursor->fetch()) { |
|
726 | + while ($data = $cursor->fetch()) { |
|
727 | 727 | $shares[] = $this->createShareObject($data); |
728 | 728 | } |
729 | 729 | $cursor->closeCursor(); |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | |
763 | 763 | $cursor = $qb->execute(); |
764 | 764 | |
765 | - while($data = $cursor->fetch()) { |
|
765 | + while ($data = $cursor->fetch()) { |
|
766 | 766 | $shares[] = $this->createShareObject($data); |
767 | 767 | } |
768 | 768 | $cursor->closeCursor(); |
@@ -839,15 +839,15 @@ discard block |
||
839 | 839 | private function createShareObject($data) { |
840 | 840 | |
841 | 841 | $share = new Share($this->rootFolder, $this->userManager); |
842 | - $share->setId((int)$data['id']) |
|
843 | - ->setShareType((int)$data['share_type']) |
|
844 | - ->setPermissions((int)$data['permissions']) |
|
842 | + $share->setId((int) $data['id']) |
|
843 | + ->setShareType((int) $data['share_type']) |
|
844 | + ->setPermissions((int) $data['permissions']) |
|
845 | 845 | ->setTarget($data['file_target']) |
846 | - ->setMailSend((bool)$data['mail_send']) |
|
846 | + ->setMailSend((bool) $data['mail_send']) |
|
847 | 847 | ->setToken($data['token']); |
848 | 848 | |
849 | 849 | $shareTime = new \DateTime(); |
850 | - $shareTime->setTimestamp((int)$data['stime']); |
|
850 | + $shareTime->setTimestamp((int) $data['stime']); |
|
851 | 851 | $share->setShareTime($shareTime); |
852 | 852 | $share->setSharedWith($data['share_with']); |
853 | 853 | |
@@ -857,13 +857,13 @@ discard block |
||
857 | 857 | } else { |
858 | 858 | //OLD SHARE |
859 | 859 | $share->setSharedBy($data['uid_owner']); |
860 | - $path = $this->getNode($share->getSharedBy(), (int)$data['file_source']); |
|
860 | + $path = $this->getNode($share->getSharedBy(), (int) $data['file_source']); |
|
861 | 861 | |
862 | 862 | $owner = $path->getOwner(); |
863 | 863 | $share->setShareOwner($owner->getUID()); |
864 | 864 | } |
865 | 865 | |
866 | - $share->setNodeId((int)$data['file_source']); |
|
866 | + $share->setNodeId((int) $data['file_source']); |
|
867 | 867 | $share->setNodeType($data['item_type']); |
868 | 868 | |
869 | 869 | $share->setProviderId($this->identifier()); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | $item = $node; |
117 | - $appendix = '/' . $node->getName(); |
|
117 | + $appendix = '/'.$node->getName(); |
|
118 | 118 | while (!empty($byId)) { |
119 | 119 | try { |
120 | 120 | /** @var Node $item */ |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | |
123 | 123 | if (!empty($byId[$item->getId()])) { |
124 | 124 | foreach ($byId[$item->getId()] as $uid => $path) { |
125 | - $results[$uid] = $path . $appendix; |
|
125 | + $results[$uid] = $path.$appendix; |
|
126 | 126 | } |
127 | 127 | unset($byId[$item->getId()]); |
128 | 128 | } |
129 | 129 | |
130 | - $appendix = '/' . $item->getName() . $appendix; |
|
130 | + $appendix = '/'.$item->getName().$appendix; |
|
131 | 131 | } catch (NotFoundException $e) { |
132 | 132 | return $results; |
133 | 133 | } catch (InvalidPathException $e) { |
@@ -212,6 +212,6 @@ discard block |
||
212 | 212 | protected function getMountedPath(Node $node) { |
213 | 213 | $path = $node->getPath(); |
214 | 214 | $sections = explode('/', $path, 4); |
215 | - return '/' . $sections[3]; |
|
215 | + return '/'.$sections[3]; |
|
216 | 216 | } |
217 | 217 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | static public function enableCaching($cache_time = null) { |
49 | 49 | if (is_numeric($cache_time)) { |
50 | - header('Pragma: public');// enable caching in IE |
|
50 | + header('Pragma: public'); // enable caching in IE |
|
51 | 51 | if ($cache_time > 0) { |
52 | 52 | self::setExpiresHeader('PT'.$cache_time.'S'); |
53 | 53 | header('Cache-Control: max-age='.$cache_time.', must-revalidate'); |
@@ -78,29 +78,29 @@ discard block |
||
78 | 78 | */ |
79 | 79 | static public function setStatus($status) { |
80 | 80 | $protocol = \OC::$server->getRequest()->getHttpProtocol(); |
81 | - switch($status) { |
|
81 | + switch ($status) { |
|
82 | 82 | case self::STATUS_NOT_MODIFIED: |
83 | - $status = $status . ' Not Modified'; |
|
83 | + $status = $status.' Not Modified'; |
|
84 | 84 | break; |
85 | 85 | case self::STATUS_TEMPORARY_REDIRECT: |
86 | 86 | if ($protocol == 'HTTP/1.1') { |
87 | - $status = $status . ' Temporary Redirect'; |
|
87 | + $status = $status.' Temporary Redirect'; |
|
88 | 88 | break; |
89 | 89 | } else { |
90 | 90 | $status = self::STATUS_FOUND; |
91 | 91 | // fallthrough |
92 | 92 | } |
93 | 93 | case self::STATUS_FOUND; |
94 | - $status = $status . ' Found'; |
|
94 | + $status = $status.' Found'; |
|
95 | 95 | break; |
96 | 96 | case self::STATUS_NOT_FOUND; |
97 | - $status = $status . ' Not Found'; |
|
97 | + $status = $status.' Not Found'; |
|
98 | 98 | break; |
99 | 99 | case self::STATUS_INTERNAL_SERVER_ERROR; |
100 | - $status = $status . ' Internal Server Error'; |
|
100 | + $status = $status.' Internal Server Error'; |
|
101 | 101 | break; |
102 | 102 | case self::STATUS_SERVICE_UNAVAILABLE; |
103 | - $status = $status . ' Service Unavailable'; |
|
103 | + $status = $status.' Service Unavailable'; |
|
104 | 104 | break; |
105 | 105 | } |
106 | 106 | header($protocol.' '.$status); |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | * @param string $filename file name |
181 | 181 | * @param string $type disposition type, either 'attachment' or 'inline' |
182 | 182 | */ |
183 | - static public function setContentDispositionHeader( $filename, $type = 'attachment' ) { |
|
183 | + static public function setContentDispositionHeader($filename, $type = 'attachment') { |
|
184 | 184 | if (\OC::$server->getRequest()->isUserAgent( |
185 | 185 | [ |
186 | 186 | \OC\AppFramework\Http\Request::USER_AGENT_IE, |
187 | 187 | \OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME, |
188 | 188 | \OC\AppFramework\Http\Request::USER_AGENT_FREEBOX, |
189 | 189 | ])) { |
190 | - header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' ); |
|
190 | + header('Content-Disposition: '.rawurlencode($type).'; filename="'.rawurlencode($filename).'"'); |
|
191 | 191 | } else { |
192 | - header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename ) |
|
193 | - . '; filename="' . rawurlencode( $filename ) . '"' ); |
|
192 | + header('Content-Disposition: '.rawurlencode($type).'; filename*=UTF-8\'\''.rawurlencode($filename) |
|
193 | + . '; filename="'.rawurlencode($filename).'"'); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -256,12 +256,12 @@ discard block |
||
256 | 256 | . 'connect-src *; ' |
257 | 257 | . 'object-src \'none\'; ' |
258 | 258 | . 'base-uri \'self\'; '; |
259 | - header('Content-Security-Policy:' . $policy); |
|
259 | + header('Content-Security-Policy:'.$policy); |
|
260 | 260 | header('X-Frame-Options: SAMEORIGIN'); // Disallow iFraming from other domains |
261 | 261 | |
262 | 262 | // Send fallback headers for installations that don't have the possibility to send |
263 | 263 | // custom headers on the webserver side |
264 | - if(getenv('modHeadersAvailable') !== 'true') { |
|
264 | + if (getenv('modHeadersAvailable') !== 'true') { |
|
265 | 265 | header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters |
266 | 266 | header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE |
267 | 267 | header('X-Robots-Tag: none'); // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag |