Completed
Push — master ( ede649...d3e7dd )
by Lukas
16:27
created
apps/user_ldap/lib/Configuration.php 1 patch
Indentation   +473 added lines, -473 removed lines patch added patch discarded remove patch
@@ -37,502 +37,502 @@
 block discarded – undo
37 37
  * @property int ldapPagingSize holds an integer
38 38
  */
39 39
 class Configuration {
40
-	protected $configPrefix = null;
41
-	protected $configRead = false;
42
-	/**
43
-	 * @var string[] pre-filled with one reference key so that at least one entry is written on save request and
44
-	 *               the config ID is registered
45
-	 */
46
-	protected $unsavedChanges = ['ldapConfigurationActive' => 'ldapConfigurationActive'];
40
+    protected $configPrefix = null;
41
+    protected $configRead = false;
42
+    /**
43
+     * @var string[] pre-filled with one reference key so that at least one entry is written on save request and
44
+     *               the config ID is registered
45
+     */
46
+    protected $unsavedChanges = ['ldapConfigurationActive' => 'ldapConfigurationActive'];
47 47
 
48
-	//settings
49
-	protected $config = array(
50
-		'ldapHost' => null,
51
-		'ldapPort' => null,
52
-		'ldapBackupHost' => null,
53
-		'ldapBackupPort' => null,
54
-		'ldapBase' => null,
55
-		'ldapBaseUsers' => null,
56
-		'ldapBaseGroups' => null,
57
-		'ldapAgentName' => null,
58
-		'ldapAgentPassword' => null,
59
-		'ldapTLS' => null,
60
-		'turnOffCertCheck' => null,
61
-		'ldapIgnoreNamingRules' => null,
62
-		'ldapUserDisplayName' => null,
63
-		'ldapUserDisplayName2' => null,
64
-		'ldapGidNumber' => null,
65
-		'ldapUserFilterObjectclass' => null,
66
-		'ldapUserFilterGroups' => null,
67
-		'ldapUserFilter' => null,
68
-		'ldapUserFilterMode' => null,
69
-		'ldapGroupFilter' => null,
70
-		'ldapGroupFilterMode' => null,
71
-		'ldapGroupFilterObjectclass' => null,
72
-		'ldapGroupFilterGroups' => null,
73
-		'ldapGroupDisplayName' => null,
74
-		'ldapGroupMemberAssocAttr' => null,
75
-		'ldapLoginFilter' => null,
76
-		'ldapLoginFilterMode' => null,
77
-		'ldapLoginFilterEmail' => null,
78
-		'ldapLoginFilterUsername' => null,
79
-		'ldapLoginFilterAttributes' => null,
80
-		'ldapQuotaAttribute' => null,
81
-		'ldapQuotaDefault' => null,
82
-		'ldapEmailAttribute' => null,
83
-		'ldapCacheTTL' => null,
84
-		'ldapUuidUserAttribute' => 'auto',
85
-		'ldapUuidGroupAttribute' => 'auto',
86
-		'ldapOverrideMainServer' => false,
87
-		'ldapConfigurationActive' => false,
88
-		'ldapAttributesForUserSearch' => null,
89
-		'ldapAttributesForGroupSearch' => null,
90
-		'ldapExperiencedAdmin' => false,
91
-		'homeFolderNamingRule' => null,
92
-		'hasPagedResultSupport' => false,
93
-		'hasMemberOfFilterSupport' => false,
94
-		'useMemberOfToDetectMembership' => true,
95
-		'ldapExpertUsernameAttr' => null,
96
-		'ldapExpertUUIDUserAttr' => null,
97
-		'ldapExpertUUIDGroupAttr' => null,
98
-		'lastJpegPhotoLookup' => null,
99
-		'ldapNestedGroups' => false,
100
-		'ldapPagingSize' => null,
101
-		'turnOnPasswordChange' => false,
102
-		'ldapDynamicGroupMemberURL' => null,
103
-		'ldapDefaultPPolicyDN' => null,
104
-	);
48
+    //settings
49
+    protected $config = array(
50
+        'ldapHost' => null,
51
+        'ldapPort' => null,
52
+        'ldapBackupHost' => null,
53
+        'ldapBackupPort' => null,
54
+        'ldapBase' => null,
55
+        'ldapBaseUsers' => null,
56
+        'ldapBaseGroups' => null,
57
+        'ldapAgentName' => null,
58
+        'ldapAgentPassword' => null,
59
+        'ldapTLS' => null,
60
+        'turnOffCertCheck' => null,
61
+        'ldapIgnoreNamingRules' => null,
62
+        'ldapUserDisplayName' => null,
63
+        'ldapUserDisplayName2' => null,
64
+        'ldapGidNumber' => null,
65
+        'ldapUserFilterObjectclass' => null,
66
+        'ldapUserFilterGroups' => null,
67
+        'ldapUserFilter' => null,
68
+        'ldapUserFilterMode' => null,
69
+        'ldapGroupFilter' => null,
70
+        'ldapGroupFilterMode' => null,
71
+        'ldapGroupFilterObjectclass' => null,
72
+        'ldapGroupFilterGroups' => null,
73
+        'ldapGroupDisplayName' => null,
74
+        'ldapGroupMemberAssocAttr' => null,
75
+        'ldapLoginFilter' => null,
76
+        'ldapLoginFilterMode' => null,
77
+        'ldapLoginFilterEmail' => null,
78
+        'ldapLoginFilterUsername' => null,
79
+        'ldapLoginFilterAttributes' => null,
80
+        'ldapQuotaAttribute' => null,
81
+        'ldapQuotaDefault' => null,
82
+        'ldapEmailAttribute' => null,
83
+        'ldapCacheTTL' => null,
84
+        'ldapUuidUserAttribute' => 'auto',
85
+        'ldapUuidGroupAttribute' => 'auto',
86
+        'ldapOverrideMainServer' => false,
87
+        'ldapConfigurationActive' => false,
88
+        'ldapAttributesForUserSearch' => null,
89
+        'ldapAttributesForGroupSearch' => null,
90
+        'ldapExperiencedAdmin' => false,
91
+        'homeFolderNamingRule' => null,
92
+        'hasPagedResultSupport' => false,
93
+        'hasMemberOfFilterSupport' => false,
94
+        'useMemberOfToDetectMembership' => true,
95
+        'ldapExpertUsernameAttr' => null,
96
+        'ldapExpertUUIDUserAttr' => null,
97
+        'ldapExpertUUIDGroupAttr' => null,
98
+        'lastJpegPhotoLookup' => null,
99
+        'ldapNestedGroups' => false,
100
+        'ldapPagingSize' => null,
101
+        'turnOnPasswordChange' => false,
102
+        'ldapDynamicGroupMemberURL' => null,
103
+        'ldapDefaultPPolicyDN' => null,
104
+    );
105 105
 
106
-	/**
107
-	 * @param string $configPrefix
108
-	 * @param bool $autoRead
109
-	 */
110
-	public function __construct($configPrefix, $autoRead = true) {
111
-		$this->configPrefix = $configPrefix;
112
-		if($autoRead) {
113
-			$this->readConfiguration();
114
-		}
115
-	}
106
+    /**
107
+     * @param string $configPrefix
108
+     * @param bool $autoRead
109
+     */
110
+    public function __construct($configPrefix, $autoRead = true) {
111
+        $this->configPrefix = $configPrefix;
112
+        if($autoRead) {
113
+            $this->readConfiguration();
114
+        }
115
+    }
116 116
 
117
-	/**
118
-	 * @param string $name
119
-	 * @return mixed|null
120
-	 */
121
-	public function __get($name) {
122
-		if(isset($this->config[$name])) {
123
-			return $this->config[$name];
124
-		}
125
-		return null;
126
-	}
117
+    /**
118
+     * @param string $name
119
+     * @return mixed|null
120
+     */
121
+    public function __get($name) {
122
+        if(isset($this->config[$name])) {
123
+            return $this->config[$name];
124
+        }
125
+        return null;
126
+    }
127 127
 
128
-	/**
129
-	 * @param string $name
130
-	 * @param mixed $value
131
-	 */
132
-	public function __set($name, $value) {
133
-		$this->setConfiguration(array($name => $value));
134
-	}
128
+    /**
129
+     * @param string $name
130
+     * @param mixed $value
131
+     */
132
+    public function __set($name, $value) {
133
+        $this->setConfiguration(array($name => $value));
134
+    }
135 135
 
136
-	/**
137
-	 * @return array
138
-	 */
139
-	public function getConfiguration() {
140
-		return $this->config;
141
-	}
136
+    /**
137
+     * @return array
138
+     */
139
+    public function getConfiguration() {
140
+        return $this->config;
141
+    }
142 142
 
143
-	/**
144
-	 * set LDAP configuration with values delivered by an array, not read
145
-	 * from configuration. It does not save the configuration! To do so, you
146
-	 * must call saveConfiguration afterwards.
147
-	 * @param array $config array that holds the config parameters in an associated
148
-	 * array
149
-	 * @param array &$applied optional; array where the set fields will be given to
150
-	 * @return false|null
151
-	 */
152
-	public function setConfiguration($config, &$applied = null) {
153
-		if(!is_array($config)) {
154
-			return false;
155
-		}
143
+    /**
144
+     * set LDAP configuration with values delivered by an array, not read
145
+     * from configuration. It does not save the configuration! To do so, you
146
+     * must call saveConfiguration afterwards.
147
+     * @param array $config array that holds the config parameters in an associated
148
+     * array
149
+     * @param array &$applied optional; array where the set fields will be given to
150
+     * @return false|null
151
+     */
152
+    public function setConfiguration($config, &$applied = null) {
153
+        if(!is_array($config)) {
154
+            return false;
155
+        }
156 156
 
157
-		$cta = $this->getConfigTranslationArray();
158
-		foreach($config as $inputKey => $val) {
159
-			if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
160
-				$key = $cta[$inputKey];
161
-			} elseif(array_key_exists($inputKey, $this->config)) {
162
-				$key = $inputKey;
163
-			} else {
164
-				continue;
165
-			}
157
+        $cta = $this->getConfigTranslationArray();
158
+        foreach($config as $inputKey => $val) {
159
+            if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
160
+                $key = $cta[$inputKey];
161
+            } elseif(array_key_exists($inputKey, $this->config)) {
162
+                $key = $inputKey;
163
+            } else {
164
+                continue;
165
+            }
166 166
 
167
-			$setMethod = 'setValue';
168
-			switch($key) {
169
-				case 'ldapAgentPassword':
170
-					$setMethod = 'setRawValue';
171
-					break;
172
-				case 'homeFolderNamingRule':
173
-					$trimmedVal = trim($val);
174
-					if ($trimmedVal !== '' && strpos($val, 'attr:') === false) {
175
-						$val = 'attr:'.$trimmedVal;
176
-					}
177
-					break;
178
-				case 'ldapBase':
179
-				case 'ldapBaseUsers':
180
-				case 'ldapBaseGroups':
181
-				case 'ldapAttributesForUserSearch':
182
-				case 'ldapAttributesForGroupSearch':
183
-				case 'ldapUserFilterObjectclass':
184
-				case 'ldapUserFilterGroups':
185
-				case 'ldapGroupFilterObjectclass':
186
-				case 'ldapGroupFilterGroups':
187
-				case 'ldapLoginFilterAttributes':
188
-					$setMethod = 'setMultiLine';
189
-					break;
190
-			}
191
-			$this->$setMethod($key, $val);
192
-			if(is_array($applied)) {
193
-				$applied[] = $inputKey;
194
-				// storing key as index avoids duplication, and as value for simplicity
195
-			}
196
-			$this->unsavedChanges[$key] = $key;
197
-		}
198
-		return null;
199
-	}
167
+            $setMethod = 'setValue';
168
+            switch($key) {
169
+                case 'ldapAgentPassword':
170
+                    $setMethod = 'setRawValue';
171
+                    break;
172
+                case 'homeFolderNamingRule':
173
+                    $trimmedVal = trim($val);
174
+                    if ($trimmedVal !== '' && strpos($val, 'attr:') === false) {
175
+                        $val = 'attr:'.$trimmedVal;
176
+                    }
177
+                    break;
178
+                case 'ldapBase':
179
+                case 'ldapBaseUsers':
180
+                case 'ldapBaseGroups':
181
+                case 'ldapAttributesForUserSearch':
182
+                case 'ldapAttributesForGroupSearch':
183
+                case 'ldapUserFilterObjectclass':
184
+                case 'ldapUserFilterGroups':
185
+                case 'ldapGroupFilterObjectclass':
186
+                case 'ldapGroupFilterGroups':
187
+                case 'ldapLoginFilterAttributes':
188
+                    $setMethod = 'setMultiLine';
189
+                    break;
190
+            }
191
+            $this->$setMethod($key, $val);
192
+            if(is_array($applied)) {
193
+                $applied[] = $inputKey;
194
+                // storing key as index avoids duplication, and as value for simplicity
195
+            }
196
+            $this->unsavedChanges[$key] = $key;
197
+        }
198
+        return null;
199
+    }
200 200
 
201
-	public function readConfiguration() {
202
-		if(!$this->configRead && !is_null($this->configPrefix)) {
203
-			$cta = array_flip($this->getConfigTranslationArray());
204
-			foreach($this->config as $key => $val) {
205
-				if(!isset($cta[$key])) {
206
-					//some are determined
207
-					continue;
208
-				}
209
-				$dbKey = $cta[$key];
210
-				switch($key) {
211
-					case 'ldapBase':
212
-					case 'ldapBaseUsers':
213
-					case 'ldapBaseGroups':
214
-					case 'ldapAttributesForUserSearch':
215
-					case 'ldapAttributesForGroupSearch':
216
-					case 'ldapUserFilterObjectclass':
217
-					case 'ldapUserFilterGroups':
218
-					case 'ldapGroupFilterObjectclass':
219
-					case 'ldapGroupFilterGroups':
220
-					case 'ldapLoginFilterAttributes':
221
-						$readMethod = 'getMultiLine';
222
-						break;
223
-					case 'ldapIgnoreNamingRules':
224
-						$readMethod = 'getSystemValue';
225
-						$dbKey = $key;
226
-						break;
227
-					case 'ldapAgentPassword':
228
-						$readMethod = 'getPwd';
229
-						break;
230
-					case 'ldapUserDisplayName2':
231
-					case 'ldapGroupDisplayName':
232
-						$readMethod = 'getLcValue';
233
-						break;
234
-					case 'ldapUserDisplayName':
235
-					default:
236
-						// user display name does not lower case because
237
-						// we rely on an upper case N as indicator whether to
238
-						// auto-detect it or not. FIXME
239
-						$readMethod = 'getValue';
240
-						break;
241
-				}
242
-				$this->config[$key] = $this->$readMethod($dbKey);
243
-			}
244
-			$this->configRead = true;
245
-		}
246
-	}
201
+    public function readConfiguration() {
202
+        if(!$this->configRead && !is_null($this->configPrefix)) {
203
+            $cta = array_flip($this->getConfigTranslationArray());
204
+            foreach($this->config as $key => $val) {
205
+                if(!isset($cta[$key])) {
206
+                    //some are determined
207
+                    continue;
208
+                }
209
+                $dbKey = $cta[$key];
210
+                switch($key) {
211
+                    case 'ldapBase':
212
+                    case 'ldapBaseUsers':
213
+                    case 'ldapBaseGroups':
214
+                    case 'ldapAttributesForUserSearch':
215
+                    case 'ldapAttributesForGroupSearch':
216
+                    case 'ldapUserFilterObjectclass':
217
+                    case 'ldapUserFilterGroups':
218
+                    case 'ldapGroupFilterObjectclass':
219
+                    case 'ldapGroupFilterGroups':
220
+                    case 'ldapLoginFilterAttributes':
221
+                        $readMethod = 'getMultiLine';
222
+                        break;
223
+                    case 'ldapIgnoreNamingRules':
224
+                        $readMethod = 'getSystemValue';
225
+                        $dbKey = $key;
226
+                        break;
227
+                    case 'ldapAgentPassword':
228
+                        $readMethod = 'getPwd';
229
+                        break;
230
+                    case 'ldapUserDisplayName2':
231
+                    case 'ldapGroupDisplayName':
232
+                        $readMethod = 'getLcValue';
233
+                        break;
234
+                    case 'ldapUserDisplayName':
235
+                    default:
236
+                        // user display name does not lower case because
237
+                        // we rely on an upper case N as indicator whether to
238
+                        // auto-detect it or not. FIXME
239
+                        $readMethod = 'getValue';
240
+                        break;
241
+                }
242
+                $this->config[$key] = $this->$readMethod($dbKey);
243
+            }
244
+            $this->configRead = true;
245
+        }
246
+    }
247 247
 
248
-	/**
249
-	 * saves the current config changes in the database
250
-	 */
251
-	public function saveConfiguration() {
252
-		$cta = array_flip($this->getConfigTranslationArray());
253
-		foreach($this->unsavedChanges as $key) {
254
-			$value = $this->config[$key];
255
-			switch ($key) {
256
-				case 'ldapAgentPassword':
257
-					$value = base64_encode($value);
258
-					break;
259
-				case 'ldapBase':
260
-				case 'ldapBaseUsers':
261
-				case 'ldapBaseGroups':
262
-				case 'ldapAttributesForUserSearch':
263
-				case 'ldapAttributesForGroupSearch':
264
-				case 'ldapUserFilterObjectclass':
265
-				case 'ldapUserFilterGroups':
266
-				case 'ldapGroupFilterObjectclass':
267
-				case 'ldapGroupFilterGroups':
268
-				case 'ldapLoginFilterAttributes':
269
-					if(is_array($value)) {
270
-						$value = implode("\n", $value);
271
-					}
272
-					break;
273
-				//following options are not stored but detected, skip them
274
-				case 'ldapIgnoreNamingRules':
275
-				case 'hasPagedResultSupport':
276
-				case 'ldapUuidUserAttribute':
277
-				case 'ldapUuidGroupAttribute':
278
-					continue 2;
279
-			}
280
-			if(is_null($value)) {
281
-				$value = '';
282
-			}
283
-			$this->saveValue($cta[$key], $value);
284
-		}
285
-		$this->saveValue('_lastChange', time());
286
-		$this->unsavedChanges = [];
287
-	}
248
+    /**
249
+     * saves the current config changes in the database
250
+     */
251
+    public function saveConfiguration() {
252
+        $cta = array_flip($this->getConfigTranslationArray());
253
+        foreach($this->unsavedChanges as $key) {
254
+            $value = $this->config[$key];
255
+            switch ($key) {
256
+                case 'ldapAgentPassword':
257
+                    $value = base64_encode($value);
258
+                    break;
259
+                case 'ldapBase':
260
+                case 'ldapBaseUsers':
261
+                case 'ldapBaseGroups':
262
+                case 'ldapAttributesForUserSearch':
263
+                case 'ldapAttributesForGroupSearch':
264
+                case 'ldapUserFilterObjectclass':
265
+                case 'ldapUserFilterGroups':
266
+                case 'ldapGroupFilterObjectclass':
267
+                case 'ldapGroupFilterGroups':
268
+                case 'ldapLoginFilterAttributes':
269
+                    if(is_array($value)) {
270
+                        $value = implode("\n", $value);
271
+                    }
272
+                    break;
273
+                //following options are not stored but detected, skip them
274
+                case 'ldapIgnoreNamingRules':
275
+                case 'hasPagedResultSupport':
276
+                case 'ldapUuidUserAttribute':
277
+                case 'ldapUuidGroupAttribute':
278
+                    continue 2;
279
+            }
280
+            if(is_null($value)) {
281
+                $value = '';
282
+            }
283
+            $this->saveValue($cta[$key], $value);
284
+        }
285
+        $this->saveValue('_lastChange', time());
286
+        $this->unsavedChanges = [];
287
+    }
288 288
 
289
-	/**
290
-	 * @param string $varName
291
-	 * @return array|string
292
-	 */
293
-	protected function getMultiLine($varName) {
294
-		$value = $this->getValue($varName);
295
-		if(empty($value)) {
296
-			$value = '';
297
-		} else {
298
-			$value = preg_split('/\r\n|\r|\n/', $value);
299
-		}
289
+    /**
290
+     * @param string $varName
291
+     * @return array|string
292
+     */
293
+    protected function getMultiLine($varName) {
294
+        $value = $this->getValue($varName);
295
+        if(empty($value)) {
296
+            $value = '';
297
+        } else {
298
+            $value = preg_split('/\r\n|\r|\n/', $value);
299
+        }
300 300
 
301
-		return $value;
302
-	}
301
+        return $value;
302
+    }
303 303
 
304
-	/**
305
-	 * Sets multi-line values as arrays
306
-	 * 
307
-	 * @param string $varName name of config-key
308
-	 * @param array|string $value to set
309
-	 */
310
-	protected function setMultiLine($varName, $value) {
311
-		if(empty($value)) {
312
-			$value = '';
313
-		} else if (!is_array($value)) {
314
-			$value = preg_split('/\r\n|\r|\n|;/', $value);
315
-			if($value === false) {
316
-				$value = '';
317
-			}
318
-		}
304
+    /**
305
+     * Sets multi-line values as arrays
306
+     * 
307
+     * @param string $varName name of config-key
308
+     * @param array|string $value to set
309
+     */
310
+    protected function setMultiLine($varName, $value) {
311
+        if(empty($value)) {
312
+            $value = '';
313
+        } else if (!is_array($value)) {
314
+            $value = preg_split('/\r\n|\r|\n|;/', $value);
315
+            if($value === false) {
316
+                $value = '';
317
+            }
318
+        }
319 319
 
320
-		if(!is_array($value)) {
321
-			$finalValue = trim($value);
322
-		} else {
323
-			$finalValue = [];
324
-			foreach($value as $key => $val) {
325
-				if(is_string($val)) {
326
-					$val = trim($val);
327
-					if ($val !== '') {
328
-						//accidental line breaks are not wanted and can cause
329
-						// odd behaviour. Thus, away with them.
330
-						$finalValue[] = $val;
331
-					}
332
-				} else {
333
-					$finalValue[] = $val;
334
-				}
335
-			}
336
-		}
320
+        if(!is_array($value)) {
321
+            $finalValue = trim($value);
322
+        } else {
323
+            $finalValue = [];
324
+            foreach($value as $key => $val) {
325
+                if(is_string($val)) {
326
+                    $val = trim($val);
327
+                    if ($val !== '') {
328
+                        //accidental line breaks are not wanted and can cause
329
+                        // odd behaviour. Thus, away with them.
330
+                        $finalValue[] = $val;
331
+                    }
332
+                } else {
333
+                    $finalValue[] = $val;
334
+                }
335
+            }
336
+        }
337 337
 
338
-		$this->setRawValue($varName, $finalValue);
339
-	}
338
+        $this->setRawValue($varName, $finalValue);
339
+    }
340 340
 
341
-	/**
342
-	 * @param string $varName
343
-	 * @return string
344
-	 */
345
-	protected function getPwd($varName) {
346
-		return base64_decode($this->getValue($varName));
347
-	}
341
+    /**
342
+     * @param string $varName
343
+     * @return string
344
+     */
345
+    protected function getPwd($varName) {
346
+        return base64_decode($this->getValue($varName));
347
+    }
348 348
 
349
-	/**
350
-	 * @param string $varName
351
-	 * @return string
352
-	 */
353
-	protected function getLcValue($varName) {
354
-		return mb_strtolower($this->getValue($varName), 'UTF-8');
355
-	}
349
+    /**
350
+     * @param string $varName
351
+     * @return string
352
+     */
353
+    protected function getLcValue($varName) {
354
+        return mb_strtolower($this->getValue($varName), 'UTF-8');
355
+    }
356 356
 
357
-	/**
358
-	 * @param string $varName
359
-	 * @return string
360
-	 */
361
-	protected function getSystemValue($varName) {
362
-		//FIXME: if another system value is added, softcode the default value
363
-		return \OC::$server->getConfig()->getSystemValue($varName, false);
364
-	}
357
+    /**
358
+     * @param string $varName
359
+     * @return string
360
+     */
361
+    protected function getSystemValue($varName) {
362
+        //FIXME: if another system value is added, softcode the default value
363
+        return \OC::$server->getConfig()->getSystemValue($varName, false);
364
+    }
365 365
 
366
-	/**
367
-	 * @param string $varName
368
-	 * @return string
369
-	 */
370
-	protected function getValue($varName) {
371
-		static $defaults;
372
-		if(is_null($defaults)) {
373
-			$defaults = $this->getDefaults();
374
-		}
375
-		return \OCP\Config::getAppValue('user_ldap',
376
-										$this->configPrefix.$varName,
377
-										$defaults[$varName]);
378
-	}
366
+    /**
367
+     * @param string $varName
368
+     * @return string
369
+     */
370
+    protected function getValue($varName) {
371
+        static $defaults;
372
+        if(is_null($defaults)) {
373
+            $defaults = $this->getDefaults();
374
+        }
375
+        return \OCP\Config::getAppValue('user_ldap',
376
+                                        $this->configPrefix.$varName,
377
+                                        $defaults[$varName]);
378
+    }
379 379
 
380
-	/**
381
-	 * Sets a scalar value.
382
-	 * 
383
-	 * @param string $varName name of config key
384
-	 * @param mixed $value to set
385
-	 */
386
-	protected function setValue($varName, $value) {
387
-		if(is_string($value)) {
388
-			$value = trim($value);
389
-		}
390
-		$this->config[$varName] = $value;
391
-	}
380
+    /**
381
+     * Sets a scalar value.
382
+     * 
383
+     * @param string $varName name of config key
384
+     * @param mixed $value to set
385
+     */
386
+    protected function setValue($varName, $value) {
387
+        if(is_string($value)) {
388
+            $value = trim($value);
389
+        }
390
+        $this->config[$varName] = $value;
391
+    }
392 392
 
393
-	/**
394
-	 * Sets a scalar value without trimming.
395
-	 *
396
-	 * @param string $varName name of config key
397
-	 * @param mixed $value to set
398
-	 */
399
-	protected function setRawValue($varName, $value) {
400
-		$this->config[$varName] = $value;
401
-	}
393
+    /**
394
+     * Sets a scalar value without trimming.
395
+     *
396
+     * @param string $varName name of config key
397
+     * @param mixed $value to set
398
+     */
399
+    protected function setRawValue($varName, $value) {
400
+        $this->config[$varName] = $value;
401
+    }
402 402
 
403
-	/**
404
-	 * @param string $varName
405
-	 * @param string $value
406
-	 * @return bool
407
-	 */
408
-	protected function saveValue($varName, $value) {
409
-		\OC::$server->getConfig()->setAppValue(
410
-			'user_ldap',
411
-			$this->configPrefix.$varName,
412
-			$value
413
-		);
414
-		return true;
415
-	}
403
+    /**
404
+     * @param string $varName
405
+     * @param string $value
406
+     * @return bool
407
+     */
408
+    protected function saveValue($varName, $value) {
409
+        \OC::$server->getConfig()->setAppValue(
410
+            'user_ldap',
411
+            $this->configPrefix.$varName,
412
+            $value
413
+        );
414
+        return true;
415
+    }
416 416
 
417
-	/**
418
-	 * @return array an associative array with the default values. Keys are correspond
419
-	 * to config-value entries in the database table
420
-	 */
421
-	public function getDefaults() {
422
-		return array(
423
-			'ldap_host'                         => '',
424
-			'ldap_port'                         => '',
425
-			'ldap_backup_host'                  => '',
426
-			'ldap_backup_port'                  => '',
427
-			'ldap_override_main_server'         => '',
428
-			'ldap_dn'                           => '',
429
-			'ldap_agent_password'               => '',
430
-			'ldap_base'                         => '',
431
-			'ldap_base_users'                   => '',
432
-			'ldap_base_groups'                  => '',
433
-			'ldap_userlist_filter'              => '',
434
-			'ldap_user_filter_mode'             => 0,
435
-			'ldap_userfilter_objectclass'       => '',
436
-			'ldap_userfilter_groups'            => '',
437
-			'ldap_login_filter'                 => '',
438
-			'ldap_login_filter_mode'            => 0,
439
-			'ldap_loginfilter_email'            => 0,
440
-			'ldap_loginfilter_username'         => 1,
441
-			'ldap_loginfilter_attributes'       => '',
442
-			'ldap_group_filter'                 => '',
443
-			'ldap_group_filter_mode'            => 0,
444
-			'ldap_groupfilter_objectclass'      => '',
445
-			'ldap_groupfilter_groups'           => '',
446
-			'ldap_gid_number'                   => 'gidNumber',
447
-			'ldap_display_name'                 => 'displayName',
448
-			'ldap_user_display_name_2'			=> '',
449
-			'ldap_group_display_name'           => 'cn',
450
-			'ldap_tls'                          => 0,
451
-			'ldap_quota_def'                    => '',
452
-			'ldap_quota_attr'                   => '',
453
-			'ldap_email_attr'                   => '',
454
-			'ldap_group_member_assoc_attribute' => 'uniqueMember',
455
-			'ldap_cache_ttl'                    => 600,
456
-			'ldap_uuid_user_attribute'          => 'auto',
457
-			'ldap_uuid_group_attribute'         => 'auto',
458
-			'home_folder_naming_rule'           => '',
459
-			'ldap_turn_off_cert_check'          => 0,
460
-			'ldap_configuration_active'         => 0,
461
-			'ldap_attributes_for_user_search'   => '',
462
-			'ldap_attributes_for_group_search'  => '',
463
-			'ldap_expert_username_attr'         => '',
464
-			'ldap_expert_uuid_user_attr'        => '',
465
-			'ldap_expert_uuid_group_attr'       => '',
466
-			'has_memberof_filter_support'       => 0,
467
-			'use_memberof_to_detect_membership' => 1,
468
-			'last_jpegPhoto_lookup'             => 0,
469
-			'ldap_nested_groups'                => 0,
470
-			'ldap_paging_size'                  => 500,
471
-			'ldap_turn_on_pwd_change'           => 0,
472
-			'ldap_experienced_admin'            => 0,
473
-			'ldap_dynamic_group_member_url'     => '',
474
-			'ldap_default_ppolicy_dn'           => '',
475
-		);
476
-	}
417
+    /**
418
+     * @return array an associative array with the default values. Keys are correspond
419
+     * to config-value entries in the database table
420
+     */
421
+    public function getDefaults() {
422
+        return array(
423
+            'ldap_host'                         => '',
424
+            'ldap_port'                         => '',
425
+            'ldap_backup_host'                  => '',
426
+            'ldap_backup_port'                  => '',
427
+            'ldap_override_main_server'         => '',
428
+            'ldap_dn'                           => '',
429
+            'ldap_agent_password'               => '',
430
+            'ldap_base'                         => '',
431
+            'ldap_base_users'                   => '',
432
+            'ldap_base_groups'                  => '',
433
+            'ldap_userlist_filter'              => '',
434
+            'ldap_user_filter_mode'             => 0,
435
+            'ldap_userfilter_objectclass'       => '',
436
+            'ldap_userfilter_groups'            => '',
437
+            'ldap_login_filter'                 => '',
438
+            'ldap_login_filter_mode'            => 0,
439
+            'ldap_loginfilter_email'            => 0,
440
+            'ldap_loginfilter_username'         => 1,
441
+            'ldap_loginfilter_attributes'       => '',
442
+            'ldap_group_filter'                 => '',
443
+            'ldap_group_filter_mode'            => 0,
444
+            'ldap_groupfilter_objectclass'      => '',
445
+            'ldap_groupfilter_groups'           => '',
446
+            'ldap_gid_number'                   => 'gidNumber',
447
+            'ldap_display_name'                 => 'displayName',
448
+            'ldap_user_display_name_2'			=> '',
449
+            'ldap_group_display_name'           => 'cn',
450
+            'ldap_tls'                          => 0,
451
+            'ldap_quota_def'                    => '',
452
+            'ldap_quota_attr'                   => '',
453
+            'ldap_email_attr'                   => '',
454
+            'ldap_group_member_assoc_attribute' => 'uniqueMember',
455
+            'ldap_cache_ttl'                    => 600,
456
+            'ldap_uuid_user_attribute'          => 'auto',
457
+            'ldap_uuid_group_attribute'         => 'auto',
458
+            'home_folder_naming_rule'           => '',
459
+            'ldap_turn_off_cert_check'          => 0,
460
+            'ldap_configuration_active'         => 0,
461
+            'ldap_attributes_for_user_search'   => '',
462
+            'ldap_attributes_for_group_search'  => '',
463
+            'ldap_expert_username_attr'         => '',
464
+            'ldap_expert_uuid_user_attr'        => '',
465
+            'ldap_expert_uuid_group_attr'       => '',
466
+            'has_memberof_filter_support'       => 0,
467
+            'use_memberof_to_detect_membership' => 1,
468
+            'last_jpegPhoto_lookup'             => 0,
469
+            'ldap_nested_groups'                => 0,
470
+            'ldap_paging_size'                  => 500,
471
+            'ldap_turn_on_pwd_change'           => 0,
472
+            'ldap_experienced_admin'            => 0,
473
+            'ldap_dynamic_group_member_url'     => '',
474
+            'ldap_default_ppolicy_dn'           => '',
475
+        );
476
+    }
477 477
 
478
-	/**
479
-	 * @return array that maps internal variable names to database fields
480
-	 */
481
-	public function getConfigTranslationArray() {
482
-		//TODO: merge them into one representation
483
-		static $array = array(
484
-			'ldap_host'                         => 'ldapHost',
485
-			'ldap_port'                         => 'ldapPort',
486
-			'ldap_backup_host'                  => 'ldapBackupHost',
487
-			'ldap_backup_port'                  => 'ldapBackupPort',
488
-			'ldap_override_main_server'         => 'ldapOverrideMainServer',
489
-			'ldap_dn'                           => 'ldapAgentName',
490
-			'ldap_agent_password'               => 'ldapAgentPassword',
491
-			'ldap_base'                         => 'ldapBase',
492
-			'ldap_base_users'                   => 'ldapBaseUsers',
493
-			'ldap_base_groups'                  => 'ldapBaseGroups',
494
-			'ldap_userfilter_objectclass'       => 'ldapUserFilterObjectclass',
495
-			'ldap_userfilter_groups'            => 'ldapUserFilterGroups',
496
-			'ldap_userlist_filter'              => 'ldapUserFilter',
497
-			'ldap_user_filter_mode'             => 'ldapUserFilterMode',
498
-			'ldap_login_filter'                 => 'ldapLoginFilter',
499
-			'ldap_login_filter_mode'            => 'ldapLoginFilterMode',
500
-			'ldap_loginfilter_email'            => 'ldapLoginFilterEmail',
501
-			'ldap_loginfilter_username'         => 'ldapLoginFilterUsername',
502
-			'ldap_loginfilter_attributes'       => 'ldapLoginFilterAttributes',
503
-			'ldap_group_filter'                 => 'ldapGroupFilter',
504
-			'ldap_group_filter_mode'            => 'ldapGroupFilterMode',
505
-			'ldap_groupfilter_objectclass'      => 'ldapGroupFilterObjectclass',
506
-			'ldap_groupfilter_groups'           => 'ldapGroupFilterGroups',
507
-			'ldap_gid_number'                   => 'ldapGidNumber',
508
-			'ldap_display_name'                 => 'ldapUserDisplayName',
509
-			'ldap_user_display_name_2'			=> 'ldapUserDisplayName2',
510
-			'ldap_group_display_name'           => 'ldapGroupDisplayName',
511
-			'ldap_tls'                          => 'ldapTLS',
512
-			'ldap_quota_def'                    => 'ldapQuotaDefault',
513
-			'ldap_quota_attr'                   => 'ldapQuotaAttribute',
514
-			'ldap_email_attr'                   => 'ldapEmailAttribute',
515
-			'ldap_group_member_assoc_attribute' => 'ldapGroupMemberAssocAttr',
516
-			'ldap_cache_ttl'                    => 'ldapCacheTTL',
517
-			'home_folder_naming_rule'           => 'homeFolderNamingRule',
518
-			'ldap_turn_off_cert_check'          => 'turnOffCertCheck',
519
-			'ldap_configuration_active'         => 'ldapConfigurationActive',
520
-			'ldap_attributes_for_user_search'   => 'ldapAttributesForUserSearch',
521
-			'ldap_attributes_for_group_search'  => 'ldapAttributesForGroupSearch',
522
-			'ldap_expert_username_attr'         => 'ldapExpertUsernameAttr',
523
-			'ldap_expert_uuid_user_attr'        => 'ldapExpertUUIDUserAttr',
524
-			'ldap_expert_uuid_group_attr'       => 'ldapExpertUUIDGroupAttr',
525
-			'has_memberof_filter_support'       => 'hasMemberOfFilterSupport',
526
-			'use_memberof_to_detect_membership' => 'useMemberOfToDetectMembership',
527
-			'last_jpegPhoto_lookup'             => 'lastJpegPhotoLookup',
528
-			'ldap_nested_groups'                => 'ldapNestedGroups',
529
-			'ldap_paging_size'                  => 'ldapPagingSize',
530
-			'ldap_turn_on_pwd_change'           => 'turnOnPasswordChange',
531
-			'ldap_experienced_admin'            => 'ldapExperiencedAdmin',
532
-			'ldap_dynamic_group_member_url'     => 'ldapDynamicGroupMemberURL',
533
-			'ldap_default_ppolicy_dn'           => 'ldapDefaultPPolicyDN',
534
-		);
535
-		return $array;
536
-	}
478
+    /**
479
+     * @return array that maps internal variable names to database fields
480
+     */
481
+    public function getConfigTranslationArray() {
482
+        //TODO: merge them into one representation
483
+        static $array = array(
484
+            'ldap_host'                         => 'ldapHost',
485
+            'ldap_port'                         => 'ldapPort',
486
+            'ldap_backup_host'                  => 'ldapBackupHost',
487
+            'ldap_backup_port'                  => 'ldapBackupPort',
488
+            'ldap_override_main_server'         => 'ldapOverrideMainServer',
489
+            'ldap_dn'                           => 'ldapAgentName',
490
+            'ldap_agent_password'               => 'ldapAgentPassword',
491
+            'ldap_base'                         => 'ldapBase',
492
+            'ldap_base_users'                   => 'ldapBaseUsers',
493
+            'ldap_base_groups'                  => 'ldapBaseGroups',
494
+            'ldap_userfilter_objectclass'       => 'ldapUserFilterObjectclass',
495
+            'ldap_userfilter_groups'            => 'ldapUserFilterGroups',
496
+            'ldap_userlist_filter'              => 'ldapUserFilter',
497
+            'ldap_user_filter_mode'             => 'ldapUserFilterMode',
498
+            'ldap_login_filter'                 => 'ldapLoginFilter',
499
+            'ldap_login_filter_mode'            => 'ldapLoginFilterMode',
500
+            'ldap_loginfilter_email'            => 'ldapLoginFilterEmail',
501
+            'ldap_loginfilter_username'         => 'ldapLoginFilterUsername',
502
+            'ldap_loginfilter_attributes'       => 'ldapLoginFilterAttributes',
503
+            'ldap_group_filter'                 => 'ldapGroupFilter',
504
+            'ldap_group_filter_mode'            => 'ldapGroupFilterMode',
505
+            'ldap_groupfilter_objectclass'      => 'ldapGroupFilterObjectclass',
506
+            'ldap_groupfilter_groups'           => 'ldapGroupFilterGroups',
507
+            'ldap_gid_number'                   => 'ldapGidNumber',
508
+            'ldap_display_name'                 => 'ldapUserDisplayName',
509
+            'ldap_user_display_name_2'			=> 'ldapUserDisplayName2',
510
+            'ldap_group_display_name'           => 'ldapGroupDisplayName',
511
+            'ldap_tls'                          => 'ldapTLS',
512
+            'ldap_quota_def'                    => 'ldapQuotaDefault',
513
+            'ldap_quota_attr'                   => 'ldapQuotaAttribute',
514
+            'ldap_email_attr'                   => 'ldapEmailAttribute',
515
+            'ldap_group_member_assoc_attribute' => 'ldapGroupMemberAssocAttr',
516
+            'ldap_cache_ttl'                    => 'ldapCacheTTL',
517
+            'home_folder_naming_rule'           => 'homeFolderNamingRule',
518
+            'ldap_turn_off_cert_check'          => 'turnOffCertCheck',
519
+            'ldap_configuration_active'         => 'ldapConfigurationActive',
520
+            'ldap_attributes_for_user_search'   => 'ldapAttributesForUserSearch',
521
+            'ldap_attributes_for_group_search'  => 'ldapAttributesForGroupSearch',
522
+            'ldap_expert_username_attr'         => 'ldapExpertUsernameAttr',
523
+            'ldap_expert_uuid_user_attr'        => 'ldapExpertUUIDUserAttr',
524
+            'ldap_expert_uuid_group_attr'       => 'ldapExpertUUIDGroupAttr',
525
+            'has_memberof_filter_support'       => 'hasMemberOfFilterSupport',
526
+            'use_memberof_to_detect_membership' => 'useMemberOfToDetectMembership',
527
+            'last_jpegPhoto_lookup'             => 'lastJpegPhotoLookup',
528
+            'ldap_nested_groups'                => 'ldapNestedGroups',
529
+            'ldap_paging_size'                  => 'ldapPagingSize',
530
+            'ldap_turn_on_pwd_change'           => 'turnOnPasswordChange',
531
+            'ldap_experienced_admin'            => 'ldapExperiencedAdmin',
532
+            'ldap_dynamic_group_member_url'     => 'ldapDynamicGroupMemberURL',
533
+            'ldap_default_ppolicy_dn'           => 'ldapDefaultPPolicyDN',
534
+        );
535
+        return $array;
536
+    }
537 537
 
538 538
 }
Please login to merge, or discard this patch.