Completed
Push — master ( 39468f...49d871 )
by Björn
14:59
created
apps/files_external/lib/Lib/Storage/Google.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 				if (isset($this->driveFiles[$path])) {
124 124
 					$parentId = $this->driveFiles[$path]->getId();
125 125
 				} else {
126
-					$q = "title='" . str_replace("'","\\'", $name) . "' and '" . str_replace("'","\\'", $parentId) . "' in parents and trashed = false";
126
+					$q = "title='".str_replace("'", "\\'", $name)."' and '".str_replace("'", "\\'", $parentId)."' in parents and trashed = false";
127 127
 					$result = $this->service->files->listFiles(array('q' => $q))->getItems();
128 128
 					if (!empty($result)) {
129 129
 						// Google Drive allows files with the same name, Nextcloud doesn't
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 				if ($result) {
237 237
 					$this->setDriveFile($path, $result);
238 238
 				}
239
-				return (bool)$result;
239
+				return (bool) $result;
240 240
 			}
241 241
 		}
242 242
 		return false;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		}
249 249
 		if (trim($path, '/') === '') {
250 250
 			$dir = $this->opendir($path);
251
-			if(is_resource($dir)) {
251
+			if (is_resource($dir)) {
252 252
 				while (($file = readdir($dir)) !== false) {
253 253
 					if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
254 254
 						if (!$this->unlink($path.'/'.$file)) {
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 				if ($pageToken !== true) {
277 277
 					$params['pageToken'] = $pageToken;
278 278
 				}
279
-				$params['q'] = "'" . str_replace("'","\\'", $folder->getId()) . "' in parents and trashed = false";
279
+				$params['q'] = "'".str_replace("'", "\\'", $folder->getId())."' in parents and trashed = false";
280 280
 				$children = $this->service->files->listFiles($params);
281 281
 				foreach ($children->getItems() as $child) {
282 282
 					$name = $child->getTitle();
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	}
370 370
 
371 371
 	public function file_exists($path) {
372
-		return (bool)$this->getDriveFile($path);
372
+		return (bool) $this->getDriveFile($path);
373 373
 	}
374 374
 
375 375
 	public function unlink($path) {
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 			if ($result) {
380 380
 				$this->setDriveFile($path, false);
381 381
 			}
382
-			return (bool)$result;
382
+			return (bool) $result;
383 383
 		} else {
384 384
 			return false;
385 385
 		}
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 					}
428 428
 				}
429 429
 			}
430
-			return (bool)$result;
430
+			return (bool) $result;
431 431
 		} else {
432 432
 			return false;
433 433
 		}
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
 							$response = $client->get($downloadUrl, [
463 463
 								'headers' => $httpRequest->getRequestHeaders(),
464 464
 								'stream' => true,
465
-								'verify' => realpath(__DIR__ . '/../../../3rdparty/google-api-php-client/src/Google/IO/cacerts.pem'),
465
+								'verify' => realpath(__DIR__.'/../../../3rdparty/google-api-php-client/src/Google/IO/cacerts.pem'),
466 466
 							]);
467 467
 						} catch (RequestException $e) {
468
-							if(!is_null($e->getResponse())) {
468
+							if (!is_null($e->getResponse())) {
469 469
 								if ($e->getResponse()->getStatusCode() === 404) {
470 470
 									return false;
471 471
 								} else {
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 					file_put_contents($tmpFile, $source);
500 500
 				}
501 501
 				$handle = fopen($tmpFile, $mode);
502
-				return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
502
+				return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) {
503 503
 					$this->writeBack($tmpFile, $path);
504 504
 				});
505 505
 		}
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 		if ($result) {
642 642
 			$this->setDriveFile($path, $result);
643 643
 		}
644
-		return (bool)$result;
644
+		return (bool) $result;
645 645
 	}
646 646
 
647 647
 	public function test() {
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 					'includeSubscribed' => true,
669 669
 				);
670 670
 				if (isset($startChangeId)) {
671
-					$startChangeId = (int)$startChangeId;
671
+					$startChangeId = (int) $startChangeId;
672 672
 					$largestChangeId = $startChangeId;
673 673
 					$params['startChangeId'] = $startChangeId + 1;
674 674
 				} else {
Please login to merge, or discard this patch.
apps/encryption/lib/KeyManager.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		$this->recoveryKeyId = $this->config->getAppValue('encryption',
127 127
 			'recoveryKeyId');
128 128
 		if (empty($this->recoveryKeyId)) {
129
-			$this->recoveryKeyId = 'recoveryKey_' . substr(md5(time()), 0, 8);
129
+			$this->recoveryKeyId = 'recoveryKey_'.substr(md5(time()), 0, 8);
130 130
 			$this->config->setAppValue('encryption',
131 131
 				'recoveryKeyId',
132 132
 				$this->recoveryKeyId);
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 		$this->publicShareKeyId = $this->config->getAppValue('encryption',
136 136
 			'publicShareKeyId');
137 137
 		if (empty($this->publicShareKeyId)) {
138
-			$this->publicShareKeyId = 'pubShare_' . substr(md5(time()), 0, 8);
138
+			$this->publicShareKeyId = 'pubShare_'.substr(md5(time()), 0, 8);
139 139
 			$this->config->setAppValue('encryption', 'publicShareKeyId', $this->publicShareKeyId);
140 140
 		}
141 141
 
142 142
 		$this->masterKeyId = $this->config->getAppValue('encryption',
143 143
 			'masterKeyId');
144 144
 		if (empty($this->masterKeyId)) {
145
-			$this->masterKeyId = 'master_' . substr(md5(time()), 0, 8);
145
+			$this->masterKeyId = 'master_'.substr(md5(time()), 0, 8);
146 146
 			$this->config->setAppValue('encryption', 'masterKeyId', $this->masterKeyId);
147 147
 		}
148 148
 
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
 
161 161
 			// Save public key
162 162
 			$this->keyStorage->setSystemUserKey(
163
-				$this->publicShareKeyId . '.publicKey', $keyPair['publicKey'],
163
+				$this->publicShareKeyId.'.publicKey', $keyPair['publicKey'],
164 164
 				Encryption::ID);
165 165
 
166 166
 			// Encrypt private key empty passphrase
167 167
 			$encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], '');
168 168
 			$header = $this->crypt->generateHeader();
169
-			$this->setSystemPrivateKey($this->publicShareKeyId, $header . $encryptedKey);
169
+			$this->setSystemPrivateKey($this->publicShareKeyId, $header.$encryptedKey);
170 170
 		}
171 171
 	}
172 172
 
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 
186 186
 			// Save public key
187 187
 			$this->keyStorage->setSystemUserKey(
188
-				$this->masterKeyId . '.publicKey', $keyPair['publicKey'],
188
+				$this->masterKeyId.'.publicKey', $keyPair['publicKey'],
189 189
 				Encryption::ID);
190 190
 
191 191
 			// Encrypt private key with system password
192 192
 			$encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $this->getMasterKeyPassword(), $this->masterKeyId);
193 193
 			$header = $this->crypt->generateHeader();
194
-			$this->setSystemPrivateKey($this->masterKeyId, $header . $encryptedKey);
194
+			$this->setSystemPrivateKey($this->masterKeyId, $header.$encryptedKey);
195 195
 		}
196 196
 	}
197 197
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @return string
210 210
 	 */
211 211
 	public function getRecoveryKey() {
212
-		return $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.publicKey', Encryption::ID);
212
+		return $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.publicKey', Encryption::ID);
213 213
 	}
214 214
 
215 215
 	/**
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @return bool
227 227
 	 */
228 228
 	public function checkRecoveryPassword($password) {
229
-		$recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.privateKey', Encryption::ID);
229
+		$recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.privateKey', Encryption::ID);
230 230
 		$decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $password);
231 231
 
232 232
 		if ($decryptedRecoveryKey) {
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		$header = $this->crypt->generateHeader();
251 251
 
252 252
 		if ($encryptedKey) {
253
-			$this->setPrivateKey($uid, $header . $encryptedKey);
253
+			$this->setPrivateKey($uid, $header.$encryptedKey);
254 254
 			return true;
255 255
 		}
256 256
 		return false;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		$header = $this->crypt->generateHeader();
273 273
 
274 274
 		if ($encryptedKey) {
275
-			$this->setSystemPrivateKey($this->getRecoveryKeyId(), $header . $encryptedKey);
275
+			$this->setSystemPrivateKey($this->getRecoveryKeyId(), $header.$encryptedKey);
276 276
 			return true;
277 277
 		}
278 278
 		return false;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	 * @return boolean
333 333
 	 */
334 334
 	public function setShareKey($path, $uid, $key) {
335
-		$keyId = $uid . '.' . $this->shareKeyId;
335
+		$keyId = $uid.'.'.$this->shareKeyId;
336 336
 		return $this->keyStorage->setFileKey($path, $keyId, $key, Encryption::ID);
337 337
 	}
338 338
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 		$this->session->setStatus(Session::INIT_EXECUTED);
349 349
 
350 350
 		try {
351
-			if($this->util->isMasterKeyEnabled()) {
351
+			if ($this->util->isMasterKeyEnabled()) {
352 352
 				$uid = $this->getMasterKeyId();
353 353
 				$passPhrase = $this->getMasterKeyPassword();
354 354
 				$privateKey = $this->getSystemPrivateKey($uid);
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 			return false;
363 363
 		} catch (\Exception $e) {
364 364
 			$this->log->warning(
365
-				'Could not decrypt the private key from user "' . $uid . '"" during login. ' .
365
+				'Could not decrypt the private key from user "'.$uid.'"" during login. '.
366 366
 				'Assume password change on the user back-end. Error message: '
367 367
 				. $e->getMessage()
368 368
 			);
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 			// use public share key for public links
424 424
 			$uid = $this->getPublicShareKeyId();
425 425
 			$shareKey = $this->getShareKey($path, $uid);
426
-			$privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.privateKey', Encryption::ID);
426
+			$privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.privateKey', Encryption::ID);
427 427
 			$privateKey = $this->crypt->decryptPrivateKey($privateKey);
428 428
 		} else {
429 429
 			$shareKey = $this->getShareKey($path, $uid);
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	 */
449 449
 	public function getVersion($path, View $view) {
450 450
 		$fileInfo = $view->getFileInfo($path);
451
-		if($fileInfo === false) {
451
+		if ($fileInfo === false) {
452 452
 			return 0;
453 453
 		}
454 454
 		return $fileInfo->getEncryptedVersion();
@@ -462,9 +462,9 @@  discard block
 block discarded – undo
462 462
 	 * @param View $view
463 463
 	 */
464 464
 	public function setVersion($path, $version, View $view) {
465
-		$fileInfo= $view->getFileInfo($path);
465
+		$fileInfo = $view->getFileInfo($path);
466 466
 
467
-		if($fileInfo !== false) {
467
+		if ($fileInfo !== false) {
468 468
 			$cache = $fileInfo->getStorage()->getCache();
469 469
 			$cache->update($fileInfo->getId(), ['encrypted' => $version, 'encryptedVersion' => $version]);
470 470
 		}
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	public function deleteShareKey($path, $keyId) {
494 494
 		return $this->keyStorage->deleteFileKey(
495 495
 			$path,
496
-			$keyId . '.' . $this->shareKeyId,
496
+			$keyId.'.'.$this->shareKeyId,
497 497
 			Encryption::ID);
498 498
 	}
499 499
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 	 * @return mixed
505 505
 	 */
506 506
 	public function getShareKey($path, $uid) {
507
-		$keyId = $uid . '.' . $this->shareKeyId;
507
+		$keyId = $uid.'.'.$this->shareKeyId;
508 508
 		return $this->keyStorage->getFileKey($path, $keyId, Encryption::ID);
509 509
 	}
510 510
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 * @return string
567 567
 	 */
568 568
 	public function getPublicShareKey() {
569
-		return $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.publicKey', Encryption::ID);
569
+		return $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.publicKey', Encryption::ID);
570 570
 	}
571 571
 
572 572
 	/**
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 	 * @return string returns openssl key
637 637
 	 */
638 638
 	public function getSystemPrivateKey($keyId) {
639
-		return $this->keyStorage->getSystemUserKey($keyId . '.' . $this->privateKeyId, Encryption::ID);
639
+		return $this->keyStorage->getSystemUserKey($keyId.'.'.$this->privateKeyId, Encryption::ID);
640 640
 	}
641 641
 
642 642
 	/**
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 	 */
647 647
 	public function setSystemPrivateKey($keyId, $key) {
648 648
 		return $this->keyStorage->setSystemUserKey(
649
-			$keyId . '.' . $this->privateKeyId,
649
+			$keyId.'.'.$this->privateKeyId,
650 650
 			$key,
651 651
 			Encryption::ID);
652 652
 	}
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 	 */
687 687
 	public function getMasterKeyPassword() {
688 688
 		$password = $this->config->getSystemValue('secret');
689
-		if (empty($password)){
689
+		if (empty($password)) {
690 690
 			throw new \Exception('Can not get secret from Nextcloud instance');
691 691
 		}
692 692
 
@@ -708,6 +708,6 @@  discard block
 block discarded – undo
708 708
 	 * @return string
709 709
 	 */
710 710
 	public function getPublicMasterKey() {
711
-		return $this->keyStorage->getSystemUserKey($this->masterKeyId . '.publicKey', Encryption::ID);
711
+		return $this->keyStorage->getSystemUserKey($this->masterKeyId.'.publicKey', Encryption::ID);
712 712
 	}
713 713
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Auth.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	private function requiresCSRFCheck() {
172 172
 		// GET requires no check at all
173
-		if($this->request->getMethod() === 'GET') {
173
+		if ($this->request->getMethod() === 'GET') {
174 174
 			return false;
175 175
 		}
176 176
 
177 177
 		// Official Nextcloud clients require no checks
178
-		if($this->request->isUserAgent([
178
+		if ($this->request->isUserAgent([
179 179
 			IRequest::USER_AGENT_CLIENT_DESKTOP,
180 180
 			IRequest::USER_AGENT_CLIENT_ANDROID,
181 181
 			IRequest::USER_AGENT_CLIENT_IOS,
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 		}
185 185
 
186 186
 		// If not logged-in no check is required
187
-		if(!$this->userSession->isLoggedIn()) {
187
+		if (!$this->userSession->isLoggedIn()) {
188 188
 			return false;
189 189
 		}
190 190
 
191 191
 		// POST always requires a check
192
-		if($this->request->getMethod() === 'POST') {
192
+		if ($this->request->getMethod() === 'POST') {
193 193
 			return true;
194 194
 		}
195 195
 
196 196
 		// If logged-in AND DAV authenticated no check is required
197
-		if($this->userSession->isLoggedIn() &&
197
+		if ($this->userSession->isLoggedIn() &&
198 198
 			$this->isDavAuthenticated($this->userSession->getUser()->getUID())) {
199 199
 			return false;
200 200
 		}
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	private function auth(RequestInterface $request, ResponseInterface $response) {
212 212
 		$forcedLogout = false;
213
-		if(!$this->request->passesCSRFCheck() &&
213
+		if (!$this->request->passesCSRFCheck() &&
214 214
 			$this->requiresCSRFCheck()) {
215 215
 			// In case of a fail with POST we need to recheck the credentials
216
-			if($this->request->getMethod() === 'POST') {
216
+			if ($this->request->getMethod() === 'POST') {
217 217
 				$forcedLogout = true;
218 218
 			} else {
219 219
 				$response->setStatus(401);
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 			}
222 222
 		}
223 223
 
224
-		if($forcedLogout) {
224
+		if ($forcedLogout) {
225 225
 			$this->userSession->logout();
226 226
 		} else {
227
-			if($this->twoFactorManager->needsSecondFactor($this->userSession->getUser())) {
227
+			if ($this->twoFactorManager->needsSecondFactor($this->userSession->getUser())) {
228 228
 				throw new \Sabre\DAV\Exception\NotAuthenticated('2FA challenge not passed.');
229 229
 			}
230 230
 			if (\OC_User::handleApacheAuth() ||
@@ -237,19 +237,19 @@  discard block
 block discarded – undo
237 237
 				\OC_Util::setupFS($user);
238 238
 				$this->currentUser = $user;
239 239
 				$this->session->close();
240
-				return [true, $this->principalPrefix . $user];
240
+				return [true, $this->principalPrefix.$user];
241 241
 			}
242 242
 		}
243 243
 
244 244
 		if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With')))) {
245 245
 			// do not re-authenticate over ajax, use dummy auth name to prevent browser popup
246
-			$response->addHeader('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"');
246
+			$response->addHeader('WWW-Authenticate', 'DummyBasic realm="'.$this->realm.'"');
247 247
 			$response->setStatus(401);
248 248
 			throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls');
249 249
 		}
250 250
 
251 251
 		$data = parent::check($request, $response);
252
-		if($data[0] === true) {
252
+		if ($data[0] === true) {
253 253
 			$startPos = strrpos($data[1], '/') + 1;
254 254
 			$user = $this->userSession->getUser()->getUID();
255 255
 			$data[1] = substr_replace($data[1], $user, $startPos);
Please login to merge, or discard this patch.
apps/user_ldap/lib/Access.php 1 patch
Spacing   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @return AbstractMapping
111 111
 	 */
112 112
 	public function getUserMapper() {
113
-		if(is_null($this->userMapper)) {
113
+		if (is_null($this->userMapper)) {
114 114
 			throw new \Exception('UserMapper was not assigned to this Access instance.');
115 115
 		}
116 116
 		return $this->userMapper;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @return AbstractMapping
131 131
 	 */
132 132
 	public function getGroupMapper() {
133
-		if(is_null($this->groupMapper)) {
133
+		if (is_null($this->groupMapper)) {
134 134
 			throw new \Exception('GroupMapper was not assigned to this Access instance.');
135 135
 		}
136 136
 		return $this->groupMapper;
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
 	 *          array if $attr is empty, false otherwise
162 162
 	 */
163 163
 	public function readAttribute($dn, $attr, $filter = 'objectClass=*') {
164
-		if(!$this->checkConnection()) {
164
+		if (!$this->checkConnection()) {
165 165
 			\OCP\Util::writeLog('user_ldap',
166 166
 				'No LDAP Connector assigned, access impossible for readAttribute.',
167 167
 				\OCP\Util::WARN);
168 168
 			return false;
169 169
 		}
170 170
 		$cr = $this->connection->getConnectionResource();
171
-		if(!$this->ldap->isResource($cr)) {
171
+		if (!$this->ldap->isResource($cr)) {
172 172
 			//LDAP not available
173 173
 			\OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', \OCP\Util::DEBUG);
174 174
 			return false;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		$isRangeRequest = false;
192 192
 		do {
193 193
 			$result = $this->executeRead($cr, $dn, $attrToRead, $filter, $maxResults);
194
-			if(is_bool($result)) {
194
+			if (is_bool($result)) {
195 195
 				// when an exists request was run and it was successful, an empty
196 196
 				// array must be returned
197 197
 				return $result ? [] : false;
@@ -208,22 +208,22 @@  discard block
 block discarded – undo
208 208
 			$result = $this->extractRangeData($result, $attr);
209 209
 			if (!empty($result)) {
210 210
 				$normalizedResult = $this->extractAttributeValuesFromResult(
211
-					[ $attr => $result['values'] ],
211
+					[$attr => $result['values']],
212 212
 					$attr
213 213
 				);
214 214
 				$values = array_merge($values, $normalizedResult);
215 215
 
216
-				if($result['rangeHigh'] === '*') {
216
+				if ($result['rangeHigh'] === '*') {
217 217
 					// when server replies with * as high range value, there are
218 218
 					// no more results left
219 219
 					return $values;
220 220
 				} else {
221
-					$low  = $result['rangeHigh'] + 1;
222
-					$attrToRead = $result['attributeName'] . ';range=' . $low . '-*';
221
+					$low = $result['rangeHigh'] + 1;
222
+					$attrToRead = $result['attributeName'].';range='.$low.'-*';
223 223
 					$isRangeRequest = true;
224 224
 				}
225 225
 			}
226
-		} while($isRangeRequest);
226
+		} while ($isRangeRequest);
227 227
 
228 228
 		\OCP\Util::writeLog('user_ldap', 'Requested attribute '.$attr.' not found for '.$dn, \OCP\Util::DEBUG);
229 229
 		return false;
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
 		if (!$this->ldap->isResource($rr)) {
249 249
 			if ($attribute !== '') {
250 250
 				//do not throw this message on userExists check, irritates
251
-				\OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN ' . $dn, \OCP\Util::DEBUG);
251
+				\OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN '.$dn, \OCP\Util::DEBUG);
252 252
 			}
253 253
 			//in case an error occurs , e.g. object does not exist
254 254
 			return false;
255 255
 		}
256 256
 		if ($attribute === '' && ($filter === 'objectclass=*' || $this->ldap->countEntries($cr, $rr) === 1)) {
257
-			\OCP\Util::writeLog('user_ldap', 'readAttribute: ' . $dn . ' found', \OCP\Util::DEBUG);
257
+			\OCP\Util::writeLog('user_ldap', 'readAttribute: '.$dn.' found', \OCP\Util::DEBUG);
258 258
 			return true;
259 259
 		}
260 260
 		$er = $this->ldap->firstEntry($cr, $rr);
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public function extractAttributeValuesFromResult($result, $attribute) {
281 281
 		$values = [];
282
-		if(isset($result[$attribute]) && $result[$attribute]['count'] > 0) {
282
+		if (isset($result[$attribute]) && $result[$attribute]['count'] > 0) {
283 283
 			$lowercaseAttribute = strtolower($attribute);
284
-			for($i=0;$i<$result[$attribute]['count'];$i++) {
285
-				if($this->resemblesDN($attribute)) {
284
+			for ($i = 0; $i < $result[$attribute]['count']; $i++) {
285
+				if ($this->resemblesDN($attribute)) {
286 286
 					$values[] = $this->helper->sanitizeDN($result[$attribute][$i]);
287
-				} elseif($lowercaseAttribute === 'objectguid' || $lowercaseAttribute === 'guid') {
287
+				} elseif ($lowercaseAttribute === 'objectguid' || $lowercaseAttribute === 'guid') {
288 288
 					$values[] = $this->convertObjectGUID2Str($result[$attribute][$i]);
289 289
 				} else {
290 290
 					$values[] = $result[$attribute][$i];
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
 	 */
307 307
 	public function extractRangeData($result, $attribute) {
308 308
 		$keys = array_keys($result);
309
-		foreach($keys as $key) {
310
-			if($key !== $attribute && strpos($key, $attribute) === 0) {
309
+		foreach ($keys as $key) {
310
+			if ($key !== $attribute && strpos($key, $attribute) === 0) {
311 311
 				$queryData = explode(';', $key);
312
-				if(strpos($queryData[1], 'range=') === 0) {
312
+				if (strpos($queryData[1], 'range=') === 0) {
313 313
 					$high = substr($queryData[1], 1 + strpos($queryData[1], '-'));
314 314
 					$data = [
315 315
 						'values' => $result[$key],
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
 	 * @throws \Exception
335 335
 	 */
336 336
 	public function setPassword($userDN, $password) {
337
-		if(intval($this->connection->turnOnPasswordChange) !== 1) {
337
+		if (intval($this->connection->turnOnPasswordChange) !== 1) {
338 338
 			throw new \Exception('LDAP password changes are disabled.');
339 339
 		}
340 340
 		$cr = $this->connection->getConnectionResource();
341
-		if(!$this->ldap->isResource($cr)) {
341
+		if (!$this->ldap->isResource($cr)) {
342 342
 			//LDAP not available
343 343
 			\OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', \OCP\Util::DEBUG);
344 344
 			return false;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 		
347 347
 		try {
348 348
 			return $this->ldap->modReplace($cr, $userDN, $password);
349
-		} catch(ConstraintViolationException $e) {
349
+		} catch (ConstraintViolationException $e) {
350 350
 			throw new HintException('Password change rejected.', \OC::$server->getL10N('user_ldap')->t('Password change rejected. Hint: ').$e->getMessage(), $e->getCode());
351 351
 		}
352 352
 	}
@@ -388,17 +388,17 @@  discard block
 block discarded – undo
388 388
 	 */
389 389
 	public function getDomainDNFromDN($dn) {
390 390
 		$allParts = $this->ldap->explodeDN($dn, 0);
391
-		if($allParts === false) {
391
+		if ($allParts === false) {
392 392
 			//not a valid DN
393 393
 			return '';
394 394
 		}
395 395
 		$domainParts = array();
396 396
 		$dcFound = false;
397
-		foreach($allParts as $part) {
398
-			if(!$dcFound && strpos($part, 'dc=') === 0) {
397
+		foreach ($allParts as $part) {
398
+			if (!$dcFound && strpos($part, 'dc=') === 0) {
399 399
 				$dcFound = true;
400 400
 			}
401
-			if($dcFound) {
401
+			if ($dcFound) {
402 402
 				$domainParts[] = $part;
403 403
 			}
404 404
 		}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 
426 426
 		//Check whether the DN belongs to the Base, to avoid issues on multi-
427 427
 		//server setups
428
-		if(is_string($fdn) && $this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) {
428
+		if (is_string($fdn) && $this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) {
429 429
 			return $fdn;
430 430
 		}
431 431
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 		//To avoid bypassing the base DN settings under certain circumstances
443 443
 		//with the group support, check whether the provided DN matches one of
444 444
 		//the given Bases
445
-		if(!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseGroups)) {
445
+		if (!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseGroups)) {
446 446
 			return false;
447 447
 		}
448 448
 
@@ -459,11 +459,11 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	public function groupsMatchFilter($groupDNs) {
461 461
 		$validGroupDNs = [];
462
-		foreach($groupDNs as $dn) {
462
+		foreach ($groupDNs as $dn) {
463 463
 			$cacheKey = 'groupsMatchFilter-'.$dn;
464 464
 			$groupMatchFilter = $this->connection->getFromCache($cacheKey);
465
-			if(!is_null($groupMatchFilter)) {
466
-				if($groupMatchFilter) {
465
+			if (!is_null($groupMatchFilter)) {
466
+				if ($groupMatchFilter) {
467 467
 					$validGroupDNs[] = $dn;
468 468
 				}
469 469
 				continue;
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 
472 472
 			// Check the base DN first. If this is not met already, we don't
473 473
 			// need to ask the server at all.
474
-			if(!$this->isDNPartOfBase($dn, $this->connection->ldapBaseGroups)) {
474
+			if (!$this->isDNPartOfBase($dn, $this->connection->ldapBaseGroups)) {
475 475
 				$this->connection->writeToCache($cacheKey, false);
476 476
 				continue;
477 477
 			}
478 478
 
479 479
 			$result = $this->readAttribute($dn, 'cn', $this->connection->ldapGroupFilter);
480
-			if(is_array($result)) {
480
+			if (is_array($result)) {
481 481
 				$this->connection->writeToCache($cacheKey, true);
482 482
 				$validGroupDNs[] = $dn;
483 483
 			} else {
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 		//To avoid bypassing the base DN settings under certain circumstances
499 499
 		//with the group support, check whether the provided DN matches one of
500 500
 		//the given Bases
501
-		if(!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) {
501
+		if (!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) {
502 502
 			return false;
503 503
 		}
504 504
 
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 	 * @return string|false with with the name to use in Nextcloud
514 514
 	 */
515 515
 	public function dn2ocname($fdn, $ldapName = null, $isUser = true) {
516
-		if($isUser) {
516
+		if ($isUser) {
517 517
 			$mapper = $this->getUserMapper();
518 518
 			$nameAttribute = $this->connection->ldapUserDisplayName;
519 519
 		} else {
@@ -523,15 +523,15 @@  discard block
 block discarded – undo
523 523
 
524 524
 		//let's try to retrieve the Nextcloud name from the mappings table
525 525
 		$ocName = $mapper->getNameByDN($fdn);
526
-		if(is_string($ocName)) {
526
+		if (is_string($ocName)) {
527 527
 			return $ocName;
528 528
 		}
529 529
 
530 530
 		//second try: get the UUID and check if it is known. Then, update the DN and return the name.
531 531
 		$uuid = $this->getUUID($fdn, $isUser);
532
-		if(is_string($uuid)) {
532
+		if (is_string($uuid)) {
533 533
 			$ocName = $mapper->getNameByUUID($uuid);
534
-			if(is_string($ocName)) {
534
+			if (is_string($ocName)) {
535 535
 				$mapper->setDNbyUUID($fdn, $uuid);
536 536
 				return $ocName;
537 537
 			}
@@ -541,16 +541,16 @@  discard block
 block discarded – undo
541 541
 			return false;
542 542
 		}
543 543
 
544
-		if(is_null($ldapName)) {
544
+		if (is_null($ldapName)) {
545 545
 			$ldapName = $this->readAttribute($fdn, $nameAttribute);
546
-			if(!isset($ldapName[0]) && empty($ldapName[0])) {
546
+			if (!isset($ldapName[0]) && empty($ldapName[0])) {
547 547
 				\OCP\Util::writeLog('user_ldap', 'No or empty name for '.$fdn.'.', \OCP\Util::INFO);
548 548
 				return false;
549 549
 			}
550 550
 			$ldapName = $ldapName[0];
551 551
 		}
552 552
 
553
-		if($isUser) {
553
+		if ($isUser) {
554 554
 			$usernameAttribute = strval($this->connection->ldapExpertUsernameAttr);
555 555
 			if ($usernameAttribute !== '') {
556 556
 				$username = $this->readAttribute($fdn, $usernameAttribute);
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
 		// outside of core user management will still cache the user as non-existing.
570 570
 		$originalTTL = $this->connection->ldapCacheTTL;
571 571
 		$this->connection->setConfiguration(array('ldapCacheTTL' => 0));
572
-		if(($isUser && !\OCP\User::userExists($intName))
572
+		if (($isUser && !\OCP\User::userExists($intName))
573 573
 			|| (!$isUser && !\OC::$server->getGroupManager()->groupExists($intName))) {
574
-			if($mapper->map($fdn, $intName, $uuid)) {
574
+			if ($mapper->map($fdn, $intName, $uuid)) {
575 575
 				$this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL));
576 576
 				return $intName;
577 577
 			}
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 		$this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL));
580 580
 
581 581
 		$altName = $this->createAltInternalOwnCloudName($intName, $isUser);
582
-		if(is_string($altName) && $mapper->map($fdn, $altName, $uuid)) {
582
+		if (is_string($altName) && $mapper->map($fdn, $altName, $uuid)) {
583 583
 			return $altName;
584 584
 		}
585 585
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 	 * @return array
617 617
 	 */
618 618
 	private function ldap2ownCloudNames($ldapObjects, $isUsers) {
619
-		if($isUsers) {
619
+		if ($isUsers) {
620 620
 			$nameAttribute = $this->connection->ldapUserDisplayName;
621 621
 			$sndAttribute  = $this->connection->ldapUserDisplayName2;
622 622
 		} else {
@@ -624,9 +624,9 @@  discard block
 block discarded – undo
624 624
 		}
625 625
 		$ownCloudNames = array();
626 626
 
627
-		foreach($ldapObjects as $ldapObject) {
627
+		foreach ($ldapObjects as $ldapObject) {
628 628
 			$nameByLDAP = null;
629
-			if(    isset($ldapObject[$nameAttribute])
629
+			if (isset($ldapObject[$nameAttribute])
630 630
 				&& is_array($ldapObject[$nameAttribute])
631 631
 				&& isset($ldapObject[$nameAttribute][0])
632 632
 			) {
@@ -635,12 +635,12 @@  discard block
 block discarded – undo
635 635
 			}
636 636
 
637 637
 			$ocName = $this->dn2ocname($ldapObject['dn'][0], $nameByLDAP, $isUsers);
638
-			if($ocName) {
638
+			if ($ocName) {
639 639
 				$ownCloudNames[] = $ocName;
640
-				if($isUsers) {
640
+				if ($isUsers) {
641 641
 					//cache the user names so it does not need to be retrieved
642 642
 					//again later (e.g. sharing dialogue).
643
-					if(is_null($nameByLDAP)) {
643
+					if (is_null($nameByLDAP)) {
644 644
 						continue;
645 645
 					}
646 646
 					$sndName = isset($ldapObject[$sndAttribute][0])
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 	 */
679 679
 	public function cacheUserDisplayName($ocName, $displayName, $displayName2 = '') {
680 680
 		$user = $this->userManager->get($ocName);
681
-		if($user === null) {
681
+		if ($user === null) {
682 682
 			return;
683 683
 		}
684 684
 		$displayName = $user->composeAndStoreDisplayName($displayName, $displayName2);
@@ -698,9 +698,9 @@  discard block
 block discarded – undo
698 698
 		$attempts = 0;
699 699
 		//while loop is just a precaution. If a name is not generated within
700 700
 		//20 attempts, something else is very wrong. Avoids infinite loop.
701
-		while($attempts < 20){
702
-			$altName = $name . '_' . rand(1000,9999);
703
-			if(!\OCP\User::userExists($altName)) {
701
+		while ($attempts < 20) {
702
+			$altName = $name.'_'.rand(1000, 9999);
703
+			if (!\OCP\User::userExists($altName)) {
704 704
 				return $altName;
705 705
 			}
706 706
 			$attempts++;
@@ -722,25 +722,25 @@  discard block
 block discarded – undo
722 722
 	 */
723 723
 	private function _createAltInternalOwnCloudNameForGroups($name) {
724 724
 		$usedNames = $this->groupMapper->getNamesBySearch($name, "", '_%');
725
-		if(!($usedNames) || count($usedNames) === 0) {
725
+		if (!($usedNames) || count($usedNames) === 0) {
726 726
 			$lastNo = 1; //will become name_2
727 727
 		} else {
728 728
 			natsort($usedNames);
729 729
 			$lastName = array_pop($usedNames);
730 730
 			$lastNo = intval(substr($lastName, strrpos($lastName, '_') + 1));
731 731
 		}
732
-		$altName = $name.'_'.strval($lastNo+1);
732
+		$altName = $name.'_'.strval($lastNo + 1);
733 733
 		unset($usedNames);
734 734
 
735 735
 		$attempts = 1;
736
-		while($attempts < 21){
736
+		while ($attempts < 21) {
737 737
 			// Check to be really sure it is unique
738 738
 			// while loop is just a precaution. If a name is not generated within
739 739
 			// 20 attempts, something else is very wrong. Avoids infinite loop.
740
-			if(!\OC::$server->getGroupManager()->groupExists($altName)) {
740
+			if (!\OC::$server->getGroupManager()->groupExists($altName)) {
741 741
 				return $altName;
742 742
 			}
743
-			$altName = $name . '_' . ($lastNo + $attempts);
743
+			$altName = $name.'_'.($lastNo + $attempts);
744 744
 			$attempts++;
745 745
 		}
746 746
 		return false;
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 	private function createAltInternalOwnCloudName($name, $isUser) {
756 756
 		$originalTTL = $this->connection->ldapCacheTTL;
757 757
 		$this->connection->setConfiguration(array('ldapCacheTTL' => 0));
758
-		if($isUser) {
758
+		if ($isUser) {
759 759
 			$altName = $this->_createAltInternalOwnCloudNameForUsers($name);
760 760
 		} else {
761 761
 			$altName = $this->_createAltInternalOwnCloudNameForGroups($name);
@@ -813,20 +813,20 @@  discard block
 block discarded – undo
813 813
 	 * and their values
814 814
 	 * @param array $ldapRecords
815 815
 	 */
816
-	public function batchApplyUserAttributes(array $ldapRecords){
816
+	public function batchApplyUserAttributes(array $ldapRecords) {
817 817
 		$displayNameAttribute = strtolower($this->connection->ldapUserDisplayName);
818
-		foreach($ldapRecords as $userRecord) {
819
-			if(!isset($userRecord[$displayNameAttribute])) {
818
+		foreach ($ldapRecords as $userRecord) {
819
+			if (!isset($userRecord[$displayNameAttribute])) {
820 820
 				// displayName is obligatory
821 821
 				continue;
822 822
 			}
823
-			$ocName  = $this->dn2ocname($userRecord['dn'][0]);
824
-			if($ocName === false) {
823
+			$ocName = $this->dn2ocname($userRecord['dn'][0]);
824
+			if ($ocName === false) {
825 825
 				continue;
826 826
 			}
827 827
 			$this->cacheUserExists($ocName);
828 828
 			$user = $this->userManager->get($ocName);
829
-			if($user instanceof OfflineUser) {
829
+			if ($user instanceof OfflineUser) {
830 830
 				$user->unmark();
831 831
 				$user = $this->userManager->get($ocName);
832 832
 			}
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @return array
859 859
 	 */
860 860
 	private function fetchList($list, $manyAttributes) {
861
-		if(is_array($list)) {
862
-			if($manyAttributes) {
861
+		if (is_array($list)) {
862
+			if ($manyAttributes) {
863 863
 				return $list;
864 864
 			} else {
865 865
 				$list = array_reduce($list, function($carry, $item) {
@@ -945,13 +945,13 @@  discard block
 block discarded – undo
945 945
 	 * second | false if not successful
946 946
 	 */
947 947
 	private function executeSearch($filter, $base, &$attr = null, $limit = null, $offset = null) {
948
-		if(!is_null($attr) && !is_array($attr)) {
948
+		if (!is_null($attr) && !is_array($attr)) {
949 949
 			$attr = array(mb_strtolower($attr, 'UTF-8'));
950 950
 		}
951 951
 
952 952
 		// See if we have a resource, in case not cancel with message
953 953
 		$cr = $this->connection->getConnectionResource();
954
-		if(!$this->ldap->isResource($cr)) {
954
+		if (!$this->ldap->isResource($cr)) {
955 955
 			// Seems like we didn't find any resource.
956 956
 			// Return an empty array just like before.
957 957
 			\OCP\Util::writeLog('user_ldap', 'Could not search, because resource is missing.', \OCP\Util::DEBUG);
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 		$linkResources = array_pad(array(), count($base), $cr);
965 965
 		$sr = $this->ldap->search($linkResources, $base, $filter, $attr);
966 966
 		$error = $this->ldap->errno($cr);
967
-		if(!is_array($sr) || $error !== 0) {
967
+		if (!is_array($sr) || $error !== 0) {
968 968
 			\OCP\Util::writeLog('user_ldap', 'Attempt for Paging?  '.print_r($pagedSearchOK, true), \OCP\Util::ERROR);
969 969
 			return false;
970 970
 		}
@@ -987,26 +987,26 @@  discard block
 block discarded – undo
987 987
 	 */
988 988
 	private function processPagedSearchStatus($sr, $filter, $base, $iFoundItems, $limit, $offset, $pagedSearchOK, $skipHandling) {
989 989
 		$cookie = null;
990
-		if($pagedSearchOK) {
990
+		if ($pagedSearchOK) {
991 991
 			$cr = $this->connection->getConnectionResource();
992
-			foreach($sr as $key => $res) {
993
-				if($this->ldap->controlPagedResultResponse($cr, $res, $cookie)) {
992
+			foreach ($sr as $key => $res) {
993
+				if ($this->ldap->controlPagedResultResponse($cr, $res, $cookie)) {
994 994
 					$this->setPagedResultCookie($base[$key], $filter, $limit, $offset, $cookie);
995 995
 				}
996 996
 			}
997 997
 
998 998
 			//browsing through prior pages to get the cookie for the new one
999
-			if($skipHandling) {
999
+			if ($skipHandling) {
1000 1000
 				return false;
1001 1001
 			}
1002 1002
 			// if count is bigger, then the server does not support
1003 1003
 			// paged search. Instead, he did a normal search. We set a
1004 1004
 			// flag here, so the callee knows how to deal with it.
1005
-			if($iFoundItems <= $limit) {
1005
+			if ($iFoundItems <= $limit) {
1006 1006
 				$this->pagedSearchedSuccessful = true;
1007 1007
 			}
1008 1008
 		} else {
1009
-			if(!is_null($limit)) {
1009
+			if (!is_null($limit)) {
1010 1010
 				\OCP\Util::writeLog('user_ldap', 'Paged search was not available', \OCP\Util::INFO);
1011 1011
 			}
1012 1012
 		}
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		\OCP\Util::writeLog('user_ldap', 'Count filter:  '.print_r($filter, true), \OCP\Util::DEBUG);
1036 1036
 
1037 1037
 		$limitPerPage = intval($this->connection->ldapPagingSize);
1038
-		if(!is_null($limit) && $limit < $limitPerPage && $limit > 0) {
1038
+		if (!is_null($limit) && $limit < $limitPerPage && $limit > 0) {
1039 1039
 			$limitPerPage = $limit;
1040 1040
 		}
1041 1041
 
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 		do {
1047 1047
 			$search = $this->executeSearch($filter, $base, $attr,
1048 1048
 										   $limitPerPage, $offset);
1049
-			if($search === false) {
1049
+			if ($search === false) {
1050 1050
 				return $counter > 0 ? $counter : false;
1051 1051
 			}
1052 1052
 			list($sr, $pagedSearchOK) = $search;
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 			 * Continue now depends on $hasMorePages value
1066 1066
 			 */
1067 1067
 			$continue = $pagedSearchOK && $hasMorePages;
1068
-		} while($continue && (is_null($limit) || $limit <= 0 || $limit > $counter));
1068
+		} while ($continue && (is_null($limit) || $limit <= 0 || $limit > $counter));
1069 1069
 
1070 1070
 		return $counter;
1071 1071
 	}
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 		$cr = $this->connection->getConnectionResource();
1079 1079
 		$counter = 0;
1080 1080
 
1081
-		foreach($searchResults as $res) {
1081
+		foreach ($searchResults as $res) {
1082 1082
 			$count = intval($this->ldap->countEntries($cr, $res));
1083 1083
 			$counter += $count;
1084 1084
 		}
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 	 * @return array with the search result
1098 1098
 	 */
1099 1099
 	private function search($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) {
1100
-		if($limit <= 0) {
1100
+		if ($limit <= 0) {
1101 1101
 			//otherwise search will fail
1102 1102
 			$limit = null;
1103 1103
 		}
@@ -1112,13 +1112,13 @@  discard block
 block discarded – undo
1112 1112
 		$savedoffset = $offset;
1113 1113
 		do {
1114 1114
 			$search = $this->executeSearch($filter, $base, $attr, $limit, $offset);
1115
-			if($search === false) {
1115
+			if ($search === false) {
1116 1116
 				return array();
1117 1117
 			}
1118 1118
 			list($sr, $pagedSearchOK) = $search;
1119 1119
 			$cr = $this->connection->getConnectionResource();
1120 1120
 
1121
-			if($skipHandling) {
1121
+			if ($skipHandling) {
1122 1122
 				//i.e. result do not need to be fetched, we just need the cookie
1123 1123
 				//thus pass 1 or any other value as $iFoundItems because it is not
1124 1124
 				//used
@@ -1128,8 +1128,8 @@  discard block
 block discarded – undo
1128 1128
 				return array();
1129 1129
 			}
1130 1130
 
1131
-			foreach($sr as $res) {
1132
-				$findings = array_merge($findings, $this->ldap->getEntries($cr	, $res ));
1131
+			foreach ($sr as $res) {
1132
+				$findings = array_merge($findings, $this->ldap->getEntries($cr, $res));
1133 1133
 			}
1134 1134
 
1135 1135
 			$continue = $this->processPagedSearchStatus($sr, $filter, $base, $findings['count'],
@@ -1142,25 +1142,25 @@  discard block
 block discarded – undo
1142 1142
 
1143 1143
 		// if we're here, probably no connection resource is returned.
1144 1144
 		// to make Nextcloud behave nicely, we simply give back an empty array.
1145
-		if(is_null($findings)) {
1145
+		if (is_null($findings)) {
1146 1146
 			return array();
1147 1147
 		}
1148 1148
 
1149
-		if(!is_null($attr)) {
1149
+		if (!is_null($attr)) {
1150 1150
 			$selection = array();
1151 1151
 			$i = 0;
1152
-			foreach($findings as $item) {
1153
-				if(!is_array($item)) {
1152
+			foreach ($findings as $item) {
1153
+				if (!is_array($item)) {
1154 1154
 					continue;
1155 1155
 				}
1156 1156
 				$item = \OCP\Util::mb_array_change_key_case($item, MB_CASE_LOWER, 'UTF-8');
1157
-				foreach($attr as $key) {
1157
+				foreach ($attr as $key) {
1158 1158
 					$key = mb_strtolower($key, 'UTF-8');
1159
-					if(isset($item[$key])) {
1160
-						if(is_array($item[$key]) && isset($item[$key]['count'])) {
1159
+					if (isset($item[$key])) {
1160
+						if (is_array($item[$key]) && isset($item[$key]['count'])) {
1161 1161
 							unset($item[$key]['count']);
1162 1162
 						}
1163
-						if($key !== 'dn') {
1163
+						if ($key !== 'dn') {
1164 1164
 							$selection[$i][$key] = $this->resemblesDN($key) ?
1165 1165
 								$this->helper->sanitizeDN($item[$key])
1166 1166
 								: $item[$key];
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		//we slice the findings, when
1178 1178
 		//a) paged search unsuccessful, though attempted
1179 1179
 		//b) no paged search, but limit set
1180
-		if((!$this->getPagedSearchResultState()
1180
+		if ((!$this->getPagedSearchResultState()
1181 1181
 			&& $pagedSearchOK)
1182 1182
 			|| (
1183 1183
 				!$pagedSearchOK
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
 	 * @return bool|mixed|string
1195 1195
 	 */
1196 1196
 	public function sanitizeUsername($name) {
1197
-		if($this->connection->ldapIgnoreNamingRules) {
1197
+		if ($this->connection->ldapIgnoreNamingRules) {
1198 1198
 			return $name;
1199 1199
 		}
1200 1200
 
@@ -1219,13 +1219,13 @@  discard block
 block discarded – undo
1219 1219
 	*/
1220 1220
 	public function escapeFilterPart($input, $allowAsterisk = false) {
1221 1221
 		$asterisk = '';
1222
-		if($allowAsterisk && strlen($input) > 0 && $input[0] === '*') {
1222
+		if ($allowAsterisk && strlen($input) > 0 && $input[0] === '*') {
1223 1223
 			$asterisk = '*';
1224 1224
 			$input = mb_substr($input, 1, null, 'UTF-8');
1225 1225
 		}
1226 1226
 		$search  = array('*', '\\', '(', ')');
1227 1227
 		$replace = array('\\*', '\\\\', '\\(', '\\)');
1228
-		return $asterisk . str_replace($search, $replace, $input);
1228
+		return $asterisk.str_replace($search, $replace, $input);
1229 1229
 	}
1230 1230
 
1231 1231
 	/**
@@ -1255,13 +1255,13 @@  discard block
 block discarded – undo
1255 1255
 	 */
1256 1256
 	private function combineFilter($filters, $operator) {
1257 1257
 		$combinedFilter = '('.$operator;
1258
-		foreach($filters as $filter) {
1258
+		foreach ($filters as $filter) {
1259 1259
 			if ($filter !== '' && $filter[0] !== '(') {
1260 1260
 				$filter = '('.$filter.')';
1261 1261
 			}
1262
-			$combinedFilter.=$filter;
1262
+			$combinedFilter .= $filter;
1263 1263
 		}
1264
-		$combinedFilter.=')';
1264
+		$combinedFilter .= ')';
1265 1265
 		return $combinedFilter;
1266 1266
 	}
1267 1267
 
@@ -1297,17 +1297,17 @@  discard block
 block discarded – undo
1297 1297
 	 * @throws \Exception
1298 1298
 	 */
1299 1299
 	private function getAdvancedFilterPartForSearch($search, $searchAttributes) {
1300
-		if(!is_array($searchAttributes) || count($searchAttributes) < 2) {
1300
+		if (!is_array($searchAttributes) || count($searchAttributes) < 2) {
1301 1301
 			throw new \Exception('searchAttributes must be an array with at least two string');
1302 1302
 		}
1303 1303
 		$searchWords = explode(' ', trim($search));
1304 1304
 		$wordFilters = array();
1305
-		foreach($searchWords as $word) {
1305
+		foreach ($searchWords as $word) {
1306 1306
 			$word = $this->prepareSearchTerm($word);
1307 1307
 			//every word needs to appear at least once
1308 1308
 			$wordMatchOneAttrFilters = array();
1309
-			foreach($searchAttributes as $attr) {
1310
-				$wordMatchOneAttrFilters[] = $attr . '=' . $word;
1309
+			foreach ($searchAttributes as $attr) {
1310
+				$wordMatchOneAttrFilters[] = $attr.'='.$word;
1311 1311
 			}
1312 1312
 			$wordFilters[] = $this->combineFilterWithOr($wordMatchOneAttrFilters);
1313 1313
 		}
@@ -1325,10 +1325,10 @@  discard block
 block discarded – undo
1325 1325
 	private function getFilterPartForSearch($search, $searchAttributes, $fallbackAttribute) {
1326 1326
 		$filter = array();
1327 1327
 		$haveMultiSearchAttributes = (is_array($searchAttributes) && count($searchAttributes) > 0);
1328
-		if($haveMultiSearchAttributes && strpos(trim($search), ' ') !== false) {
1328
+		if ($haveMultiSearchAttributes && strpos(trim($search), ' ') !== false) {
1329 1329
 			try {
1330 1330
 				return $this->getAdvancedFilterPartForSearch($search, $searchAttributes);
1331
-			} catch(\Exception $e) {
1331
+			} catch (\Exception $e) {
1332 1332
 				\OCP\Util::writeLog(
1333 1333
 					'user_ldap',
1334 1334
 					'Creating advanced filter for search failed, falling back to simple method.',
@@ -1338,17 +1338,17 @@  discard block
 block discarded – undo
1338 1338
 		}
1339 1339
 
1340 1340
 		$search = $this->prepareSearchTerm($search);
1341
-		if(!is_array($searchAttributes) || count($searchAttributes) === 0) {
1341
+		if (!is_array($searchAttributes) || count($searchAttributes) === 0) {
1342 1342
 			if ($fallbackAttribute === '') {
1343 1343
 				return '';
1344 1344
 			}
1345
-			$filter[] = $fallbackAttribute . '=' . $search;
1345
+			$filter[] = $fallbackAttribute.'='.$search;
1346 1346
 		} else {
1347
-			foreach($searchAttributes as $attribute) {
1348
-				$filter[] = $attribute . '=' . $search;
1347
+			foreach ($searchAttributes as $attribute) {
1348
+				$filter[] = $attribute.'='.$search;
1349 1349
 			}
1350 1350
 		}
1351
-		if(count($filter) === 1) {
1351
+		if (count($filter) === 1) {
1352 1352
 			return '('.$filter[0].')';
1353 1353
 		}
1354 1354
 		return $this->combineFilterWithOr($filter);
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
 		if ($term === '') {
1370 1370
 			$result = '*';
1371 1371
 		} else if ($allowEnum !== 'no') {
1372
-			$result = $term . '*';
1372
+			$result = $term.'*';
1373 1373
 		}
1374 1374
 		return $result;
1375 1375
 	}
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 	public function getFilterForUserCount() {
1382 1382
 		$filter = $this->combineFilterWithAnd(array(
1383 1383
 			$this->connection->ldapUserFilter,
1384
-			$this->connection->ldapUserDisplayName . '=*'
1384
+			$this->connection->ldapUserDisplayName.'=*'
1385 1385
 		));
1386 1386
 
1387 1387
 		return $filter;
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
 			'ldapAgentName' => $name,
1400 1400
 			'ldapAgentPassword' => $password
1401 1401
 		);
1402
-		if(!$testConnection->setConfiguration($credentials)) {
1402
+		if (!$testConnection->setConfiguration($credentials)) {
1403 1403
 			return false;
1404 1404
 		}
1405 1405
 		return $testConnection->bind();
@@ -1421,30 +1421,30 @@  discard block
 block discarded – undo
1421 1421
 			// Sacrebleu! The UUID attribute is unknown :( We need first an
1422 1422
 			// existing DN to be able to reliably detect it.
1423 1423
 			$result = $this->search($filter, $base, ['dn'], 1);
1424
-			if(!isset($result[0]) || !isset($result[0]['dn'])) {
1424
+			if (!isset($result[0]) || !isset($result[0]['dn'])) {
1425 1425
 				throw new \Exception('Cannot determine UUID attribute');
1426 1426
 			}
1427 1427
 			$dn = $result[0]['dn'][0];
1428
-			if(!$this->detectUuidAttribute($dn, true)) {
1428
+			if (!$this->detectUuidAttribute($dn, true)) {
1429 1429
 				throw new \Exception('Cannot determine UUID attribute');
1430 1430
 			}
1431 1431
 		} else {
1432 1432
 			// The UUID attribute is either known or an override is given.
1433 1433
 			// By calling this method we ensure that $this->connection->$uuidAttr
1434 1434
 			// is definitely set
1435
-			if(!$this->detectUuidAttribute('', true)) {
1435
+			if (!$this->detectUuidAttribute('', true)) {
1436 1436
 				throw new \Exception('Cannot determine UUID attribute');
1437 1437
 			}
1438 1438
 		}
1439 1439
 
1440 1440
 		$uuidAttr = $this->connection->ldapUuidUserAttribute;
1441
-		if($uuidAttr === 'guid' || $uuidAttr === 'objectguid') {
1441
+		if ($uuidAttr === 'guid' || $uuidAttr === 'objectguid') {
1442 1442
 			$uuid = $this->formatGuid2ForFilterUser($uuid);
1443 1443
 		}
1444 1444
 
1445
-		$filter = $uuidAttr . '=' . $uuid;
1445
+		$filter = $uuidAttr.'='.$uuid;
1446 1446
 		$result = $this->searchUsers($filter, ['dn'], 2);
1447
-		if(is_array($result) && isset($result[0]) && isset($result[0]['dn']) && count($result) === 1) {
1447
+		if (is_array($result) && isset($result[0]) && isset($result[0]['dn']) && count($result) === 1) {
1448 1448
 			// we put the count into account to make sure that this is
1449 1449
 			// really unique
1450 1450
 			return $result[0]['dn'][0];
@@ -1461,7 +1461,7 @@  discard block
 block discarded – undo
1461 1461
 	 * @return bool true on success, false otherwise
1462 1462
 	 */
1463 1463
 	private function detectUuidAttribute($dn, $isUser = true, $force = false) {
1464
-		if($isUser) {
1464
+		if ($isUser) {
1465 1465
 			$uuidAttr     = 'ldapUuidUserAttribute';
1466 1466
 			$uuidOverride = $this->connection->ldapExpertUUIDUserAttr;
1467 1467
 		} else {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 			$uuidOverride = $this->connection->ldapExpertUUIDGroupAttr;
1470 1470
 		}
1471 1471
 
1472
-		if(($this->connection->$uuidAttr !== 'auto') && !$force) {
1472
+		if (($this->connection->$uuidAttr !== 'auto') && !$force) {
1473 1473
 			return true;
1474 1474
 		}
1475 1475
 
@@ -1481,9 +1481,9 @@  discard block
 block discarded – undo
1481 1481
 		// for now, supported attributes are entryUUID, nsuniqueid, objectGUID, ipaUniqueID
1482 1482
 		$testAttributes = array('entryuuid', 'nsuniqueid', 'objectguid', 'guid', 'ipauniqueid');
1483 1483
 
1484
-		foreach($testAttributes as $attribute) {
1484
+		foreach ($testAttributes as $attribute) {
1485 1485
 			$value = $this->readAttribute($dn, $attribute);
1486
-			if(is_array($value) && isset($value[0]) && !empty($value[0])) {
1486
+			if (is_array($value) && isset($value[0]) && !empty($value[0])) {
1487 1487
 				\OCP\Util::writeLog('user_ldap',
1488 1488
 									'Setting '.$attribute.' as '.$uuidAttr,
1489 1489
 									\OCP\Util::DEBUG);
@@ -1504,7 +1504,7 @@  discard block
 block discarded – undo
1504 1504
 	 * @return string|bool
1505 1505
 	 */
1506 1506
 	public function getUUID($dn, $isUser = true) {
1507
-		if($isUser) {
1507
+		if ($isUser) {
1508 1508
 			$uuidAttr     = 'ldapUuidUserAttribute';
1509 1509
 			$uuidOverride = $this->connection->ldapExpertUUIDUserAttr;
1510 1510
 		} else {
@@ -1513,15 +1513,15 @@  discard block
 block discarded – undo
1513 1513
 		}
1514 1514
 
1515 1515
 		$uuid = false;
1516
-		if($this->detectUuidAttribute($dn, $isUser)) {
1516
+		if ($this->detectUuidAttribute($dn, $isUser)) {
1517 1517
 			$uuid = $this->readAttribute($dn, $this->connection->$uuidAttr);
1518
-			if( !is_array($uuid)
1518
+			if (!is_array($uuid)
1519 1519
 				&& $uuidOverride !== ''
1520 1520
 				&& $this->detectUuidAttribute($dn, $isUser, true)) {
1521 1521
 					$uuid = $this->readAttribute($dn,
1522 1522
 												 $this->connection->$uuidAttr);
1523 1523
 			}
1524
-			if(is_array($uuid) && isset($uuid[0]) && !empty($uuid[0])) {
1524
+			if (is_array($uuid) && isset($uuid[0]) && !empty($uuid[0])) {
1525 1525
 				$uuid = $uuid[0];
1526 1526
 			}
1527 1527
 		}
@@ -1538,19 +1538,19 @@  discard block
 block discarded – undo
1538 1538
 	private function convertObjectGUID2Str($oguid) {
1539 1539
 		$hex_guid = bin2hex($oguid);
1540 1540
 		$hex_guid_to_guid_str = '';
1541
-		for($k = 1; $k <= 4; ++$k) {
1541
+		for ($k = 1; $k <= 4; ++$k) {
1542 1542
 			$hex_guid_to_guid_str .= substr($hex_guid, 8 - 2 * $k, 2);
1543 1543
 		}
1544 1544
 		$hex_guid_to_guid_str .= '-';
1545
-		for($k = 1; $k <= 2; ++$k) {
1545
+		for ($k = 1; $k <= 2; ++$k) {
1546 1546
 			$hex_guid_to_guid_str .= substr($hex_guid, 12 - 2 * $k, 2);
1547 1547
 		}
1548 1548
 		$hex_guid_to_guid_str .= '-';
1549
-		for($k = 1; $k <= 2; ++$k) {
1549
+		for ($k = 1; $k <= 2; ++$k) {
1550 1550
 			$hex_guid_to_guid_str .= substr($hex_guid, 16 - 2 * $k, 2);
1551 1551
 		}
1552
-		$hex_guid_to_guid_str .= '-' . substr($hex_guid, 16, 4);
1553
-		$hex_guid_to_guid_str .= '-' . substr($hex_guid, 20);
1552
+		$hex_guid_to_guid_str .= '-'.substr($hex_guid, 16, 4);
1553
+		$hex_guid_to_guid_str .= '-'.substr($hex_guid, 20);
1554 1554
 
1555 1555
 		return strtoupper($hex_guid_to_guid_str);
1556 1556
 	}
@@ -1567,11 +1567,11 @@  discard block
 block discarded – undo
1567 1567
 	 * @return string
1568 1568
 	 */
1569 1569
 	public function formatGuid2ForFilterUser($guid) {
1570
-		if(!is_string($guid)) {
1570
+		if (!is_string($guid)) {
1571 1571
 			throw new \InvalidArgumentException('String expected');
1572 1572
 		}
1573 1573
 		$blocks = explode('-', $guid);
1574
-		if(count($blocks) !== 5) {
1574
+		if (count($blocks) !== 5) {
1575 1575
 			/*
1576 1576
 			 * Why not throw an Exception instead? This method is a utility
1577 1577
 			 * called only when trying to figure out whether a "missing" known
@@ -1584,20 +1584,20 @@  discard block
 block discarded – undo
1584 1584
 			 * user. Instead we write a log message.
1585 1585
 			 */
1586 1586
 			\OC::$server->getLogger()->info(
1587
-				'Passed string does not resemble a valid GUID. Known UUID ' .
1587
+				'Passed string does not resemble a valid GUID. Known UUID '.
1588 1588
 				'({uuid}) probably does not match UUID configuration.',
1589
-				[ 'app' => 'user_ldap', 'uuid' => $guid ]
1589
+				['app' => 'user_ldap', 'uuid' => $guid]
1590 1590
 			);
1591 1591
 			return $guid;
1592 1592
 		}
1593
-		for($i=0; $i < 3; $i++) {
1593
+		for ($i = 0; $i < 3; $i++) {
1594 1594
 			$pairs = str_split($blocks[$i], 2);
1595 1595
 			$pairs = array_reverse($pairs);
1596 1596
 			$blocks[$i] = implode('', $pairs);
1597 1597
 		}
1598
-		for($i=0; $i < 5; $i++) {
1598
+		for ($i = 0; $i < 5; $i++) {
1599 1599
 			$pairs = str_split($blocks[$i], 2);
1600
-			$blocks[$i] = '\\' . implode('\\', $pairs);
1600
+			$blocks[$i] = '\\'.implode('\\', $pairs);
1601 1601
 		}
1602 1602
 		return implode('', $blocks);
1603 1603
 	}
@@ -1611,12 +1611,12 @@  discard block
 block discarded – undo
1611 1611
 		$domainDN = $this->getDomainDNFromDN($dn);
1612 1612
 		$cacheKey = 'getSID-'.$domainDN;
1613 1613
 		$sid = $this->connection->getFromCache($cacheKey);
1614
-		if(!is_null($sid)) {
1614
+		if (!is_null($sid)) {
1615 1615
 			return $sid;
1616 1616
 		}
1617 1617
 
1618 1618
 		$objectSid = $this->readAttribute($domainDN, 'objectsid');
1619
-		if(!is_array($objectSid) || empty($objectSid)) {
1619
+		if (!is_array($objectSid) || empty($objectSid)) {
1620 1620
 			$this->connection->writeToCache($cacheKey, false);
1621 1621
 			return false;
1622 1622
 		}
@@ -1674,12 +1674,12 @@  discard block
 block discarded – undo
1674 1674
 		$belongsToBase = false;
1675 1675
 		$bases = $this->helper->sanitizeDN($bases);
1676 1676
 
1677
-		foreach($bases as $base) {
1677
+		foreach ($bases as $base) {
1678 1678
 			$belongsToBase = true;
1679
-			if(mb_strripos($dn, $base, 0, 'UTF-8') !== (mb_strlen($dn, 'UTF-8')-mb_strlen($base, 'UTF-8'))) {
1679
+			if (mb_strripos($dn, $base, 0, 'UTF-8') !== (mb_strlen($dn, 'UTF-8') - mb_strlen($base, 'UTF-8'))) {
1680 1680
 				$belongsToBase = false;
1681 1681
 			}
1682
-			if($belongsToBase) {
1682
+			if ($belongsToBase) {
1683 1683
 				break;
1684 1684
 			}
1685 1685
 		}
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
 	 * resets a running Paged Search operation
1691 1691
 	 */
1692 1692
 	private function abandonPagedSearch() {
1693
-		if($this->connection->hasPagedResultSupport) {
1693
+		if ($this->connection->hasPagedResultSupport) {
1694 1694
 			$cr = $this->connection->getConnectionResource();
1695 1695
 			$this->ldap->controlPagedResult($cr, 0, false, $this->lastCookie);
1696 1696
 			$this->getPagedSearchResultState();
@@ -1708,16 +1708,16 @@  discard block
 block discarded – undo
1708 1708
 	 * @return string containing the key or empty if none is cached
1709 1709
 	 */
1710 1710
 	private function getPagedResultCookie($base, $filter, $limit, $offset) {
1711
-		if($offset === 0) {
1711
+		if ($offset === 0) {
1712 1712
 			return '';
1713 1713
 		}
1714 1714
 		$offset -= $limit;
1715 1715
 		//we work with cache here
1716
-		$cacheKey = 'lc' . crc32($base) . '-' . crc32($filter) . '-' . intval($limit) . '-' . intval($offset);
1716
+		$cacheKey = 'lc'.crc32($base).'-'.crc32($filter).'-'.intval($limit).'-'.intval($offset);
1717 1717
 		$cookie = '';
1718
-		if(isset($this->cookies[$cacheKey])) {
1718
+		if (isset($this->cookies[$cacheKey])) {
1719 1719
 			$cookie = $this->cookies[$cacheKey];
1720
-			if(is_null($cookie)) {
1720
+			if (is_null($cookie)) {
1721 1721
 				$cookie = '';
1722 1722
 			}
1723 1723
 		}
@@ -1735,11 +1735,11 @@  discard block
 block discarded – undo
1735 1735
 	 * @return bool
1736 1736
 	 */
1737 1737
 	public function hasMoreResults() {
1738
-		if(!$this->connection->hasPagedResultSupport) {
1738
+		if (!$this->connection->hasPagedResultSupport) {
1739 1739
 			return false;
1740 1740
 		}
1741 1741
 
1742
-		if(empty($this->lastCookie) && $this->lastCookie !== '0') {
1742
+		if (empty($this->lastCookie) && $this->lastCookie !== '0') {
1743 1743
 			// as in RFC 2696, when all results are returned, the cookie will
1744 1744
 			// be empty.
1745 1745
 			return false;
@@ -1759,8 +1759,8 @@  discard block
 block discarded – undo
1759 1759
 	 */
1760 1760
 	private function setPagedResultCookie($base, $filter, $limit, $offset, $cookie) {
1761 1761
 		// allow '0' for 389ds
1762
-		if(!empty($cookie) || $cookie === '0') {
1763
-			$cacheKey = 'lc' . crc32($base) . '-' . crc32($filter) . '-' .intval($limit) . '-' . intval($offset);
1762
+		if (!empty($cookie) || $cookie === '0') {
1763
+			$cacheKey = 'lc'.crc32($base).'-'.crc32($filter).'-'.intval($limit).'-'.intval($offset);
1764 1764
 			$this->cookies[$cacheKey] = $cookie;
1765 1765
 			$this->lastCookie = $cookie;
1766 1766
 		}
@@ -1787,17 +1787,17 @@  discard block
 block discarded – undo
1787 1787
 	 */
1788 1788
 	private function initPagedSearch($filter, $bases, $attr, $limit, $offset) {
1789 1789
 		$pagedSearchOK = false;
1790
-		if($this->connection->hasPagedResultSupport && ($limit !== 0)) {
1790
+		if ($this->connection->hasPagedResultSupport && ($limit !== 0)) {
1791 1791
 			$offset = intval($offset); //can be null
1792 1792
 			\OCP\Util::writeLog('user_ldap',
1793 1793
 				'initializing paged search for  Filter '.$filter.' base '.print_r($bases, true)
1794
-				.' attr '.print_r($attr, true). ' limit ' .$limit.' offset '.$offset,
1794
+				.' attr '.print_r($attr, true).' limit '.$limit.' offset '.$offset,
1795 1795
 				\OCP\Util::DEBUG);
1796 1796
 			//get the cookie from the search for the previous search, required by LDAP
1797
-			foreach($bases as $base) {
1797
+			foreach ($bases as $base) {
1798 1798
 
1799 1799
 				$cookie = $this->getPagedResultCookie($base, $filter, $limit, $offset);
1800
-				if(empty($cookie) && $cookie !== "0" && ($offset > 0)) {
1800
+				if (empty($cookie) && $cookie !== "0" && ($offset > 0)) {
1801 1801
 					// no cookie known, although the offset is not 0. Maybe cache run out. We need
1802 1802
 					// to start all over *sigh* (btw, Dear Reader, did you know LDAP paged
1803 1803
 					// searching was designed by MSFT?)
@@ -1810,18 +1810,18 @@  discard block
 block discarded – undo
1810 1810
 					$cookie = $this->getPagedResultCookie($base, $filter, $limit, $offset);
1811 1811
 					//still no cookie? obviously, the server does not like us. Let's skip paging efforts.
1812 1812
 					//TODO: remember this, probably does not change in the next request...
1813
-					if(empty($cookie) && $cookie !== '0') {
1813
+					if (empty($cookie) && $cookie !== '0') {
1814 1814
 						// '0' is valid, because 389ds
1815 1815
 						$cookie = null;
1816 1816
 					}
1817 1817
 				}
1818
-				if(!is_null($cookie)) {
1818
+				if (!is_null($cookie)) {
1819 1819
 					//since offset = 0, this is a new search. We abandon other searches that might be ongoing.
1820 1820
 					$this->abandonPagedSearch();
1821 1821
 					$pagedSearchOK = $this->ldap->controlPagedResult(
1822 1822
 						$this->connection->getConnectionResource(), $limit,
1823 1823
 						false, $cookie);
1824
-					if(!$pagedSearchOK) {
1824
+					if (!$pagedSearchOK) {
1825 1825
 						return false;
1826 1826
 					}
1827 1827
 					\OCP\Util::writeLog('user_ldap', 'Ready for a paged search', \OCP\Util::DEBUG);
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
 		 * So we added "&& !empty($this->lastCookie)" to this test to ignore pagination
1839 1839
 		 * if we don't have a previous paged search.
1840 1840
 		 */
1841
-		} else if($this->connection->hasPagedResultSupport && $limit === 0 && !empty($this->lastCookie)) {
1841
+		} else if ($this->connection->hasPagedResultSupport && $limit === 0 && !empty($this->lastCookie)) {
1842 1842
 			// a search without limit was requested. However, if we do use
1843 1843
 			// Paged Search once, we always must do it. This requires us to
1844 1844
 			// initialize it with the configured page size.
Please login to merge, or discard this patch.