aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/Configuration.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/lib/Configuration.php')
-rw-r--r--apps/user_ldap/lib/Configuration.php57
1 files changed, 28 insertions, 29 deletions
diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php
index ccba7b43586..4076a6e8a3d 100644
--- a/apps/user_ldap/lib/Configuration.php
+++ b/apps/user_ldap/lib/Configuration.php
@@ -118,7 +118,7 @@ class Configuration {
*/
public function __construct($configPrefix, $autoRead = true) {
$this->configPrefix = $configPrefix;
- if($autoRead) {
+ if ($autoRead) {
$this->readConfiguration();
}
}
@@ -128,7 +128,7 @@ class Configuration {
* @return mixed|null
*/
public function __get($name) {
- if(isset($this->config[$name])) {
+ if (isset($this->config[$name])) {
return $this->config[$name];
}
return null;
@@ -159,22 +159,22 @@ class Configuration {
* @return false|null
*/
public function setConfiguration($config, &$applied = null) {
- if(!is_array($config)) {
+ if (!is_array($config)) {
return false;
}
$cta = $this->getConfigTranslationArray();
- foreach($config as $inputKey => $val) {
- if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
+ foreach ($config as $inputKey => $val) {
+ if (strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
$key = $cta[$inputKey];
- } elseif(array_key_exists($inputKey, $this->config)) {
+ } elseif (array_key_exists($inputKey, $this->config)) {
$key = $inputKey;
} else {
continue;
}
$setMethod = 'setValue';
- switch($key) {
+ switch ($key) {
case 'ldapAgentPassword':
$setMethod = 'setRawValue';
break;
@@ -198,7 +198,7 @@ class Configuration {
break;
}
$this->$setMethod($key, $val);
- if(is_array($applied)) {
+ if (is_array($applied)) {
$applied[] = $inputKey;
// storing key as index avoids duplication, and as value for simplicity
}
@@ -208,15 +208,15 @@ class Configuration {
}
public function readConfiguration() {
- if(!$this->configRead && !is_null($this->configPrefix)) {
+ if (!$this->configRead && !is_null($this->configPrefix)) {
$cta = array_flip($this->getConfigTranslationArray());
- foreach($this->config as $key => $val) {
- if(!isset($cta[$key])) {
+ foreach ($this->config as $key => $val) {
+ if (!isset($cta[$key])) {
//some are determined
continue;
}
$dbKey = $cta[$key];
- switch($key) {
+ switch ($key) {
case 'ldapBase':
case 'ldapBaseUsers':
case 'ldapBaseGroups':
@@ -259,7 +259,7 @@ class Configuration {
*/
public function saveConfiguration() {
$cta = array_flip($this->getConfigTranslationArray());
- foreach($this->unsavedChanges as $key) {
+ foreach ($this->unsavedChanges as $key) {
$value = $this->config[$key];
switch ($key) {
case 'ldapAgentPassword':
@@ -275,7 +275,7 @@ class Configuration {
case 'ldapGroupFilterObjectclass':
case 'ldapGroupFilterGroups':
case 'ldapLoginFilterAttributes':
- if(is_array($value)) {
+ if (is_array($value)) {
$value = implode("\n", $value);
}
break;
@@ -285,7 +285,7 @@ class Configuration {
case 'ldapUuidGroupAttribute':
continue 2;
}
- if(is_null($value)) {
+ if (is_null($value)) {
$value = '';
}
$this->saveValue($cta[$key], $value);
@@ -300,7 +300,7 @@ class Configuration {
*/
protected function getMultiLine($varName) {
$value = $this->getValue($varName);
- if(empty($value)) {
+ if (empty($value)) {
$value = '';
} else {
$value = preg_split('/\r\n|\r|\n/', $value);
@@ -316,21 +316,21 @@ class Configuration {
* @param array|string $value to set
*/
protected function setMultiLine($varName, $value) {
- if(empty($value)) {
+ if (empty($value)) {
$value = '';
} elseif (!is_array($value)) {
$value = preg_split('/\r\n|\r|\n|;/', $value);
- if($value === false) {
+ if ($value === false) {
$value = '';
}
}
- if(!is_array($value)) {
+ if (!is_array($value)) {
$finalValue = trim($value);
} else {
$finalValue = [];
- foreach($value as $key => $val) {
- if(is_string($val)) {
+ foreach ($value as $key => $val) {
+ if (is_string($val)) {
$val = trim($val);
if ($val !== '') {
//accidental line breaks are not wanted and can cause
@@ -377,7 +377,7 @@ class Configuration {
*/
protected function getValue($varName) {
static $defaults;
- if(is_null($defaults)) {
+ if (is_null($defaults)) {
$defaults = $this->getDefaults();
}
return \OC::$server->getConfig()->getAppValue('user_ldap',
@@ -392,7 +392,7 @@ class Configuration {
* @param mixed $value to set
*/
protected function setValue($varName, $value) {
- if(is_string($value)) {
+ if (is_string($value)) {
$value = trim($value);
}
$this->config[$varName] = $value;
@@ -554,7 +554,7 @@ class Configuration {
* @throws \RuntimeException
*/
public function resolveRule($rule) {
- if($rule === 'avatar') {
+ if ($rule === 'avatar') {
return $this->getAvatarAttributes();
}
throw new \RuntimeException('Invalid rule');
@@ -564,20 +564,19 @@ class Configuration {
$value = $this->ldapUserAvatarRule ?: self::AVATAR_PREFIX_DEFAULT;
$defaultAttributes = ['jpegphoto', 'thumbnailphoto'];
- if($value === self::AVATAR_PREFIX_NONE) {
+ if ($value === self::AVATAR_PREFIX_NONE) {
return [];
}
- if(strpos($value, self::AVATAR_PREFIX_DATA_ATTRIBUTE) === 0) {
+ if (strpos($value, self::AVATAR_PREFIX_DATA_ATTRIBUTE) === 0) {
$attribute = trim(substr($value, strlen(self::AVATAR_PREFIX_DATA_ATTRIBUTE)));
- if($attribute === '') {
+ if ($attribute === '') {
return $defaultAttributes;
}
return [strtolower($attribute)];
}
- if($value !== self::AVATAR_PREFIX_DEFAULT) {
+ if ($value !== self::AVATAR_PREFIX_DEFAULT) {
\OC::$server->getLogger()->warning('Invalid config value to ldapUserAvatarRule; falling back to default.');
}
return $defaultAttributes;
}
-
}