Completed
Pull Request — master (#5568)
by Blizzz
15:29
created
apps/user_ldap/lib/Configuration.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function __construct($configPrefix, $autoRead = true) {
107 107
 		$this->configPrefix = $configPrefix;
108
-		if($autoRead) {
108
+		if ($autoRead) {
109 109
 			$this->readConfiguration();
110 110
 		}
111 111
 	}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @return mixed|null
116 116
 	 */
117 117
 	public function __get($name) {
118
-		if(isset($this->config[$name])) {
118
+		if (isset($this->config[$name])) {
119 119
 			return $this->config[$name];
120 120
 		}
121 121
 		return null;
@@ -146,22 +146,22 @@  discard block
 block discarded – undo
146 146
 	 * @return false|null
147 147
 	 */
148 148
 	public function setConfiguration($config, &$applied = null) {
149
-		if(!is_array($config)) {
149
+		if (!is_array($config)) {
150 150
 			return false;
151 151
 		}
152 152
 
153 153
 		$cta = $this->getConfigTranslationArray();
154
-		foreach($config as $inputKey => $val) {
155
-			if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
154
+		foreach ($config as $inputKey => $val) {
155
+			if (strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
156 156
 				$key = $cta[$inputKey];
157
-			} elseif(array_key_exists($inputKey, $this->config)) {
157
+			} elseif (array_key_exists($inputKey, $this->config)) {
158 158
 				$key = $inputKey;
159 159
 			} else {
160 160
 				continue;
161 161
 			}
162 162
 
163 163
 			$setMethod = 'setValue';
164
-			switch($key) {
164
+			switch ($key) {
165 165
 				case 'ldapAgentPassword':
166 166
 					$setMethod = 'setRawValue';
167 167
 					break;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 					break;
186 186
 			}
187 187
 			$this->$setMethod($key, $val);
188
-			if(is_array($applied)) {
188
+			if (is_array($applied)) {
189 189
 				$applied[] = $inputKey;
190 190
 				// storing key as index avoids duplication, and as value for simplicity
191 191
 				$this->unsavedChanges[$key] = $key;
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 	}
196 196
 
197 197
 	public function readConfiguration() {
198
-		if(!$this->configRead && !is_null($this->configPrefix)) {
198
+		if (!$this->configRead && !is_null($this->configPrefix)) {
199 199
 			$cta = array_flip($this->getConfigTranslationArray());
200
-			foreach($this->config as $key => $val) {
201
-				if(!isset($cta[$key])) {
200
+			foreach ($this->config as $key => $val) {
201
+				if (!isset($cta[$key])) {
202 202
 					//some are determined
203 203
 					continue;
204 204
 				}
205 205
 				$dbKey = $cta[$key];
206
-				switch($key) {
206
+				switch ($key) {
207 207
 					case 'ldapBase':
208 208
 					case 'ldapBaseUsers':
209 209
 					case 'ldapBaseGroups':
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	public function saveConfiguration() {
248 248
 		$cta = array_flip($this->getConfigTranslationArray());
249
-		foreach($this->unsavedChanges as $key) {
249
+		foreach ($this->unsavedChanges as $key) {
250 250
 			$value = $this->config[$key];
251 251
 			switch ($key) {
252 252
 				case 'ldapAgentPassword':
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 				case 'ldapGroupFilterObjectclass':
263 263
 				case 'ldapGroupFilterGroups':
264 264
 				case 'ldapLoginFilterAttributes':
265
-					if(is_array($value)) {
265
+					if (is_array($value)) {
266 266
 						$value = implode("\n", $value);
267 267
 					}
268 268
 					break;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 				case 'ldapUuidGroupAttribute':
274 274
 					continue 2;
275 275
 			}
276
-			if(is_null($value)) {
276
+			if (is_null($value)) {
277 277
 				$value = '';
278 278
 			}
279 279
 			$this->saveValue($cta[$key], $value);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 */
288 288
 	protected function getMultiLine($varName) {
289 289
 		$value = $this->getValue($varName);
290
-		if(empty($value)) {
290
+		if (empty($value)) {
291 291
 			$value = '';
292 292
 		} else {
293 293
 			$value = preg_split('/\r\n|\r|\n/', $value);
@@ -303,21 +303,21 @@  discard block
 block discarded – undo
303 303
 	 * @param array|string $value to set
304 304
 	 */
305 305
 	protected function setMultiLine($varName, $value) {
306
-		if(empty($value)) {
306
+		if (empty($value)) {
307 307
 			$value = '';
308 308
 		} else if (!is_array($value)) {
309 309
 			$value = preg_split('/\r\n|\r|\n|;/', $value);
310
-			if($value === false) {
310
+			if ($value === false) {
311 311
 				$value = '';
312 312
 			}
313 313
 		}
314 314
 
315
-		if(!is_array($value)) {
315
+		if (!is_array($value)) {
316 316
 			$finalValue = trim($value);
317 317
 		} else {
318 318
 			$finalValue = [];
319
-			foreach($value as $key => $val) {
320
-				if(is_string($val)) {
319
+			foreach ($value as $key => $val) {
320
+				if (is_string($val)) {
321 321
 					$val = trim($val);
322 322
 					if ($val !== '') {
323 323
 						//accidental line breaks are not wanted and can cause
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	 */
365 365
 	protected function getValue($varName) {
366 366
 		static $defaults;
367
-		if(is_null($defaults)) {
367
+		if (is_null($defaults)) {
368 368
 			$defaults = $this->getDefaults();
369 369
 		}
370 370
 		return \OCP\Config::getAppValue('user_ldap',
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	 * @param mixed $value to set
380 380
 	 */
381 381
 	protected function setValue($varName, $value) {
382
-		if(is_string($value)) {
382
+		if (is_string($value)) {
383 383
 			$value = trim($value);
384 384
 		}
385 385
 		$this->config[$varName] = $value;
Please login to merge, or discard this patch.
apps/user_ldap/lib/Connection.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		$this->configuration = new Configuration($configPrefix,
94 94
 												 !is_null($configID));
95 95
 		$memcache = \OC::$server->getMemCacheFactory();
96
-		if($memcache->isAvailable()) {
96
+		if ($memcache->isAvailable()) {
97 97
 			$this->cache = $memcache->create();
98 98
 		}
99 99
 		$helper = new Helper(\OC::$server->getConfig());
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 
107 107
 	public function __destruct() {
108
-		if(!$this->dontDestruct && $this->ldap->isResource($this->ldapConnectionRes)) {
108
+		if (!$this->dontDestruct && $this->ldap->isResource($this->ldapConnectionRes)) {
109 109
 			@$this->ldap->unbind($this->ldapConnectionRes);
110 110
 		};
111 111
 	}
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 	 * @return bool|mixed|void
126 126
 	 */
127 127
 	public function __get($name) {
128
-		if(!$this->configured) {
128
+		if (!$this->configured) {
129 129
 			$this->readConfiguration();
130 130
 		}
131 131
 
132
-		if($name === 'hasPagedResultSupport') {
132
+		if ($name === 'hasPagedResultSupport') {
133 133
 			return $this->hasPagedResultSupport;
134 134
 		}
135 135
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		$before = $this->configuration->$name;
146 146
 		$this->configuration->$name = $value;
147 147
 		$after = $this->configuration->$name;
148
-		if($before !== $after) {
148
+		if ($before !== $after) {
149 149
 			if ($this->configID !== '' && $this->configID !== null) {
150 150
 				$this->configuration->saveConfiguration();
151 151
 			}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @param bool $state
161 161
 	 */
162 162
 	public function setIgnoreValidation($state) {
163
-		$this->ignoreValidation = (bool)$state;
163
+		$this->ignoreValidation = (bool) $state;
164 164
 	}
165 165
 
166 166
 	/**
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 	 * Returns the LDAP handler
177 177
 	 */
178 178
 	public function getConnectionResource() {
179
-		if(!$this->ldapConnectionRes) {
179
+		if (!$this->ldapConnectionRes) {
180 180
 			$this->init();
181
-		} else if(!$this->ldap->isResource($this->ldapConnectionRes)) {
181
+		} else if (!$this->ldap->isResource($this->ldapConnectionRes)) {
182 182
 			$this->ldapConnectionRes = null;
183 183
 			$this->establishConnection();
184 184
 		}
185
-		if(is_null($this->ldapConnectionRes)) {
186
-			\OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server ' . $this->configuration->ldapHost, \OCP\Util::ERROR);
185
+		if (is_null($this->ldapConnectionRes)) {
186
+			\OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server '.$this->configuration->ldapHost, \OCP\Util::ERROR);
187 187
 			throw new ServerNotAvailableException('Connection to LDAP server could not be established');
188 188
 		}
189 189
 		return $this->ldapConnectionRes;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * resets the connection resource
194 194
 	 */
195 195
 	public function resetConnectionResource() {
196
-		if(!is_null($this->ldapConnectionRes)) {
196
+		if (!is_null($this->ldapConnectionRes)) {
197 197
 			@$this->ldap->unbind($this->ldapConnectionRes);
198 198
 			$this->ldapConnectionRes = null;
199 199
 		}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 */
206 206
 	private function getCacheKey($key) {
207 207
 		$prefix = 'LDAP-'.$this->configID.'-'.$this->configPrefix.'-';
208
-		if(is_null($key)) {
208
+		if (is_null($key)) {
209 209
 			return $prefix;
210 210
 		}
211 211
 		return $prefix.md5($key);
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 	 * @return mixed|null
217 217
 	 */
218 218
 	public function getFromCache($key) {
219
-		if(!$this->configured) {
219
+		if (!$this->configured) {
220 220
 			$this->readConfiguration();
221 221
 		}
222
-		if(is_null($this->cache) || !$this->configuration->ldapCacheTTL) {
222
+		if (is_null($this->cache) || !$this->configuration->ldapCacheTTL) {
223 223
 			return null;
224 224
 		}
225 225
 		$key = $this->getCacheKey($key);
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 	 * @return string
235 235
 	 */
236 236
 	public function writeToCache($key, $value) {
237
-		if(!$this->configured) {
237
+		if (!$this->configured) {
238 238
 			$this->readConfiguration();
239 239
 		}
240
-		if(is_null($this->cache)
240
+		if (is_null($this->cache)
241 241
 			|| !$this->configuration->ldapCacheTTL
242 242
 			|| !$this->configuration->ldapConfigurationActive) {
243 243
 			return null;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	}
249 249
 
250 250
 	public function clearCache() {
251
-		if(!is_null($this->cache)) {
251
+		if (!is_null($this->cache)) {
252 252
 			$this->cache->clear($this->getCacheKey(null));
253 253
 		}
254 254
 	}
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 * @return null
261 261
 	 */
262 262
 	private function readConfiguration($force = false) {
263
-		if((!$this->configured || $force) && !is_null($this->configID)) {
263
+		if ((!$this->configured || $force) && !is_null($this->configID)) {
264 264
 			$this->configuration->readConfiguration();
265 265
 			$this->configured = $this->validateConfiguration();
266 266
 		}
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
 	 * @return boolean true if config validates, false otherwise. Check with $setParameters for detailed success on single parameters
274 274
 	 */
275 275
 	public function setConfiguration($config, &$setParameters = null) {
276
-		if(is_null($setParameters)) {
276
+		if (is_null($setParameters)) {
277 277
 			$setParameters = array();
278 278
 		}
279 279
 		$this->doNotValidate = false;
280 280
 		$this->configuration->setConfiguration($config, $setParameters);
281
-		if(count($setParameters) > 0) {
281
+		if (count($setParameters) > 0) {
282 282
 			$this->configured = $this->validateConfiguration();
283 283
 		}
284 284
 
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
 		$config = $this->configuration->getConfiguration();
306 306
 		$cta = $this->configuration->getConfigTranslationArray();
307 307
 		$result = array();
308
-		foreach($cta as $dbkey => $configkey) {
309
-			switch($configkey) {
308
+		foreach ($cta as $dbkey => $configkey) {
309
+			switch ($configkey) {
310 310
 				case 'homeFolderNamingRule':
311
-					if(strpos($config[$configkey], 'attr:') === 0) {
311
+					if (strpos($config[$configkey], 'attr:') === 0) {
312 312
 						$result[$dbkey] = substr($config[$configkey], 5);
313 313
 					} else {
314 314
 						$result[$dbkey] = '';
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 				case 'ldapBaseGroups':
320 320
 				case 'ldapAttributesForUserSearch':
321 321
 				case 'ldapAttributesForGroupSearch':
322
-					if(is_array($config[$configkey])) {
322
+					if (is_array($config[$configkey])) {
323 323
 						$result[$dbkey] = implode("\n", $config[$configkey]);
324 324
 						break;
325 325
 					} //else follows default
@@ -332,23 +332,23 @@  discard block
 block discarded – undo
332 332
 
333 333
 	private function doSoftValidation() {
334 334
 		//if User or Group Base are not set, take over Base DN setting
335
-		foreach(array('ldapBaseUsers', 'ldapBaseGroups') as $keyBase) {
335
+		foreach (array('ldapBaseUsers', 'ldapBaseGroups') as $keyBase) {
336 336
 			$val = $this->configuration->$keyBase;
337
-			if(empty($val)) {
337
+			if (empty($val)) {
338 338
 				$this->configuration->$keyBase = $this->configuration->ldapBase;
339 339
 			}
340 340
 		}
341 341
 
342
-		foreach(array('ldapExpertUUIDUserAttr'  => 'ldapUuidUserAttribute',
342
+		foreach (array('ldapExpertUUIDUserAttr'  => 'ldapUuidUserAttribute',
343 343
 					  'ldapExpertUUIDGroupAttr' => 'ldapUuidGroupAttribute')
344 344
 				as $expertSetting => $effectiveSetting) {
345 345
 			$uuidOverride = $this->configuration->$expertSetting;
346
-			if(!empty($uuidOverride)) {
346
+			if (!empty($uuidOverride)) {
347 347
 				$this->configuration->$effectiveSetting = $uuidOverride;
348 348
 			} else {
349 349
 				$uuidAttributes = array('auto', 'entryuuid', 'nsuniqueid',
350 350
 										'objectguid', 'guid', 'ipauniqueid');
351
-				if(!in_array($this->configuration->$effectiveSetting,
351
+				if (!in_array($this->configuration->$effectiveSetting,
352 352
 							$uuidAttributes)
353 353
 					&& (!is_null($this->configID))) {
354 354
 					$this->configuration->$effectiveSetting = 'auto';
@@ -370,14 +370,14 @@  discard block
 block discarded – undo
370 370
 		//make sure empty search attributes are saved as simple, empty array
371 371
 		$saKeys = array('ldapAttributesForUserSearch',
372 372
 						'ldapAttributesForGroupSearch');
373
-		foreach($saKeys as $key) {
373
+		foreach ($saKeys as $key) {
374 374
 			$val = $this->configuration->$key;
375
-			if(is_array($val) && count($val) === 1 && empty($val[0])) {
375
+			if (is_array($val) && count($val) === 1 && empty($val[0])) {
376 376
 				$this->configuration->$key = array();
377 377
 			}
378 378
 		}
379 379
 
380
-		if((stripos($this->configuration->ldapHost, 'ldaps://') === 0)
380
+		if ((stripos($this->configuration->ldapHost, 'ldaps://') === 0)
381 381
 			&& $this->configuration->ldapTLS) {
382 382
 			$this->configuration->ldapTLS = false;
383 383
 			\OCP\Util::writeLog('user_ldap',
@@ -398,10 +398,10 @@  discard block
 block discarded – undo
398 398
 		//options that shall not be empty
399 399
 		$options = array('ldapHost', 'ldapPort', 'ldapUserDisplayName',
400 400
 						 'ldapGroupDisplayName', 'ldapLoginFilter');
401
-		foreach($options as $key) {
401
+		foreach ($options as $key) {
402 402
 			$val = $this->configuration->$key;
403
-			if(empty($val)) {
404
-				switch($key) {
403
+			if (empty($val)) {
404
+				switch ($key) {
405 405
 					case 'ldapHost':
406 406
 						$subj = 'LDAP Host';
407 407
 						break;
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		$agent = $this->configuration->ldapAgentName;
433 433
 		$pwd = $this->configuration->ldapAgentPassword;
434 434
 		if (
435
-			($agent === ''  && $pwd !== '')
435
+			($agent === '' && $pwd !== '')
436 436
 			|| ($agent !== '' && $pwd === '')
437 437
 		) {
438 438
 			\OCP\Util::writeLog('user_ldap',
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
 		$baseUsers = $this->configuration->ldapBaseUsers;
448 448
 		$baseGroups = $this->configuration->ldapBaseGroups;
449 449
 
450
-		if(empty($base) && empty($baseUsers) && empty($baseGroups)) {
450
+		if (empty($base) && empty($baseUsers) && empty($baseGroups)) {
451 451
 			\OCP\Util::writeLog('user_ldap',
452 452
 								$errorStr.'Not a single Base DN given.',
453 453
 								\OCP\Util::WARN);
454 454
 			$configurationOK = false;
455 455
 		}
456 456
 
457
-		if(mb_strpos($this->configuration->ldapLoginFilter, '%uid', 0, 'UTF-8')
457
+		if (mb_strpos($this->configuration->ldapLoginFilter, '%uid', 0, 'UTF-8')
458 458
 		   === false) {
459 459
 			\OCP\Util::writeLog('user_ldap',
460 460
 								$errorStr.'login filter does not contain %uid '.
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 */
473 473
 	private function validateConfiguration() {
474 474
 
475
-		if($this->doNotValidate) {
475
+		if ($this->doNotValidate) {
476 476
 			//don't do a validation if it is a new configuration with pure
477 477
 			//default values. Will be allowed on changes via __set or
478 478
 			//setConfiguration
@@ -493,21 +493,21 @@  discard block
 block discarded – undo
493 493
 	 * Connects and Binds to LDAP
494 494
 	 */
495 495
 	private function establishConnection() {
496
-		if(!$this->configuration->ldapConfigurationActive) {
496
+		if (!$this->configuration->ldapConfigurationActive) {
497 497
 			return null;
498 498
 		}
499 499
 		static $phpLDAPinstalled = true;
500
-		if(!$phpLDAPinstalled) {
500
+		if (!$phpLDAPinstalled) {
501 501
 			return false;
502 502
 		}
503
-		if(!$this->ignoreValidation && !$this->configured) {
503
+		if (!$this->ignoreValidation && !$this->configured) {
504 504
 			\OCP\Util::writeLog('user_ldap',
505 505
 								'Configuration is invalid, cannot connect',
506 506
 								\OCP\Util::WARN);
507 507
 			return false;
508 508
 		}
509
-		if(!$this->ldapConnectionRes) {
510
-			if(!$this->ldap->areLDAPFunctionsAvailable()) {
509
+		if (!$this->ldapConnectionRes) {
510
+			if (!$this->ldap->areLDAPFunctionsAvailable()) {
511 511
 				$phpLDAPinstalled = false;
512 512
 				\OCP\Util::writeLog('user_ldap',
513 513
 									'function ldap_connect is not available. Make '.
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
 
517 517
 				return false;
518 518
 			}
519
-			if($this->configuration->turnOffCertCheck) {
520
-				if(putenv('LDAPTLS_REQCERT=never')) {
519
+			if ($this->configuration->turnOffCertCheck) {
520
+				if (putenv('LDAPTLS_REQCERT=never')) {
521 521
 					\OCP\Util::writeLog('user_ldap',
522 522
 						'Turned off SSL certificate validation successfully.',
523 523
 						\OCP\Util::DEBUG);
@@ -540,24 +540,24 @@  discard block
 block discarded – undo
540 540
 					$error = $this->ldap->isResource($this->ldapConnectionRes) ?
541 541
 						$this->ldap->errno($this->ldapConnectionRes) : -1;
542 542
 				}
543
-				if($bindStatus === true) {
543
+				if ($bindStatus === true) {
544 544
 					return $bindStatus;
545 545
 				}
546 546
 			} catch (\OC\ServerNotAvailableException $e) {
547
-				if(trim($this->configuration->ldapBackupHost) === "") {
547
+				if (trim($this->configuration->ldapBackupHost) === "") {
548 548
 					throw $e;
549 549
 				}
550 550
 			}
551 551
 
552 552
 			//if LDAP server is not reachable, try the Backup (Replica!) Server
553
-			if(    $error !== 0
553
+			if ($error !== 0
554 554
 				|| $this->configuration->ldapOverrideMainServer
555 555
 				|| $this->getFromCache('overrideMainServer'))
556 556
 			{
557 557
 				$this->doConnect($this->configuration->ldapBackupHost,
558 558
 								 $this->configuration->ldapBackupPort);
559 559
 				$bindStatus = $this->bind();
560
-				if($bindStatus && $error === -1 && !$this->getFromCache('overrideMainServer')) {
560
+				if ($bindStatus && $error === -1 && !$this->getFromCache('overrideMainServer')) {
561 561
 					//when bind to backup server succeeded and failed to main server,
562 562
 					//skip contacting him until next cache refresh
563 563
 					$this->writeToCache('overrideMainServer', true);
@@ -579,9 +579,9 @@  discard block
 block discarded – undo
579 579
 			return false;
580 580
 		}
581 581
 		$this->ldapConnectionRes = $this->ldap->connect($host, $port);
582
-		if($this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) {
583
-			if($this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) {
584
-				if($this->configuration->ldapTLS) {
582
+		if ($this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) {
583
+			if ($this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) {
584
+				if ($this->configuration->ldapTLS) {
585 585
 					$this->ldap->startTls($this->ldapConnectionRes);
586 586
 				}
587 587
 			}
@@ -596,25 +596,25 @@  discard block
 block discarded – undo
596 596
 	 */
597 597
 	public function bind() {
598 598
 		static $getConnectionResourceAttempt = false;
599
-		if(!$this->configuration->ldapConfigurationActive) {
599
+		if (!$this->configuration->ldapConfigurationActive) {
600 600
 			return false;
601 601
 		}
602
-		if($getConnectionResourceAttempt) {
602
+		if ($getConnectionResourceAttempt) {
603 603
 			$getConnectionResourceAttempt = false;
604 604
 			return false;
605 605
 		}
606 606
 		$getConnectionResourceAttempt = true;
607 607
 		$cr = $this->getConnectionResource();
608 608
 		$getConnectionResourceAttempt = false;
609
-		if(!$this->ldap->isResource($cr)) {
609
+		if (!$this->ldap->isResource($cr)) {
610 610
 			return false;
611 611
 		}
612 612
 		$ldapLogin = @$this->ldap->bind($cr,
613 613
 										$this->configuration->ldapAgentName,
614 614
 										$this->configuration->ldapAgentPassword);
615
-		if(!$ldapLogin) {
615
+		if (!$ldapLogin) {
616 616
 			\OCP\Util::writeLog('user_ldap',
617
-				'Bind failed: ' . $this->ldap->errno($cr) . ': ' . $this->ldap->error($cr),
617
+				'Bind failed: '.$this->ldap->errno($cr).': '.$this->ldap->error($cr),
618 618
 				\OCP\Util::WARN);
619 619
 			$this->ldapConnectionRes = null;
620 620
 			return false;
Please login to merge, or discard this patch.
apps/user_ldap/templates/part.wizard-server.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <fieldset id="ldapWizard1">
2 2
 		<p>
3 3
 		<select id="ldap_serverconfig_chooser" name="ldap_serverconfig_chooser">
4
-		<?php if(count($_['serverConfigurationPrefixes']) === 0 ) {
4
+		<?php if (count($_['serverConfigurationPrefixes']) === 0) {
5 5
 			?>
6
-				<option value="" selected><?php p($l->t('1. Server'));?></option>');
6
+				<option value="" selected><?php p($l->t('1. Server')); ?></option>');
7 7
 			<?php
8 8
 		} else {
9 9
 			$i = 1;
10 10
 			$sel = ' selected';
11
-			foreach($_['serverConfigurationPrefixes'] as $prefix) {
11
+			foreach ($_['serverConfigurationPrefixes'] as $prefix) {
12 12
 				?>
13
-				<option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($l->t('%s. Server:', array($i++)));?> <?php p(' '.$_['serverConfigurationHosts'][$prefix]); ?></option>
13
+				<option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($l->t('%s. Server:', array($i++))); ?> <?php p(' '.$_['serverConfigurationHosts'][$prefix]); ?></option>
14 14
 				<?php
15 15
 			}
16 16
 		}
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 		</select>
19 19
 		<button type="button" id="ldap_action_add_configuration"
20 20
 			name="ldap_action_add_configuration" class="icon-add icon-default-style"
21
-			title="<?php p($l->t('Add a new configuration'));?>">&nbsp;</button>
21
+			title="<?php p($l->t('Add a new configuration')); ?>">&nbsp;</button>
22 22
 		<button type="button" id="ldap_action_copy_configuration"
23 23
 			name="ldap_action_copy_configuration"
24 24
 			class="ldapIconCopy icon-default-style"
25
-			title="<?php p($l->t('Copy current configuration into new directory binding'));?>">&nbsp;</button>
25
+			title="<?php p($l->t('Copy current configuration into new directory binding')); ?>">&nbsp;</button>
26 26
 		<button type="button" id="ldap_action_delete_configuration"
27 27
 			name="ldap_action_delete_configuration" class="icon-delete icon-default-style"
28
-			title="<?php p($l->t('Delete the current configuration'));?>">&nbsp;</button>
28
+			title="<?php p($l->t('Delete the current configuration')); ?>">&nbsp;</button>
29 29
 		</p>
30 30
 
31 31
 		<div class="hostPortCombinator">
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 					<div class="table">
35 35
 						<input type="text" class="host" id="ldap_host"
36 36
 							name="ldap_host"
37
-							placeholder="<?php p($l->t('Host'));?>"
38
-							title="<?php p($l->t('You can omit the protocol, unless you require SSL. If so, start with ldaps://'));?>"
37
+							placeholder="<?php p($l->t('Host')); ?>"
38
+							title="<?php p($l->t('You can omit the protocol, unless you require SSL. If so, start with ldaps://')); ?>"
39 39
 							/>
40 40
 						<span class="hostPortCombinatorSpan">
41 41
 							<input type="number" id="ldap_port" name="ldap_port"
42
-								placeholder="<?php p($l->t('Port'));?>" />
42
+								placeholder="<?php p($l->t('Port')); ?>" />
43 43
 							<button class="ldapDetectPort" name="ldapDetectPort" type="button">
44
-								<?php p($l->t('Detect Port'));?>
44
+								<?php p($l->t('Detect Port')); ?>
45 45
 							</button>
46 46
 						</span>
47 47
 					</div>
@@ -51,19 +51,19 @@  discard block
 block discarded – undo
51 51
 			<div class="tablerow">
52 52
 				<input type="text" id="ldap_dn" name="ldap_dn"
53 53
 				class="tablecell"
54
-				placeholder="<?php p($l->t('User DN'));?>" autocomplete="off"
55
-				title="<?php p($l->t('The DN of the client user with which the bind shall be done, e.g. uid=agent,dc=example,dc=com. For anonymous access, leave DN and Password empty.'));?>"
54
+				placeholder="<?php p($l->t('User DN')); ?>" autocomplete="off"
55
+				title="<?php p($l->t('The DN of the client user with which the bind shall be done, e.g. uid=agent,dc=example,dc=com. For anonymous access, leave DN and Password empty.')); ?>"
56 56
 				/>
57 57
 			</div>
58 58
 
59 59
 			<div class="tablerow">
60 60
 				<input type="password" id="ldap_agent_password"
61 61
 				class="tablecell" name="ldap_agent_password"
62
-				placeholder="<?php p($l->t('Password'));?>" autocomplete="off"
63
-				title="<?php p($l->t('For anonymous access, leave DN and Password empty.'));?>"
62
+				placeholder="<?php p($l->t('Password')); ?>" autocomplete="off"
63
+				title="<?php p($l->t('For anonymous access, leave DN and Password empty.')); ?>"
64 64
 				/>
65 65
 				<button class="ldapSaveAgentCredentials" name="ldapSaveAgentCredentials" type="button">
66
-					<?php p($l->t('Save Credentials'));?>
66
+					<?php p($l->t('Save Credentials')); ?>
67 67
 				</button>
68 68
 			</div>
69 69
 			<div class="tablerow">&nbsp;</div>
@@ -71,24 +71,24 @@  discard block
 block discarded – undo
71 71
 			<div class="tablerow">
72 72
 				<textarea id="ldap_base" name="ldap_base"
73 73
 					class="tablecell"
74
-					placeholder="<?php p($l->t('One Base DN per line'));?>"
75
-					title="<?php p($l->t('You can specify Base DN for users and groups in the Advanced tab'));?>">
74
+					placeholder="<?php p($l->t('One Base DN per line')); ?>"
75
+					title="<?php p($l->t('You can specify Base DN for users and groups in the Advanced tab')); ?>">
76 76
 				</textarea>
77 77
 				<button class="ldapDetectBase" name="ldapDetectBase" type="button">
78
-					<?php p($l->t('Detect Base DN'));?>
78
+					<?php p($l->t('Detect Base DN')); ?>
79 79
 				</button>
80 80
 				<button class="ldapTestBase" name="ldapTestBase" type="button">
81
-					<?php p($l->t('Test Base DN'));?>
81
+					<?php p($l->t('Test Base DN')); ?>
82 82
 				</button>
83 83
 			</div>
84 84
 
85 85
 			<div class="tablerow left">
86 86
 				<input type="checkbox" id="ldap_experienced_admin" value="1"
87 87
 					name="ldap_experienced_admin" class="tablecell"
88
-					title="<?php p($l->t('Avoids automatic LDAP requests. Better for bigger setups, but requires some LDAP knowledge.'));?>"
88
+					title="<?php p($l->t('Avoids automatic LDAP requests. Better for bigger setups, but requires some LDAP knowledge.')); ?>"
89 89
 					/>
90 90
 				<label for="ldap_experienced_admin" class="tablecell">
91
-					<?php p($l->t('Manually enter LDAP filters (recommended for large directories)'));?>
91
+					<?php p($l->t('Manually enter LDAP filters (recommended for large directories)')); ?>
92 92
 				</label>
93 93
 			</div>
94 94
 
Please login to merge, or discard this patch.