@@ -102,19 +102,19 @@ discard block |
||
102 | 102 | $this->configuration = new Configuration($configPrefix, |
103 | 103 | !is_null($configID)); |
104 | 104 | $memcache = \OC::$server->getMemCacheFactory(); |
105 | - if($memcache->isAvailable()) { |
|
105 | + if ($memcache->isAvailable()) { |
|
106 | 106 | $this->cache = $memcache->createDistributed(); |
107 | 107 | } |
108 | 108 | $helper = new Helper(\OC::$server->getConfig()); |
109 | 109 | $this->doNotValidate = !in_array($this->configPrefix, |
110 | 110 | $helper->getServerConfigurationPrefixes()); |
111 | 111 | $this->hasPagedResultSupport = |
112 | - (int)$this->configuration->ldapPagingSize !== 0 |
|
112 | + (int) $this->configuration->ldapPagingSize !== 0 |
|
113 | 113 | || $this->ldap->hasPagedResultSupport(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | public function __destruct() { |
117 | - if(!$this->dontDestruct && $this->ldap->isResource($this->ldapConnectionRes)) { |
|
117 | + if (!$this->dontDestruct && $this->ldap->isResource($this->ldapConnectionRes)) { |
|
118 | 118 | @$this->ldap->unbind($this->ldapConnectionRes); |
119 | 119 | $this->bindResult = []; |
120 | 120 | } |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | * @return bool|mixed |
136 | 136 | */ |
137 | 137 | public function __get($name) { |
138 | - if(!$this->configured) { |
|
138 | + if (!$this->configured) { |
|
139 | 139 | $this->readConfiguration(); |
140 | 140 | } |
141 | 141 | |
142 | - if($name === 'hasPagedResultSupport') { |
|
142 | + if ($name === 'hasPagedResultSupport') { |
|
143 | 143 | return $this->hasPagedResultSupport; |
144 | 144 | } |
145 | 145 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $before = $this->configuration->$name; |
156 | 156 | $this->configuration->$name = $value; |
157 | 157 | $after = $this->configuration->$name; |
158 | - if($before !== $after) { |
|
158 | + if ($before !== $after) { |
|
159 | 159 | if ($this->configID !== '' && $this->configID !== null) { |
160 | 160 | $this->configuration->saveConfiguration(); |
161 | 161 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param bool $state |
171 | 171 | */ |
172 | 172 | public function setIgnoreValidation($state) { |
173 | - $this->ignoreValidation = (bool)$state; |
|
173 | + $this->ignoreValidation = (bool) $state; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | * Returns the LDAP handler |
187 | 187 | */ |
188 | 188 | public function getConnectionResource() { |
189 | - if(!$this->ldapConnectionRes) { |
|
189 | + if (!$this->ldapConnectionRes) { |
|
190 | 190 | $this->init(); |
191 | - } else if(!$this->ldap->isResource($this->ldapConnectionRes)) { |
|
191 | + } else if (!$this->ldap->isResource($this->ldapConnectionRes)) { |
|
192 | 192 | $this->ldapConnectionRes = null; |
193 | 193 | $this->establishConnection(); |
194 | 194 | } |
195 | - if(is_null($this->ldapConnectionRes)) { |
|
196 | - \OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server ' . $this->configuration->ldapHost, ILogger::ERROR); |
|
195 | + if (is_null($this->ldapConnectionRes)) { |
|
196 | + \OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server '.$this->configuration->ldapHost, ILogger::ERROR); |
|
197 | 197 | throw new ServerNotAvailableException('Connection to LDAP server could not be established'); |
198 | 198 | } |
199 | 199 | return $this->ldapConnectionRes; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * resets the connection resource |
204 | 204 | */ |
205 | 205 | public function resetConnectionResource() { |
206 | - if(!is_null($this->ldapConnectionRes)) { |
|
206 | + if (!is_null($this->ldapConnectionRes)) { |
|
207 | 207 | @$this->ldap->unbind($this->ldapConnectionRes); |
208 | 208 | $this->ldapConnectionRes = null; |
209 | 209 | $this->bindResult = []; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | private function getCacheKey($key) { |
218 | 218 | $prefix = 'LDAP-'.$this->configID.'-'.$this->configPrefix.'-'; |
219 | - if(is_null($key)) { |
|
219 | + if (is_null($key)) { |
|
220 | 220 | return $prefix; |
221 | 221 | } |
222 | 222 | return $prefix.hash('sha256', $key); |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | * @return mixed|null |
228 | 228 | */ |
229 | 229 | public function getFromCache($key) { |
230 | - if(!$this->configured) { |
|
230 | + if (!$this->configured) { |
|
231 | 231 | $this->readConfiguration(); |
232 | 232 | } |
233 | - if(is_null($this->cache) || !$this->configuration->ldapCacheTTL) { |
|
233 | + if (is_null($this->cache) || !$this->configuration->ldapCacheTTL) { |
|
234 | 234 | return null; |
235 | 235 | } |
236 | 236 | $key = $this->getCacheKey($key); |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * @return string |
246 | 246 | */ |
247 | 247 | public function writeToCache($key, $value) { |
248 | - if(!$this->configured) { |
|
248 | + if (!$this->configured) { |
|
249 | 249 | $this->readConfiguration(); |
250 | 250 | } |
251 | - if(is_null($this->cache) |
|
251 | + if (is_null($this->cache) |
|
252 | 252 | || !$this->configuration->ldapCacheTTL |
253 | 253 | || !$this->configuration->ldapConfigurationActive) { |
254 | 254 | return null; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | public function clearCache() { |
262 | - if(!is_null($this->cache)) { |
|
262 | + if (!is_null($this->cache)) { |
|
263 | 263 | $this->cache->clear($this->getCacheKey(null)); |
264 | 264 | } |
265 | 265 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @return null |
272 | 272 | */ |
273 | 273 | private function readConfiguration($force = false) { |
274 | - if((!$this->configured || $force) && !is_null($this->configID)) { |
|
274 | + if ((!$this->configured || $force) && !is_null($this->configID)) { |
|
275 | 275 | $this->configuration->readConfiguration(); |
276 | 276 | $this->configured = $this->validateConfiguration(); |
277 | 277 | } |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | * @return boolean true if config validates, false otherwise. Check with $setParameters for detailed success on single parameters |
285 | 285 | */ |
286 | 286 | public function setConfiguration($config, &$setParameters = null) { |
287 | - if(is_null($setParameters)) { |
|
287 | + if (is_null($setParameters)) { |
|
288 | 288 | $setParameters = array(); |
289 | 289 | } |
290 | 290 | $this->doNotValidate = false; |
291 | 291 | $this->configuration->setConfiguration($config, $setParameters); |
292 | - if(count($setParameters) > 0) { |
|
292 | + if (count($setParameters) > 0) { |
|
293 | 293 | $this->configured = $this->validateConfiguration(); |
294 | 294 | } |
295 | 295 | |
@@ -316,10 +316,10 @@ discard block |
||
316 | 316 | $config = $this->configuration->getConfiguration(); |
317 | 317 | $cta = $this->configuration->getConfigTranslationArray(); |
318 | 318 | $result = array(); |
319 | - foreach($cta as $dbkey => $configkey) { |
|
320 | - switch($configkey) { |
|
319 | + foreach ($cta as $dbkey => $configkey) { |
|
320 | + switch ($configkey) { |
|
321 | 321 | case 'homeFolderNamingRule': |
322 | - if(strpos($config[$configkey], 'attr:') === 0) { |
|
322 | + if (strpos($config[$configkey], 'attr:') === 0) { |
|
323 | 323 | $result[$dbkey] = substr($config[$configkey], 5); |
324 | 324 | } else { |
325 | 325 | $result[$dbkey] = ''; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | case 'ldapBaseGroups': |
331 | 331 | case 'ldapAttributesForUserSearch': |
332 | 332 | case 'ldapAttributesForGroupSearch': |
333 | - if(is_array($config[$configkey])) { |
|
333 | + if (is_array($config[$configkey])) { |
|
334 | 334 | $result[$dbkey] = implode("\n", $config[$configkey]); |
335 | 335 | break; |
336 | 336 | } //else follows default |
@@ -343,23 +343,23 @@ discard block |
||
343 | 343 | |
344 | 344 | private function doSoftValidation() { |
345 | 345 | //if User or Group Base are not set, take over Base DN setting |
346 | - foreach(array('ldapBaseUsers', 'ldapBaseGroups') as $keyBase) { |
|
346 | + foreach (array('ldapBaseUsers', 'ldapBaseGroups') as $keyBase) { |
|
347 | 347 | $val = $this->configuration->$keyBase; |
348 | - if(empty($val)) { |
|
348 | + if (empty($val)) { |
|
349 | 349 | $this->configuration->$keyBase = $this->configuration->ldapBase; |
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
353 | - foreach(array('ldapExpertUUIDUserAttr' => 'ldapUuidUserAttribute', |
|
353 | + foreach (array('ldapExpertUUIDUserAttr' => 'ldapUuidUserAttribute', |
|
354 | 354 | 'ldapExpertUUIDGroupAttr' => 'ldapUuidGroupAttribute') |
355 | 355 | as $expertSetting => $effectiveSetting) { |
356 | 356 | $uuidOverride = $this->configuration->$expertSetting; |
357 | - if(!empty($uuidOverride)) { |
|
357 | + if (!empty($uuidOverride)) { |
|
358 | 358 | $this->configuration->$effectiveSetting = $uuidOverride; |
359 | 359 | } else { |
360 | 360 | $uuidAttributes = Access::UUID_ATTRIBUTES; |
361 | 361 | array_unshift($uuidAttributes, 'auto'); |
362 | - if(!in_array($this->configuration->$effectiveSetting, |
|
362 | + if (!in_array($this->configuration->$effectiveSetting, |
|
363 | 363 | $uuidAttributes) |
364 | 364 | && (!is_null($this->configID))) { |
365 | 365 | $this->configuration->$effectiveSetting = 'auto'; |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | - $backupPort = (int)$this->configuration->ldapBackupPort; |
|
376 | + $backupPort = (int) $this->configuration->ldapBackupPort; |
|
377 | 377 | if ($backupPort <= 0) { |
378 | 378 | $this->configuration->backupPort = $this->configuration->ldapPort; |
379 | 379 | } |
@@ -381,14 +381,14 @@ discard block |
||
381 | 381 | //make sure empty search attributes are saved as simple, empty array |
382 | 382 | $saKeys = array('ldapAttributesForUserSearch', |
383 | 383 | 'ldapAttributesForGroupSearch'); |
384 | - foreach($saKeys as $key) { |
|
384 | + foreach ($saKeys as $key) { |
|
385 | 385 | $val = $this->configuration->$key; |
386 | - if(is_array($val) && count($val) === 1 && empty($val[0])) { |
|
386 | + if (is_array($val) && count($val) === 1 && empty($val[0])) { |
|
387 | 387 | $this->configuration->$key = array(); |
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | - if((stripos($this->configuration->ldapHost, 'ldaps://') === 0) |
|
391 | + if ((stripos($this->configuration->ldapHost, 'ldaps://') === 0) |
|
392 | 392 | && $this->configuration->ldapTLS) { |
393 | 393 | $this->configuration->ldapTLS = false; |
394 | 394 | \OCP\Util::writeLog( |
@@ -405,15 +405,15 @@ discard block |
||
405 | 405 | private function doCriticalValidation() { |
406 | 406 | $configurationOK = true; |
407 | 407 | $errorStr = 'Configuration Error (prefix '. |
408 | - (string)$this->configPrefix .'): '; |
|
408 | + (string) $this->configPrefix.'): '; |
|
409 | 409 | |
410 | 410 | //options that shall not be empty |
411 | 411 | $options = array('ldapHost', 'ldapPort', 'ldapUserDisplayName', |
412 | 412 | 'ldapGroupDisplayName', 'ldapLoginFilter'); |
413 | - foreach($options as $key) { |
|
413 | + foreach ($options as $key) { |
|
414 | 414 | $val = $this->configuration->$key; |
415 | - if(empty($val)) { |
|
416 | - switch($key) { |
|
415 | + if (empty($val)) { |
|
416 | + switch ($key) { |
|
417 | 417 | case 'ldapHost': |
418 | 418 | $subj = 'LDAP Host'; |
419 | 419 | break; |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | $agent = $this->configuration->ldapAgentName; |
447 | 447 | $pwd = $this->configuration->ldapAgentPassword; |
448 | 448 | if ( |
449 | - ($agent === '' && $pwd !== '') |
|
449 | + ($agent === '' && $pwd !== '') |
|
450 | 450 | || ($agent !== '' && $pwd === '') |
451 | 451 | ) { |
452 | 452 | \OCP\Util::writeLog( |
453 | 453 | 'user_ldap', |
454 | - $errorStr.'either no password is given for the user ' . |
|
454 | + $errorStr.'either no password is given for the user '. |
|
455 | 455 | 'agent or a password is given, but not an LDAP agent.', |
456 | 456 | ILogger::WARN); |
457 | 457 | $configurationOK = false; |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $baseUsers = $this->configuration->ldapBaseUsers; |
462 | 462 | $baseGroups = $this->configuration->ldapBaseGroups; |
463 | 463 | |
464 | - if(empty($base) && empty($baseUsers) && empty($baseGroups)) { |
|
464 | + if (empty($base) && empty($baseUsers) && empty($baseGroups)) { |
|
465 | 465 | \OCP\Util::writeLog( |
466 | 466 | 'user_ldap', |
467 | 467 | $errorStr.'Not a single Base DN given.', |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | $configurationOK = false; |
471 | 471 | } |
472 | 472 | |
473 | - if(mb_strpos($this->configuration->ldapLoginFilter, '%uid', 0, 'UTF-8') |
|
473 | + if (mb_strpos($this->configuration->ldapLoginFilter, '%uid', 0, 'UTF-8') |
|
474 | 474 | === false) { |
475 | 475 | \OCP\Util::writeLog( |
476 | 476 | 'user_ldap', |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | */ |
490 | 490 | private function validateConfiguration() { |
491 | 491 | |
492 | - if($this->doNotValidate) { |
|
492 | + if ($this->doNotValidate) { |
|
493 | 493 | //don't do a validation if it is a new configuration with pure |
494 | 494 | //default values. Will be allowed on changes via __set or |
495 | 495 | //setConfiguration |
@@ -510,14 +510,14 @@ discard block |
||
510 | 510 | * Connects and Binds to LDAP |
511 | 511 | */ |
512 | 512 | private function establishConnection() { |
513 | - if(!$this->configuration->ldapConfigurationActive) { |
|
513 | + if (!$this->configuration->ldapConfigurationActive) { |
|
514 | 514 | return null; |
515 | 515 | } |
516 | 516 | static $phpLDAPinstalled = true; |
517 | - if(!$phpLDAPinstalled) { |
|
517 | + if (!$phpLDAPinstalled) { |
|
518 | 518 | return false; |
519 | 519 | } |
520 | - if(!$this->ignoreValidation && !$this->configured) { |
|
520 | + if (!$this->ignoreValidation && !$this->configured) { |
|
521 | 521 | \OCP\Util::writeLog( |
522 | 522 | 'user_ldap', |
523 | 523 | 'Configuration is invalid, cannot connect', |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | ); |
526 | 526 | return false; |
527 | 527 | } |
528 | - if(!$this->ldapConnectionRes) { |
|
529 | - if(!$this->ldap->areLDAPFunctionsAvailable()) { |
|
528 | + if (!$this->ldapConnectionRes) { |
|
529 | + if (!$this->ldap->areLDAPFunctionsAvailable()) { |
|
530 | 530 | $phpLDAPinstalled = false; |
531 | 531 | \OCP\Util::writeLog( |
532 | 532 | 'user_ldap', |
@@ -536,8 +536,8 @@ discard block |
||
536 | 536 | |
537 | 537 | return false; |
538 | 538 | } |
539 | - if($this->configuration->turnOffCertCheck) { |
|
540 | - if(putenv('LDAPTLS_REQCERT=never')) { |
|
539 | + if ($this->configuration->turnOffCertCheck) { |
|
540 | + if (putenv('LDAPTLS_REQCERT=never')) { |
|
541 | 541 | \OCP\Util::writeLog('user_ldap', |
542 | 542 | 'Turned off SSL certificate validation successfully.', |
543 | 543 | ILogger::DEBUG); |
@@ -563,24 +563,24 @@ discard block |
||
563 | 563 | $error = $this->ldap->isResource($this->ldapConnectionRes) ? |
564 | 564 | $this->ldap->errno($this->ldapConnectionRes) : -1; |
565 | 565 | } |
566 | - if($bindStatus === true) { |
|
566 | + if ($bindStatus === true) { |
|
567 | 567 | return $bindStatus; |
568 | 568 | } |
569 | 569 | } catch (ServerNotAvailableException $e) { |
570 | - if(!$isBackupHost) { |
|
570 | + if (!$isBackupHost) { |
|
571 | 571 | throw $e; |
572 | 572 | } |
573 | 573 | } |
574 | 574 | |
575 | 575 | //if LDAP server is not reachable, try the Backup (Replica!) Server |
576 | - if($isBackupHost && ($error !== 0 || $isOverrideMainServer)) { |
|
576 | + if ($isBackupHost && ($error !== 0 || $isOverrideMainServer)) { |
|
577 | 577 | $this->doConnect($this->configuration->ldapBackupHost, |
578 | 578 | $this->configuration->ldapBackupPort); |
579 | 579 | $this->bindResult = []; |
580 | 580 | $bindStatus = $this->bind(); |
581 | 581 | $error = $this->ldap->isResource($this->ldapConnectionRes) ? |
582 | 582 | $this->ldap->errno($this->ldapConnectionRes) : -1; |
583 | - if($bindStatus && $error === 0 && !$this->getFromCache('overrideMainServer')) { |
|
583 | + if ($bindStatus && $error === 0 && !$this->getFromCache('overrideMainServer')) { |
|
584 | 584 | //when bind to backup server succeeded and failed to main server, |
585 | 585 | //skip contacting him until next cache refresh |
586 | 586 | $this->writeToCache('overrideMainServer', true); |
@@ -605,17 +605,17 @@ discard block |
||
605 | 605 | |
606 | 606 | $this->ldapConnectionRes = $this->ldap->connect($host, $port); |
607 | 607 | |
608 | - if(!$this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) { |
|
608 | + if (!$this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) { |
|
609 | 609 | throw new ServerNotAvailableException('Could not set required LDAP Protocol version.'); |
610 | 610 | } |
611 | 611 | |
612 | - if(!$this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) { |
|
612 | + if (!$this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) { |
|
613 | 613 | throw new ServerNotAvailableException('Could not disable LDAP referrals.'); |
614 | 614 | } |
615 | 615 | |
616 | - if($this->configuration->ldapTLS) { |
|
617 | - if(!$this->ldap->startTls($this->ldapConnectionRes)) { |
|
618 | - throw new ServerNotAvailableException('Start TLS failed, when connecting to LDAP host ' . $host . '.'); |
|
616 | + if ($this->configuration->ldapTLS) { |
|
617 | + if (!$this->ldap->startTls($this->ldapConnectionRes)) { |
|
618 | + throw new ServerNotAvailableException('Start TLS failed, when connecting to LDAP host '.$host.'.'); |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 | |
@@ -626,19 +626,19 @@ discard block |
||
626 | 626 | * Binds to LDAP |
627 | 627 | */ |
628 | 628 | public function bind() { |
629 | - if(!$this->configuration->ldapConfigurationActive) { |
|
629 | + if (!$this->configuration->ldapConfigurationActive) { |
|
630 | 630 | return false; |
631 | 631 | } |
632 | 632 | $cr = $this->ldapConnectionRes; |
633 | - if(!$this->ldap->isResource($cr)) { |
|
633 | + if (!$this->ldap->isResource($cr)) { |
|
634 | 634 | $cr = $this->getConnectionResource(); |
635 | 635 | } |
636 | 636 | |
637 | - if( |
|
637 | + if ( |
|
638 | 638 | count($this->bindResult) !== 0 |
639 | 639 | && $this->bindResult['dn'] === $this->configuration->ldapAgentName |
640 | 640 | && \OC::$server->getHasher()->verify( |
641 | - $this->configPrefix . $this->configuration->ldapAgentPassword, |
|
641 | + $this->configPrefix.$this->configuration->ldapAgentPassword, |
|
642 | 642 | $this->bindResult['hash'] |
643 | 643 | ) |
644 | 644 | ) { |
@@ -654,19 +654,19 @@ discard block |
||
654 | 654 | |
655 | 655 | $this->bindResult = [ |
656 | 656 | 'dn' => $this->configuration->ldapAgentName, |
657 | - 'hash' => \OC::$server->getHasher()->hash($this->configPrefix . $this->configuration->ldapAgentPassword), |
|
657 | + 'hash' => \OC::$server->getHasher()->hash($this->configPrefix.$this->configuration->ldapAgentPassword), |
|
658 | 658 | 'result' => $ldapLogin, |
659 | 659 | ]; |
660 | 660 | |
661 | - if(!$ldapLogin) { |
|
661 | + if (!$ldapLogin) { |
|
662 | 662 | $errno = $this->ldap->errno($cr); |
663 | 663 | |
664 | 664 | \OCP\Util::writeLog('user_ldap', |
665 | - 'Bind failed: ' . $errno . ': ' . $this->ldap->error($cr), |
|
665 | + 'Bind failed: '.$errno.': '.$this->ldap->error($cr), |
|
666 | 666 | ILogger::WARN); |
667 | 667 | |
668 | 668 | // Set to failure mode, if LDAP error code is not LDAP_SUCCESS or LDAP_INVALID_CREDENTIALS |
669 | - if($errno !== 0x00 && $errno !== 0x31) { |
|
669 | + if ($errno !== 0x00 && $errno !== 0x31) { |
|
670 | 670 | $this->ldapConnectionRes = null; |
671 | 671 | } |
672 | 672 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function __construct(Configuration $configuration, ILDAPWrapper $ldap, Access $access) { |
73 | 73 | parent::__construct($ldap); |
74 | 74 | $this->configuration = $configuration; |
75 | - if(is_null(Wizard::$l)) { |
|
75 | + if (is_null(Wizard::$l)) { |
|
76 | 76 | Wizard::$l = \OC::$server->getL10N('user_ldap'); |
77 | 77 | } |
78 | 78 | $this->access = $access; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | public function __destruct() { |
83 | - if($this->result->hasChanges()) { |
|
83 | + if ($this->result->hasChanges()) { |
|
84 | 84 | $this->configuration->saveConfiguration(); |
85 | 85 | } |
86 | 86 | } |
@@ -95,18 +95,18 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function countEntries(string $filter, string $type): int { |
97 | 97 | $reqs = ['ldapHost', 'ldapPort', 'ldapBase']; |
98 | - if($type === 'users') { |
|
98 | + if ($type === 'users') { |
|
99 | 99 | $reqs[] = 'ldapUserFilter'; |
100 | 100 | } |
101 | - if(!$this->checkRequirements($reqs)) { |
|
101 | + if (!$this->checkRequirements($reqs)) { |
|
102 | 102 | throw new \Exception('Requirements not met', 400); |
103 | 103 | } |
104 | 104 | |
105 | 105 | $attr = ['dn']; // default |
106 | 106 | $limit = 1001; |
107 | - if($type === 'groups') { |
|
108 | - $result = $this->access->countGroups($filter, $attr, $limit); |
|
109 | - } else if($type === 'users') { |
|
107 | + if ($type === 'groups') { |
|
108 | + $result = $this->access->countGroups($filter, $attr, $limit); |
|
109 | + } else if ($type === 'users') { |
|
110 | 110 | $result = $this->access->countUsers($filter, $attr, $limit); |
111 | 111 | } else if ($type === 'objects') { |
112 | 112 | $result = $this->access->countObjects($limit); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | throw new \Exception('Internal error: Invalid object type', 500); |
115 | 115 | } |
116 | 116 | |
117 | - return (int)$result; |
|
117 | + return (int) $result; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | * @return string |
126 | 126 | */ |
127 | 127 | private function formatCountResult(int $count): string { |
128 | - if($count > 1000) { |
|
128 | + if ($count > 1000) { |
|
129 | 129 | return '> 1000'; |
130 | 130 | } |
131 | - return (string)$count; |
|
131 | + return (string) $count; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | public function countGroups() { |
135 | 135 | $filter = $this->configuration->ldapGroupFilter; |
136 | 136 | |
137 | - if(empty($filter)) { |
|
137 | + if (empty($filter)) { |
|
138 | 138 | $output = self::$l->n('%s group found', '%s groups found', 0, array(0)); |
139 | 139 | $this->result->addChange('ldap_group_count', $output); |
140 | 140 | return $this->result; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $groupsTotal = $this->countEntries($filter, 'groups'); |
145 | 145 | } catch (\Exception $e) { |
146 | 146 | //400 can be ignored, 500 is forwarded |
147 | - if($e->getCode() === 500) { |
|
147 | + if ($e->getCode() === 500) { |
|
148 | 148 | throw $e; |
149 | 149 | } |
150 | 150 | return false; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | public function countInBaseDN() { |
187 | 187 | // we don't need to provide a filter in this case |
188 | 188 | $total = $this->countEntries('', 'objects'); |
189 | - if($total === false) { |
|
189 | + if ($total === false) { |
|
190 | 190 | throw new \Exception('invalid results received'); |
191 | 191 | } |
192 | 192 | $this->result->addChange('ldap_test_base', $total); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @return int|bool |
201 | 201 | */ |
202 | 202 | public function countUsersWithAttribute($attr, $existsCheck = false) { |
203 | - if(!$this->checkRequirements(array('ldapHost', |
|
203 | + if (!$this->checkRequirements(array('ldapHost', |
|
204 | 204 | 'ldapPort', |
205 | 205 | 'ldapBase', |
206 | 206 | 'ldapUserFilter', |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | $filter = $this->access->combineFilterWithAnd(array( |
212 | 212 | $this->configuration->ldapUserFilter, |
213 | - $attr . '=*' |
|
213 | + $attr.'=*' |
|
214 | 214 | )); |
215 | 215 | |
216 | 216 | $limit = ($existsCheck === false) ? null : 1; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @throws \Exception |
226 | 226 | */ |
227 | 227 | public function detectUserDisplayNameAttribute() { |
228 | - if(!$this->checkRequirements(array('ldapHost', |
|
228 | + if (!$this->checkRequirements(array('ldapHost', |
|
229 | 229 | 'ldapPort', |
230 | 230 | 'ldapBase', |
231 | 231 | 'ldapUserFilter', |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | if ($attr !== '' && $attr !== 'displayName') { |
238 | 238 | // most likely not the default value with upper case N, |
239 | 239 | // verify it still produces a result |
240 | - $count = (int)$this->countUsersWithAttribute($attr, true); |
|
241 | - if($count > 0) { |
|
240 | + $count = (int) $this->countUsersWithAttribute($attr, true); |
|
241 | + if ($count > 0) { |
|
242 | 242 | //no change, but we sent it back to make sure the user interface |
243 | 243 | //is still correct, even if the ajax call was cancelled meanwhile |
244 | 244 | $this->result->addChange('ldap_display_name', $attr); |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | // first attribute that has at least one result wins |
250 | 250 | $displayNameAttrs = array('displayname', 'cn'); |
251 | 251 | foreach ($displayNameAttrs as $attr) { |
252 | - $count = (int)$this->countUsersWithAttribute($attr, true); |
|
252 | + $count = (int) $this->countUsersWithAttribute($attr, true); |
|
253 | 253 | |
254 | - if($count > 0) { |
|
254 | + if ($count > 0) { |
|
255 | 255 | $this->applyFind('ldap_display_name', $attr); |
256 | 256 | return $this->result; |
257 | 257 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return WizardResult|bool |
268 | 268 | */ |
269 | 269 | public function detectEmailAttribute() { |
270 | - if(!$this->checkRequirements(array('ldapHost', |
|
270 | + if (!$this->checkRequirements(array('ldapHost', |
|
271 | 271 | 'ldapPort', |
272 | 272 | 'ldapBase', |
273 | 273 | 'ldapUserFilter', |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | |
278 | 278 | $attr = $this->configuration->ldapEmailAttribute; |
279 | 279 | if ($attr !== '') { |
280 | - $count = (int)$this->countUsersWithAttribute($attr, true); |
|
281 | - if($count > 0) { |
|
280 | + $count = (int) $this->countUsersWithAttribute($attr, true); |
|
281 | + if ($count > 0) { |
|
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | $writeLog = true; |
@@ -289,19 +289,19 @@ discard block |
||
289 | 289 | $emailAttributes = array('mail', 'mailPrimaryAddress'); |
290 | 290 | $winner = ''; |
291 | 291 | $maxUsers = 0; |
292 | - foreach($emailAttributes as $attr) { |
|
292 | + foreach ($emailAttributes as $attr) { |
|
293 | 293 | $count = $this->countUsersWithAttribute($attr); |
294 | - if($count > $maxUsers) { |
|
294 | + if ($count > $maxUsers) { |
|
295 | 295 | $maxUsers = $count; |
296 | 296 | $winner = $attr; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - if($winner !== '') { |
|
300 | + if ($winner !== '') { |
|
301 | 301 | $this->applyFind('ldap_email_attr', $winner); |
302 | - if($writeLog) { |
|
303 | - \OCP\Util::writeLog('user_ldap', 'The mail attribute has ' . |
|
304 | - 'automatically been reset, because the original value ' . |
|
302 | + if ($writeLog) { |
|
303 | + \OCP\Util::writeLog('user_ldap', 'The mail attribute has '. |
|
304 | + 'automatically been reset, because the original value '. |
|
305 | 305 | 'did not return any results.', ILogger::INFO); |
306 | 306 | } |
307 | 307 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @throws \Exception |
315 | 315 | */ |
316 | 316 | public function determineAttributes() { |
317 | - if(!$this->checkRequirements(array('ldapHost', |
|
317 | + if (!$this->checkRequirements(array('ldapHost', |
|
318 | 318 | 'ldapPort', |
319 | 319 | 'ldapBase', |
320 | 320 | 'ldapUserFilter', |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $this->result->addOptions('ldap_loginfilter_attributes', $attributes); |
331 | 331 | |
332 | 332 | $selected = $this->configuration->ldapLoginFilterAttributes; |
333 | - if(is_array($selected) && !empty($selected)) { |
|
333 | + if (is_array($selected) && !empty($selected)) { |
|
334 | 334 | $this->result->addChange('ldap_loginfilter_attributes', $selected); |
335 | 335 | } |
336 | 336 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @throws \Exception |
344 | 344 | */ |
345 | 345 | private function getUserAttributes() { |
346 | - if(!$this->checkRequirements(array('ldapHost', |
|
346 | + if (!$this->checkRequirements(array('ldapHost', |
|
347 | 347 | 'ldapPort', |
348 | 348 | 'ldapBase', |
349 | 349 | 'ldapUserFilter', |
@@ -351,20 +351,20 @@ discard block |
||
351 | 351 | return false; |
352 | 352 | } |
353 | 353 | $cr = $this->getConnection(); |
354 | - if(!$cr) { |
|
354 | + if (!$cr) { |
|
355 | 355 | throw new \Exception('Could not connect to LDAP'); |
356 | 356 | } |
357 | 357 | |
358 | 358 | $base = $this->configuration->ldapBase[0]; |
359 | 359 | $filter = $this->configuration->ldapUserFilter; |
360 | 360 | $rr = $this->ldap->search($cr, $base, $filter, array(), 1, 1); |
361 | - if(!$this->ldap->isResource($rr)) { |
|
361 | + if (!$this->ldap->isResource($rr)) { |
|
362 | 362 | return false; |
363 | 363 | } |
364 | 364 | $er = $this->ldap->firstEntry($cr, $rr); |
365 | 365 | $attributes = $this->ldap->getAttributes($cr, $er); |
366 | 366 | $pureAttributes = array(); |
367 | - for($i = 0; $i < $attributes['count']; $i++) { |
|
367 | + for ($i = 0; $i < $attributes['count']; $i++) { |
|
368 | 368 | $pureAttributes[] = $attributes[$i]; |
369 | 369 | } |
370 | 370 | |
@@ -399,23 +399,23 @@ discard block |
||
399 | 399 | * @throws \Exception |
400 | 400 | */ |
401 | 401 | private function determineGroups($dbKey, $confKey, $testMemberOf = true) { |
402 | - if(!$this->checkRequirements(array('ldapHost', |
|
402 | + if (!$this->checkRequirements(array('ldapHost', |
|
403 | 403 | 'ldapPort', |
404 | 404 | 'ldapBase', |
405 | 405 | ))) { |
406 | 406 | return false; |
407 | 407 | } |
408 | 408 | $cr = $this->getConnection(); |
409 | - if(!$cr) { |
|
409 | + if (!$cr) { |
|
410 | 410 | throw new \Exception('Could not connect to LDAP'); |
411 | 411 | } |
412 | 412 | |
413 | 413 | $this->fetchGroups($dbKey, $confKey); |
414 | 414 | |
415 | - if($testMemberOf) { |
|
415 | + if ($testMemberOf) { |
|
416 | 416 | $this->configuration->hasMemberOfFilterSupport = $this->testMemberOf(); |
417 | 417 | $this->result->markChange(); |
418 | - if(!$this->configuration->hasMemberOfFilterSupport) { |
|
418 | + if (!$this->configuration->hasMemberOfFilterSupport) { |
|
419 | 419 | throw new \Exception('memberOf is not supported by the server'); |
420 | 420 | } |
421 | 421 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $obclasses = array('posixGroup', 'group', 'zimbraDistributionList', 'groupOfNames', 'groupOfUniqueNames'); |
436 | 436 | |
437 | 437 | $filterParts = array(); |
438 | - foreach($obclasses as $obclass) { |
|
438 | + foreach ($obclasses as $obclass) { |
|
439 | 439 | $filterParts[] = 'objectclass='.$obclass; |
440 | 440 | } |
441 | 441 | //we filter for everything |
@@ -452,8 +452,8 @@ discard block |
||
452 | 452 | // we need to request dn additionally here, otherwise memberOf |
453 | 453 | // detection will fail later |
454 | 454 | $result = $this->access->searchGroups($filter, array('cn', 'dn'), $limit, $offset); |
455 | - foreach($result as $item) { |
|
456 | - if(!isset($item['cn']) && !is_array($item['cn']) && !isset($item['cn'][0])) { |
|
455 | + foreach ($result as $item) { |
|
456 | + if (!isset($item['cn']) && !is_array($item['cn']) && !isset($item['cn'][0])) { |
|
457 | 457 | // just in case - no issue known |
458 | 458 | continue; |
459 | 459 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | $offset += $limit; |
464 | 464 | } while ($this->access->hasMoreResults()); |
465 | 465 | |
466 | - if(count($groupNames) > 0) { |
|
466 | + if (count($groupNames) > 0) { |
|
467 | 467 | natsort($groupNames); |
468 | 468 | $this->result->addOptions($dbKey, array_values($groupNames)); |
469 | 469 | } else { |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | } |
472 | 472 | |
473 | 473 | $setFeatures = $this->configuration->$confKey; |
474 | - if(is_array($setFeatures) && !empty($setFeatures)) { |
|
474 | + if (is_array($setFeatures) && !empty($setFeatures)) { |
|
475 | 475 | //something is already configured? pre-select it. |
476 | 476 | $this->result->addChange($dbKey, $setFeatures); |
477 | 477 | } |
@@ -479,14 +479,14 @@ discard block |
||
479 | 479 | } |
480 | 480 | |
481 | 481 | public function determineGroupMemberAssoc() { |
482 | - if(!$this->checkRequirements(array('ldapHost', |
|
482 | + if (!$this->checkRequirements(array('ldapHost', |
|
483 | 483 | 'ldapPort', |
484 | 484 | 'ldapGroupFilter', |
485 | 485 | ))) { |
486 | 486 | return false; |
487 | 487 | } |
488 | 488 | $attribute = $this->detectGroupMemberAssoc(); |
489 | - if($attribute === false) { |
|
489 | + if ($attribute === false) { |
|
490 | 490 | return false; |
491 | 491 | } |
492 | 492 | $this->configuration->setConfiguration(array('ldapGroupMemberAssocAttr' => $attribute)); |
@@ -501,14 +501,14 @@ discard block |
||
501 | 501 | * @throws \Exception |
502 | 502 | */ |
503 | 503 | public function determineGroupObjectClasses() { |
504 | - if(!$this->checkRequirements(array('ldapHost', |
|
504 | + if (!$this->checkRequirements(array('ldapHost', |
|
505 | 505 | 'ldapPort', |
506 | 506 | 'ldapBase', |
507 | 507 | ))) { |
508 | 508 | return false; |
509 | 509 | } |
510 | 510 | $cr = $this->getConnection(); |
511 | - if(!$cr) { |
|
511 | + if (!$cr) { |
|
512 | 512 | throw new \Exception('Could not connect to LDAP'); |
513 | 513 | } |
514 | 514 | |
@@ -528,14 +528,14 @@ discard block |
||
528 | 528 | * @throws \Exception |
529 | 529 | */ |
530 | 530 | public function determineUserObjectClasses() { |
531 | - if(!$this->checkRequirements(array('ldapHost', |
|
531 | + if (!$this->checkRequirements(array('ldapHost', |
|
532 | 532 | 'ldapPort', |
533 | 533 | 'ldapBase', |
534 | 534 | ))) { |
535 | 535 | return false; |
536 | 536 | } |
537 | 537 | $cr = $this->getConnection(); |
538 | - if(!$cr) { |
|
538 | + if (!$cr) { |
|
539 | 539 | throw new \Exception('Could not connect to LDAP'); |
540 | 540 | } |
541 | 541 | |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | * @throws \Exception |
559 | 559 | */ |
560 | 560 | public function getGroupFilter() { |
561 | - if(!$this->checkRequirements(array('ldapHost', |
|
561 | + if (!$this->checkRequirements(array('ldapHost', |
|
562 | 562 | 'ldapPort', |
563 | 563 | 'ldapBase', |
564 | 564 | ))) { |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | * @throws \Exception |
583 | 583 | */ |
584 | 584 | public function getUserListFilter() { |
585 | - if(!$this->checkRequirements(array('ldapHost', |
|
585 | + if (!$this->checkRequirements(array('ldapHost', |
|
586 | 586 | 'ldapPort', |
587 | 587 | 'ldapBase', |
588 | 588 | ))) { |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | $this->applyFind('ldap_display_name', $d['ldap_display_name']); |
596 | 596 | } |
597 | 597 | $filter = $this->composeLdapFilter(self::LFILTER_USER_LIST); |
598 | - if(!$filter) { |
|
598 | + if (!$filter) { |
|
599 | 599 | throw new \Exception('Cannot create filter'); |
600 | 600 | } |
601 | 601 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @throws \Exception |
609 | 609 | */ |
610 | 610 | public function getUserLoginFilter() { |
611 | - if(!$this->checkRequirements(array('ldapHost', |
|
611 | + if (!$this->checkRequirements(array('ldapHost', |
|
612 | 612 | 'ldapPort', |
613 | 613 | 'ldapBase', |
614 | 614 | 'ldapUserFilter', |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | } |
618 | 618 | |
619 | 619 | $filter = $this->composeLdapFilter(self::LFILTER_LOGIN); |
620 | - if(!$filter) { |
|
620 | + if (!$filter) { |
|
621 | 621 | throw new \Exception('Cannot create filter'); |
622 | 622 | } |
623 | 623 | |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | * @throws \Exception |
632 | 632 | */ |
633 | 633 | public function testLoginName($loginName) { |
634 | - if(!$this->checkRequirements(array('ldapHost', |
|
634 | + if (!$this->checkRequirements(array('ldapHost', |
|
635 | 635 | 'ldapPort', |
636 | 636 | 'ldapBase', |
637 | 637 | 'ldapLoginFilter', |
@@ -640,17 +640,17 @@ discard block |
||
640 | 640 | } |
641 | 641 | |
642 | 642 | $cr = $this->access->connection->getConnectionResource(); |
643 | - if(!$this->ldap->isResource($cr)) { |
|
643 | + if (!$this->ldap->isResource($cr)) { |
|
644 | 644 | throw new \Exception('connection error'); |
645 | 645 | } |
646 | 646 | |
647 | - if(mb_strpos($this->access->connection->ldapLoginFilter, '%uid', 0, 'UTF-8') |
|
647 | + if (mb_strpos($this->access->connection->ldapLoginFilter, '%uid', 0, 'UTF-8') |
|
648 | 648 | === false) { |
649 | 649 | throw new \Exception('missing placeholder'); |
650 | 650 | } |
651 | 651 | |
652 | 652 | $users = $this->access->countUsersByLoginName($loginName); |
653 | - if($this->ldap->errno($cr) !== 0) { |
|
653 | + if ($this->ldap->errno($cr) !== 0) { |
|
654 | 654 | throw new \Exception($this->ldap->error($cr)); |
655 | 655 | } |
656 | 656 | $filter = str_replace('%uid', $loginName, $this->access->connection->ldapLoginFilter); |
@@ -665,22 +665,22 @@ discard block |
||
665 | 665 | * @throws \Exception |
666 | 666 | */ |
667 | 667 | public function guessPortAndTLS() { |
668 | - if(!$this->checkRequirements(array('ldapHost', |
|
668 | + if (!$this->checkRequirements(array('ldapHost', |
|
669 | 669 | ))) { |
670 | 670 | return false; |
671 | 671 | } |
672 | 672 | $this->checkHost(); |
673 | 673 | $portSettings = $this->getPortSettingsToTry(); |
674 | 674 | |
675 | - if(!is_array($portSettings)) { |
|
675 | + if (!is_array($portSettings)) { |
|
676 | 676 | throw new \Exception(print_r($portSettings, true)); |
677 | 677 | } |
678 | 678 | |
679 | 679 | //proceed from the best configuration and return on first success |
680 | - foreach($portSettings as $setting) { |
|
680 | + foreach ($portSettings as $setting) { |
|
681 | 681 | $p = $setting['port']; |
682 | 682 | $t = $setting['tls']; |
683 | - \OCP\Util::writeLog('user_ldap', 'Wiz: trying port '. $p . ', TLS '. $t, ILogger::DEBUG); |
|
683 | + \OCP\Util::writeLog('user_ldap', 'Wiz: trying port '.$p.', TLS '.$t, ILogger::DEBUG); |
|
684 | 684 | //connectAndBind may throw Exception, it needs to be catched by the |
685 | 685 | //callee of this method |
686 | 686 | |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | // any reply other than -1 (= cannot connect) is already okay, |
691 | 691 | // because then we found the server |
692 | 692 | // unavailable startTLS returns -11 |
693 | - if($e->getCode() > 0) { |
|
693 | + if ($e->getCode() > 0) { |
|
694 | 694 | $settingsFound = true; |
695 | 695 | } else { |
696 | 696 | throw $e; |
@@ -700,10 +700,10 @@ discard block |
||
700 | 700 | if ($settingsFound === true) { |
701 | 701 | $config = array( |
702 | 702 | 'ldapPort' => $p, |
703 | - 'ldapTLS' => (int)$t |
|
703 | + 'ldapTLS' => (int) $t |
|
704 | 704 | ); |
705 | 705 | $this->configuration->setConfiguration($config); |
706 | - \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, ILogger::DEBUG); |
|
706 | + \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port '.$p, ILogger::DEBUG); |
|
707 | 707 | $this->result->addChange('ldap_port', $p); |
708 | 708 | return $this->result; |
709 | 709 | } |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | * @return WizardResult|false WizardResult on success, false otherwise |
719 | 719 | */ |
720 | 720 | public function guessBaseDN() { |
721 | - if(!$this->checkRequirements(array('ldapHost', |
|
721 | + if (!$this->checkRequirements(array('ldapHost', |
|
722 | 722 | 'ldapPort', |
723 | 723 | ))) { |
724 | 724 | return false; |
@@ -727,9 +727,9 @@ discard block |
||
727 | 727 | //check whether a DN is given in the agent name (99.9% of all cases) |
728 | 728 | $base = null; |
729 | 729 | $i = stripos($this->configuration->ldapAgentName, 'dc='); |
730 | - if($i !== false) { |
|
730 | + if ($i !== false) { |
|
731 | 731 | $base = substr($this->configuration->ldapAgentName, $i); |
732 | - if($this->testBaseDN($base)) { |
|
732 | + if ($this->testBaseDN($base)) { |
|
733 | 733 | $this->applyFind('ldap_base', $base); |
734 | 734 | return $this->result; |
735 | 735 | } |
@@ -740,13 +740,13 @@ discard block |
||
740 | 740 | //a base DN |
741 | 741 | $helper = new Helper(\OC::$server->getConfig()); |
742 | 742 | $domain = $helper->getDomainFromURL($this->configuration->ldapHost); |
743 | - if(!$domain) { |
|
743 | + if (!$domain) { |
|
744 | 744 | return false; |
745 | 745 | } |
746 | 746 | |
747 | 747 | $dparts = explode('.', $domain); |
748 | - while(count($dparts) > 0) { |
|
749 | - $base2 = 'dc=' . implode(',dc=', $dparts); |
|
748 | + while (count($dparts) > 0) { |
|
749 | + $base2 = 'dc='.implode(',dc=', $dparts); |
|
750 | 750 | if ($base !== $base2 && $this->testBaseDN($base2)) { |
751 | 751 | $this->applyFind('ldap_base', $base2); |
752 | 752 | return $this->result; |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | $hostInfo = parse_url($host); |
780 | 780 | |
781 | 781 | //removes Port from Host |
782 | - if(is_array($hostInfo) && isset($hostInfo['port'])) { |
|
782 | + if (is_array($hostInfo) && isset($hostInfo['port'])) { |
|
783 | 783 | $port = $hostInfo['port']; |
784 | 784 | $host = str_replace(':'.$port, '', $host); |
785 | 785 | $this->applyFind('ldap_host', $host); |
@@ -796,30 +796,30 @@ discard block |
||
796 | 796 | private function detectGroupMemberAssoc() { |
797 | 797 | $possibleAttrs = array('uniqueMember', 'memberUid', 'member', 'gidNumber'); |
798 | 798 | $filter = $this->configuration->ldapGroupFilter; |
799 | - if(empty($filter)) { |
|
799 | + if (empty($filter)) { |
|
800 | 800 | return false; |
801 | 801 | } |
802 | 802 | $cr = $this->getConnection(); |
803 | - if(!$cr) { |
|
803 | + if (!$cr) { |
|
804 | 804 | throw new \Exception('Could not connect to LDAP'); |
805 | 805 | } |
806 | 806 | $base = $this->configuration->ldapBase[0]; |
807 | 807 | $rr = $this->ldap->search($cr, $base, $filter, $possibleAttrs, 0, 1000); |
808 | - if(!$this->ldap->isResource($rr)) { |
|
808 | + if (!$this->ldap->isResource($rr)) { |
|
809 | 809 | return false; |
810 | 810 | } |
811 | 811 | $er = $this->ldap->firstEntry($cr, $rr); |
812 | - while(is_resource($er)) { |
|
812 | + while (is_resource($er)) { |
|
813 | 813 | $this->ldap->getDN($cr, $er); |
814 | 814 | $attrs = $this->ldap->getAttributes($cr, $er); |
815 | 815 | $result = array(); |
816 | 816 | $possibleAttrsCount = count($possibleAttrs); |
817 | - for($i = 0; $i < $possibleAttrsCount; $i++) { |
|
818 | - if(isset($attrs[$possibleAttrs[$i]])) { |
|
817 | + for ($i = 0; $i < $possibleAttrsCount; $i++) { |
|
818 | + if (isset($attrs[$possibleAttrs[$i]])) { |
|
819 | 819 | $result[$possibleAttrs[$i]] = $attrs[$possibleAttrs[$i]]['count']; |
820 | 820 | } |
821 | 821 | } |
822 | - if(!empty($result)) { |
|
822 | + if (!empty($result)) { |
|
823 | 823 | natsort($result); |
824 | 824 | return key($result); |
825 | 825 | } |
@@ -838,14 +838,14 @@ discard block |
||
838 | 838 | */ |
839 | 839 | private function testBaseDN($base) { |
840 | 840 | $cr = $this->getConnection(); |
841 | - if(!$cr) { |
|
841 | + if (!$cr) { |
|
842 | 842 | throw new \Exception('Could not connect to LDAP'); |
843 | 843 | } |
844 | 844 | |
845 | 845 | //base is there, let's validate it. If we search for anything, we should |
846 | 846 | //get a result set > 0 on a proper base |
847 | 847 | $rr = $this->ldap->search($cr, $base, 'objectClass=*', array('dn'), 0, 1); |
848 | - if(!$this->ldap->isResource($rr)) { |
|
848 | + if (!$this->ldap->isResource($rr)) { |
|
849 | 849 | $errorNo = $this->ldap->errno($cr); |
850 | 850 | $errorMsg = $this->ldap->error($cr); |
851 | 851 | \OCP\Util::writeLog('user_ldap', 'Wiz: Could not search base '.$base. |
@@ -867,11 +867,11 @@ discard block |
||
867 | 867 | */ |
868 | 868 | private function testMemberOf() { |
869 | 869 | $cr = $this->getConnection(); |
870 | - if(!$cr) { |
|
870 | + if (!$cr) { |
|
871 | 871 | throw new \Exception('Could not connect to LDAP'); |
872 | 872 | } |
873 | 873 | $result = $this->access->countUsers('memberOf=*', array('memberOf'), 1); |
874 | - if(is_int($result) && $result > 0) { |
|
874 | + if (is_int($result) && $result > 0) { |
|
875 | 875 | return true; |
876 | 876 | } |
877 | 877 | return false; |
@@ -892,27 +892,27 @@ discard block |
||
892 | 892 | case self::LFILTER_USER_LIST: |
893 | 893 | $objcs = $this->configuration->ldapUserFilterObjectclass; |
894 | 894 | //glue objectclasses |
895 | - if(is_array($objcs) && count($objcs) > 0) { |
|
895 | + if (is_array($objcs) && count($objcs) > 0) { |
|
896 | 896 | $filter .= '(|'; |
897 | - foreach($objcs as $objc) { |
|
898 | - $filter .= '(objectclass=' . $objc . ')'; |
|
897 | + foreach ($objcs as $objc) { |
|
898 | + $filter .= '(objectclass='.$objc.')'; |
|
899 | 899 | } |
900 | 900 | $filter .= ')'; |
901 | 901 | $parts++; |
902 | 902 | } |
903 | 903 | //glue group memberships |
904 | - if($this->configuration->hasMemberOfFilterSupport) { |
|
904 | + if ($this->configuration->hasMemberOfFilterSupport) { |
|
905 | 905 | $cns = $this->configuration->ldapUserFilterGroups; |
906 | - if(is_array($cns) && count($cns) > 0) { |
|
906 | + if (is_array($cns) && count($cns) > 0) { |
|
907 | 907 | $filter .= '(|'; |
908 | 908 | $cr = $this->getConnection(); |
909 | - if(!$cr) { |
|
909 | + if (!$cr) { |
|
910 | 910 | throw new \Exception('Could not connect to LDAP'); |
911 | 911 | } |
912 | 912 | $base = $this->configuration->ldapBase[0]; |
913 | - foreach($cns as $cn) { |
|
914 | - $rr = $this->ldap->search($cr, $base, 'cn=' . $cn, array('dn', 'primaryGroupToken')); |
|
915 | - if(!$this->ldap->isResource($rr)) { |
|
913 | + foreach ($cns as $cn) { |
|
914 | + $rr = $this->ldap->search($cr, $base, 'cn='.$cn, array('dn', 'primaryGroupToken')); |
|
915 | + if (!$this->ldap->isResource($rr)) { |
|
916 | 916 | continue; |
917 | 917 | } |
918 | 918 | $er = $this->ldap->firstEntry($cr, $rr); |
@@ -921,11 +921,11 @@ discard block |
||
921 | 921 | if ($dn === false || $dn === '') { |
922 | 922 | continue; |
923 | 923 | } |
924 | - $filterPart = '(memberof=' . $dn . ')'; |
|
925 | - if(isset($attrs['primaryGroupToken'])) { |
|
924 | + $filterPart = '(memberof='.$dn.')'; |
|
925 | + if (isset($attrs['primaryGroupToken'])) { |
|
926 | 926 | $pgt = $attrs['primaryGroupToken'][0]; |
927 | - $primaryFilterPart = '(primaryGroupID=' . $pgt .')'; |
|
928 | - $filterPart = '(|' . $filterPart . $primaryFilterPart . ')'; |
|
927 | + $primaryFilterPart = '(primaryGroupID='.$pgt.')'; |
|
928 | + $filterPart = '(|'.$filterPart.$primaryFilterPart.')'; |
|
929 | 929 | } |
930 | 930 | $filter .= $filterPart; |
931 | 931 | } |
@@ -934,8 +934,8 @@ discard block |
||
934 | 934 | $parts++; |
935 | 935 | } |
936 | 936 | //wrap parts in AND condition |
937 | - if($parts > 1) { |
|
938 | - $filter = '(&' . $filter . ')'; |
|
937 | + if ($parts > 1) { |
|
938 | + $filter = '(&'.$filter.')'; |
|
939 | 939 | } |
940 | 940 | if ($filter === '') { |
941 | 941 | $filter = '(objectclass=*)'; |
@@ -945,27 +945,27 @@ discard block |
||
945 | 945 | case self::LFILTER_GROUP_LIST: |
946 | 946 | $objcs = $this->configuration->ldapGroupFilterObjectclass; |
947 | 947 | //glue objectclasses |
948 | - if(is_array($objcs) && count($objcs) > 0) { |
|
948 | + if (is_array($objcs) && count($objcs) > 0) { |
|
949 | 949 | $filter .= '(|'; |
950 | - foreach($objcs as $objc) { |
|
951 | - $filter .= '(objectclass=' . $objc . ')'; |
|
950 | + foreach ($objcs as $objc) { |
|
951 | + $filter .= '(objectclass='.$objc.')'; |
|
952 | 952 | } |
953 | 953 | $filter .= ')'; |
954 | 954 | $parts++; |
955 | 955 | } |
956 | 956 | //glue group memberships |
957 | 957 | $cns = $this->configuration->ldapGroupFilterGroups; |
958 | - if(is_array($cns) && count($cns) > 0) { |
|
958 | + if (is_array($cns) && count($cns) > 0) { |
|
959 | 959 | $filter .= '(|'; |
960 | - foreach($cns as $cn) { |
|
961 | - $filter .= '(cn=' . $cn . ')'; |
|
960 | + foreach ($cns as $cn) { |
|
961 | + $filter .= '(cn='.$cn.')'; |
|
962 | 962 | } |
963 | 963 | $filter .= ')'; |
964 | 964 | } |
965 | 965 | $parts++; |
966 | 966 | //wrap parts in AND condition |
967 | - if($parts > 1) { |
|
968 | - $filter = '(&' . $filter . ')'; |
|
967 | + if ($parts > 1) { |
|
968 | + $filter = '(&'.$filter.')'; |
|
969 | 969 | } |
970 | 970 | break; |
971 | 971 | |
@@ -977,47 +977,47 @@ discard block |
||
977 | 977 | $userAttributes = array_change_key_case(array_flip($userAttributes)); |
978 | 978 | $parts = 0; |
979 | 979 | |
980 | - if($this->configuration->ldapLoginFilterUsername === '1') { |
|
980 | + if ($this->configuration->ldapLoginFilterUsername === '1') { |
|
981 | 981 | $attr = ''; |
982 | - if(isset($userAttributes['uid'])) { |
|
982 | + if (isset($userAttributes['uid'])) { |
|
983 | 983 | $attr = 'uid'; |
984 | - } else if(isset($userAttributes['samaccountname'])) { |
|
984 | + } else if (isset($userAttributes['samaccountname'])) { |
|
985 | 985 | $attr = 'samaccountname'; |
986 | - } else if(isset($userAttributes['cn'])) { |
|
986 | + } else if (isset($userAttributes['cn'])) { |
|
987 | 987 | //fallback |
988 | 988 | $attr = 'cn'; |
989 | 989 | } |
990 | 990 | if ($attr !== '') { |
991 | - $filterUsername = '(' . $attr . $loginpart . ')'; |
|
991 | + $filterUsername = '('.$attr.$loginpart.')'; |
|
992 | 992 | $parts++; |
993 | 993 | } |
994 | 994 | } |
995 | 995 | |
996 | 996 | $filterEmail = ''; |
997 | - if($this->configuration->ldapLoginFilterEmail === '1') { |
|
997 | + if ($this->configuration->ldapLoginFilterEmail === '1') { |
|
998 | 998 | $filterEmail = '(|(mailPrimaryAddress=%uid)(mail=%uid))'; |
999 | 999 | $parts++; |
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | $filterAttributes = ''; |
1003 | 1003 | $attrsToFilter = $this->configuration->ldapLoginFilterAttributes; |
1004 | - if(is_array($attrsToFilter) && count($attrsToFilter) > 0) { |
|
1004 | + if (is_array($attrsToFilter) && count($attrsToFilter) > 0) { |
|
1005 | 1005 | $filterAttributes = '(|'; |
1006 | - foreach($attrsToFilter as $attribute) { |
|
1007 | - $filterAttributes .= '(' . $attribute . $loginpart . ')'; |
|
1006 | + foreach ($attrsToFilter as $attribute) { |
|
1007 | + $filterAttributes .= '('.$attribute.$loginpart.')'; |
|
1008 | 1008 | } |
1009 | 1009 | $filterAttributes .= ')'; |
1010 | 1010 | $parts++; |
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | $filterLogin = ''; |
1014 | - if($parts > 1) { |
|
1014 | + if ($parts > 1) { |
|
1015 | 1015 | $filterLogin = '(|'; |
1016 | 1016 | } |
1017 | 1017 | $filterLogin .= $filterUsername; |
1018 | 1018 | $filterLogin .= $filterEmail; |
1019 | 1019 | $filterLogin .= $filterAttributes; |
1020 | - if($parts > 1) { |
|
1020 | + if ($parts > 1) { |
|
1021 | 1021 | $filterLogin .= ')'; |
1022 | 1022 | } |
1023 | 1023 | |
@@ -1042,12 +1042,12 @@ discard block |
||
1042 | 1042 | //connect, does not really trigger any server communication |
1043 | 1043 | $host = $this->configuration->ldapHost; |
1044 | 1044 | $hostInfo = parse_url($host); |
1045 | - if(!$hostInfo) { |
|
1045 | + if (!$hostInfo) { |
|
1046 | 1046 | throw new \Exception(self::$l->t('Invalid Host')); |
1047 | 1047 | } |
1048 | 1048 | \OCP\Util::writeLog('user_ldap', 'Wiz: Attempting to connect ', ILogger::DEBUG); |
1049 | 1049 | $cr = $this->ldap->connect($host, $port); |
1050 | - if(!is_resource($cr)) { |
|
1050 | + if (!is_resource($cr)) { |
|
1051 | 1051 | throw new \Exception(self::$l->t('Invalid Host')); |
1052 | 1052 | } |
1053 | 1053 | |
@@ -1057,9 +1057,9 @@ discard block |
||
1057 | 1057 | $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); |
1058 | 1058 | |
1059 | 1059 | try { |
1060 | - if($tls) { |
|
1060 | + if ($tls) { |
|
1061 | 1061 | $isTlsWorking = @$this->ldap->startTls($cr); |
1062 | - if(!$isTlsWorking) { |
|
1062 | + if (!$isTlsWorking) { |
|
1063 | 1063 | return false; |
1064 | 1064 | } |
1065 | 1065 | } |
@@ -1073,17 +1073,17 @@ discard block |
||
1073 | 1073 | $errNo = $this->ldap->errno($cr); |
1074 | 1074 | $error = ldap_error($cr); |
1075 | 1075 | $this->ldap->unbind($cr); |
1076 | - } catch(ServerNotAvailableException $e) { |
|
1076 | + } catch (ServerNotAvailableException $e) { |
|
1077 | 1077 | return false; |
1078 | 1078 | } |
1079 | 1079 | |
1080 | - if($login === true) { |
|
1080 | + if ($login === true) { |
|
1081 | 1081 | $this->ldap->unbind($cr); |
1082 | - \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '. $port . ' TLS ' . (int)$tls, ILogger::DEBUG); |
|
1082 | + \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '.$port.' TLS '.(int) $tls, ILogger::DEBUG); |
|
1083 | 1083 | return true; |
1084 | 1084 | } |
1085 | 1085 | |
1086 | - if($errNo === -1) { |
|
1086 | + if ($errNo === -1) { |
|
1087 | 1087 | //host, port or TLS wrong |
1088 | 1088 | return false; |
1089 | 1089 | } |
@@ -1111,9 +1111,9 @@ discard block |
||
1111 | 1111 | */ |
1112 | 1112 | private function checkRequirements($reqs) { |
1113 | 1113 | $this->checkAgentRequirements(); |
1114 | - foreach($reqs as $option) { |
|
1114 | + foreach ($reqs as $option) { |
|
1115 | 1115 | $value = $this->configuration->$option; |
1116 | - if(empty($value)) { |
|
1116 | + if (empty($value)) { |
|
1117 | 1117 | return false; |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1135,33 +1135,33 @@ discard block |
||
1135 | 1135 | $dnRead = array(); |
1136 | 1136 | $foundItems = array(); |
1137 | 1137 | $maxEntries = 0; |
1138 | - if(!is_array($this->configuration->ldapBase) |
|
1138 | + if (!is_array($this->configuration->ldapBase) |
|
1139 | 1139 | || !isset($this->configuration->ldapBase[0])) { |
1140 | 1140 | return false; |
1141 | 1141 | } |
1142 | 1142 | $base = $this->configuration->ldapBase[0]; |
1143 | 1143 | $cr = $this->getConnection(); |
1144 | - if(!$this->ldap->isResource($cr)) { |
|
1144 | + if (!$this->ldap->isResource($cr)) { |
|
1145 | 1145 | return false; |
1146 | 1146 | } |
1147 | 1147 | $lastFilter = null; |
1148 | - if(isset($filters[count($filters)-1])) { |
|
1149 | - $lastFilter = $filters[count($filters)-1]; |
|
1148 | + if (isset($filters[count($filters) - 1])) { |
|
1149 | + $lastFilter = $filters[count($filters) - 1]; |
|
1150 | 1150 | } |
1151 | - foreach($filters as $filter) { |
|
1152 | - if($lastFilter === $filter && count($foundItems) > 0) { |
|
1151 | + foreach ($filters as $filter) { |
|
1152 | + if ($lastFilter === $filter && count($foundItems) > 0) { |
|
1153 | 1153 | //skip when the filter is a wildcard and results were found |
1154 | 1154 | continue; |
1155 | 1155 | } |
1156 | 1156 | // 20k limit for performance and reason |
1157 | 1157 | $rr = $this->ldap->search($cr, $base, $filter, array($attr), 0, 20000); |
1158 | - if(!$this->ldap->isResource($rr)) { |
|
1158 | + if (!$this->ldap->isResource($rr)) { |
|
1159 | 1159 | continue; |
1160 | 1160 | } |
1161 | 1161 | $entries = $this->ldap->countEntries($cr, $rr); |
1162 | 1162 | $getEntryFunc = 'firstEntry'; |
1163 | - if(($entries !== false) && ($entries > 0)) { |
|
1164 | - if(!is_null($maxF) && $entries > $maxEntries) { |
|
1163 | + if (($entries !== false) && ($entries > 0)) { |
|
1164 | + if (!is_null($maxF) && $entries > $maxEntries) { |
|
1165 | 1165 | $maxEntries = $entries; |
1166 | 1166 | $maxF = $filter; |
1167 | 1167 | } |
@@ -1169,13 +1169,13 @@ discard block |
||
1169 | 1169 | do { |
1170 | 1170 | $entry = $this->ldap->$getEntryFunc($cr, $rr); |
1171 | 1171 | $getEntryFunc = 'nextEntry'; |
1172 | - if(!$this->ldap->isResource($entry)) { |
|
1172 | + if (!$this->ldap->isResource($entry)) { |
|
1173 | 1173 | continue 2; |
1174 | 1174 | } |
1175 | 1175 | $rr = $entry; //will be expected by nextEntry next round |
1176 | 1176 | $attributes = $this->ldap->getAttributes($cr, $entry); |
1177 | 1177 | $dn = $this->ldap->getDN($cr, $entry); |
1178 | - if($dn === false || in_array($dn, $dnRead)) { |
|
1178 | + if ($dn === false || in_array($dn, $dnRead)) { |
|
1179 | 1179 | continue; |
1180 | 1180 | } |
1181 | 1181 | $newItems = array(); |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | $foundItems = array_merge($foundItems, $newItems); |
1187 | 1187 | $this->resultCache[$dn][$attr] = $newItems; |
1188 | 1188 | $dnRead[] = $dn; |
1189 | - } while(($state === self::LRESULT_PROCESSED_SKIP |
|
1189 | + } while (($state === self::LRESULT_PROCESSED_SKIP |
|
1190 | 1190 | || $this->ldap->isResource($entry)) |
1191 | 1191 | && ($dnReadLimit === 0 || $dnReadCount < $dnReadLimit)); |
1192 | 1192 | } |
@@ -1209,11 +1209,11 @@ discard block |
||
1209 | 1209 | */ |
1210 | 1210 | private function determineFeature($objectclasses, $attr, $dbkey, $confkey, $po = false) { |
1211 | 1211 | $cr = $this->getConnection(); |
1212 | - if(!$cr) { |
|
1212 | + if (!$cr) { |
|
1213 | 1213 | throw new \Exception('Could not connect to LDAP'); |
1214 | 1214 | } |
1215 | 1215 | $p = 'objectclass='; |
1216 | - foreach($objectclasses as $key => $value) { |
|
1216 | + foreach ($objectclasses as $key => $value) { |
|
1217 | 1217 | $objectclasses[$key] = $p.$value; |
1218 | 1218 | } |
1219 | 1219 | $maxEntryObjC = ''; |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | $availableFeatures = |
1226 | 1226 | $this->cumulativeSearchOnAttribute($objectclasses, $attr, |
1227 | 1227 | $dig, $maxEntryObjC); |
1228 | - if(is_array($availableFeatures) |
|
1228 | + if (is_array($availableFeatures) |
|
1229 | 1229 | && count($availableFeatures) > 0) { |
1230 | 1230 | natcasesort($availableFeatures); |
1231 | 1231 | //natcasesort keeps indices, but we must get rid of them for proper |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | } |
1237 | 1237 | |
1238 | 1238 | $setFeatures = $this->configuration->$confkey; |
1239 | - if(is_array($setFeatures) && !empty($setFeatures)) { |
|
1239 | + if (is_array($setFeatures) && !empty($setFeatures)) { |
|
1240 | 1240 | //something is already configured? pre-select it. |
1241 | 1241 | $this->result->addChange($dbkey, $setFeatures); |
1242 | 1242 | } else if ($po && $maxEntryObjC !== '') { |
@@ -1258,7 +1258,7 @@ discard block |
||
1258 | 1258 | * LRESULT_PROCESSED_INVALID or LRESULT_PROCESSED_SKIP |
1259 | 1259 | */ |
1260 | 1260 | private function getAttributeValuesFromEntry($result, $attribute, &$known) { |
1261 | - if(!is_array($result) |
|
1261 | + if (!is_array($result) |
|
1262 | 1262 | || !isset($result['count']) |
1263 | 1263 | || !$result['count'] > 0) { |
1264 | 1264 | return self::LRESULT_PROCESSED_INVALID; |
@@ -1267,12 +1267,12 @@ discard block |
||
1267 | 1267 | // strtolower on all keys for proper comparison |
1268 | 1268 | $result = \OCP\Util::mb_array_change_key_case($result); |
1269 | 1269 | $attribute = strtolower($attribute); |
1270 | - if(isset($result[$attribute])) { |
|
1271 | - foreach($result[$attribute] as $key => $val) { |
|
1272 | - if($key === 'count') { |
|
1270 | + if (isset($result[$attribute])) { |
|
1271 | + foreach ($result[$attribute] as $key => $val) { |
|
1272 | + if ($key === 'count') { |
|
1273 | 1273 | continue; |
1274 | 1274 | } |
1275 | - if(!in_array($val, $known)) { |
|
1275 | + if (!in_array($val, $known)) { |
|
1276 | 1276 | $known[] = $val; |
1277 | 1277 | } |
1278 | 1278 | } |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | * @return bool|mixed |
1287 | 1287 | */ |
1288 | 1288 | private function getConnection() { |
1289 | - if(!is_null($this->cr)) { |
|
1289 | + if (!is_null($this->cr)) { |
|
1290 | 1290 | return $this->cr; |
1291 | 1291 | } |
1292 | 1292 | |
@@ -1298,14 +1298,14 @@ discard block |
||
1298 | 1298 | $this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3); |
1299 | 1299 | $this->ldap->setOption($cr, LDAP_OPT_REFERRALS, 0); |
1300 | 1300 | $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); |
1301 | - if($this->configuration->ldapTLS === 1) { |
|
1301 | + if ($this->configuration->ldapTLS === 1) { |
|
1302 | 1302 | $this->ldap->startTls($cr); |
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | $lo = @$this->ldap->bind($cr, |
1306 | 1306 | $this->configuration->ldapAgentName, |
1307 | 1307 | $this->configuration->ldapAgentPassword); |
1308 | - if($lo === true) { |
|
1308 | + if ($lo === true) { |
|
1309 | 1309 | $this->$cr = $cr; |
1310 | 1310 | return $cr; |
1311 | 1311 | } |
@@ -1336,18 +1336,18 @@ discard block |
||
1336 | 1336 | //636 ← LDAPS / SSL |
1337 | 1337 | //7xxx ← UCS. need to be checked first, because both ports may be open |
1338 | 1338 | $host = $this->configuration->ldapHost; |
1339 | - $port = (int)$this->configuration->ldapPort; |
|
1339 | + $port = (int) $this->configuration->ldapPort; |
|
1340 | 1340 | $portSettings = array(); |
1341 | 1341 | |
1342 | 1342 | //In case the port is already provided, we will check this first |
1343 | - if($port > 0) { |
|
1343 | + if ($port > 0) { |
|
1344 | 1344 | $hostInfo = parse_url($host); |
1345 | - if(!(is_array($hostInfo) |
|
1345 | + if (!(is_array($hostInfo) |
|
1346 | 1346 | && isset($hostInfo['scheme']) |
1347 | 1347 | && stripos($hostInfo['scheme'], 'ldaps') !== false)) { |
1348 | 1348 | $portSettings[] = array('port' => $port, 'tls' => true); |
1349 | 1349 | } |
1350 | - $portSettings[] =array('port' => $port, 'tls' => false); |
|
1350 | + $portSettings[] = array('port' => $port, 'tls' => false); |
|
1351 | 1351 | } |
1352 | 1352 | |
1353 | 1353 | //default ports |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | $user = $this->access->userManager->get($uid); |
105 | - if(!$user instanceof User) { |
|
105 | + if (!$user instanceof User) { |
|
106 | 106 | return false; |
107 | 107 | } |
108 | - if($user->getAvatarImage() === false) { |
|
108 | + if ($user->getAvatarImage() === false) { |
|
109 | 109 | return true; |
110 | 110 | } |
111 | 111 | |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | public function loginName2UserName($loginName) { |
122 | 122 | $cacheKey = 'loginName2UserName-'.$loginName; |
123 | 123 | $username = $this->access->connection->getFromCache($cacheKey); |
124 | - if(!is_null($username)) { |
|
124 | + if (!is_null($username)) { |
|
125 | 125 | return $username; |
126 | 126 | } |
127 | 127 | |
128 | 128 | try { |
129 | 129 | $ldapRecord = $this->getLDAPUserByLoginName($loginName); |
130 | 130 | $user = $this->access->userManager->get($ldapRecord['dn'][0]); |
131 | - if($user instanceof OfflineUser) { |
|
131 | + if ($user instanceof OfflineUser) { |
|
132 | 132 | // this path is not really possible, however get() is documented |
133 | 133 | // to return User or OfflineUser so we are very defensive here. |
134 | 134 | $this->access->connection->writeToCache($cacheKey, false); |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | //find out dn of the user name |
165 | 165 | $attrs = $this->access->userManager->getAttributes(); |
166 | 166 | $users = $this->access->fetchUsersByLoginName($loginName, $attrs); |
167 | - if(count($users) < 1) { |
|
168 | - throw new NotOnLDAP('No user available for the given login name on ' . |
|
169 | - $this->access->connection->ldapHost . ':' . $this->access->connection->ldapPort); |
|
167 | + if (count($users) < 1) { |
|
168 | + throw new NotOnLDAP('No user available for the given login name on '. |
|
169 | + $this->access->connection->ldapHost.':'.$this->access->connection->ldapPort); |
|
170 | 170 | } |
171 | 171 | return $users[0]; |
172 | 172 | } |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | public function checkPassword($uid, $password) { |
182 | 182 | try { |
183 | 183 | $ldapRecord = $this->getLDAPUserByLoginName($uid); |
184 | - } catch(NotOnLDAP $e) { |
|
185 | - if($this->ocConfig->getSystemValue('loglevel', ILogger::WARN) === ILogger::DEBUG) { |
|
184 | + } catch (NotOnLDAP $e) { |
|
185 | + if ($this->ocConfig->getSystemValue('loglevel', ILogger::WARN) === ILogger::DEBUG) { |
|
186 | 186 | \OC::$server->getLogger()->logException($e, ['app' => 'user_ldap']); |
187 | 187 | } |
188 | 188 | return false; |
@@ -190,16 +190,16 @@ discard block |
||
190 | 190 | $dn = $ldapRecord['dn'][0]; |
191 | 191 | $user = $this->access->userManager->get($dn); |
192 | 192 | |
193 | - if(!$user instanceof User) { |
|
193 | + if (!$user instanceof User) { |
|
194 | 194 | Util::writeLog('user_ldap', |
195 | - 'LDAP Login: Could not get user object for DN ' . $dn . |
|
195 | + 'LDAP Login: Could not get user object for DN '.$dn. |
|
196 | 196 | '. Maybe the LDAP entry has no set display name attribute?', |
197 | 197 | ILogger::WARN); |
198 | 198 | return false; |
199 | 199 | } |
200 | - if($user->getUsername() !== false) { |
|
200 | + if ($user->getUsername() !== false) { |
|
201 | 201 | //are the credentials OK? |
202 | - if(!$this->access->areCredentialsValid($dn, $password)) { |
|
202 | + if (!$this->access->areCredentialsValid($dn, $password)) { |
|
203 | 203 | return false; |
204 | 204 | } |
205 | 205 | |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | |
227 | 227 | $user = $this->access->userManager->get($uid); |
228 | 228 | |
229 | - if(!$user instanceof User) { |
|
230 | - throw new \Exception('LDAP setPassword: Could not get user object for uid ' . $uid . |
|
229 | + if (!$user instanceof User) { |
|
230 | + throw new \Exception('LDAP setPassword: Could not get user object for uid '.$uid. |
|
231 | 231 | '. Maybe the LDAP entry has no set display name attribute?'); |
232 | 232 | } |
233 | - if($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) { |
|
233 | + if ($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) { |
|
234 | 234 | $ldapDefaultPPolicyDN = $this->access->connection->ldapDefaultPPolicyDN; |
235 | 235 | $turnOnPasswordChange = $this->access->connection->turnOnPasswordChange; |
236 | - if (!empty($ldapDefaultPPolicyDN) && ((int)$turnOnPasswordChange === 1)) { |
|
236 | + if (!empty($ldapDefaultPPolicyDN) && ((int) $turnOnPasswordChange === 1)) { |
|
237 | 237 | //remove last password expiry warning if any |
238 | 238 | $notification = $this->notificationManager->createNotification(); |
239 | 239 | $notification->setApp('user_ldap') |
@@ -262,18 +262,18 @@ discard block |
||
262 | 262 | |
263 | 263 | //check if users are cached, if so return |
264 | 264 | $ldap_users = $this->access->connection->getFromCache($cachekey); |
265 | - if(!is_null($ldap_users)) { |
|
265 | + if (!is_null($ldap_users)) { |
|
266 | 266 | return $ldap_users; |
267 | 267 | } |
268 | 268 | |
269 | 269 | // if we'd pass -1 to LDAP search, we'd end up in a Protocol |
270 | 270 | // error. With a limit of 0, we get 0 results. So we pass null. |
271 | - if($limit <= 0) { |
|
271 | + if ($limit <= 0) { |
|
272 | 272 | $limit = null; |
273 | 273 | } |
274 | 274 | $filter = $this->access->combineFilterWithAnd(array( |
275 | 275 | $this->access->connection->ldapUserFilter, |
276 | - $this->access->connection->ldapUserDisplayName . '=*', |
|
276 | + $this->access->connection->ldapUserDisplayName.'=*', |
|
277 | 277 | $this->access->getFilterPartForUserSearch($search) |
278 | 278 | )); |
279 | 279 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $this->access->userManager->getAttributes(true), |
287 | 287 | $limit, $offset); |
288 | 288 | $ldap_users = $this->access->nextcloudUserNames($ldap_users); |
289 | - Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', ILogger::DEBUG); |
|
289 | + Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users).' Users found', ILogger::DEBUG); |
|
290 | 290 | |
291 | 291 | $this->access->connection->writeToCache($cachekey, $ldap_users); |
292 | 292 | return $ldap_users; |
@@ -302,19 +302,19 @@ discard block |
||
302 | 302 | * @throws \OC\ServerNotAvailableException |
303 | 303 | */ |
304 | 304 | public function userExistsOnLDAP($user) { |
305 | - if(is_string($user)) { |
|
305 | + if (is_string($user)) { |
|
306 | 306 | $user = $this->access->userManager->get($user); |
307 | 307 | } |
308 | - if(is_null($user)) { |
|
308 | + if (is_null($user)) { |
|
309 | 309 | return false; |
310 | 310 | } |
311 | 311 | |
312 | 312 | $dn = $user->getDN(); |
313 | 313 | //check if user really still exists by reading its entry |
314 | - if(!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) { |
|
314 | + if (!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) { |
|
315 | 315 | $lcr = $this->access->connection->getConnectionResource(); |
316 | - if(is_null($lcr)) { |
|
317 | - throw new \Exception('No LDAP Connection to server ' . $this->access->connection->ldapHost); |
|
316 | + if (is_null($lcr)) { |
|
317 | + throw new \Exception('No LDAP Connection to server '.$this->access->connection->ldapHost); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | try { |
@@ -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, ILogger::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; |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | |
371 | 371 | $result = $this->userExistsOnLDAP($user); |
372 | 372 | $this->access->connection->writeToCache('userExists'.$uid, $result); |
373 | - if($result === true) { |
|
373 | + if ($result === true) { |
|
374 | 374 | $user->update(); |
375 | 375 | } |
376 | 376 | return $result; |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | $marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0); |
391 | - if((int)$marked === 0) { |
|
391 | + if ((int) $marked === 0) { |
|
392 | 392 | \OC::$server->getLogger()->notice( |
393 | - 'User '.$uid . ' is not marked as deleted, not cleaning up.', |
|
393 | + 'User '.$uid.' is not marked as deleted, not cleaning up.', |
|
394 | 394 | array('app' => 'user_ldap')); |
395 | 395 | return false; |
396 | 396 | } |
397 | - \OC::$server->getLogger()->info('Cleaning up after user ' . $uid, |
|
397 | + \OC::$server->getLogger()->info('Cleaning up after user '.$uid, |
|
398 | 398 | array('app' => 'user_ldap')); |
399 | 399 | |
400 | 400 | $this->access->getUserMapper()->unmap($uid); // we don't emit unassign signals here, since it is implicit to delete signals fired from core |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function getHome($uid) { |
414 | 414 | // user Exists check required as it is not done in user proxy! |
415 | - if(!$this->userExists($uid)) { |
|
415 | + if (!$this->userExists($uid)) { |
|
416 | 416 | return false; |
417 | 417 | } |
418 | 418 | |
@@ -422,22 +422,22 @@ discard block |
||
422 | 422 | |
423 | 423 | $cacheKey = 'getHome'.$uid; |
424 | 424 | $path = $this->access->connection->getFromCache($cacheKey); |
425 | - if(!is_null($path)) { |
|
425 | + if (!is_null($path)) { |
|
426 | 426 | return $path; |
427 | 427 | } |
428 | 428 | |
429 | 429 | // early return path if it is a deleted user |
430 | 430 | $user = $this->access->userManager->get($uid); |
431 | - if($user instanceof OfflineUser) { |
|
432 | - if($this->currentUserInDeletionProcess !== null |
|
431 | + if ($user instanceof OfflineUser) { |
|
432 | + if ($this->currentUserInDeletionProcess !== null |
|
433 | 433 | && $this->currentUserInDeletionProcess === $user->getOCName() |
434 | 434 | ) { |
435 | 435 | return $user->getHomePath(); |
436 | 436 | } else { |
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 | } else if ($user === null) { |
440 | - throw new NoUserException($uid . ' is not a valid user anymore'); |
|
440 | + throw new NoUserException($uid.' is not a valid user anymore'); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | $path = $user->getHomePath(); |
@@ -456,12 +456,12 @@ discard block |
||
456 | 456 | return $this->userPluginManager->getDisplayName($uid); |
457 | 457 | } |
458 | 458 | |
459 | - if(!$this->userExists($uid)) { |
|
459 | + if (!$this->userExists($uid)) { |
|
460 | 460 | return false; |
461 | 461 | } |
462 | 462 | |
463 | 463 | $cacheKey = 'getDisplayName'.$uid; |
464 | - if(!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
|
464 | + if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
|
465 | 465 | return $displayName; |
466 | 466 | } |
467 | 467 | |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | $this->access->username2dn($uid), |
479 | 479 | $this->access->connection->ldapUserDisplayName); |
480 | 480 | |
481 | - if($displayName && (count($displayName) > 0)) { |
|
481 | + if ($displayName && (count($displayName) > 0)) { |
|
482 | 482 | $displayName = $displayName[0]; |
483 | 483 | |
484 | - if (is_array($displayName2)){ |
|
484 | + if (is_array($displayName2)) { |
|
485 | 485 | $displayName2 = count($displayName2) > 0 ? $displayName2[0] : ''; |
486 | 486 | } |
487 | 487 | |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | */ |
524 | 524 | public function getDisplayNames($search = '', $limit = null, $offset = null) { |
525 | 525 | $cacheKey = 'getDisplayNames-'.$search.'-'.$limit.'-'.$offset; |
526 | - if(!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) { |
|
526 | + if (!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) { |
|
527 | 527 | return $displayNames; |
528 | 528 | } |
529 | 529 | |
@@ -545,12 +545,12 @@ discard block |
||
545 | 545 | * compared with \OC\User\Backend::CREATE_USER etc. |
546 | 546 | */ |
547 | 547 | public function implementsActions($actions) { |
548 | - return (bool)((Backend::CHECK_PASSWORD |
|
548 | + return (bool) ((Backend::CHECK_PASSWORD |
|
549 | 549 | | Backend::GET_HOME |
550 | 550 | | Backend::GET_DISPLAYNAME |
551 | 551 | | Backend::PROVIDE_AVATAR |
552 | 552 | | Backend::COUNT_USERS |
553 | - | (((int)$this->access->connection->turnOnPasswordChange === 1)? Backend::SET_PASSWORD :0) |
|
553 | + | (((int) $this->access->connection->turnOnPasswordChange === 1) ? Backend::SET_PASSWORD : 0) |
|
554 | 554 | | $this->userPluginManager->getImplementedActions()) |
555 | 555 | & $actions); |
556 | 556 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | |
575 | 575 | $filter = $this->access->getFilterForUserCount(); |
576 | 576 | $cacheKey = 'countUsers-'.$filter; |
577 | - if(!is_null($entries = $this->access->connection->getFromCache($cacheKey))) { |
|
577 | + if (!is_null($entries = $this->access->connection->getFromCache($cacheKey))) { |
|
578 | 578 | return $entries; |
579 | 579 | } |
580 | 580 | $entries = $this->access->countUsers($filter); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | * Backend name to be shown in user management |
587 | 587 | * @return string the name of the backend to be shown |
588 | 588 | */ |
589 | - public function getBackendName(){ |
|
589 | + public function getBackendName() { |
|
590 | 590 | return 'LDAP'; |
591 | 591 | } |
592 | 592 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | parent::__construct($access); |
66 | 66 | $filter = $this->access->connection->ldapGroupFilter; |
67 | 67 | $gassoc = $this->access->connection->ldapGroupMemberAssocAttr; |
68 | - if(!empty($filter) && !empty($gassoc)) { |
|
68 | + if (!empty($filter) && !empty($gassoc)) { |
|
69 | 69 | $this->enabled = true; |
70 | 70 | } |
71 | 71 | |
@@ -83,25 +83,25 @@ discard block |
||
83 | 83 | * Checks whether the user is member of a group or not. |
84 | 84 | */ |
85 | 85 | public function inGroup($uid, $gid) { |
86 | - if(!$this->enabled) { |
|
86 | + if (!$this->enabled) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | $cacheKey = 'inGroup'.$uid.':'.$gid; |
90 | 90 | $inGroup = $this->access->connection->getFromCache($cacheKey); |
91 | - if(!is_null($inGroup)) { |
|
92 | - return (bool)$inGroup; |
|
91 | + if (!is_null($inGroup)) { |
|
92 | + return (bool) $inGroup; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $userDN = $this->access->username2dn($uid); |
96 | 96 | |
97 | - if(isset($this->cachedGroupMembers[$gid])) { |
|
97 | + if (isset($this->cachedGroupMembers[$gid])) { |
|
98 | 98 | $isInGroup = in_array($userDN, $this->cachedGroupMembers[$gid]); |
99 | 99 | return $isInGroup; |
100 | 100 | } |
101 | 101 | |
102 | 102 | $cacheKeyMembers = 'inGroup-members:'.$gid; |
103 | 103 | $members = $this->access->connection->getFromCache($cacheKeyMembers); |
104 | - if(!is_null($members)) { |
|
104 | + if (!is_null($members)) { |
|
105 | 105 | $this->cachedGroupMembers[$gid] = $members; |
106 | 106 | $isInGroup = in_array($userDN, $members); |
107 | 107 | $this->access->connection->writeToCache($cacheKey, $isInGroup); |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | |
111 | 111 | $groupDN = $this->access->groupname2dn($gid); |
112 | 112 | // just in case |
113 | - if(!$groupDN || !$userDN) { |
|
113 | + if (!$groupDN || !$userDN) { |
|
114 | 114 | $this->access->connection->writeToCache($cacheKey, false); |
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | |
118 | 118 | //check primary group first |
119 | - if($gid === $this->getUserPrimaryGroup($userDN)) { |
|
119 | + if ($gid === $this->getUserPrimaryGroup($userDN)) { |
|
120 | 120 | $this->access->connection->writeToCache($cacheKey, true); |
121 | 121 | return true; |
122 | 122 | } |
@@ -124,21 +124,21 @@ discard block |
||
124 | 124 | //usually, LDAP attributes are said to be case insensitive. But there are exceptions of course. |
125 | 125 | $members = $this->_groupMembers($groupDN); |
126 | 126 | $members = array_keys($members); // uids are returned as keys |
127 | - if(!is_array($members) || count($members) === 0) { |
|
127 | + if (!is_array($members) || count($members) === 0) { |
|
128 | 128 | $this->access->connection->writeToCache($cacheKey, false); |
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | 132 | //extra work if we don't get back user DNs |
133 | - if(strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid') { |
|
133 | + if (strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid') { |
|
134 | 134 | $dns = array(); |
135 | 135 | $filterParts = array(); |
136 | 136 | $bytes = 0; |
137 | - foreach($members as $mid) { |
|
137 | + foreach ($members as $mid) { |
|
138 | 138 | $filter = str_replace('%uid', $mid, $this->access->connection->ldapLoginFilter); |
139 | 139 | $filterParts[] = $filter; |
140 | 140 | $bytes += strlen($filter); |
141 | - if($bytes >= 9000000) { |
|
141 | + if ($bytes >= 9000000) { |
|
142 | 142 | // AD has a default input buffer of 10 MB, we do not want |
143 | 143 | // to take even the chance to exceed it |
144 | 144 | $filter = $this->access->combineFilterWithOr($filterParts); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $dns = array_merge($dns, $users); |
149 | 149 | } |
150 | 150 | } |
151 | - if(count($filterParts) > 0) { |
|
151 | + if (count($filterParts) > 0) { |
|
152 | 152 | $filter = $this->access->combineFilterWithOr($filterParts); |
153 | 153 | $users = $this->access->fetchListOfUsers($filter, 'dn', count($filterParts)); |
154 | 154 | $dns = array_merge($dns, $users); |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | $pos = strpos($memberURLs[0], '('); |
192 | 192 | if ($pos !== false) { |
193 | 193 | $memberUrlFilter = substr($memberURLs[0], $pos); |
194 | - $foundMembers = $this->access->searchUsers($memberUrlFilter,'dn'); |
|
194 | + $foundMembers = $this->access->searchUsers($memberUrlFilter, 'dn'); |
|
195 | 195 | $dynamicMembers = array(); |
196 | - foreach($foundMembers as $value) { |
|
196 | + foreach ($foundMembers as $value) { |
|
197 | 197 | $dynamicMembers[$value['dn'][0]] = 1; |
198 | 198 | } |
199 | 199 | } else { |
200 | 200 | \OCP\Util::writeLog('user_ldap', 'No search filter found on member url '. |
201 | - 'of group ' . $dnGroup, ILogger::DEBUG); |
|
201 | + 'of group '.$dnGroup, ILogger::DEBUG); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | return $dynamicMembers; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | // used extensively in cron job, caching makes sense for nested groups |
223 | 223 | $cacheKey = '_groupMembers'.$dnGroup; |
224 | 224 | $groupMembers = $this->access->connection->getFromCache($cacheKey); |
225 | - if($groupMembers !== null) { |
|
225 | + if ($groupMembers !== null) { |
|
226 | 226 | return $groupMembers; |
227 | 227 | } |
228 | 228 | $seen[$dnGroup] = 1; |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | return array(); |
267 | 267 | } |
268 | 268 | $groups = $this->access->groupsMatchFilter($groups); |
269 | - $allGroups = $groups; |
|
269 | + $allGroups = $groups; |
|
270 | 270 | $nestedGroups = $this->access->connection->ldapNestedGroups; |
271 | - if ((int)$nestedGroups === 1) { |
|
271 | + if ((int) $nestedGroups === 1) { |
|
272 | 272 | foreach ($groups as $group) { |
273 | 273 | $subGroups = $this->_getGroupDNsFromMemberOf($group, $seen); |
274 | 274 | $allGroups = array_merge($allGroups, $subGroups); |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | * @return string|bool |
285 | 285 | */ |
286 | 286 | public function gidNumber2Name($gid, $dn) { |
287 | - $cacheKey = 'gidNumberToName' . $gid; |
|
287 | + $cacheKey = 'gidNumberToName'.$gid; |
|
288 | 288 | $groupName = $this->access->connection->getFromCache($cacheKey); |
289 | - if(!is_null($groupName) && isset($groupName)) { |
|
289 | + if (!is_null($groupName) && isset($groupName)) { |
|
290 | 290 | return $groupName; |
291 | 291 | } |
292 | 292 | |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | $filter = $this->access->combineFilterWithAnd([ |
295 | 295 | $this->access->connection->ldapGroupFilter, |
296 | 296 | 'objectClass=posixGroup', |
297 | - $this->access->connection->ldapGidNumber . '=' . $gid |
|
297 | + $this->access->connection->ldapGidNumber.'='.$gid |
|
298 | 298 | ]); |
299 | 299 | $result = $this->access->searchGroups($filter, array('dn'), 1); |
300 | - if(empty($result)) { |
|
300 | + if (empty($result)) { |
|
301 | 301 | return false; |
302 | 302 | } |
303 | 303 | $dn = $result[0]['dn'][0]; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | private function getEntryGidNumber($dn, $attribute) { |
322 | 322 | $value = $this->access->readAttribute($dn, $attribute); |
323 | - if(is_array($value) && !empty($value)) { |
|
323 | + if (is_array($value) && !empty($value)) { |
|
324 | 324 | return $value[0]; |
325 | 325 | } |
326 | 326 | return false; |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | */ |
343 | 343 | public function getUserGidNumber($dn) { |
344 | 344 | $gidNumber = false; |
345 | - if($this->access->connection->hasGidNumber) { |
|
345 | + if ($this->access->connection->hasGidNumber) { |
|
346 | 346 | $gidNumber = $this->getEntryGidNumber($dn, $this->access->connection->ldapGidNumber); |
347 | - if($gidNumber === false) { |
|
347 | + if ($gidNumber === false) { |
|
348 | 348 | $this->access->connection->hasGidNumber = false; |
349 | 349 | } |
350 | 350 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | */ |
362 | 362 | private function prepareFilterForUsersHasGidNumber($groupDN, $search = '') { |
363 | 363 | $groupID = $this->getGroupGidNumber($groupDN); |
364 | - if($groupID === false) { |
|
364 | + if ($groupID === false) { |
|
365 | 365 | throw new \Exception('Not a valid group'); |
366 | 366 | } |
367 | 367 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | if ($search !== '') { |
371 | 371 | $filterParts[] = $this->access->getFilterPartForUserSearch($search); |
372 | 372 | } |
373 | - $filterParts[] = $this->access->connection->ldapGidNumber .'=' . $groupID; |
|
373 | + $filterParts[] = $this->access->connection->ldapGidNumber.'='.$groupID; |
|
374 | 374 | |
375 | 375 | return $this->access->combineFilterWithAnd($filterParts); |
376 | 376 | } |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | try { |
413 | 413 | $filter = $this->prepareFilterForUsersHasGidNumber($groupDN, $search); |
414 | 414 | $users = $this->access->countUsers($filter, ['dn'], $limit, $offset); |
415 | - return (int)$users; |
|
415 | + return (int) $users; |
|
416 | 416 | } catch (\Exception $e) { |
417 | 417 | return 0; |
418 | 418 | } |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | */ |
426 | 426 | public function getUserGroupByGid($dn) { |
427 | 427 | $groupID = $this->getUserGidNumber($dn); |
428 | - if($groupID !== false) { |
|
428 | + if ($groupID !== false) { |
|
429 | 429 | $groupName = $this->gidNumber2Name($groupID, $dn); |
430 | - if($groupName !== false) { |
|
430 | + if ($groupName !== false) { |
|
431 | 431 | return $groupName; |
432 | 432 | } |
433 | 433 | } |
@@ -444,22 +444,22 @@ discard block |
||
444 | 444 | public function primaryGroupID2Name($gid, $dn) { |
445 | 445 | $cacheKey = 'primaryGroupIDtoName'; |
446 | 446 | $groupNames = $this->access->connection->getFromCache($cacheKey); |
447 | - if(!is_null($groupNames) && isset($groupNames[$gid])) { |
|
447 | + if (!is_null($groupNames) && isset($groupNames[$gid])) { |
|
448 | 448 | return $groupNames[$gid]; |
449 | 449 | } |
450 | 450 | |
451 | 451 | $domainObjectSid = $this->access->getSID($dn); |
452 | - if($domainObjectSid === false) { |
|
452 | + if ($domainObjectSid === false) { |
|
453 | 453 | return false; |
454 | 454 | } |
455 | 455 | |
456 | 456 | //we need to get the DN from LDAP |
457 | 457 | $filter = $this->access->combineFilterWithAnd(array( |
458 | 458 | $this->access->connection->ldapGroupFilter, |
459 | - 'objectsid=' . $domainObjectSid . '-' . $gid |
|
459 | + 'objectsid='.$domainObjectSid.'-'.$gid |
|
460 | 460 | )); |
461 | 461 | $result = $this->access->searchGroups($filter, array('dn'), 1); |
462 | - if(empty($result)) { |
|
462 | + if (empty($result)) { |
|
463 | 463 | return false; |
464 | 464 | } |
465 | 465 | $dn = $result[0]['dn'][0]; |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | */ |
483 | 483 | private function getEntryGroupID($dn, $attribute) { |
484 | 484 | $value = $this->access->readAttribute($dn, $attribute); |
485 | - if(is_array($value) && !empty($value)) { |
|
485 | + if (is_array($value) && !empty($value)) { |
|
486 | 486 | return $value[0]; |
487 | 487 | } |
488 | 488 | return false; |
@@ -504,9 +504,9 @@ discard block |
||
504 | 504 | */ |
505 | 505 | public function getUserPrimaryGroupIDs($dn) { |
506 | 506 | $primaryGroupID = false; |
507 | - if($this->access->connection->hasPrimaryGroups) { |
|
507 | + if ($this->access->connection->hasPrimaryGroups) { |
|
508 | 508 | $primaryGroupID = $this->getEntryGroupID($dn, 'primaryGroupID'); |
509 | - if($primaryGroupID === false) { |
|
509 | + if ($primaryGroupID === false) { |
|
510 | 510 | $this->access->connection->hasPrimaryGroups = false; |
511 | 511 | } |
512 | 512 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | */ |
524 | 524 | private function prepareFilterForUsersInPrimaryGroup($groupDN, $search = '') { |
525 | 525 | $groupID = $this->getGroupPrimaryGroupID($groupDN); |
526 | - if($groupID === false) { |
|
526 | + if ($groupID === false) { |
|
527 | 527 | throw new \Exception('Not a valid group'); |
528 | 528 | } |
529 | 529 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | if ($search !== '') { |
533 | 533 | $filterParts[] = $this->access->getFilterPartForUserSearch($search); |
534 | 534 | } |
535 | - $filterParts[] = 'primaryGroupID=' . $groupID; |
|
535 | + $filterParts[] = 'primaryGroupID='.$groupID; |
|
536 | 536 | |
537 | 537 | return $this->access->combineFilterWithAnd($filterParts); |
538 | 538 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | try { |
575 | 575 | $filter = $this->prepareFilterForUsersInPrimaryGroup($groupDN, $search); |
576 | 576 | $users = $this->access->countUsers($filter, array('dn'), $limit, $offset); |
577 | - return (int)$users; |
|
577 | + return (int) $users; |
|
578 | 578 | } catch (\Exception $e) { |
579 | 579 | return 0; |
580 | 580 | } |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | */ |
588 | 588 | public function getUserPrimaryGroup($dn) { |
589 | 589 | $groupID = $this->getUserPrimaryGroupIDs($dn); |
590 | - if($groupID !== false) { |
|
590 | + if ($groupID !== false) { |
|
591 | 591 | $groupName = $this->primaryGroupID2Name($groupID, $dn); |
592 | - if($groupName !== false) { |
|
592 | + if ($groupName !== false) { |
|
593 | 593 | return $groupName; |
594 | 594 | } |
595 | 595 | } |
@@ -608,16 +608,16 @@ discard block |
||
608 | 608 | * This function includes groups based on dynamic group membership. |
609 | 609 | */ |
610 | 610 | public function getUserGroups($uid) { |
611 | - if(!$this->enabled) { |
|
611 | + if (!$this->enabled) { |
|
612 | 612 | return array(); |
613 | 613 | } |
614 | 614 | $cacheKey = 'getUserGroups'.$uid; |
615 | 615 | $userGroups = $this->access->connection->getFromCache($cacheKey); |
616 | - if(!is_null($userGroups)) { |
|
616 | + if (!is_null($userGroups)) { |
|
617 | 617 | return $userGroups; |
618 | 618 | } |
619 | 619 | $userDN = $this->access->username2dn($uid); |
620 | - if(!$userDN) { |
|
620 | + if (!$userDN) { |
|
621 | 621 | $this->access->connection->writeToCache($cacheKey, array()); |
622 | 622 | return array(); |
623 | 623 | } |
@@ -631,14 +631,14 @@ discard block |
||
631 | 631 | if (!empty($dynamicGroupMemberURL)) { |
632 | 632 | // look through dynamic groups to add them to the result array if needed |
633 | 633 | $groupsToMatch = $this->access->fetchListOfGroups( |
634 | - $this->access->connection->ldapGroupFilter,array('dn',$dynamicGroupMemberURL)); |
|
635 | - foreach($groupsToMatch as $dynamicGroup) { |
|
634 | + $this->access->connection->ldapGroupFilter, array('dn', $dynamicGroupMemberURL)); |
|
635 | + foreach ($groupsToMatch as $dynamicGroup) { |
|
636 | 636 | if (!array_key_exists($dynamicGroupMemberURL, $dynamicGroup)) { |
637 | 637 | continue; |
638 | 638 | } |
639 | 639 | $pos = strpos($dynamicGroup[$dynamicGroupMemberURL][0], '('); |
640 | 640 | if ($pos !== false) { |
641 | - $memberUrlFilter = substr($dynamicGroup[$dynamicGroupMemberURL][0],$pos); |
|
641 | + $memberUrlFilter = substr($dynamicGroup[$dynamicGroupMemberURL][0], $pos); |
|
642 | 642 | // apply filter via ldap search to see if this user is in this |
643 | 643 | // dynamic group |
644 | 644 | $userMatch = $this->access->readAttribute( |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | if ($userMatch !== false) { |
650 | 650 | // match found so this user is in this group |
651 | 651 | $groupName = $this->access->dn2groupname($dynamicGroup['dn'][0]); |
652 | - if(is_string($groupName)) { |
|
652 | + if (is_string($groupName)) { |
|
653 | 653 | // be sure to never return false if the dn could not be |
654 | 654 | // resolved to a name, for whatever reason. |
655 | 655 | $groups[] = $groupName; |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | } |
658 | 658 | } else { |
659 | 659 | \OCP\Util::writeLog('user_ldap', 'No search filter found on member url '. |
660 | - 'of group ' . print_r($dynamicGroup, true), ILogger::DEBUG); |
|
660 | + 'of group '.print_r($dynamicGroup, true), ILogger::DEBUG); |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | } |
@@ -665,15 +665,15 @@ discard block |
||
665 | 665 | // if possible, read out membership via memberOf. It's far faster than |
666 | 666 | // performing a search, which still is a fallback later. |
667 | 667 | // memberof doesn't support memberuid, so skip it here. |
668 | - if((int)$this->access->connection->hasMemberOfFilterSupport === 1 |
|
669 | - && (int)$this->access->connection->useMemberOfToDetectMembership === 1 |
|
668 | + if ((int) $this->access->connection->hasMemberOfFilterSupport === 1 |
|
669 | + && (int) $this->access->connection->useMemberOfToDetectMembership === 1 |
|
670 | 670 | && strtolower($this->access->connection->ldapGroupMemberAssocAttr) !== 'memberuid' |
671 | 671 | ) { |
672 | 672 | $groupDNs = $this->_getGroupDNsFromMemberOf($userDN); |
673 | 673 | if (is_array($groupDNs)) { |
674 | 674 | foreach ($groupDNs as $dn) { |
675 | 675 | $groupName = $this->access->dn2groupname($dn); |
676 | - if(is_string($groupName)) { |
|
676 | + if (is_string($groupName)) { |
|
677 | 677 | // be sure to never return false if the dn could not be |
678 | 678 | // resolved to a name, for whatever reason. |
679 | 679 | $groups[] = $groupName; |
@@ -681,10 +681,10 @@ discard block |
||
681 | 681 | } |
682 | 682 | } |
683 | 683 | |
684 | - if($primaryGroup !== false) { |
|
684 | + if ($primaryGroup !== false) { |
|
685 | 685 | $groups[] = $primaryGroup; |
686 | 686 | } |
687 | - if($gidGroupName !== false) { |
|
687 | + if ($gidGroupName !== false) { |
|
688 | 688 | $groups[] = $gidGroupName; |
689 | 689 | } |
690 | 690 | $this->access->connection->writeToCache($cacheKey, $groups); |
@@ -692,14 +692,14 @@ discard block |
||
692 | 692 | } |
693 | 693 | |
694 | 694 | //uniqueMember takes DN, memberuid the uid, so we need to distinguish |
695 | - if((strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'uniquemember') |
|
695 | + if ((strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'uniquemember') |
|
696 | 696 | || (strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'member') |
697 | 697 | ) { |
698 | 698 | $uid = $userDN; |
699 | - } else if(strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid') { |
|
699 | + } else if (strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid') { |
|
700 | 700 | $result = $this->access->readAttribute($userDN, 'uid'); |
701 | 701 | if ($result === false) { |
702 | - \OCP\Util::writeLog('user_ldap', 'No uid attribute found for DN ' . $userDN . ' on '. |
|
702 | + \OCP\Util::writeLog('user_ldap', 'No uid attribute found for DN '.$userDN.' on '. |
|
703 | 703 | $this->access->connection->ldapHost, ILogger::DEBUG); |
704 | 704 | } |
705 | 705 | $uid = $result[0]; |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | $uid = $userDN; |
709 | 709 | } |
710 | 710 | |
711 | - if(isset($this->cachedGroupsByMember[$uid])) { |
|
711 | + if (isset($this->cachedGroupsByMember[$uid])) { |
|
712 | 712 | $groups = array_merge($groups, $this->cachedGroupsByMember[$uid]); |
713 | 713 | } else { |
714 | 714 | $groupsByMember = array_values($this->getGroupsByMember($uid)); |
@@ -717,10 +717,10 @@ discard block |
||
717 | 717 | $groups = array_merge($groups, $groupsByMember); |
718 | 718 | } |
719 | 719 | |
720 | - if($primaryGroup !== false) { |
|
720 | + if ($primaryGroup !== false) { |
|
721 | 721 | $groups[] = $primaryGroup; |
722 | 722 | } |
723 | - if($gidGroupName !== false) { |
|
723 | + if ($gidGroupName !== false) { |
|
724 | 724 | $groups[] = $gidGroupName; |
725 | 725 | } |
726 | 726 | |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | $nestedGroups = $this->access->connection->ldapNestedGroups; |
759 | 759 | if (!empty($nestedGroups)) { |
760 | 760 | $supergroups = $this->getGroupsByMember($groupDN, $seen); |
761 | - if (is_array($supergroups) && (count($supergroups)>0)) { |
|
761 | + if (is_array($supergroups) && (count($supergroups) > 0)) { |
|
762 | 762 | $allGroups = array_merge($allGroups, $supergroups); |
763 | 763 | } |
764 | 764 | } |
@@ -777,33 +777,33 @@ discard block |
||
777 | 777 | * @return array with user ids |
778 | 778 | */ |
779 | 779 | public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { |
780 | - if(!$this->enabled) { |
|
780 | + if (!$this->enabled) { |
|
781 | 781 | return array(); |
782 | 782 | } |
783 | - if(!$this->groupExists($gid)) { |
|
783 | + if (!$this->groupExists($gid)) { |
|
784 | 784 | return array(); |
785 | 785 | } |
786 | 786 | $search = $this->access->escapeFilterPart($search, true); |
787 | 787 | $cacheKey = 'usersInGroup-'.$gid.'-'.$search.'-'.$limit.'-'.$offset; |
788 | 788 | // check for cache of the exact query |
789 | 789 | $groupUsers = $this->access->connection->getFromCache($cacheKey); |
790 | - if(!is_null($groupUsers)) { |
|
790 | + if (!is_null($groupUsers)) { |
|
791 | 791 | return $groupUsers; |
792 | 792 | } |
793 | 793 | |
794 | 794 | // check for cache of the query without limit and offset |
795 | 795 | $groupUsers = $this->access->connection->getFromCache('usersInGroup-'.$gid.'-'.$search); |
796 | - if(!is_null($groupUsers)) { |
|
796 | + if (!is_null($groupUsers)) { |
|
797 | 797 | $groupUsers = array_slice($groupUsers, $offset, $limit); |
798 | 798 | $this->access->connection->writeToCache($cacheKey, $groupUsers); |
799 | 799 | return $groupUsers; |
800 | 800 | } |
801 | 801 | |
802 | - if($limit === -1) { |
|
802 | + if ($limit === -1) { |
|
803 | 803 | $limit = null; |
804 | 804 | } |
805 | 805 | $groupDN = $this->access->groupname2dn($gid); |
806 | - if(!$groupDN) { |
|
806 | + if (!$groupDN) { |
|
807 | 807 | // group couldn't be found, return empty resultset |
808 | 808 | $this->access->connection->writeToCache($cacheKey, array()); |
809 | 809 | return array(); |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | $primaryUsers = $this->getUsersInPrimaryGroup($groupDN, $search, $limit, $offset); |
813 | 813 | $posixGroupUsers = $this->getUsersInGidNumber($groupDN, $search, $limit, $offset); |
814 | 814 | $members = array_keys($this->_groupMembers($groupDN)); |
815 | - if(!$members && empty($posixGroupUsers) && empty($primaryUsers)) { |
|
815 | + if (!$members && empty($posixGroupUsers) && empty($primaryUsers)) { |
|
816 | 816 | //in case users could not be retrieved, return empty result set |
817 | 817 | $this->access->connection->writeToCache($cacheKey, []); |
818 | 818 | return []; |
@@ -821,29 +821,29 @@ discard block |
||
821 | 821 | $groupUsers = array(); |
822 | 822 | $isMemberUid = (strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid'); |
823 | 823 | $attrs = $this->access->userManager->getAttributes(true); |
824 | - foreach($members as $member) { |
|
825 | - if($isMemberUid) { |
|
824 | + foreach ($members as $member) { |
|
825 | + if ($isMemberUid) { |
|
826 | 826 | //we got uids, need to get their DNs to 'translate' them to user names |
827 | 827 | $filter = $this->access->combineFilterWithAnd(array( |
828 | 828 | str_replace('%uid', $member, $this->access->connection->ldapLoginFilter), |
829 | 829 | $this->access->getFilterPartForUserSearch($search) |
830 | 830 | )); |
831 | 831 | $ldap_users = $this->access->fetchListOfUsers($filter, $attrs, 1); |
832 | - if(count($ldap_users) < 1) { |
|
832 | + if (count($ldap_users) < 1) { |
|
833 | 833 | continue; |
834 | 834 | } |
835 | 835 | $groupUsers[] = $this->access->dn2username($ldap_users[0]['dn'][0]); |
836 | 836 | } else { |
837 | 837 | //we got DNs, check if we need to filter by search or we can give back all of them |
838 | 838 | if ($search !== '') { |
839 | - if(!$this->access->readAttribute($member, |
|
839 | + if (!$this->access->readAttribute($member, |
|
840 | 840 | $this->access->connection->ldapUserDisplayName, |
841 | 841 | $this->access->getFilterPartForUserSearch($search))) { |
842 | 842 | continue; |
843 | 843 | } |
844 | 844 | } |
845 | 845 | // dn2username will also check if the users belong to the allowed base |
846 | - if($ocname = $this->access->dn2username($member)) { |
|
846 | + if ($ocname = $this->access->dn2username($member)) { |
|
847 | 847 | $groupUsers[] = $ocname; |
848 | 848 | } |
849 | 849 | } |
@@ -871,16 +871,16 @@ discard block |
||
871 | 871 | } |
872 | 872 | |
873 | 873 | $cacheKey = 'countUsersInGroup-'.$gid.'-'.$search; |
874 | - if(!$this->enabled || !$this->groupExists($gid)) { |
|
874 | + if (!$this->enabled || !$this->groupExists($gid)) { |
|
875 | 875 | return false; |
876 | 876 | } |
877 | 877 | $groupUsers = $this->access->connection->getFromCache($cacheKey); |
878 | - if(!is_null($groupUsers)) { |
|
878 | + if (!is_null($groupUsers)) { |
|
879 | 879 | return $groupUsers; |
880 | 880 | } |
881 | 881 | |
882 | 882 | $groupDN = $this->access->groupname2dn($gid); |
883 | - if(!$groupDN) { |
|
883 | + if (!$groupDN) { |
|
884 | 884 | // group couldn't be found, return empty result set |
885 | 885 | $this->access->connection->writeToCache($cacheKey, false); |
886 | 886 | return false; |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | |
889 | 889 | $members = array_keys($this->_groupMembers($groupDN)); |
890 | 890 | $primaryUserCount = $this->countUsersInPrimaryGroup($groupDN, ''); |
891 | - if(!$members && $primaryUserCount === 0) { |
|
891 | + if (!$members && $primaryUserCount === 0) { |
|
892 | 892 | //in case users could not be retrieved, return empty result set |
893 | 893 | $this->access->connection->writeToCache($cacheKey, false); |
894 | 894 | return false; |
@@ -913,27 +913,27 @@ discard block |
||
913 | 913 | //For now this is not important, because the only use of this method |
914 | 914 | //does not supply a search string |
915 | 915 | $groupUsers = array(); |
916 | - foreach($members as $member) { |
|
917 | - if($isMemberUid) { |
|
916 | + foreach ($members as $member) { |
|
917 | + if ($isMemberUid) { |
|
918 | 918 | //we got uids, need to get their DNs to 'translate' them to user names |
919 | 919 | $filter = $this->access->combineFilterWithAnd(array( |
920 | 920 | str_replace('%uid', $member, $this->access->connection->ldapLoginFilter), |
921 | 921 | $this->access->getFilterPartForUserSearch($search) |
922 | 922 | )); |
923 | 923 | $ldap_users = $this->access->fetchListOfUsers($filter, 'dn', 1); |
924 | - if(count($ldap_users) < 1) { |
|
924 | + if (count($ldap_users) < 1) { |
|
925 | 925 | continue; |
926 | 926 | } |
927 | 927 | $groupUsers[] = $this->access->dn2username($ldap_users[0]); |
928 | 928 | } else { |
929 | 929 | //we need to apply the search filter now |
930 | - if(!$this->access->readAttribute($member, |
|
930 | + if (!$this->access->readAttribute($member, |
|
931 | 931 | $this->access->connection->ldapUserDisplayName, |
932 | 932 | $this->access->getFilterPartForUserSearch($search))) { |
933 | 933 | continue; |
934 | 934 | } |
935 | 935 | // dn2username will also check if the users belong to the allowed base |
936 | - if($ocname = $this->access->dn2username($member)) { |
|
936 | + if ($ocname = $this->access->dn2username($member)) { |
|
937 | 937 | $groupUsers[] = $ocname; |
938 | 938 | } |
939 | 939 | } |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | * Returns a list with all groups (used by getGroups) |
957 | 957 | */ |
958 | 958 | protected function getGroupsChunk($search = '', $limit = -1, $offset = 0) { |
959 | - if(!$this->enabled) { |
|
959 | + if (!$this->enabled) { |
|
960 | 960 | return array(); |
961 | 961 | } |
962 | 962 | $cacheKey = 'getGroups-'.$search.'-'.$limit.'-'.$offset; |
@@ -964,13 +964,13 @@ discard block |
||
964 | 964 | //Check cache before driving unnecessary searches |
965 | 965 | \OCP\Util::writeLog('user_ldap', 'getGroups '.$cacheKey, ILogger::DEBUG); |
966 | 966 | $ldap_groups = $this->access->connection->getFromCache($cacheKey); |
967 | - if(!is_null($ldap_groups)) { |
|
967 | + if (!is_null($ldap_groups)) { |
|
968 | 968 | return $ldap_groups; |
969 | 969 | } |
970 | 970 | |
971 | 971 | // if we'd pass -1 to LDAP search, we'd end up in a Protocol |
972 | 972 | // error. With a limit of 0, we get 0 results. So we pass null. |
973 | - if($limit <= 0) { |
|
973 | + if ($limit <= 0) { |
|
974 | 974 | $limit = null; |
975 | 975 | } |
976 | 976 | $filter = $this->access->combineFilterWithAnd(array( |
@@ -1002,11 +1002,11 @@ discard block |
||
1002 | 1002 | * (active directory has a limit of 1000 by default) |
1003 | 1003 | */ |
1004 | 1004 | public function getGroups($search = '', $limit = -1, $offset = 0) { |
1005 | - if(!$this->enabled) { |
|
1005 | + if (!$this->enabled) { |
|
1006 | 1006 | return array(); |
1007 | 1007 | } |
1008 | 1008 | $search = $this->access->escapeFilterPart($search, true); |
1009 | - $pagingSize = (int)$this->access->connection->ldapPagingSize; |
|
1009 | + $pagingSize = (int) $this->access->connection->ldapPagingSize; |
|
1010 | 1010 | if (!$this->access->connection->hasPagedResultSupport || $pagingSize <= 0) { |
1011 | 1011 | return $this->getGroupsChunk($search, $limit, $offset); |
1012 | 1012 | } |
@@ -1049,20 +1049,20 @@ discard block |
||
1049 | 1049 | */ |
1050 | 1050 | public function groupExists($gid) { |
1051 | 1051 | $groupExists = $this->access->connection->getFromCache('groupExists'.$gid); |
1052 | - if(!is_null($groupExists)) { |
|
1053 | - return (bool)$groupExists; |
|
1052 | + if (!is_null($groupExists)) { |
|
1053 | + return (bool) $groupExists; |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | //getting dn, if false the group does not exist. If dn, it may be mapped |
1057 | 1057 | //only, requires more checking. |
1058 | 1058 | $dn = $this->access->groupname2dn($gid); |
1059 | - if(!$dn) { |
|
1059 | + if (!$dn) { |
|
1060 | 1060 | $this->access->connection->writeToCache('groupExists'.$gid, false); |
1061 | 1061 | return false; |
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | //if group really still exists, we will be able to read its objectclass |
1065 | - if(!is_array($this->access->readAttribute($dn, ''))) { |
|
1065 | + if (!is_array($this->access->readAttribute($dn, ''))) { |
|
1066 | 1066 | $this->access->connection->writeToCache('groupExists'.$gid, false); |
1067 | 1067 | return false; |
1068 | 1068 | } |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | * compared with GroupInterface::CREATE_GROUP etc. |
1081 | 1081 | */ |
1082 | 1082 | public function implementsActions($actions) { |
1083 | - return (bool)((GroupInterface::COUNT_USERS | |
|
1083 | + return (bool) ((GroupInterface::COUNT_USERS | |
|
1084 | 1084 | $this->groupPluginManager->getImplementedActions()) & $actions); |
1085 | 1085 | } |
1086 | 1086 |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return AbstractMapping |
132 | 132 | */ |
133 | 133 | public function getUserMapper() { |
134 | - if(is_null($this->userMapper)) { |
|
134 | + if (is_null($this->userMapper)) { |
|
135 | 135 | throw new \Exception('UserMapper was not assigned to this Access instance.'); |
136 | 136 | } |
137 | 137 | return $this->userMapper; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @return AbstractMapping |
152 | 152 | */ |
153 | 153 | public function getGroupMapper() { |
154 | - if(is_null($this->groupMapper)) { |
|
154 | + if (is_null($this->groupMapper)) { |
|
155 | 155 | throw new \Exception('GroupMapper was not assigned to this Access instance.'); |
156 | 156 | } |
157 | 157 | return $this->groupMapper; |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | * @throws ServerNotAvailableException |
185 | 185 | */ |
186 | 186 | public function readAttribute($dn, $attr, $filter = 'objectClass=*') { |
187 | - if(!$this->checkConnection()) { |
|
187 | + if (!$this->checkConnection()) { |
|
188 | 188 | \OCP\Util::writeLog('user_ldap', |
189 | 189 | 'No LDAP Connector assigned, access impossible for readAttribute.', |
190 | 190 | ILogger::WARN); |
191 | 191 | return false; |
192 | 192 | } |
193 | 193 | $cr = $this->connection->getConnectionResource(); |
194 | - if(!$this->ldap->isResource($cr)) { |
|
194 | + if (!$this->ldap->isResource($cr)) { |
|
195 | 195 | //LDAP not available |
196 | 196 | \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', ILogger::DEBUG); |
197 | 197 | return false; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $this->abandonPagedSearch(); |
202 | 202 | // openLDAP requires that we init a new Paged Search. Not needed by AD, |
203 | 203 | // but does not hurt either. |
204 | - $pagingSize = (int)$this->connection->ldapPagingSize; |
|
204 | + $pagingSize = (int) $this->connection->ldapPagingSize; |
|
205 | 205 | // 0 won't result in replies, small numbers may leave out groups |
206 | 206 | // (cf. #12306), 500 is default for paging and should work everywhere. |
207 | 207 | $maxResults = $pagingSize > 20 ? $pagingSize : 500; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $isRangeRequest = false; |
215 | 215 | do { |
216 | 216 | $result = $this->executeRead($cr, $dn, $attrToRead, $filter, $maxResults); |
217 | - if(is_bool($result)) { |
|
217 | + if (is_bool($result)) { |
|
218 | 218 | // when an exists request was run and it was successful, an empty |
219 | 219 | // array must be returned |
220 | 220 | return $result ? [] : false; |
@@ -231,22 +231,22 @@ discard block |
||
231 | 231 | $result = $this->extractRangeData($result, $attr); |
232 | 232 | if (!empty($result)) { |
233 | 233 | $normalizedResult = $this->extractAttributeValuesFromResult( |
234 | - [ $attr => $result['values'] ], |
|
234 | + [$attr => $result['values']], |
|
235 | 235 | $attr |
236 | 236 | ); |
237 | 237 | $values = array_merge($values, $normalizedResult); |
238 | 238 | |
239 | - if($result['rangeHigh'] === '*') { |
|
239 | + if ($result['rangeHigh'] === '*') { |
|
240 | 240 | // when server replies with * as high range value, there are |
241 | 241 | // no more results left |
242 | 242 | return $values; |
243 | 243 | } else { |
244 | - $low = $result['rangeHigh'] + 1; |
|
245 | - $attrToRead = $result['attributeName'] . ';range=' . $low . '-*'; |
|
244 | + $low = $result['rangeHigh'] + 1; |
|
245 | + $attrToRead = $result['attributeName'].';range='.$low.'-*'; |
|
246 | 246 | $isRangeRequest = true; |
247 | 247 | } |
248 | 248 | } |
249 | - } while($isRangeRequest); |
|
249 | + } while ($isRangeRequest); |
|
250 | 250 | |
251 | 251 | \OCP\Util::writeLog('user_ldap', 'Requested attribute '.$attr.' not found for '.$dn, ILogger::DEBUG); |
252 | 252 | return false; |
@@ -272,13 +272,13 @@ discard block |
||
272 | 272 | if (!$this->ldap->isResource($rr)) { |
273 | 273 | if ($attribute !== '') { |
274 | 274 | //do not throw this message on userExists check, irritates |
275 | - \OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN ' . $dn, ILogger::DEBUG); |
|
275 | + \OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN '.$dn, ILogger::DEBUG); |
|
276 | 276 | } |
277 | 277 | //in case an error occurs , e.g. object does not exist |
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | if ($attribute === '' && ($filter === 'objectclass=*' || $this->invokeLDAPMethod('countEntries', $cr, $rr) === 1)) { |
281 | - \OCP\Util::writeLog('user_ldap', 'readAttribute: ' . $dn . ' found', ILogger::DEBUG); |
|
281 | + \OCP\Util::writeLog('user_ldap', 'readAttribute: '.$dn.' found', ILogger::DEBUG); |
|
282 | 282 | return true; |
283 | 283 | } |
284 | 284 | $er = $this->invokeLDAPMethod('firstEntry', $cr, $rr); |
@@ -303,12 +303,12 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function extractAttributeValuesFromResult($result, $attribute) { |
305 | 305 | $values = []; |
306 | - if(isset($result[$attribute]) && $result[$attribute]['count'] > 0) { |
|
306 | + if (isset($result[$attribute]) && $result[$attribute]['count'] > 0) { |
|
307 | 307 | $lowercaseAttribute = strtolower($attribute); |
308 | - for($i=0;$i<$result[$attribute]['count'];$i++) { |
|
309 | - if($this->resemblesDN($attribute)) { |
|
308 | + for ($i = 0; $i < $result[$attribute]['count']; $i++) { |
|
309 | + if ($this->resemblesDN($attribute)) { |
|
310 | 310 | $values[] = $this->helper->sanitizeDN($result[$attribute][$i]); |
311 | - } elseif($lowercaseAttribute === 'objectguid' || $lowercaseAttribute === 'guid') { |
|
311 | + } elseif ($lowercaseAttribute === 'objectguid' || $lowercaseAttribute === 'guid') { |
|
312 | 312 | $values[] = $this->convertObjectGUID2Str($result[$attribute][$i]); |
313 | 313 | } else { |
314 | 314 | $values[] = $result[$attribute][$i]; |
@@ -330,10 +330,10 @@ discard block |
||
330 | 330 | */ |
331 | 331 | public function extractRangeData($result, $attribute) { |
332 | 332 | $keys = array_keys($result); |
333 | - foreach($keys as $key) { |
|
334 | - if($key !== $attribute && strpos($key, $attribute) === 0) { |
|
333 | + foreach ($keys as $key) { |
|
334 | + if ($key !== $attribute && strpos($key, $attribute) === 0) { |
|
335 | 335 | $queryData = explode(';', $key); |
336 | - if(strpos($queryData[1], 'range=') === 0) { |
|
336 | + if (strpos($queryData[1], 'range=') === 0) { |
|
337 | 337 | $high = substr($queryData[1], 1 + strpos($queryData[1], '-')); |
338 | 338 | $data = [ |
339 | 339 | 'values' => $result[$key], |
@@ -358,18 +358,18 @@ discard block |
||
358 | 358 | * @throws \Exception |
359 | 359 | */ |
360 | 360 | public function setPassword($userDN, $password) { |
361 | - if((int)$this->connection->turnOnPasswordChange !== 1) { |
|
361 | + if ((int) $this->connection->turnOnPasswordChange !== 1) { |
|
362 | 362 | throw new \Exception('LDAP password changes are disabled.'); |
363 | 363 | } |
364 | 364 | $cr = $this->connection->getConnectionResource(); |
365 | - if(!$this->ldap->isResource($cr)) { |
|
365 | + if (!$this->ldap->isResource($cr)) { |
|
366 | 366 | //LDAP not available |
367 | 367 | \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', ILogger::DEBUG); |
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | try { |
371 | 371 | return @$this->invokeLDAPMethod('modReplace', $cr, $userDN, $password); |
372 | - } catch(ConstraintViolationException $e) { |
|
372 | + } catch (ConstraintViolationException $e) { |
|
373 | 373 | throw new HintException('Password change rejected.', \OC::$server->getL10N('user_ldap')->t('Password change rejected. Hint: ').$e->getMessage(), $e->getCode()); |
374 | 374 | } |
375 | 375 | } |
@@ -411,17 +411,17 @@ discard block |
||
411 | 411 | */ |
412 | 412 | public function getDomainDNFromDN($dn) { |
413 | 413 | $allParts = $this->ldap->explodeDN($dn, 0); |
414 | - if($allParts === false) { |
|
414 | + if ($allParts === false) { |
|
415 | 415 | //not a valid DN |
416 | 416 | return ''; |
417 | 417 | } |
418 | 418 | $domainParts = array(); |
419 | 419 | $dcFound = false; |
420 | - foreach($allParts as $part) { |
|
421 | - if(!$dcFound && strpos($part, 'dc=') === 0) { |
|
420 | + foreach ($allParts as $part) { |
|
421 | + if (!$dcFound && strpos($part, 'dc=') === 0) { |
|
422 | 422 | $dcFound = true; |
423 | 423 | } |
424 | - if($dcFound) { |
|
424 | + if ($dcFound) { |
|
425 | 425 | $domainParts[] = $part; |
426 | 426 | } |
427 | 427 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | |
448 | 448 | //Check whether the DN belongs to the Base, to avoid issues on multi- |
449 | 449 | //server setups |
450 | - if(is_string($fdn) && $this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) { |
|
450 | + if (is_string($fdn) && $this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) { |
|
451 | 451 | return $fdn; |
452 | 452 | } |
453 | 453 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | //To avoid bypassing the base DN settings under certain circumstances |
465 | 465 | //with the group support, check whether the provided DN matches one of |
466 | 466 | //the given Bases |
467 | - if(!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseGroups)) { |
|
467 | + if (!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseGroups)) { |
|
468 | 468 | return false; |
469 | 469 | } |
470 | 470 | |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | */ |
483 | 483 | public function groupsMatchFilter($groupDNs) { |
484 | 484 | $validGroupDNs = []; |
485 | - foreach($groupDNs as $dn) { |
|
485 | + foreach ($groupDNs as $dn) { |
|
486 | 486 | $cacheKey = 'groupsMatchFilter-'.$dn; |
487 | 487 | $groupMatchFilter = $this->connection->getFromCache($cacheKey); |
488 | - if(!is_null($groupMatchFilter)) { |
|
489 | - if($groupMatchFilter) { |
|
488 | + if (!is_null($groupMatchFilter)) { |
|
489 | + if ($groupMatchFilter) { |
|
490 | 490 | $validGroupDNs[] = $dn; |
491 | 491 | } |
492 | 492 | continue; |
@@ -494,13 +494,13 @@ discard block |
||
494 | 494 | |
495 | 495 | // Check the base DN first. If this is not met already, we don't |
496 | 496 | // need to ask the server at all. |
497 | - if(!$this->isDNPartOfBase($dn, $this->connection->ldapBaseGroups)) { |
|
497 | + if (!$this->isDNPartOfBase($dn, $this->connection->ldapBaseGroups)) { |
|
498 | 498 | $this->connection->writeToCache($cacheKey, false); |
499 | 499 | continue; |
500 | 500 | } |
501 | 501 | |
502 | 502 | $result = $this->readAttribute($dn, '', $this->connection->ldapGroupFilter); |
503 | - if(is_array($result)) { |
|
503 | + if (is_array($result)) { |
|
504 | 504 | $this->connection->writeToCache($cacheKey, true); |
505 | 505 | $validGroupDNs[] = $dn; |
506 | 506 | } else { |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | //To avoid bypassing the base DN settings under certain circumstances |
522 | 522 | //with the group support, check whether the provided DN matches one of |
523 | 523 | //the given Bases |
524 | - if(!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) { |
|
524 | + if (!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) { |
|
525 | 525 | return false; |
526 | 526 | } |
527 | 527 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | */ |
542 | 542 | public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped = null, array $record = null) { |
543 | 543 | $newlyMapped = false; |
544 | - if($isUser) { |
|
544 | + if ($isUser) { |
|
545 | 545 | $mapper = $this->getUserMapper(); |
546 | 546 | $nameAttribute = $this->connection->ldapUserDisplayName; |
547 | 547 | $filter = $this->connection->ldapUserFilter; |
@@ -553,15 +553,15 @@ discard block |
||
553 | 553 | |
554 | 554 | //let's try to retrieve the Nextcloud name from the mappings table |
555 | 555 | $ncName = $mapper->getNameByDN($fdn); |
556 | - if(is_string($ncName)) { |
|
556 | + if (is_string($ncName)) { |
|
557 | 557 | return $ncName; |
558 | 558 | } |
559 | 559 | |
560 | 560 | //second try: get the UUID and check if it is known. Then, update the DN and return the name. |
561 | 561 | $uuid = $this->getUUID($fdn, $isUser, $record); |
562 | - if(is_string($uuid)) { |
|
562 | + if (is_string($uuid)) { |
|
563 | 563 | $ncName = $mapper->getNameByUUID($uuid); |
564 | - if(is_string($ncName)) { |
|
564 | + if (is_string($ncName)) { |
|
565 | 565 | $mapper->setDNbyUUID($fdn, $uuid); |
566 | 566 | return $ncName; |
567 | 567 | } |
@@ -571,17 +571,17 @@ discard block |
||
571 | 571 | return false; |
572 | 572 | } |
573 | 573 | |
574 | - if(is_null($ldapName)) { |
|
574 | + if (is_null($ldapName)) { |
|
575 | 575 | $ldapName = $this->readAttribute($fdn, $nameAttribute, $filter); |
576 | - if(!isset($ldapName[0]) && empty($ldapName[0])) { |
|
576 | + if (!isset($ldapName[0]) && empty($ldapName[0])) { |
|
577 | 577 | \OCP\Util::writeLog('user_ldap', 'No or empty name for '.$fdn.' with filter '.$filter.'.', ILogger::INFO); |
578 | 578 | return false; |
579 | 579 | } |
580 | 580 | $ldapName = $ldapName[0]; |
581 | 581 | } |
582 | 582 | |
583 | - if($isUser) { |
|
584 | - $usernameAttribute = (string)$this->connection->ldapExpertUsernameAttr; |
|
583 | + if ($isUser) { |
|
584 | + $usernameAttribute = (string) $this->connection->ldapExpertUsernameAttr; |
|
585 | 585 | if ($usernameAttribute !== '') { |
586 | 586 | $username = $this->readAttribute($fdn, $usernameAttribute); |
587 | 587 | $username = $username[0]; |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | // outside of core user management will still cache the user as non-existing. |
612 | 612 | $originalTTL = $this->connection->ldapCacheTTL; |
613 | 613 | $this->connection->setConfiguration(array('ldapCacheTTL' => 0)); |
614 | - if(($isUser && $intName !== '' && !$this->ncUserManager->userExists($intName)) |
|
614 | + if (($isUser && $intName !== '' && !$this->ncUserManager->userExists($intName)) |
|
615 | 615 | || (!$isUser && !\OC::$server->getGroupManager()->groupExists($intName))) { |
616 | - if($mapper->map($fdn, $intName, $uuid)) { |
|
616 | + if ($mapper->map($fdn, $intName, $uuid)) { |
|
617 | 617 | $this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL)); |
618 | - if($this->ncUserManager instanceof PublicEmitter) { |
|
618 | + if ($this->ncUserManager instanceof PublicEmitter) { |
|
619 | 619 | $this->ncUserManager->emit('\OC\User', 'assignedUserId', [$intName]); |
620 | 620 | } |
621 | 621 | $newlyMapped = true; |
@@ -625,8 +625,8 @@ discard block |
||
625 | 625 | $this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL)); |
626 | 626 | |
627 | 627 | $altName = $this->createAltInternalOwnCloudName($intName, $isUser); |
628 | - if(is_string($altName) && $mapper->map($fdn, $altName, $uuid)) { |
|
629 | - if($this->ncUserManager instanceof PublicEmitter) { |
|
628 | + if (is_string($altName) && $mapper->map($fdn, $altName, $uuid)) { |
|
629 | + if ($this->ncUserManager instanceof PublicEmitter) { |
|
630 | 630 | $this->ncUserManager->emit('\OC\User', 'assignedUserId', [$intName]); |
631 | 631 | } |
632 | 632 | $newlyMapped = true; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * @return array |
667 | 667 | */ |
668 | 668 | private function ldap2NextcloudNames($ldapObjects, $isUsers) { |
669 | - if($isUsers) { |
|
669 | + if ($isUsers) { |
|
670 | 670 | $nameAttribute = $this->connection->ldapUserDisplayName; |
671 | 671 | $sndAttribute = $this->connection->ldapUserDisplayName2; |
672 | 672 | } else { |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | } |
675 | 675 | $nextcloudNames = array(); |
676 | 676 | |
677 | - foreach($ldapObjects as $ldapObject) { |
|
677 | + foreach ($ldapObjects as $ldapObject) { |
|
678 | 678 | $nameByLDAP = null; |
679 | - if( isset($ldapObject[$nameAttribute]) |
|
679 | + if (isset($ldapObject[$nameAttribute]) |
|
680 | 680 | && is_array($ldapObject[$nameAttribute]) |
681 | 681 | && isset($ldapObject[$nameAttribute][0]) |
682 | 682 | ) { |
@@ -685,12 +685,12 @@ discard block |
||
685 | 685 | } |
686 | 686 | |
687 | 687 | $ncName = $this->dn2ocname($ldapObject['dn'][0], $nameByLDAP, $isUsers); |
688 | - if($ncName) { |
|
688 | + if ($ncName) { |
|
689 | 689 | $nextcloudNames[] = $ncName; |
690 | - if($isUsers) { |
|
690 | + if ($isUsers) { |
|
691 | 691 | //cache the user names so it does not need to be retrieved |
692 | 692 | //again later (e.g. sharing dialogue). |
693 | - if(is_null($nameByLDAP)) { |
|
693 | + if (is_null($nameByLDAP)) { |
|
694 | 694 | continue; |
695 | 695 | } |
696 | 696 | $sndName = isset($ldapObject[$sndAttribute][0]) |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | */ |
729 | 729 | public function cacheUserDisplayName($ocName, $displayName, $displayName2 = '') { |
730 | 730 | $user = $this->userManager->get($ocName); |
731 | - if($user === null) { |
|
731 | + if ($user === null) { |
|
732 | 732 | return; |
733 | 733 | } |
734 | 734 | $displayName = $user->composeAndStoreDisplayName($displayName, $displayName2); |
@@ -748,9 +748,9 @@ discard block |
||
748 | 748 | $attempts = 0; |
749 | 749 | //while loop is just a precaution. If a name is not generated within |
750 | 750 | //20 attempts, something else is very wrong. Avoids infinite loop. |
751 | - while($attempts < 20){ |
|
752 | - $altName = $name . '_' . rand(1000,9999); |
|
753 | - if(!$this->ncUserManager->userExists($altName)) { |
|
751 | + while ($attempts < 20) { |
|
752 | + $altName = $name.'_'.rand(1000, 9999); |
|
753 | + if (!$this->ncUserManager->userExists($altName)) { |
|
754 | 754 | return $altName; |
755 | 755 | } |
756 | 756 | $attempts++; |
@@ -772,25 +772,25 @@ discard block |
||
772 | 772 | */ |
773 | 773 | private function _createAltInternalOwnCloudNameForGroups($name) { |
774 | 774 | $usedNames = $this->groupMapper->getNamesBySearch($name, "", '_%'); |
775 | - if(!$usedNames || count($usedNames) === 0) { |
|
775 | + if (!$usedNames || count($usedNames) === 0) { |
|
776 | 776 | $lastNo = 1; //will become name_2 |
777 | 777 | } else { |
778 | 778 | natsort($usedNames); |
779 | 779 | $lastName = array_pop($usedNames); |
780 | - $lastNo = (int)substr($lastName, strrpos($lastName, '_') + 1); |
|
780 | + $lastNo = (int) substr($lastName, strrpos($lastName, '_') + 1); |
|
781 | 781 | } |
782 | - $altName = $name.'_'. (string)($lastNo+1); |
|
782 | + $altName = $name.'_'.(string) ($lastNo + 1); |
|
783 | 783 | unset($usedNames); |
784 | 784 | |
785 | 785 | $attempts = 1; |
786 | - while($attempts < 21){ |
|
786 | + while ($attempts < 21) { |
|
787 | 787 | // Check to be really sure it is unique |
788 | 788 | // while loop is just a precaution. If a name is not generated within |
789 | 789 | // 20 attempts, something else is very wrong. Avoids infinite loop. |
790 | - if(!\OC::$server->getGroupManager()->groupExists($altName)) { |
|
790 | + if (!\OC::$server->getGroupManager()->groupExists($altName)) { |
|
791 | 791 | return $altName; |
792 | 792 | } |
793 | - $altName = $name . '_' . ($lastNo + $attempts); |
|
793 | + $altName = $name.'_'.($lastNo + $attempts); |
|
794 | 794 | $attempts++; |
795 | 795 | } |
796 | 796 | return false; |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | private function createAltInternalOwnCloudName($name, $isUser) { |
806 | 806 | $originalTTL = $this->connection->ldapCacheTTL; |
807 | 807 | $this->connection->setConfiguration(array('ldapCacheTTL' => 0)); |
808 | - if($isUser) { |
|
808 | + if ($isUser) { |
|
809 | 809 | $altName = $this->_createAltInternalOwnCloudNameForUsers($name); |
810 | 810 | } else { |
811 | 811 | $altName = $this->_createAltInternalOwnCloudNameForGroups($name); |
@@ -853,13 +853,13 @@ discard block |
||
853 | 853 | public function fetchListOfUsers($filter, $attr, $limit = null, $offset = null, $forceApplyAttributes = false) { |
854 | 854 | $ldapRecords = $this->searchUsers($filter, $attr, $limit, $offset); |
855 | 855 | $recordsToUpdate = $ldapRecords; |
856 | - if(!$forceApplyAttributes) { |
|
856 | + if (!$forceApplyAttributes) { |
|
857 | 857 | $isBackgroundJobModeAjax = $this->config |
858 | 858 | ->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'ajax'; |
859 | 859 | $recordsToUpdate = array_filter($ldapRecords, function($record) use ($isBackgroundJobModeAjax) { |
860 | 860 | $newlyMapped = false; |
861 | 861 | $uid = $this->dn2ocname($record['dn'][0], null, true, $newlyMapped, $record); |
862 | - if(is_string($uid)) { |
|
862 | + if (is_string($uid)) { |
|
863 | 863 | $this->cacheUserExists($uid); |
864 | 864 | } |
865 | 865 | return ($uid !== false) && ($newlyMapped || $isBackgroundJobModeAjax); |
@@ -875,19 +875,19 @@ discard block |
||
875 | 875 | * and their values |
876 | 876 | * @param array $ldapRecords |
877 | 877 | */ |
878 | - public function batchApplyUserAttributes(array $ldapRecords){ |
|
878 | + public function batchApplyUserAttributes(array $ldapRecords) { |
|
879 | 879 | $displayNameAttribute = strtolower($this->connection->ldapUserDisplayName); |
880 | - foreach($ldapRecords as $userRecord) { |
|
881 | - if(!isset($userRecord[$displayNameAttribute])) { |
|
880 | + foreach ($ldapRecords as $userRecord) { |
|
881 | + if (!isset($userRecord[$displayNameAttribute])) { |
|
882 | 882 | // displayName is obligatory |
883 | 883 | continue; |
884 | 884 | } |
885 | - $ocName = $this->dn2ocname($userRecord['dn'][0], null, true); |
|
886 | - if($ocName === false) { |
|
885 | + $ocName = $this->dn2ocname($userRecord['dn'][0], null, true); |
|
886 | + if ($ocName === false) { |
|
887 | 887 | continue; |
888 | 888 | } |
889 | 889 | $user = $this->userManager->get($ocName); |
890 | - if($user instanceof OfflineUser) { |
|
890 | + if ($user instanceof OfflineUser) { |
|
891 | 891 | $user->unmark(); |
892 | 892 | $user = $this->userManager->get($ocName); |
893 | 893 | } |
@@ -919,8 +919,8 @@ discard block |
||
919 | 919 | * @return array |
920 | 920 | */ |
921 | 921 | private function fetchList($list, $manyAttributes) { |
922 | - if(is_array($list)) { |
|
923 | - if($manyAttributes) { |
|
922 | + if (is_array($list)) { |
|
923 | + if ($manyAttributes) { |
|
924 | 924 | return $list; |
925 | 925 | } else { |
926 | 926 | $list = array_reduce($list, function($carry, $item) { |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | // php no longer supports call-time pass-by-reference |
1019 | 1019 | // thus cannot support controlPagedResultResponse as the third argument |
1020 | 1020 | // is a reference |
1021 | - $doMethod = function () use ($command, &$arguments) { |
|
1021 | + $doMethod = function() use ($command, &$arguments) { |
|
1022 | 1022 | if ($command == 'controlPagedResultResponse') { |
1023 | 1023 | throw new \InvalidArgumentException('Invoker does not support controlPagedResultResponse, call LDAP Wrapper directly instead.'); |
1024 | 1024 | } else { |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | $this->connection->resetConnectionResource(); |
1037 | 1037 | $cr = $this->connection->getConnectionResource(); |
1038 | 1038 | |
1039 | - if(!$this->ldap->isResource($cr)) { |
|
1039 | + if (!$this->ldap->isResource($cr)) { |
|
1040 | 1040 | // Seems like we didn't find any resource. |
1041 | 1041 | \OCP\Util::writeLog('user_ldap', "Could not $command, because resource is missing.", ILogger::DEBUG); |
1042 | 1042 | throw $e; |
@@ -1061,13 +1061,13 @@ discard block |
||
1061 | 1061 | * @throws ServerNotAvailableException |
1062 | 1062 | */ |
1063 | 1063 | private function executeSearch($filter, $base, &$attr = null, $limit = null, $offset = null) { |
1064 | - if(!is_null($attr) && !is_array($attr)) { |
|
1064 | + if (!is_null($attr) && !is_array($attr)) { |
|
1065 | 1065 | $attr = array(mb_strtolower($attr, 'UTF-8')); |
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | // See if we have a resource, in case not cancel with message |
1069 | 1069 | $cr = $this->connection->getConnectionResource(); |
1070 | - if(!$this->ldap->isResource($cr)) { |
|
1070 | + if (!$this->ldap->isResource($cr)) { |
|
1071 | 1071 | // Seems like we didn't find any resource. |
1072 | 1072 | // Return an empty array just like before. |
1073 | 1073 | \OCP\Util::writeLog('user_ldap', 'Could not search, because resource is missing.', ILogger::DEBUG); |
@@ -1075,13 +1075,13 @@ discard block |
||
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | //check whether paged search should be attempted |
1078 | - $pagedSearchOK = $this->initPagedSearch($filter, $base, $attr, (int)$limit, $offset); |
|
1078 | + $pagedSearchOK = $this->initPagedSearch($filter, $base, $attr, (int) $limit, $offset); |
|
1079 | 1079 | |
1080 | 1080 | $linkResources = array_pad(array(), count($base), $cr); |
1081 | 1081 | $sr = $this->invokeLDAPMethod('search', $linkResources, $base, $filter, $attr); |
1082 | 1082 | // cannot use $cr anymore, might have changed in the previous call! |
1083 | 1083 | $error = $this->ldap->errno($this->connection->getConnectionResource()); |
1084 | - if(!is_array($sr) || $error !== 0) { |
|
1084 | + if (!is_array($sr) || $error !== 0) { |
|
1085 | 1085 | \OCP\Util::writeLog('user_ldap', 'Attempt for Paging? '.print_r($pagedSearchOK, true), ILogger::ERROR); |
1086 | 1086 | return false; |
1087 | 1087 | } |
@@ -1104,29 +1104,29 @@ discard block |
||
1104 | 1104 | */ |
1105 | 1105 | private function processPagedSearchStatus($sr, $filter, $base, $iFoundItems, $limit, $offset, $pagedSearchOK, $skipHandling) { |
1106 | 1106 | $cookie = null; |
1107 | - if($pagedSearchOK) { |
|
1107 | + if ($pagedSearchOK) { |
|
1108 | 1108 | $cr = $this->connection->getConnectionResource(); |
1109 | - foreach($sr as $key => $res) { |
|
1110 | - if($this->ldap->controlPagedResultResponse($cr, $res, $cookie)) { |
|
1109 | + foreach ($sr as $key => $res) { |
|
1110 | + if ($this->ldap->controlPagedResultResponse($cr, $res, $cookie)) { |
|
1111 | 1111 | $this->setPagedResultCookie($base[$key], $filter, $limit, $offset, $cookie); |
1112 | 1112 | } |
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | //browsing through prior pages to get the cookie for the new one |
1116 | - if($skipHandling) { |
|
1116 | + if ($skipHandling) { |
|
1117 | 1117 | return false; |
1118 | 1118 | } |
1119 | 1119 | // if count is bigger, then the server does not support |
1120 | 1120 | // paged search. Instead, he did a normal search. We set a |
1121 | 1121 | // flag here, so the callee knows how to deal with it. |
1122 | - if($iFoundItems <= $limit) { |
|
1122 | + if ($iFoundItems <= $limit) { |
|
1123 | 1123 | $this->pagedSearchedSuccessful = true; |
1124 | 1124 | } |
1125 | 1125 | } else { |
1126 | - if(!is_null($limit) && (int)$this->connection->ldapPagingSize !== 0) { |
|
1126 | + if (!is_null($limit) && (int) $this->connection->ldapPagingSize !== 0) { |
|
1127 | 1127 | \OC::$server->getLogger()->debug( |
1128 | 1128 | 'Paged search was not available', |
1129 | - [ 'app' => 'user_ldap' ] |
|
1129 | + ['app' => 'user_ldap'] |
|
1130 | 1130 | ); |
1131 | 1131 | } |
1132 | 1132 | } |
@@ -1155,8 +1155,8 @@ discard block |
||
1155 | 1155 | private function count($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) { |
1156 | 1156 | \OCP\Util::writeLog('user_ldap', 'Count filter: '.print_r($filter, true), ILogger::DEBUG); |
1157 | 1157 | |
1158 | - $limitPerPage = (int)$this->connection->ldapPagingSize; |
|
1159 | - if(!is_null($limit) && $limit < $limitPerPage && $limit > 0) { |
|
1158 | + $limitPerPage = (int) $this->connection->ldapPagingSize; |
|
1159 | + if (!is_null($limit) && $limit < $limitPerPage && $limit > 0) { |
|
1160 | 1160 | $limitPerPage = $limit; |
1161 | 1161 | } |
1162 | 1162 | |
@@ -1166,7 +1166,7 @@ discard block |
||
1166 | 1166 | |
1167 | 1167 | do { |
1168 | 1168 | $search = $this->executeSearch($filter, $base, $attr, $limitPerPage, $offset); |
1169 | - if($search === false) { |
|
1169 | + if ($search === false) { |
|
1170 | 1170 | return $counter > 0 ? $counter : false; |
1171 | 1171 | } |
1172 | 1172 | list($sr, $pagedSearchOK) = $search; |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | * Continue now depends on $hasMorePages value |
1186 | 1186 | */ |
1187 | 1187 | $continue = $pagedSearchOK && $hasMorePages; |
1188 | - } while($continue && (is_null($limit) || $limit <= 0 || $limit > $counter)); |
|
1188 | + } while ($continue && (is_null($limit) || $limit <= 0 || $limit > $counter)); |
|
1189 | 1189 | |
1190 | 1190 | return $counter; |
1191 | 1191 | } |
@@ -1197,8 +1197,8 @@ discard block |
||
1197 | 1197 | private function countEntriesInSearchResults($searchResults) { |
1198 | 1198 | $counter = 0; |
1199 | 1199 | |
1200 | - foreach($searchResults as $res) { |
|
1201 | - $count = (int)$this->invokeLDAPMethod('countEntries', $this->connection->getConnectionResource(), $res); |
|
1200 | + foreach ($searchResults as $res) { |
|
1201 | + $count = (int) $this->invokeLDAPMethod('countEntries', $this->connection->getConnectionResource(), $res); |
|
1202 | 1202 | $counter += $count; |
1203 | 1203 | } |
1204 | 1204 | |
@@ -1218,8 +1218,8 @@ discard block |
||
1218 | 1218 | * @throws ServerNotAvailableException |
1219 | 1219 | */ |
1220 | 1220 | public function search($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) { |
1221 | - $limitPerPage = (int)$this->connection->ldapPagingSize; |
|
1222 | - if(!is_null($limit) && $limit < $limitPerPage && $limit > 0) { |
|
1221 | + $limitPerPage = (int) $this->connection->ldapPagingSize; |
|
1222 | + if (!is_null($limit) && $limit < $limitPerPage && $limit > 0) { |
|
1223 | 1223 | $limitPerPage = $limit; |
1224 | 1224 | } |
1225 | 1225 | |
@@ -1233,13 +1233,13 @@ discard block |
||
1233 | 1233 | $savedoffset = $offset; |
1234 | 1234 | do { |
1235 | 1235 | $search = $this->executeSearch($filter, $base, $attr, $limitPerPage, $offset); |
1236 | - if($search === false) { |
|
1236 | + if ($search === false) { |
|
1237 | 1237 | return []; |
1238 | 1238 | } |
1239 | 1239 | list($sr, $pagedSearchOK) = $search; |
1240 | 1240 | $cr = $this->connection->getConnectionResource(); |
1241 | 1241 | |
1242 | - if($skipHandling) { |
|
1242 | + if ($skipHandling) { |
|
1243 | 1243 | //i.e. result do not need to be fetched, we just need the cookie |
1244 | 1244 | //thus pass 1 or any other value as $iFoundItems because it is not |
1245 | 1245 | //used |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | } |
1251 | 1251 | |
1252 | 1252 | $iFoundItems = 0; |
1253 | - foreach($sr as $res) { |
|
1253 | + foreach ($sr as $res) { |
|
1254 | 1254 | $findings = array_merge($findings, $this->invokeLDAPMethod('getEntries', $cr, $res)); |
1255 | 1255 | $iFoundItems = max($iFoundItems, $findings['count']); |
1256 | 1256 | unset($findings['count']); |
@@ -1266,27 +1266,27 @@ discard block |
||
1266 | 1266 | |
1267 | 1267 | // if we're here, probably no connection resource is returned. |
1268 | 1268 | // to make Nextcloud behave nicely, we simply give back an empty array. |
1269 | - if(is_null($findings)) { |
|
1269 | + if (is_null($findings)) { |
|
1270 | 1270 | return array(); |
1271 | 1271 | } |
1272 | 1272 | |
1273 | - if(!is_null($attr)) { |
|
1273 | + if (!is_null($attr)) { |
|
1274 | 1274 | $selection = []; |
1275 | 1275 | $i = 0; |
1276 | - foreach($findings as $item) { |
|
1277 | - if(!is_array($item)) { |
|
1276 | + foreach ($findings as $item) { |
|
1277 | + if (!is_array($item)) { |
|
1278 | 1278 | continue; |
1279 | 1279 | } |
1280 | 1280 | $item = \OCP\Util::mb_array_change_key_case($item, MB_CASE_LOWER, 'UTF-8'); |
1281 | - foreach($attr as $key) { |
|
1282 | - if(isset($item[$key])) { |
|
1283 | - if(is_array($item[$key]) && isset($item[$key]['count'])) { |
|
1281 | + foreach ($attr as $key) { |
|
1282 | + if (isset($item[$key])) { |
|
1283 | + if (is_array($item[$key]) && isset($item[$key]['count'])) { |
|
1284 | 1284 | unset($item[$key]['count']); |
1285 | 1285 | } |
1286 | - if($key !== 'dn') { |
|
1287 | - if($this->resemblesDN($key)) { |
|
1286 | + if ($key !== 'dn') { |
|
1287 | + if ($this->resemblesDN($key)) { |
|
1288 | 1288 | $selection[$i][$key] = $this->helper->sanitizeDN($item[$key]); |
1289 | - } else if($key === 'objectguid' || $key === 'guid') { |
|
1289 | + } else if ($key === 'objectguid' || $key === 'guid') { |
|
1290 | 1290 | $selection[$i][$key] = [$this->convertObjectGUID2Str($item[$key][0])]; |
1291 | 1291 | } else { |
1292 | 1292 | $selection[$i][$key] = $item[$key]; |
@@ -1304,14 +1304,14 @@ discard block |
||
1304 | 1304 | //we slice the findings, when |
1305 | 1305 | //a) paged search unsuccessful, though attempted |
1306 | 1306 | //b) no paged search, but limit set |
1307 | - if((!$this->getPagedSearchResultState() |
|
1307 | + if ((!$this->getPagedSearchResultState() |
|
1308 | 1308 | && $pagedSearchOK) |
1309 | 1309 | || ( |
1310 | 1310 | !$pagedSearchOK |
1311 | 1311 | && !is_null($limit) |
1312 | 1312 | ) |
1313 | 1313 | ) { |
1314 | - $findings = array_slice($findings, (int)$offset, $limit); |
|
1314 | + $findings = array_slice($findings, (int) $offset, $limit); |
|
1315 | 1315 | } |
1316 | 1316 | return $findings; |
1317 | 1317 | } |
@@ -1324,13 +1324,13 @@ discard block |
||
1324 | 1324 | public function sanitizeUsername($name) { |
1325 | 1325 | $name = trim($name); |
1326 | 1326 | |
1327 | - if($this->connection->ldapIgnoreNamingRules) { |
|
1327 | + if ($this->connection->ldapIgnoreNamingRules) { |
|
1328 | 1328 | return $name; |
1329 | 1329 | } |
1330 | 1330 | |
1331 | 1331 | // Transliteration to ASCII |
1332 | 1332 | $transliterated = @iconv('UTF-8', 'ASCII//TRANSLIT', $name); |
1333 | - if($transliterated !== false) { |
|
1333 | + if ($transliterated !== false) { |
|
1334 | 1334 | // depending on system config iconv can work or not |
1335 | 1335 | $name = $transliterated; |
1336 | 1336 | } |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | // Every remaining disallowed characters will be removed |
1342 | 1342 | $name = preg_replace('/[^a-zA-Z0-9_.@-]/u', '', $name); |
1343 | 1343 | |
1344 | - if($name === '') { |
|
1344 | + if ($name === '') { |
|
1345 | 1345 | throw new \InvalidArgumentException('provided name template for username does not contain any allowed characters'); |
1346 | 1346 | } |
1347 | 1347 | |
@@ -1356,13 +1356,13 @@ discard block |
||
1356 | 1356 | */ |
1357 | 1357 | public function escapeFilterPart($input, $allowAsterisk = false) { |
1358 | 1358 | $asterisk = ''; |
1359 | - if($allowAsterisk && strlen($input) > 0 && $input[0] === '*') { |
|
1359 | + if ($allowAsterisk && strlen($input) > 0 && $input[0] === '*') { |
|
1360 | 1360 | $asterisk = '*'; |
1361 | 1361 | $input = mb_substr($input, 1, null, 'UTF-8'); |
1362 | 1362 | } |
1363 | 1363 | $search = array('*', '\\', '(', ')'); |
1364 | 1364 | $replace = array('\\*', '\\\\', '\\(', '\\)'); |
1365 | - return $asterisk . str_replace($search, $replace, $input); |
|
1365 | + return $asterisk.str_replace($search, $replace, $input); |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 | /** |
@@ -1392,13 +1392,13 @@ discard block |
||
1392 | 1392 | */ |
1393 | 1393 | private function combineFilter($filters, $operator) { |
1394 | 1394 | $combinedFilter = '('.$operator; |
1395 | - foreach($filters as $filter) { |
|
1395 | + foreach ($filters as $filter) { |
|
1396 | 1396 | if ($filter !== '' && $filter[0] !== '(') { |
1397 | 1397 | $filter = '('.$filter.')'; |
1398 | 1398 | } |
1399 | - $combinedFilter.=$filter; |
|
1399 | + $combinedFilter .= $filter; |
|
1400 | 1400 | } |
1401 | - $combinedFilter.=')'; |
|
1401 | + $combinedFilter .= ')'; |
|
1402 | 1402 | return $combinedFilter; |
1403 | 1403 | } |
1404 | 1404 | |
@@ -1434,17 +1434,17 @@ discard block |
||
1434 | 1434 | * @throws \Exception |
1435 | 1435 | */ |
1436 | 1436 | private function getAdvancedFilterPartForSearch($search, $searchAttributes) { |
1437 | - if(!is_array($searchAttributes) || count($searchAttributes) < 2) { |
|
1437 | + if (!is_array($searchAttributes) || count($searchAttributes) < 2) { |
|
1438 | 1438 | throw new \Exception('searchAttributes must be an array with at least two string'); |
1439 | 1439 | } |
1440 | 1440 | $searchWords = explode(' ', trim($search)); |
1441 | 1441 | $wordFilters = array(); |
1442 | - foreach($searchWords as $word) { |
|
1442 | + foreach ($searchWords as $word) { |
|
1443 | 1443 | $word = $this->prepareSearchTerm($word); |
1444 | 1444 | //every word needs to appear at least once |
1445 | 1445 | $wordMatchOneAttrFilters = array(); |
1446 | - foreach($searchAttributes as $attr) { |
|
1447 | - $wordMatchOneAttrFilters[] = $attr . '=' . $word; |
|
1446 | + foreach ($searchAttributes as $attr) { |
|
1447 | + $wordMatchOneAttrFilters[] = $attr.'='.$word; |
|
1448 | 1448 | } |
1449 | 1449 | $wordFilters[] = $this->combineFilterWithOr($wordMatchOneAttrFilters); |
1450 | 1450 | } |
@@ -1462,10 +1462,10 @@ discard block |
||
1462 | 1462 | private function getFilterPartForSearch($search, $searchAttributes, $fallbackAttribute) { |
1463 | 1463 | $filter = array(); |
1464 | 1464 | $haveMultiSearchAttributes = (is_array($searchAttributes) && count($searchAttributes) > 0); |
1465 | - if($haveMultiSearchAttributes && strpos(trim($search), ' ') !== false) { |
|
1465 | + if ($haveMultiSearchAttributes && strpos(trim($search), ' ') !== false) { |
|
1466 | 1466 | try { |
1467 | 1467 | return $this->getAdvancedFilterPartForSearch($search, $searchAttributes); |
1468 | - } catch(\Exception $e) { |
|
1468 | + } catch (\Exception $e) { |
|
1469 | 1469 | \OCP\Util::writeLog( |
1470 | 1470 | 'user_ldap', |
1471 | 1471 | 'Creating advanced filter for search failed, falling back to simple method.', |
@@ -1475,17 +1475,17 @@ discard block |
||
1475 | 1475 | } |
1476 | 1476 | |
1477 | 1477 | $search = $this->prepareSearchTerm($search); |
1478 | - if(!is_array($searchAttributes) || count($searchAttributes) === 0) { |
|
1478 | + if (!is_array($searchAttributes) || count($searchAttributes) === 0) { |
|
1479 | 1479 | if ($fallbackAttribute === '') { |
1480 | 1480 | return ''; |
1481 | 1481 | } |
1482 | - $filter[] = $fallbackAttribute . '=' . $search; |
|
1482 | + $filter[] = $fallbackAttribute.'='.$search; |
|
1483 | 1483 | } else { |
1484 | - foreach($searchAttributes as $attribute) { |
|
1485 | - $filter[] = $attribute . '=' . $search; |
|
1484 | + foreach ($searchAttributes as $attribute) { |
|
1485 | + $filter[] = $attribute.'='.$search; |
|
1486 | 1486 | } |
1487 | 1487 | } |
1488 | - if(count($filter) === 1) { |
|
1488 | + if (count($filter) === 1) { |
|
1489 | 1489 | return '('.$filter[0].')'; |
1490 | 1490 | } |
1491 | 1491 | return $this->combineFilterWithOr($filter); |
@@ -1506,7 +1506,7 @@ discard block |
||
1506 | 1506 | if ($term === '') { |
1507 | 1507 | $result = '*'; |
1508 | 1508 | } else if ($allowEnum !== 'no') { |
1509 | - $result = $term . '*'; |
|
1509 | + $result = $term.'*'; |
|
1510 | 1510 | } |
1511 | 1511 | return $result; |
1512 | 1512 | } |
@@ -1518,7 +1518,7 @@ discard block |
||
1518 | 1518 | public function getFilterForUserCount() { |
1519 | 1519 | $filter = $this->combineFilterWithAnd(array( |
1520 | 1520 | $this->connection->ldapUserFilter, |
1521 | - $this->connection->ldapUserDisplayName . '=*' |
|
1521 | + $this->connection->ldapUserDisplayName.'=*' |
|
1522 | 1522 | )); |
1523 | 1523 | |
1524 | 1524 | return $filter; |
@@ -1536,7 +1536,7 @@ discard block |
||
1536 | 1536 | 'ldapAgentName' => $name, |
1537 | 1537 | 'ldapAgentPassword' => $password |
1538 | 1538 | ); |
1539 | - if(!$testConnection->setConfiguration($credentials)) { |
|
1539 | + if (!$testConnection->setConfiguration($credentials)) { |
|
1540 | 1540 | return false; |
1541 | 1541 | } |
1542 | 1542 | return $testConnection->bind(); |
@@ -1558,30 +1558,30 @@ discard block |
||
1558 | 1558 | // Sacrebleu! The UUID attribute is unknown :( We need first an |
1559 | 1559 | // existing DN to be able to reliably detect it. |
1560 | 1560 | $result = $this->search($filter, $base, ['dn'], 1); |
1561 | - if(!isset($result[0]) || !isset($result[0]['dn'])) { |
|
1561 | + if (!isset($result[0]) || !isset($result[0]['dn'])) { |
|
1562 | 1562 | throw new \Exception('Cannot determine UUID attribute'); |
1563 | 1563 | } |
1564 | 1564 | $dn = $result[0]['dn'][0]; |
1565 | - if(!$this->detectUuidAttribute($dn, true)) { |
|
1565 | + if (!$this->detectUuidAttribute($dn, true)) { |
|
1566 | 1566 | throw new \Exception('Cannot determine UUID attribute'); |
1567 | 1567 | } |
1568 | 1568 | } else { |
1569 | 1569 | // The UUID attribute is either known or an override is given. |
1570 | 1570 | // By calling this method we ensure that $this->connection->$uuidAttr |
1571 | 1571 | // is definitely set |
1572 | - if(!$this->detectUuidAttribute('', true)) { |
|
1572 | + if (!$this->detectUuidAttribute('', true)) { |
|
1573 | 1573 | throw new \Exception('Cannot determine UUID attribute'); |
1574 | 1574 | } |
1575 | 1575 | } |
1576 | 1576 | |
1577 | 1577 | $uuidAttr = $this->connection->ldapUuidUserAttribute; |
1578 | - if($uuidAttr === 'guid' || $uuidAttr === 'objectguid') { |
|
1578 | + if ($uuidAttr === 'guid' || $uuidAttr === 'objectguid') { |
|
1579 | 1579 | $uuid = $this->formatGuid2ForFilterUser($uuid); |
1580 | 1580 | } |
1581 | 1581 | |
1582 | - $filter = $uuidAttr . '=' . $uuid; |
|
1582 | + $filter = $uuidAttr.'='.$uuid; |
|
1583 | 1583 | $result = $this->searchUsers($filter, ['dn'], 2); |
1584 | - if(is_array($result) && isset($result[0]) && isset($result[0]['dn']) && count($result) === 1) { |
|
1584 | + if (is_array($result) && isset($result[0]) && isset($result[0]['dn']) && count($result) === 1) { |
|
1585 | 1585 | // we put the count into account to make sure that this is |
1586 | 1586 | // really unique |
1587 | 1587 | return $result[0]['dn'][0]; |
@@ -1600,7 +1600,7 @@ discard block |
||
1600 | 1600 | * @return bool true on success, false otherwise |
1601 | 1601 | */ |
1602 | 1602 | private function detectUuidAttribute($dn, $isUser = true, $force = false, array $ldapRecord = null) { |
1603 | - if($isUser) { |
|
1603 | + if ($isUser) { |
|
1604 | 1604 | $uuidAttr = 'ldapUuidUserAttribute'; |
1605 | 1605 | $uuidOverride = $this->connection->ldapExpertUUIDUserAttr; |
1606 | 1606 | } else { |
@@ -1608,7 +1608,7 @@ discard block |
||
1608 | 1608 | $uuidOverride = $this->connection->ldapExpertUUIDGroupAttr; |
1609 | 1609 | } |
1610 | 1610 | |
1611 | - if(($this->connection->$uuidAttr !== 'auto') && !$force) { |
|
1611 | + if (($this->connection->$uuidAttr !== 'auto') && !$force) { |
|
1612 | 1612 | return true; |
1613 | 1613 | } |
1614 | 1614 | |
@@ -1617,10 +1617,10 @@ discard block |
||
1617 | 1617 | return true; |
1618 | 1618 | } |
1619 | 1619 | |
1620 | - foreach(self::UUID_ATTRIBUTES as $attribute) { |
|
1621 | - if($ldapRecord !== null) { |
|
1620 | + foreach (self::UUID_ATTRIBUTES as $attribute) { |
|
1621 | + if ($ldapRecord !== null) { |
|
1622 | 1622 | // we have the info from LDAP already, we don't need to talk to the server again |
1623 | - if(isset($ldapRecord[$attribute])) { |
|
1623 | + if (isset($ldapRecord[$attribute])) { |
|
1624 | 1624 | $this->connection->$uuidAttr = $attribute; |
1625 | 1625 | return true; |
1626 | 1626 | } else { |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | $value = $this->readAttribute($dn, $attribute); |
1632 | - if(is_array($value) && isset($value[0]) && !empty($value[0])) { |
|
1632 | + if (is_array($value) && isset($value[0]) && !empty($value[0])) { |
|
1633 | 1633 | \OCP\Util::writeLog( |
1634 | 1634 | 'user_ldap', |
1635 | 1635 | 'Setting '.$attribute.' as '.$uuidAttr, |
@@ -1655,7 +1655,7 @@ discard block |
||
1655 | 1655 | * @return bool|string |
1656 | 1656 | */ |
1657 | 1657 | public function getUUID($dn, $isUser = true, $ldapRecord = null) { |
1658 | - if($isUser) { |
|
1658 | + if ($isUser) { |
|
1659 | 1659 | $uuidAttr = 'ldapUuidUserAttribute'; |
1660 | 1660 | $uuidOverride = $this->connection->ldapExpertUUIDUserAttr; |
1661 | 1661 | } else { |
@@ -1664,10 +1664,10 @@ discard block |
||
1664 | 1664 | } |
1665 | 1665 | |
1666 | 1666 | $uuid = false; |
1667 | - if($this->detectUuidAttribute($dn, $isUser, false, $ldapRecord)) { |
|
1667 | + if ($this->detectUuidAttribute($dn, $isUser, false, $ldapRecord)) { |
|
1668 | 1668 | $attr = $this->connection->$uuidAttr; |
1669 | 1669 | $uuid = isset($ldapRecord[$attr]) ? $ldapRecord[$attr] : $this->readAttribute($dn, $attr); |
1670 | - if( !is_array($uuid) |
|
1670 | + if (!is_array($uuid) |
|
1671 | 1671 | && $uuidOverride !== '' |
1672 | 1672 | && $this->detectUuidAttribute($dn, $isUser, true, $ldapRecord)) |
1673 | 1673 | { |
@@ -1675,7 +1675,7 @@ discard block |
||
1675 | 1675 | ? $ldapRecord[$this->connection->$uuidAttr] |
1676 | 1676 | : $this->readAttribute($dn, $this->connection->$uuidAttr); |
1677 | 1677 | } |
1678 | - if(is_array($uuid) && isset($uuid[0]) && !empty($uuid[0])) { |
|
1678 | + if (is_array($uuid) && isset($uuid[0]) && !empty($uuid[0])) { |
|
1679 | 1679 | $uuid = $uuid[0]; |
1680 | 1680 | } |
1681 | 1681 | } |
@@ -1692,19 +1692,19 @@ discard block |
||
1692 | 1692 | private function convertObjectGUID2Str($oguid) { |
1693 | 1693 | $hex_guid = bin2hex($oguid); |
1694 | 1694 | $hex_guid_to_guid_str = ''; |
1695 | - for($k = 1; $k <= 4; ++$k) { |
|
1695 | + for ($k = 1; $k <= 4; ++$k) { |
|
1696 | 1696 | $hex_guid_to_guid_str .= substr($hex_guid, 8 - 2 * $k, 2); |
1697 | 1697 | } |
1698 | 1698 | $hex_guid_to_guid_str .= '-'; |
1699 | - for($k = 1; $k <= 2; ++$k) { |
|
1699 | + for ($k = 1; $k <= 2; ++$k) { |
|
1700 | 1700 | $hex_guid_to_guid_str .= substr($hex_guid, 12 - 2 * $k, 2); |
1701 | 1701 | } |
1702 | 1702 | $hex_guid_to_guid_str .= '-'; |
1703 | - for($k = 1; $k <= 2; ++$k) { |
|
1703 | + for ($k = 1; $k <= 2; ++$k) { |
|
1704 | 1704 | $hex_guid_to_guid_str .= substr($hex_guid, 16 - 2 * $k, 2); |
1705 | 1705 | } |
1706 | - $hex_guid_to_guid_str .= '-' . substr($hex_guid, 16, 4); |
|
1707 | - $hex_guid_to_guid_str .= '-' . substr($hex_guid, 20); |
|
1706 | + $hex_guid_to_guid_str .= '-'.substr($hex_guid, 16, 4); |
|
1707 | + $hex_guid_to_guid_str .= '-'.substr($hex_guid, 20); |
|
1708 | 1708 | |
1709 | 1709 | return strtoupper($hex_guid_to_guid_str); |
1710 | 1710 | } |
@@ -1721,11 +1721,11 @@ discard block |
||
1721 | 1721 | * @return string |
1722 | 1722 | */ |
1723 | 1723 | public function formatGuid2ForFilterUser($guid) { |
1724 | - if(!is_string($guid)) { |
|
1724 | + if (!is_string($guid)) { |
|
1725 | 1725 | throw new \InvalidArgumentException('String expected'); |
1726 | 1726 | } |
1727 | 1727 | $blocks = explode('-', $guid); |
1728 | - if(count($blocks) !== 5) { |
|
1728 | + if (count($blocks) !== 5) { |
|
1729 | 1729 | /* |
1730 | 1730 | * Why not throw an Exception instead? This method is a utility |
1731 | 1731 | * called only when trying to figure out whether a "missing" known |
@@ -1738,20 +1738,20 @@ discard block |
||
1738 | 1738 | * user. Instead we write a log message. |
1739 | 1739 | */ |
1740 | 1740 | \OC::$server->getLogger()->info( |
1741 | - 'Passed string does not resemble a valid GUID. Known UUID ' . |
|
1741 | + 'Passed string does not resemble a valid GUID. Known UUID '. |
|
1742 | 1742 | '({uuid}) probably does not match UUID configuration.', |
1743 | - [ 'app' => 'user_ldap', 'uuid' => $guid ] |
|
1743 | + ['app' => 'user_ldap', 'uuid' => $guid] |
|
1744 | 1744 | ); |
1745 | 1745 | return $guid; |
1746 | 1746 | } |
1747 | - for($i=0; $i < 3; $i++) { |
|
1747 | + for ($i = 0; $i < 3; $i++) { |
|
1748 | 1748 | $pairs = str_split($blocks[$i], 2); |
1749 | 1749 | $pairs = array_reverse($pairs); |
1750 | 1750 | $blocks[$i] = implode('', $pairs); |
1751 | 1751 | } |
1752 | - for($i=0; $i < 5; $i++) { |
|
1752 | + for ($i = 0; $i < 5; $i++) { |
|
1753 | 1753 | $pairs = str_split($blocks[$i], 2); |
1754 | - $blocks[$i] = '\\' . implode('\\', $pairs); |
|
1754 | + $blocks[$i] = '\\'.implode('\\', $pairs); |
|
1755 | 1755 | } |
1756 | 1756 | return implode('', $blocks); |
1757 | 1757 | } |
@@ -1765,12 +1765,12 @@ discard block |
||
1765 | 1765 | $domainDN = $this->getDomainDNFromDN($dn); |
1766 | 1766 | $cacheKey = 'getSID-'.$domainDN; |
1767 | 1767 | $sid = $this->connection->getFromCache($cacheKey); |
1768 | - if(!is_null($sid)) { |
|
1768 | + if (!is_null($sid)) { |
|
1769 | 1769 | return $sid; |
1770 | 1770 | } |
1771 | 1771 | |
1772 | 1772 | $objectSid = $this->readAttribute($domainDN, 'objectsid'); |
1773 | - if(!is_array($objectSid) || empty($objectSid)) { |
|
1773 | + if (!is_array($objectSid) || empty($objectSid)) { |
|
1774 | 1774 | $this->connection->writeToCache($cacheKey, false); |
1775 | 1775 | return false; |
1776 | 1776 | } |
@@ -1828,12 +1828,12 @@ discard block |
||
1828 | 1828 | $belongsToBase = false; |
1829 | 1829 | $bases = $this->helper->sanitizeDN($bases); |
1830 | 1830 | |
1831 | - foreach($bases as $base) { |
|
1831 | + foreach ($bases as $base) { |
|
1832 | 1832 | $belongsToBase = true; |
1833 | - if(mb_strripos($dn, $base, 0, 'UTF-8') !== (mb_strlen($dn, 'UTF-8')-mb_strlen($base, 'UTF-8'))) { |
|
1833 | + if (mb_strripos($dn, $base, 0, 'UTF-8') !== (mb_strlen($dn, 'UTF-8') - mb_strlen($base, 'UTF-8'))) { |
|
1834 | 1834 | $belongsToBase = false; |
1835 | 1835 | } |
1836 | - if($belongsToBase) { |
|
1836 | + if ($belongsToBase) { |
|
1837 | 1837 | break; |
1838 | 1838 | } |
1839 | 1839 | } |
@@ -1844,7 +1844,7 @@ discard block |
||
1844 | 1844 | * resets a running Paged Search operation |
1845 | 1845 | */ |
1846 | 1846 | private function abandonPagedSearch() { |
1847 | - if($this->connection->hasPagedResultSupport) { |
|
1847 | + if ($this->connection->hasPagedResultSupport) { |
|
1848 | 1848 | $cr = $this->connection->getConnectionResource(); |
1849 | 1849 | $this->invokeLDAPMethod('controlPagedResult', $cr, 0, false, $this->lastCookie); |
1850 | 1850 | $this->getPagedSearchResultState(); |
@@ -1862,16 +1862,16 @@ discard block |
||
1862 | 1862 | * @return string containing the key or empty if none is cached |
1863 | 1863 | */ |
1864 | 1864 | private function getPagedResultCookie($base, $filter, $limit, $offset) { |
1865 | - if($offset === 0) { |
|
1865 | + if ($offset === 0) { |
|
1866 | 1866 | return ''; |
1867 | 1867 | } |
1868 | 1868 | $offset -= $limit; |
1869 | 1869 | //we work with cache here |
1870 | - $cacheKey = 'lc' . crc32($base) . '-' . crc32($filter) . '-' . (int)$limit . '-' . (int)$offset; |
|
1870 | + $cacheKey = 'lc'.crc32($base).'-'.crc32($filter).'-'.(int) $limit.'-'.(int) $offset; |
|
1871 | 1871 | $cookie = ''; |
1872 | - if(isset($this->cookies[$cacheKey])) { |
|
1872 | + if (isset($this->cookies[$cacheKey])) { |
|
1873 | 1873 | $cookie = $this->cookies[$cacheKey]; |
1874 | - if(is_null($cookie)) { |
|
1874 | + if (is_null($cookie)) { |
|
1875 | 1875 | $cookie = ''; |
1876 | 1876 | } |
1877 | 1877 | } |
@@ -1889,11 +1889,11 @@ discard block |
||
1889 | 1889 | * @return bool |
1890 | 1890 | */ |
1891 | 1891 | public function hasMoreResults() { |
1892 | - if(!$this->connection->hasPagedResultSupport) { |
|
1892 | + if (!$this->connection->hasPagedResultSupport) { |
|
1893 | 1893 | return false; |
1894 | 1894 | } |
1895 | 1895 | |
1896 | - if(empty($this->lastCookie) && $this->lastCookie !== '0') { |
|
1896 | + if (empty($this->lastCookie) && $this->lastCookie !== '0') { |
|
1897 | 1897 | // as in RFC 2696, when all results are returned, the cookie will |
1898 | 1898 | // be empty. |
1899 | 1899 | return false; |
@@ -1913,8 +1913,8 @@ discard block |
||
1913 | 1913 | */ |
1914 | 1914 | private function setPagedResultCookie($base, $filter, $limit, $offset, $cookie) { |
1915 | 1915 | // allow '0' for 389ds |
1916 | - if(!empty($cookie) || $cookie === '0') { |
|
1917 | - $cacheKey = 'lc' . crc32($base) . '-' . crc32($filter) . '-' . (int)$limit . '-' . (int)$offset; |
|
1916 | + if (!empty($cookie) || $cookie === '0') { |
|
1917 | + $cacheKey = 'lc'.crc32($base).'-'.crc32($filter).'-'.(int) $limit.'-'.(int) $offset; |
|
1918 | 1918 | $this->cookies[$cacheKey] = $cookie; |
1919 | 1919 | $this->lastCookie = $cookie; |
1920 | 1920 | } |
@@ -1941,17 +1941,17 @@ discard block |
||
1941 | 1941 | */ |
1942 | 1942 | private function initPagedSearch($filter, $bases, $attr, $limit, $offset) { |
1943 | 1943 | $pagedSearchOK = false; |
1944 | - if($this->connection->hasPagedResultSupport && ($limit !== 0)) { |
|
1945 | - $offset = (int)$offset; //can be null |
|
1944 | + if ($this->connection->hasPagedResultSupport && ($limit !== 0)) { |
|
1945 | + $offset = (int) $offset; //can be null |
|
1946 | 1946 | \OCP\Util::writeLog('user_ldap', |
1947 | 1947 | 'initializing paged search for Filter '.$filter.' base '.print_r($bases, true) |
1948 | - .' attr '.print_r($attr, true). ' limit ' .$limit.' offset '.$offset, |
|
1948 | + .' attr '.print_r($attr, true).' limit '.$limit.' offset '.$offset, |
|
1949 | 1949 | ILogger::DEBUG); |
1950 | 1950 | //get the cookie from the search for the previous search, required by LDAP |
1951 | - foreach($bases as $base) { |
|
1951 | + foreach ($bases as $base) { |
|
1952 | 1952 | |
1953 | 1953 | $cookie = $this->getPagedResultCookie($base, $filter, $limit, $offset); |
1954 | - if(empty($cookie) && $cookie !== "0" && ($offset > 0)) { |
|
1954 | + if (empty($cookie) && $cookie !== "0" && ($offset > 0)) { |
|
1955 | 1955 | // no cookie known from a potential previous search. We need |
1956 | 1956 | // to start from 0 to come to the desired page. cookie value |
1957 | 1957 | // of '0' is valid, because 389ds |
@@ -1961,17 +1961,17 @@ discard block |
||
1961 | 1961 | //still no cookie? obviously, the server does not like us. Let's skip paging efforts. |
1962 | 1962 | // '0' is valid, because 389ds |
1963 | 1963 | //TODO: remember this, probably does not change in the next request... |
1964 | - if(empty($cookie) && $cookie !== '0') { |
|
1964 | + if (empty($cookie) && $cookie !== '0') { |
|
1965 | 1965 | $cookie = null; |
1966 | 1966 | } |
1967 | 1967 | } |
1968 | - if(!is_null($cookie)) { |
|
1968 | + if (!is_null($cookie)) { |
|
1969 | 1969 | //since offset = 0, this is a new search. We abandon other searches that might be ongoing. |
1970 | 1970 | $this->abandonPagedSearch(); |
1971 | 1971 | $pagedSearchOK = $this->invokeLDAPMethod('controlPagedResult', |
1972 | 1972 | $this->connection->getConnectionResource(), $limit, |
1973 | 1973 | false, $cookie); |
1974 | - if(!$pagedSearchOK) { |
|
1974 | + if (!$pagedSearchOK) { |
|
1975 | 1975 | return false; |
1976 | 1976 | } |
1977 | 1977 | \OCP\Util::writeLog('user_ldap', 'Ready for a paged search', ILogger::DEBUG); |
@@ -1987,14 +1987,14 @@ discard block |
||
1987 | 1987 | * So we added "&& !empty($this->lastCookie)" to this test to ignore pagination |
1988 | 1988 | * if we don't have a previous paged search. |
1989 | 1989 | */ |
1990 | - } else if($this->connection->hasPagedResultSupport && $limit === 0 && !empty($this->lastCookie)) { |
|
1990 | + } else if ($this->connection->hasPagedResultSupport && $limit === 0 && !empty($this->lastCookie)) { |
|
1991 | 1991 | // a search without limit was requested. However, if we do use |
1992 | 1992 | // Paged Search once, we always must do it. This requires us to |
1993 | 1993 | // initialize it with the configured page size. |
1994 | 1994 | $this->abandonPagedSearch(); |
1995 | 1995 | // in case someone set it to 0 … use 500, otherwise no results will |
1996 | 1996 | // be returned. |
1997 | - $pageSize = (int)$this->connection->ldapPagingSize > 0 ? (int)$this->connection->ldapPagingSize : 500; |
|
1997 | + $pageSize = (int) $this->connection->ldapPagingSize > 0 ? (int) $this->connection->ldapPagingSize : 500; |
|
1998 | 1998 | $pagedSearchOK = $this->invokeLDAPMethod('controlPagedResult', |
1999 | 1999 | $this->connection->getConnectionResource(), |
2000 | 2000 | $pageSize, false, ''); |
@@ -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,20 +495,20 @@ 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 | $quota = false; |
503 | - if(is_null($valueFromLDAP)) { |
|
503 | + if (is_null($valueFromLDAP)) { |
|
504 | 504 | $quotaAttribute = $this->connection->ldapQuotaAttribute; |
505 | 505 | if ($quotaAttribute !== '') { |
506 | 506 | $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute); |
507 | - if($aQuota && (count($aQuota) > 0)) { |
|
507 | + if ($aQuota && (count($aQuota) > 0)) { |
|
508 | 508 | if ($this->verifyQuotaValue($aQuota[0])) { |
509 | 509 | $quota = $aQuota[0]; |
510 | 510 | } else { |
511 | - $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::WARN); |
|
511 | + $this->log->log('not suitable LDAP quota found for user '.$this->uid.': ['.$aQuota[0].']', ILogger::WARN); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | } |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | if ($this->verifyQuotaValue($valueFromLDAP)) { |
517 | 517 | $quota = $valueFromLDAP; |
518 | 518 | } else { |
519 | - $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::WARN); |
|
519 | + $this->log->log('not suitable LDAP quota found for user '.$this->uid.': ['.$valueFromLDAP.']', ILogger::WARN); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
@@ -530,13 +530,13 @@ discard block |
||
530 | 530 | |
531 | 531 | $targetUser = $this->userManager->get($this->uid); |
532 | 532 | if ($targetUser) { |
533 | - if($quota !== false) { |
|
533 | + if ($quota !== false) { |
|
534 | 534 | $targetUser->setQuota($quota); |
535 | 535 | } else { |
536 | - $this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::WARN); |
|
536 | + $this->log->log('not suitable default quota found for user '.$this->uid.': ['.$defaultQuota.']', ILogger::WARN); |
|
537 | 537 | } |
538 | 538 | } else { |
539 | - $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::ERROR); |
|
539 | + $this->log->log('trying to set a quota for user '.$this->uid.' but the user is missing', ILogger::ERROR); |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @param array $params |
551 | 551 | */ |
552 | 552 | public function updateAvatarPostLogin($params) { |
553 | - if(isset($params['uid']) && $params['uid'] === $this->getUsername()) { |
|
553 | + if (isset($params['uid']) && $params['uid'] === $this->getUsername()) { |
|
554 | 554 | $this->updateAvatar(); |
555 | 555 | } |
556 | 556 | } |
@@ -560,11 +560,11 @@ discard block |
||
560 | 560 | * @return null |
561 | 561 | */ |
562 | 562 | public function updateAvatar() { |
563 | - if($this->wasRefreshed('avatar')) { |
|
563 | + if ($this->wasRefreshed('avatar')) { |
|
564 | 564 | return; |
565 | 565 | } |
566 | 566 | $avatarImage = $this->getAvatarImage(); |
567 | - if($avatarImage === false) { |
|
567 | + if ($avatarImage === false) { |
|
568 | 568 | //not set, nothing left to do; |
569 | 569 | return; |
570 | 570 | } |
@@ -577,18 +577,18 @@ discard block |
||
577 | 577 | * @return null |
578 | 578 | */ |
579 | 579 | private function setOwnCloudAvatar() { |
580 | - if(!$this->image->valid()) { |
|
580 | + if (!$this->image->valid()) { |
|
581 | 581 | $this->log->log('jpegPhoto data invalid for '.$this->dn, ILogger::ERROR); |
582 | 582 | return; |
583 | 583 | } |
584 | 584 | //make sure it is a square and not bigger than 128x128 |
585 | 585 | $size = min(array($this->image->width(), $this->image->height(), 128)); |
586 | - if(!$this->image->centerCrop($size)) { |
|
586 | + if (!$this->image->centerCrop($size)) { |
|
587 | 587 | $this->log->log('croping image for avatar failed for '.$this->dn, ILogger::ERROR); |
588 | 588 | return; |
589 | 589 | } |
590 | 590 | |
591 | - if(!$this->fs->isLoaded()) { |
|
591 | + if (!$this->fs->isLoaded()) { |
|
592 | 592 | $this->fs->setup($this->uid); |
593 | 593 | } |
594 | 594 | |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | $avatar->set($this->image); |
598 | 598 | } catch (\Exception $e) { |
599 | 599 | \OC::$server->getLogger()->logException($e, [ |
600 | - 'message' => 'Could not set avatar for ' . $this->dn, |
|
600 | + 'message' => 'Could not set avatar for '.$this->dn, |
|
601 | 601 | 'level' => ILogger::INFO, |
602 | 602 | 'app' => 'user_ldap', |
603 | 603 | ]); |
@@ -611,18 +611,18 @@ discard block |
||
611 | 611 | */ |
612 | 612 | public function handlePasswordExpiry($params) { |
613 | 613 | $ppolicyDN = $this->connection->ldapDefaultPPolicyDN; |
614 | - if (empty($ppolicyDN) || ((int)$this->connection->turnOnPasswordChange !== 1)) { |
|
615 | - return;//password expiry handling disabled |
|
614 | + if (empty($ppolicyDN) || ((int) $this->connection->turnOnPasswordChange !== 1)) { |
|
615 | + return; //password expiry handling disabled |
|
616 | 616 | } |
617 | 617 | $uid = $params['uid']; |
618 | - if(isset($uid) && $uid === $this->getUsername()) { |
|
618 | + if (isset($uid) && $uid === $this->getUsername()) { |
|
619 | 619 | //retrieve relevant user attributes |
620 | 620 | $result = $this->access->search('objectclass=*', $this->dn, ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']); |
621 | 621 | |
622 | - if(array_key_exists('pwdpolicysubentry', $result[0])) { |
|
622 | + if (array_key_exists('pwdpolicysubentry', $result[0])) { |
|
623 | 623 | $pwdPolicySubentry = $result[0]['pwdpolicysubentry']; |
624 | - if($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)){ |
|
625 | - $ppolicyDN = $pwdPolicySubentry[0];//custom ppolicy DN |
|
624 | + if ($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)) { |
|
625 | + $ppolicyDN = $pwdPolicySubentry[0]; //custom ppolicy DN |
|
626 | 626 | } |
627 | 627 | } |
628 | 628 | |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | $pwdChangedTime = array_key_exists('pwdchangedtime', $result[0]) ? $result[0]['pwdchangedtime'] : null; |
632 | 632 | |
633 | 633 | //retrieve relevant password policy attributes |
634 | - $cacheKey = 'ppolicyAttributes' . $ppolicyDN; |
|
634 | + $cacheKey = 'ppolicyAttributes'.$ppolicyDN; |
|
635 | 635 | $result = $this->connection->getFromCache($cacheKey); |
636 | - if(is_null($result)) { |
|
636 | + if (is_null($result)) { |
|
637 | 637 | $result = $this->access->search('objectclass=*', $ppolicyDN, ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']); |
638 | 638 | $this->connection->writeToCache($cacheKey, $result); |
639 | 639 | } |
@@ -644,10 +644,10 @@ discard block |
||
644 | 644 | |
645 | 645 | //handle grace login |
646 | 646 | $pwdGraceUseTimeCount = count($pwdGraceUseTime); |
647 | - if($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login? |
|
648 | - if($pwdGraceAuthNLimit |
|
647 | + if ($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login? |
|
648 | + if ($pwdGraceAuthNLimit |
|
649 | 649 | && (count($pwdGraceAuthNLimit) > 0) |
650 | - &&($pwdGraceUseTimeCount < (int)$pwdGraceAuthNLimit[0])) { //at least one more grace login available? |
|
650 | + &&($pwdGraceUseTimeCount < (int) $pwdGraceAuthNLimit[0])) { //at least one more grace login available? |
|
651 | 651 | $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); |
652 | 652 | header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( |
653 | 653 | 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid))); |
@@ -658,24 +658,24 @@ discard block |
||
658 | 658 | exit(); |
659 | 659 | } |
660 | 660 | //handle pwdReset attribute |
661 | - if($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password |
|
661 | + if ($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password |
|
662 | 662 | $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); |
663 | 663 | header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( |
664 | 664 | 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid))); |
665 | 665 | exit(); |
666 | 666 | } |
667 | 667 | //handle password expiry warning |
668 | - if($pwdChangedTime && (count($pwdChangedTime) > 0)) { |
|
669 | - if($pwdMaxAge && (count($pwdMaxAge) > 0) |
|
668 | + if ($pwdChangedTime && (count($pwdChangedTime) > 0)) { |
|
669 | + if ($pwdMaxAge && (count($pwdMaxAge) > 0) |
|
670 | 670 | && $pwdExpireWarning && (count($pwdExpireWarning) > 0)) { |
671 | - $pwdMaxAgeInt = (int)$pwdMaxAge[0]; |
|
672 | - $pwdExpireWarningInt = (int)$pwdExpireWarning[0]; |
|
673 | - if($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0){ |
|
671 | + $pwdMaxAgeInt = (int) $pwdMaxAge[0]; |
|
672 | + $pwdExpireWarningInt = (int) $pwdExpireWarning[0]; |
|
673 | + if ($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0) { |
|
674 | 674 | $pwdChangedTimeDt = \DateTime::createFromFormat('YmdHisZ', $pwdChangedTime[0]); |
675 | 675 | $pwdChangedTimeDt->add(new \DateInterval('PT'.$pwdMaxAgeInt.'S')); |
676 | 676 | $currentDateTime = new \DateTime(); |
677 | 677 | $secondsToExpiry = $pwdChangedTimeDt->getTimestamp() - $currentDateTime->getTimestamp(); |
678 | - if($secondsToExpiry <= $pwdExpireWarningInt) { |
|
678 | + if ($secondsToExpiry <= $pwdExpireWarningInt) { |
|
679 | 679 | //remove last password expiry warning if any |
680 | 680 | $notification = $this->notificationManager->createNotification(); |
681 | 681 | $notification->setApp('user_ldap') |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $owner = isset($_POST['owner']) ? $_POST['owner'] : null; |
136 | 136 | $sharedBy = isset($_POST['sharedBy']) ? $_POST['sharedBy'] : null; |
137 | 137 | $shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null; |
138 | - $remoteId = isset($_POST['remoteId']) ? (int)$_POST['remoteId'] : null; |
|
138 | + $remoteId = isset($_POST['remoteId']) ? (int) $_POST['remoteId'] : null; |
|
139 | 139 | $sharedByFederatedId = isset($_POST['sharedByFederatedId']) ? $_POST['sharedByFederatedId'] : null; |
140 | 140 | $ownerFederatedId = isset($_POST['ownerFederatedId']) ? $_POST['ownerFederatedId'] : null; |
141 | 141 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | // FIXME this should be a method in the user management instead |
149 | - $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
149 | + $this->logger->debug('shareWith before, '.$shareWith, ['app' => 'files_sharing']); |
|
150 | 150 | \OCP\Util::emitHook( |
151 | 151 | '\OCA\Files_Sharing\API\Server2Server', |
152 | 152 | 'preLoginNameUsedAsUserName', |
153 | 153 | array('uid' => &$shareWith) |
154 | 154 | ); |
155 | - $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
155 | + $this->logger->debug('shareWith after, '.$shareWith, ['app' => 'files_sharing']); |
|
156 | 156 | |
157 | 157 | if (!\OC::$server->getUserManager()->userExists($shareWith)) { |
158 | 158 | throw new OCSException('User does not exists', 400); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | ->setType('remote_share') |
189 | 189 | ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
190 | 190 | ->setAffectedUser($shareWith) |
191 | - ->setObject('remote_share', (int)$shareId, $name); |
|
191 | + ->setObject('remote_share', (int) $shareId, $name); |
|
192 | 192 | \OC::$server->getActivityManager()->publish($event); |
193 | 193 | |
194 | 194 | $urlGenerator = \OC::$server->getURLGenerator(); |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | |
204 | 204 | $declineAction = $notification->createAction(); |
205 | 205 | $declineAction->setLabel('decline') |
206 | - ->setLink($urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
206 | + ->setLink($urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'DELETE'); |
|
207 | 207 | $notification->addAction($declineAction); |
208 | 208 | |
209 | 209 | $acceptAction = $notification->createAction(); |
210 | 210 | $acceptAction->setLabel('accept') |
211 | - ->setLink($urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
211 | + ->setLink($urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'POST'); |
|
212 | 212 | $notification->addAction($acceptAction); |
213 | 213 | |
214 | 214 | $notificationManager->notify($notification); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | 'level' => ILogger::ERROR, |
221 | 221 | 'app' => 'files_sharing' |
222 | 222 | ]); |
223 | - throw new OCSException('internal server error, was not able to add share from ' . $remote, 500); |
|
223 | + throw new OCSException('internal server error, was not able to add share from '.$remote, 500); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | |
244 | 244 | $token = $this->request->getParam('token', null); |
245 | 245 | $shareWith = $this->request->getParam('shareWith', null); |
246 | - $permission = (int)$this->request->getParam('permission', null); |
|
247 | - $remoteId = (int)$this->request->getParam('remoteId', null); |
|
246 | + $permission = (int) $this->request->getParam('permission', null); |
|
247 | + $remoteId = (int) $this->request->getParam('remoteId', null); |
|
248 | 248 | |
249 | 249 | if ($id === null || |
250 | 250 | $token === null || |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $share->setSharedWith($shareWith); |
280 | 280 | try { |
281 | 281 | $result = $this->federatedShareProvider->create($share); |
282 | - $this->federatedShareProvider->storeRemoteId((int)$result->getId(), $remoteId); |
|
282 | + $this->federatedShareProvider->storeRemoteId((int) $result->getId(), $remoteId); |
|
283 | 283 | return new Http\DataResponse([ |
284 | 284 | 'token' => $result->getToken(), |
285 | 285 | 'remoteId' => $result->getId() |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $notification = $notificationManager->createNotification(); |
478 | 478 | $notification->setApp('files_sharing') |
479 | 479 | ->setUser($share['user']) |
480 | - ->setObject('remote_share', (int)$share['id']); |
|
480 | + ->setObject('remote_share', (int) $share['id']); |
|
481 | 481 | $notificationManager->markProcessed($notification); |
482 | 482 | |
483 | 483 | $event = \OC::$server->getActivityManager()->generateEvent(); |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | ->setType('remote_share') |
486 | 486 | ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path]) |
487 | 487 | ->setAffectedUser($user) |
488 | - ->setObject('remote_share', (int)$share['id'], $path); |
|
488 | + ->setObject('remote_share', (int) $share['id'], $path); |
|
489 | 489 | \OC::$server->getActivityManager()->publish($event); |
490 | 490 | } |
491 | 491 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | $validPermission = ctype_digit($permissions); |
628 | 628 | $validToken = $this->verifyShare($share, $token); |
629 | 629 | if ($validPermission && $validToken) { |
630 | - $this->updatePermissionsInDatabase($share, (int)$permissions); |
|
630 | + $this->updatePermissionsInDatabase($share, (int) $permissions); |
|
631 | 631 | } else { |
632 | 632 | throw new OCSBadRequestException(); |
633 | 633 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $this->recoveryKeyId = $this->config->getAppValue('encryption', |
129 | 129 | 'recoveryKeyId'); |
130 | 130 | if (empty($this->recoveryKeyId)) { |
131 | - $this->recoveryKeyId = 'recoveryKey_' . substr(md5(time()), 0, 8); |
|
131 | + $this->recoveryKeyId = 'recoveryKey_'.substr(md5(time()), 0, 8); |
|
132 | 132 | $this->config->setAppValue('encryption', |
133 | 133 | 'recoveryKeyId', |
134 | 134 | $this->recoveryKeyId); |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | $this->publicShareKeyId = $this->config->getAppValue('encryption', |
138 | 138 | 'publicShareKeyId'); |
139 | 139 | if (empty($this->publicShareKeyId)) { |
140 | - $this->publicShareKeyId = 'pubShare_' . substr(md5(time()), 0, 8); |
|
140 | + $this->publicShareKeyId = 'pubShare_'.substr(md5(time()), 0, 8); |
|
141 | 141 | $this->config->setAppValue('encryption', 'publicShareKeyId', $this->publicShareKeyId); |
142 | 142 | } |
143 | 143 | |
144 | 144 | $this->masterKeyId = $this->config->getAppValue('encryption', |
145 | 145 | 'masterKeyId'); |
146 | 146 | if (empty($this->masterKeyId)) { |
147 | - $this->masterKeyId = 'master_' . substr(md5(time()), 0, 8); |
|
147 | + $this->masterKeyId = 'master_'.substr(md5(time()), 0, 8); |
|
148 | 148 | $this->config->setAppValue('encryption', 'masterKeyId', $this->masterKeyId); |
149 | 149 | } |
150 | 150 | |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | |
163 | 163 | // Save public key |
164 | 164 | $this->keyStorage->setSystemUserKey( |
165 | - $this->publicShareKeyId . '.publicKey', $keyPair['publicKey'], |
|
165 | + $this->publicShareKeyId.'.publicKey', $keyPair['publicKey'], |
|
166 | 166 | Encryption::ID); |
167 | 167 | |
168 | 168 | // Encrypt private key empty passphrase |
169 | 169 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], ''); |
170 | 170 | $header = $this->crypt->generateHeader(); |
171 | - $this->setSystemPrivateKey($this->publicShareKeyId, $header . $encryptedKey); |
|
171 | + $this->setSystemPrivateKey($this->publicShareKeyId, $header.$encryptedKey); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | |
188 | 188 | // Save public key |
189 | 189 | $this->keyStorage->setSystemUserKey( |
190 | - $this->masterKeyId . '.publicKey', $keyPair['publicKey'], |
|
190 | + $this->masterKeyId.'.publicKey', $keyPair['publicKey'], |
|
191 | 191 | Encryption::ID); |
192 | 192 | |
193 | 193 | // Encrypt private key with system password |
194 | 194 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $this->getMasterKeyPassword(), $this->masterKeyId); |
195 | 195 | $header = $this->crypt->generateHeader(); |
196 | - $this->setSystemPrivateKey($this->masterKeyId, $header . $encryptedKey); |
|
196 | + $this->setSystemPrivateKey($this->masterKeyId, $header.$encryptedKey); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | if (!$this->session->isPrivateKeySet()) { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return string |
221 | 221 | */ |
222 | 222 | public function getRecoveryKey() { |
223 | - return $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.publicKey', Encryption::ID); |
|
223 | + return $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.publicKey', Encryption::ID); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @return bool |
238 | 238 | */ |
239 | 239 | public function checkRecoveryPassword($password) { |
240 | - $recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.privateKey', Encryption::ID); |
|
240 | + $recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.privateKey', Encryption::ID); |
|
241 | 241 | $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $password); |
242 | 242 | |
243 | 243 | if ($decryptedRecoveryKey) { |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $header = $this->crypt->generateHeader(); |
262 | 262 | |
263 | 263 | if ($encryptedKey) { |
264 | - $this->setPrivateKey($uid, $header . $encryptedKey); |
|
264 | + $this->setPrivateKey($uid, $header.$encryptedKey); |
|
265 | 265 | return true; |
266 | 266 | } |
267 | 267 | return false; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $header = $this->crypt->generateHeader(); |
284 | 284 | |
285 | 285 | if ($encryptedKey) { |
286 | - $this->setSystemPrivateKey($this->getRecoveryKeyId(), $header . $encryptedKey); |
|
286 | + $this->setSystemPrivateKey($this->getRecoveryKeyId(), $header.$encryptedKey); |
|
287 | 287 | return true; |
288 | 288 | } |
289 | 289 | return false; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @return boolean |
344 | 344 | */ |
345 | 345 | public function setShareKey($path, $uid, $key) { |
346 | - $keyId = $uid . '.' . $this->shareKeyId; |
|
346 | + $keyId = $uid.'.'.$this->shareKeyId; |
|
347 | 347 | return $this->keyStorage->setFileKey($path, $keyId, $key, Encryption::ID); |
348 | 348 | } |
349 | 349 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $this->session->setStatus(Session::INIT_EXECUTED); |
360 | 360 | |
361 | 361 | try { |
362 | - if($this->util->isMasterKeyEnabled()) { |
|
362 | + if ($this->util->isMasterKeyEnabled()) { |
|
363 | 363 | $uid = $this->getMasterKeyId(); |
364 | 364 | $passPhrase = $this->getMasterKeyPassword(); |
365 | 365 | $privateKey = $this->getSystemPrivateKey($uid); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | return false; |
374 | 374 | } catch (\Exception $e) { |
375 | 375 | $this->log->logException($e, [ |
376 | - 'message' => 'Could not decrypt the private key from user "' . $uid . '"" during login. Assume password change on the user back-end.', |
|
376 | + 'message' => 'Could not decrypt the private key from user "'.$uid.'"" during login. Assume password change on the user back-end.', |
|
377 | 377 | 'level' => ILogger::WARN, |
378 | 378 | 'app' => 'encryption', |
379 | 379 | ]); |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | // use public share key for public links |
435 | 435 | $uid = $this->getPublicShareKeyId(); |
436 | 436 | $shareKey = $this->getShareKey($path, $uid); |
437 | - $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.privateKey', Encryption::ID); |
|
437 | + $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.privateKey', Encryption::ID); |
|
438 | 438 | $privateKey = $this->crypt->decryptPrivateKey($privateKey); |
439 | 439 | } else { |
440 | 440 | $shareKey = $this->getShareKey($path, $uid); |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function getVersion($path, View $view) { |
461 | 461 | $fileInfo = $view->getFileInfo($path); |
462 | - if($fileInfo === false) { |
|
462 | + if ($fileInfo === false) { |
|
463 | 463 | return 0; |
464 | 464 | } |
465 | 465 | return $fileInfo->getEncryptedVersion(); |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | * @param View $view |
474 | 474 | */ |
475 | 475 | public function setVersion($path, $version, View $view) { |
476 | - $fileInfo= $view->getFileInfo($path); |
|
476 | + $fileInfo = $view->getFileInfo($path); |
|
477 | 477 | |
478 | - if($fileInfo !== false) { |
|
478 | + if ($fileInfo !== false) { |
|
479 | 479 | $cache = $fileInfo->getStorage()->getCache(); |
480 | 480 | $cache->update($fileInfo->getId(), ['encrypted' => $version, 'encryptedVersion' => $version]); |
481 | 481 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | public function deleteShareKey($path, $keyId) { |
505 | 505 | return $this->keyStorage->deleteFileKey( |
506 | 506 | $path, |
507 | - $keyId . '.' . $this->shareKeyId, |
|
507 | + $keyId.'.'.$this->shareKeyId, |
|
508 | 508 | Encryption::ID); |
509 | 509 | } |
510 | 510 | |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @return mixed |
516 | 516 | */ |
517 | 517 | public function getShareKey($path, $uid) { |
518 | - $keyId = $uid . '.' . $this->shareKeyId; |
|
518 | + $keyId = $uid.'.'.$this->shareKeyId; |
|
519 | 519 | return $this->keyStorage->getFileKey($path, $keyId, Encryption::ID); |
520 | 520 | } |
521 | 521 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @return string |
578 | 578 | */ |
579 | 579 | public function getPublicShareKey() { |
580 | - return $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.publicKey', Encryption::ID); |
|
580 | + return $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.publicKey', Encryption::ID); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | * @return string returns openssl key |
648 | 648 | */ |
649 | 649 | public function getSystemPrivateKey($keyId) { |
650 | - return $this->keyStorage->getSystemUserKey($keyId . '.' . $this->privateKeyId, Encryption::ID); |
|
650 | + return $this->keyStorage->getSystemUserKey($keyId.'.'.$this->privateKeyId, Encryption::ID); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | */ |
658 | 658 | public function setSystemPrivateKey($keyId, $key) { |
659 | 659 | return $this->keyStorage->setSystemUserKey( |
660 | - $keyId . '.' . $this->privateKeyId, |
|
660 | + $keyId.'.'.$this->privateKeyId, |
|
661 | 661 | $key, |
662 | 662 | Encryption::ID); |
663 | 663 | } |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | */ |
698 | 698 | public function getMasterKeyPassword() { |
699 | 699 | $password = $this->config->getSystemValue('secret'); |
700 | - if (empty($password)){ |
|
700 | + if (empty($password)) { |
|
701 | 701 | throw new \Exception('Can not get secret from Nextcloud instance'); |
702 | 702 | } |
703 | 703 | |
@@ -719,6 +719,6 @@ discard block |
||
719 | 719 | * @return string |
720 | 720 | */ |
721 | 721 | public function getPublicMasterKey() { |
722 | - return $this->keyStorage->getSystemUserKey($this->masterKeyId . '.publicKey', Encryption::ID); |
|
722 | + return $this->keyStorage->getSystemUserKey($this->masterKeyId.'.publicKey', Encryption::ID); |
|
723 | 723 | } |
724 | 724 | } |
@@ -101,24 +101,24 @@ discard block |
||
101 | 101 | * Remove "apps/" from inclusion path for smooth migration to multi app dir |
102 | 102 | */ |
103 | 103 | if (strpos(\OC::$CLASSPATH[$class], 'apps/') === 0) { |
104 | - \OCP\Util::writeLog('core', 'include path for class "' . $class . '" starts with "apps/"', ILogger::DEBUG); |
|
104 | + \OCP\Util::writeLog('core', 'include path for class "'.$class.'" starts with "apps/"', ILogger::DEBUG); |
|
105 | 105 | $paths[] = str_replace('apps/', '', \OC::$CLASSPATH[$class]); |
106 | 106 | } |
107 | 107 | } elseif (strpos($class, 'OC_') === 0) { |
108 | - $paths[] = \OC::$SERVERROOT . '/lib/private/legacy/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php'); |
|
108 | + $paths[] = \OC::$SERVERROOT.'/lib/private/legacy/'.strtolower(str_replace('_', '/', substr($class, 3)).'.php'); |
|
109 | 109 | } elseif (strpos($class, 'OCA\\') === 0) { |
110 | 110 | list(, $app, $rest) = explode('\\', $class, 3); |
111 | 111 | $app = strtolower($app); |
112 | 112 | $appPath = \OC_App::getAppPath($app); |
113 | 113 | if ($appPath && stream_resolve_include_path($appPath)) { |
114 | - $paths[] = $appPath . '/' . strtolower(str_replace('\\', '/', $rest) . '.php'); |
|
114 | + $paths[] = $appPath.'/'.strtolower(str_replace('\\', '/', $rest).'.php'); |
|
115 | 115 | // If not found in the root of the app directory, insert '/lib' after app id and try again. |
116 | - $paths[] = $appPath . '/lib/' . strtolower(str_replace('\\', '/', $rest) . '.php'); |
|
116 | + $paths[] = $appPath.'/lib/'.strtolower(str_replace('\\', '/', $rest).'.php'); |
|
117 | 117 | } |
118 | 118 | } elseif ($class === 'Test\\TestCase') { |
119 | 119 | // This File is considered public API, so we make sure that the class |
120 | 120 | // can still be loaded, although the PSR-4 paths have not been loaded. |
121 | - $paths[] = \OC::$SERVERROOT . '/tests/lib/TestCase.php'; |
|
121 | + $paths[] = \OC::$SERVERROOT.'/tests/lib/TestCase.php'; |
|
122 | 122 | } |
123 | 123 | return $paths; |
124 | 124 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | protected function isValidPath(string $fullPath): bool { |
132 | 132 | foreach ($this->validRoots as $root => $true) { |
133 | - if (substr($fullPath, 0, strlen($root) + 1) === $root . '/') { |
|
133 | + if (substr($fullPath, 0, strlen($root) + 1) === $root.'/') { |
|
134 | 134 | return true; |
135 | 135 | } |
136 | 136 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $pathsToRequire = $this->memoryCache->get($class); |
151 | 151 | } |
152 | 152 | |
153 | - if(class_exists($class, false)) { |
|
153 | + if (class_exists($class, false)) { |
|
154 | 154 | return false; |
155 | 155 | } |
156 | 156 |