Completed
Pull Request — master (#3218)
by Vars
46:46 queued 34:29
created
apps/user_ldap/lib/Migration/UUIDFix.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -30,31 +30,31 @@
 block discarded – undo
30 30
 use OCA\User_LDAP\User_Proxy;
31 31
 
32 32
 abstract class UUIDFix extends QueuedJob {
33
-	/** @var  AbstractMapping */
34
-	protected $mapper;
33
+    /** @var  AbstractMapping */
34
+    protected $mapper;
35 35
 
36
-	/** @var  Proxy */
37
-	protected $proxy;
36
+    /** @var  Proxy */
37
+    protected $proxy;
38 38
 
39
-	public function run($argument) {
40
-		$isUser = $this->proxy instanceof User_Proxy;
41
-		foreach($argument['records'] as $record) {
42
-			$access = $this->proxy->getLDAPAccess($record['name']);
43
-			$uuid = $access->getUUID($record['dn'], $isUser);
44
-			if($uuid === false) {
45
-				// record not found, no prob, continue with the next
46
-				continue;
47
-			}
48
-			if($uuid !== $record['uuid']) {
49
-				$this->mapper->setUUIDbyDN($uuid, $record['dn']);
50
-			}
51
-		}
52
-	}
39
+    public function run($argument) {
40
+        $isUser = $this->proxy instanceof User_Proxy;
41
+        foreach($argument['records'] as $record) {
42
+            $access = $this->proxy->getLDAPAccess($record['name']);
43
+            $uuid = $access->getUUID($record['dn'], $isUser);
44
+            if($uuid === false) {
45
+                // record not found, no prob, continue with the next
46
+                continue;
47
+            }
48
+            if($uuid !== $record['uuid']) {
49
+                $this->mapper->setUUIDbyDN($uuid, $record['dn']);
50
+            }
51
+        }
52
+    }
53 53
 
54
-	/**
55
-	 * @param Proxy $proxy
56
-	 */
57
-	public function overrideProxy(Proxy $proxy) {
58
-		$this->proxy = $proxy;
59
-	}
54
+    /**
55
+     * @param Proxy $proxy
56
+     */
57
+    public function overrideProxy(Proxy $proxy) {
58
+        $this->proxy = $proxy;
59
+    }
60 60
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@
 block discarded – undo
38 38
 
39 39
 	public function run($argument) {
40 40
 		$isUser = $this->proxy instanceof User_Proxy;
41
-		foreach($argument['records'] as $record) {
41
+		foreach ($argument['records'] as $record) {
42 42
 			$access = $this->proxy->getLDAPAccess($record['name']);
43 43
 			$uuid = $access->getUUID($record['dn'], $isUser);
44
-			if($uuid === false) {
44
+			if ($uuid === false) {
45 45
 				// record not found, no prob, continue with the next
46 46
 				continue;
47 47
 			}
48
-			if($uuid !== $record['uuid']) {
48
+			if ($uuid !== $record['uuid']) {
49 49
 				$this->mapper->setUUIDbyDN($uuid, $record['dn']);
50 50
 			}
51 51
 		}
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/CheckUser.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -36,101 +36,101 @@
 block discarded – undo
36 36
 use OCA\User_LDAP\User_Proxy;
37 37
 
38 38
 class CheckUser extends Command {
39
-	/** @var \OCA\User_LDAP\User_Proxy */
40
-	protected $backend;
41
-
42
-	/** @var \OCA\User_LDAP\Helper */
43
-	protected $helper;
44
-
45
-	/** @var \OCA\User_LDAP\User\DeletedUsersIndex */
46
-	protected $dui;
47
-
48
-	/** @var \OCA\User_LDAP\Mapping\UserMapping */
49
-	protected $mapping;
50
-
51
-	/**
52
-	 * @param User_Proxy $uBackend
53
-	 * @param LDAPHelper $helper
54
-	 * @param DeletedUsersIndex $dui
55
-	 * @param UserMapping $mapping
56
-	 */
57
-	public function __construct(User_Proxy $uBackend, LDAPHelper $helper, DeletedUsersIndex $dui, UserMapping $mapping) {
58
-		$this->backend = $uBackend;
59
-		$this->helper = $helper;
60
-		$this->dui = $dui;
61
-		$this->mapping = $mapping;
62
-		parent::__construct();
63
-	}
64
-
65
-	protected function configure() {
66
-		$this
67
-			->setName('ldap:check-user')
68
-			->setDescription('checks whether a user exists on LDAP.')
69
-			->addArgument(
70
-					'ocName',
71
-					InputArgument::REQUIRED,
72
-					'the user name as used in ownCloud'
73
-				     )
74
-			->addOption(
75
-					'force',
76
-					null,
77
-					InputOption::VALUE_NONE,
78
-					'ignores disabled LDAP configuration'
79
-				     )
80
-		;
81
-	}
82
-
83
-	protected function execute(InputInterface $input, OutputInterface $output) {
84
-		try {
85
-			$uid = $input->getArgument('ocName');
86
-			$this->isAllowed($input->getOption('force'));
87
-			$this->confirmUserIsMapped($uid);
88
-			$exists = $this->backend->userExistsOnLDAP($uid);
89
-			if($exists === true) {
90
-				$output->writeln('The user is still available on LDAP.');
91
-				return;
92
-			}
93
-
94
-			$this->dui->markUser($uid);
95
-			$output->writeln('The user does not exists on LDAP anymore.');
96
-			$output->writeln('Clean up the user\'s remnants by: ./occ user:delete "'
97
-				. $uid . '"');
98
-		} catch (\Exception $e) {
99
-			$output->writeln('<error>' . $e->getMessage(). '</error>');
100
-		}
101
-	}
102
-
103
-	/**
104
-	 * checks whether a user is actually mapped
105
-	 * @param string $ocName the username as used in ownCloud
106
-	 * @throws \Exception
107
-	 * @return true
108
-	 */
109
-	protected function confirmUserIsMapped($ocName) {
110
-		$dn = $this->mapping->getDNByName($ocName);
111
-		if ($dn === false) {
112
-			throw new \Exception('The given user is not a recognized LDAP user.');
113
-		}
114
-
115
-		return true;
116
-	}
117
-
118
-	/**
119
-	 * checks whether the setup allows reliable checking of LDAP user existence
120
-	 * @throws \Exception
121
-	 * @return true
122
-	 */
123
-	protected function isAllowed($force) {
124
-		if($this->helper->haveDisabledConfigurations() && !$force) {
125
-			throw new \Exception('Cannot check user existence, because '
126
-				. 'disabled LDAP configurations are present.');
127
-		}
128
-
129
-		// we don't check ldapUserCleanupInterval from config.php because this
130
-		// action is triggered manually, while the setting only controls the
131
-		// background job.
132
-
133
-		return true;
134
-	}
39
+    /** @var \OCA\User_LDAP\User_Proxy */
40
+    protected $backend;
41
+
42
+    /** @var \OCA\User_LDAP\Helper */
43
+    protected $helper;
44
+
45
+    /** @var \OCA\User_LDAP\User\DeletedUsersIndex */
46
+    protected $dui;
47
+
48
+    /** @var \OCA\User_LDAP\Mapping\UserMapping */
49
+    protected $mapping;
50
+
51
+    /**
52
+     * @param User_Proxy $uBackend
53
+     * @param LDAPHelper $helper
54
+     * @param DeletedUsersIndex $dui
55
+     * @param UserMapping $mapping
56
+     */
57
+    public function __construct(User_Proxy $uBackend, LDAPHelper $helper, DeletedUsersIndex $dui, UserMapping $mapping) {
58
+        $this->backend = $uBackend;
59
+        $this->helper = $helper;
60
+        $this->dui = $dui;
61
+        $this->mapping = $mapping;
62
+        parent::__construct();
63
+    }
64
+
65
+    protected function configure() {
66
+        $this
67
+            ->setName('ldap:check-user')
68
+            ->setDescription('checks whether a user exists on LDAP.')
69
+            ->addArgument(
70
+                    'ocName',
71
+                    InputArgument::REQUIRED,
72
+                    'the user name as used in ownCloud'
73
+                        )
74
+            ->addOption(
75
+                    'force',
76
+                    null,
77
+                    InputOption::VALUE_NONE,
78
+                    'ignores disabled LDAP configuration'
79
+                        )
80
+        ;
81
+    }
82
+
83
+    protected function execute(InputInterface $input, OutputInterface $output) {
84
+        try {
85
+            $uid = $input->getArgument('ocName');
86
+            $this->isAllowed($input->getOption('force'));
87
+            $this->confirmUserIsMapped($uid);
88
+            $exists = $this->backend->userExistsOnLDAP($uid);
89
+            if($exists === true) {
90
+                $output->writeln('The user is still available on LDAP.');
91
+                return;
92
+            }
93
+
94
+            $this->dui->markUser($uid);
95
+            $output->writeln('The user does not exists on LDAP anymore.');
96
+            $output->writeln('Clean up the user\'s remnants by: ./occ user:delete "'
97
+                . $uid . '"');
98
+        } catch (\Exception $e) {
99
+            $output->writeln('<error>' . $e->getMessage(). '</error>');
100
+        }
101
+    }
102
+
103
+    /**
104
+     * checks whether a user is actually mapped
105
+     * @param string $ocName the username as used in ownCloud
106
+     * @throws \Exception
107
+     * @return true
108
+     */
109
+    protected function confirmUserIsMapped($ocName) {
110
+        $dn = $this->mapping->getDNByName($ocName);
111
+        if ($dn === false) {
112
+            throw new \Exception('The given user is not a recognized LDAP user.');
113
+        }
114
+
115
+        return true;
116
+    }
117
+
118
+    /**
119
+     * checks whether the setup allows reliable checking of LDAP user existence
120
+     * @throws \Exception
121
+     * @return true
122
+     */
123
+    protected function isAllowed($force) {
124
+        if($this->helper->haveDisabledConfigurations() && !$force) {
125
+            throw new \Exception('Cannot check user existence, because '
126
+                . 'disabled LDAP configurations are present.');
127
+        }
128
+
129
+        // we don't check ldapUserCleanupInterval from config.php because this
130
+        // action is triggered manually, while the setting only controls the
131
+        // background job.
132
+
133
+        return true;
134
+    }
135 135
 
136 136
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			$this->isAllowed($input->getOption('force'));
87 87
 			$this->confirmUserIsMapped($uid);
88 88
 			$exists = $this->backend->userExistsOnLDAP($uid);
89
-			if($exists === true) {
89
+			if ($exists === true) {
90 90
 				$output->writeln('The user is still available on LDAP.');
91 91
 				return;
92 92
 			}
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 			$this->dui->markUser($uid);
95 95
 			$output->writeln('The user does not exists on LDAP anymore.');
96 96
 			$output->writeln('Clean up the user\'s remnants by: ./occ user:delete "'
97
-				. $uid . '"');
97
+				. $uid.'"');
98 98
 		} catch (\Exception $e) {
99
-			$output->writeln('<error>' . $e->getMessage(). '</error>');
99
+			$output->writeln('<error>'.$e->getMessage().'</error>');
100 100
 		}
101 101
 	}
102 102
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @return true
122 122
 	 */
123 123
 	protected function isAllowed($force) {
124
-		if($this->helper->haveDisabledConfigurations() && !$force) {
124
+		if ($this->helper->haveDisabledConfigurations() && !$force) {
125 125
 			throw new \Exception('Cannot check user existence, because '
126 126
 				. 'disabled LDAP configurations are present.');
127 127
 		}
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/Search.php 2 patches
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -37,93 +37,93 @@
 block discarded – undo
37 37
 use OCP\IConfig;
38 38
 
39 39
 class Search extends Command {
40
-	/** @var \OCP\IConfig */
41
-	protected $ocConfig;
40
+    /** @var \OCP\IConfig */
41
+    protected $ocConfig;
42 42
 
43
-	/**
44
-	 * @param \OCP\IConfig $ocConfig
45
-	 */
46
-	public function __construct(IConfig $ocConfig) {
47
-		$this->ocConfig = $ocConfig;
48
-		parent::__construct();
49
-	}
43
+    /**
44
+     * @param \OCP\IConfig $ocConfig
45
+     */
46
+    public function __construct(IConfig $ocConfig) {
47
+        $this->ocConfig = $ocConfig;
48
+        parent::__construct();
49
+    }
50 50
 
51
-	protected function configure() {
52
-		$this
53
-			->setName('ldap:search')
54
-			->setDescription('executes a user or group search')
55
-			->addArgument(
56
-					'search',
57
-					InputArgument::REQUIRED,
58
-					'the search string (can be empty)'
59
-				     )
60
-			->addOption(
61
-					'group',
62
-					null,
63
-					InputOption::VALUE_NONE,
64
-					'searches groups instead of users'
65
-				     )
66
-			->addOption(
67
-					'offset',
68
-					null,
69
-					InputOption::VALUE_REQUIRED,
70
-					'The offset of the result set. Needs to be a multiple of limit. defaults to 0.',
71
-					0
72
-				     )
73
-			->addOption(
74
-					'limit',
75
-					null,
76
-					InputOption::VALUE_REQUIRED,
77
-					'limit the results. 0 means no limit, defaults to 15',
78
-					15
79
-				     )
80
-		;
81
-	}
51
+    protected function configure() {
52
+        $this
53
+            ->setName('ldap:search')
54
+            ->setDescription('executes a user or group search')
55
+            ->addArgument(
56
+                    'search',
57
+                    InputArgument::REQUIRED,
58
+                    'the search string (can be empty)'
59
+                        )
60
+            ->addOption(
61
+                    'group',
62
+                    null,
63
+                    InputOption::VALUE_NONE,
64
+                    'searches groups instead of users'
65
+                        )
66
+            ->addOption(
67
+                    'offset',
68
+                    null,
69
+                    InputOption::VALUE_REQUIRED,
70
+                    'The offset of the result set. Needs to be a multiple of limit. defaults to 0.',
71
+                    0
72
+                        )
73
+            ->addOption(
74
+                    'limit',
75
+                    null,
76
+                    InputOption::VALUE_REQUIRED,
77
+                    'limit the results. 0 means no limit, defaults to 15',
78
+                    15
79
+                        )
80
+        ;
81
+    }
82 82
 
83
-	/**
84
-	 * Tests whether the offset and limit options are valid
85
-	 * @param int $offset
86
-	 * @param int $limit
87
-	 * @throws \InvalidArgumentException
88
-	 */
89
-	protected function validateOffsetAndLimit($offset, $limit) {
90
-		if($limit < 0) {
91
-			throw new \InvalidArgumentException('limit must be  0 or greater');
92
-		}
93
-		if($offset  < 0) {
94
-			throw new \InvalidArgumentException('offset must be 0 or greater');
95
-		}
96
-		if($limit === 0 && $offset !== 0) {
97
-			throw new \InvalidArgumentException('offset must be 0 if limit is also set to 0');
98
-		}
99
-		if($offset > 0 && ($offset % $limit !== 0)) {
100
-			throw new \InvalidArgumentException('offset must be a multiple of limit');
101
-		}
102
-	}
83
+    /**
84
+     * Tests whether the offset and limit options are valid
85
+     * @param int $offset
86
+     * @param int $limit
87
+     * @throws \InvalidArgumentException
88
+     */
89
+    protected function validateOffsetAndLimit($offset, $limit) {
90
+        if($limit < 0) {
91
+            throw new \InvalidArgumentException('limit must be  0 or greater');
92
+        }
93
+        if($offset  < 0) {
94
+            throw new \InvalidArgumentException('offset must be 0 or greater');
95
+        }
96
+        if($limit === 0 && $offset !== 0) {
97
+            throw new \InvalidArgumentException('offset must be 0 if limit is also set to 0');
98
+        }
99
+        if($offset > 0 && ($offset % $limit !== 0)) {
100
+            throw new \InvalidArgumentException('offset must be a multiple of limit');
101
+        }
102
+    }
103 103
 
104
-	protected function execute(InputInterface $input, OutputInterface $output) {
105
-		$helper = new Helper($this->ocConfig);
106
-		$configPrefixes = $helper->getServerConfigurationPrefixes(true);
107
-		$ldapWrapper = new LDAP();
104
+    protected function execute(InputInterface $input, OutputInterface $output) {
105
+        $helper = new Helper($this->ocConfig);
106
+        $configPrefixes = $helper->getServerConfigurationPrefixes(true);
107
+        $ldapWrapper = new LDAP();
108 108
 
109
-		$offset = intval($input->getOption('offset'));
110
-		$limit = intval($input->getOption('limit'));
111
-		$this->validateOffsetAndLimit($offset, $limit);
109
+        $offset = intval($input->getOption('offset'));
110
+        $limit = intval($input->getOption('limit'));
111
+        $this->validateOffsetAndLimit($offset, $limit);
112 112
 
113
-		if($input->getOption('group')) {
114
-			$proxy = new Group_Proxy($configPrefixes, $ldapWrapper);
115
-			$getMethod = 'getGroups';
116
-			$printID = false;
117
-		} else {
118
-			$proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig);
119
-			$getMethod = 'getDisplayNames';
120
-			$printID = true;
121
-		}
113
+        if($input->getOption('group')) {
114
+            $proxy = new Group_Proxy($configPrefixes, $ldapWrapper);
115
+            $getMethod = 'getGroups';
116
+            $printID = false;
117
+        } else {
118
+            $proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig);
119
+            $getMethod = 'getDisplayNames';
120
+            $printID = true;
121
+        }
122 122
 
123
-		$result = $proxy->$getMethod($input->getArgument('search'), $limit, $offset);
124
-		foreach($result as $id => $name) {
125
-			$line = $name . ($printID ? ' ('.$id.')' : '');
126
-			$output->writeln($line);
127
-		}
128
-	}
123
+        $result = $proxy->$getMethod($input->getArgument('search'), $limit, $offset);
124
+        foreach($result as $id => $name) {
125
+            $line = $name . ($printID ? ' ('.$id.')' : '');
126
+            $output->writeln($line);
127
+        }
128
+    }
129 129
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
 	 * @throws \InvalidArgumentException
88 88
 	 */
89 89
 	protected function validateOffsetAndLimit($offset, $limit) {
90
-		if($limit < 0) {
90
+		if ($limit < 0) {
91 91
 			throw new \InvalidArgumentException('limit must be  0 or greater');
92 92
 		}
93
-		if($offset  < 0) {
93
+		if ($offset < 0) {
94 94
 			throw new \InvalidArgumentException('offset must be 0 or greater');
95 95
 		}
96
-		if($limit === 0 && $offset !== 0) {
96
+		if ($limit === 0 && $offset !== 0) {
97 97
 			throw new \InvalidArgumentException('offset must be 0 if limit is also set to 0');
98 98
 		}
99
-		if($offset > 0 && ($offset % $limit !== 0)) {
99
+		if ($offset > 0 && ($offset % $limit !== 0)) {
100 100
 			throw new \InvalidArgumentException('offset must be a multiple of limit');
101 101
 		}
102 102
 	}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		$limit = intval($input->getOption('limit'));
111 111
 		$this->validateOffsetAndLimit($offset, $limit);
112 112
 
113
-		if($input->getOption('group')) {
113
+		if ($input->getOption('group')) {
114 114
 			$proxy = new Group_Proxy($configPrefixes, $ldapWrapper);
115 115
 			$getMethod = 'getGroups';
116 116
 			$printID = false;
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 		}
122 122
 
123 123
 		$result = $proxy->$getMethod($input->getArgument('search'), $limit, $offset);
124
-		foreach($result as $id => $name) {
125
-			$line = $name . ($printID ? ' ('.$id.')' : '');
124
+		foreach ($result as $id => $name) {
125
+			$line = $name.($printID ? ' ('.$id.')' : '');
126 126
 			$output->writeln($line);
127 127
 		}
128 128
 	}
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/DeleteConfig.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -33,39 +33,39 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class DeleteConfig extends Command {
36
-	/** @var \OCA\User_LDAP\Helper */
37
-	protected $helper;
36
+    /** @var \OCA\User_LDAP\Helper */
37
+    protected $helper;
38 38
 
39
-	/**
40
-	 * @param Helper $helper
41
-	 */
42
-	public function __construct(Helper $helper) {
43
-		$this->helper = $helper;
44
-		parent::__construct();
45
-	}
39
+    /**
40
+     * @param Helper $helper
41
+     */
42
+    public function __construct(Helper $helper) {
43
+        $this->helper = $helper;
44
+        parent::__construct();
45
+    }
46 46
 
47
-	protected function configure() {
48
-		$this
49
-			->setName('ldap:delete-config')
50
-			->setDescription('deletes an existing LDAP configuration')
51
-			->addArgument(
52
-					'configID',
53
-					InputArgument::REQUIRED,
54
-					'the configuration ID'
55
-				     )
56
-		;
57
-	}
47
+    protected function configure() {
48
+        $this
49
+            ->setName('ldap:delete-config')
50
+            ->setDescription('deletes an existing LDAP configuration')
51
+            ->addArgument(
52
+                    'configID',
53
+                    InputArgument::REQUIRED,
54
+                    'the configuration ID'
55
+                        )
56
+        ;
57
+    }
58 58
 
59 59
 
60
-	protected function execute(InputInterface $input, OutputInterface $output) {
61
-		$configPrefix = $input->getArgument('configID');
60
+    protected function execute(InputInterface $input, OutputInterface $output) {
61
+        $configPrefix = $input->getArgument('configID');
62 62
 
63
-		$success = $this->helper->deleteServerConfiguration($configPrefix);
63
+        $success = $this->helper->deleteServerConfiguration($configPrefix);
64 64
 
65
-		if($success) {
66
-			$output->writeln("Deleted configuration with configID '{$configPrefix}'");
67
-		} else {
68
-			$output->writeln("Cannot delete configuration with configID '{$configPrefix}'");
69
-		}
70
-	}
65
+        if($success) {
66
+            $output->writeln("Deleted configuration with configID '{$configPrefix}'");
67
+        } else {
68
+            $output->writeln("Cannot delete configuration with configID '{$configPrefix}'");
69
+        }
70
+    }
71 71
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 
63 63
 		$success = $this->helper->deleteServerConfiguration($configPrefix);
64 64
 
65
-		if($success) {
65
+		if ($success) {
66 66
 			$output->writeln("Deleted configuration with configID '{$configPrefix}'");
67 67
 		} else {
68 68
 			$output->writeln("Cannot delete configuration with configID '{$configPrefix}'");
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/TestConfig.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -34,59 +34,59 @@
 block discarded – undo
34 34
 
35 35
 class TestConfig extends Command {
36 36
 
37
-	protected function configure() {
38
-		$this
39
-			->setName('ldap:test-config')
40
-			->setDescription('tests an LDAP configuration')
41
-			->addArgument(
42
-					'configID',
43
-					InputArgument::REQUIRED,
44
-					'the configuration ID'
45
-				     )
46
-		;
47
-	}
37
+    protected function configure() {
38
+        $this
39
+            ->setName('ldap:test-config')
40
+            ->setDescription('tests an LDAP configuration')
41
+            ->addArgument(
42
+                    'configID',
43
+                    InputArgument::REQUIRED,
44
+                    'the configuration ID'
45
+                        )
46
+        ;
47
+    }
48 48
 
49
-	protected function execute(InputInterface $input, OutputInterface $output) {
50
-		$helper = new Helper(\OC::$server->getConfig());
51
-		$availableConfigs = $helper->getServerConfigurationPrefixes();
52
-		$configID = $input->getArgument('configID');
53
-		if(!in_array($configID, $availableConfigs)) {
54
-			$output->writeln("Invalid configID");
55
-			return;
56
-		}
49
+    protected function execute(InputInterface $input, OutputInterface $output) {
50
+        $helper = new Helper(\OC::$server->getConfig());
51
+        $availableConfigs = $helper->getServerConfigurationPrefixes();
52
+        $configID = $input->getArgument('configID');
53
+        if(!in_array($configID, $availableConfigs)) {
54
+            $output->writeln("Invalid configID");
55
+            return;
56
+        }
57 57
 
58
-		$result = $this->testConfig($configID);
59
-		if($result === 0) {
60
-			$output->writeln('The configuration is valid and the connection could be established!');
61
-		} else if($result === 1) {
62
-			$output->writeln('The configuration is invalid. Please have a look at the logs for further details.');
63
-		} else if($result === 2) {
64
-			$output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.');
65
-		} else {
66
-			$output->writeln('Your LDAP server was kidnapped by aliens.');
67
-		}
68
-	}
58
+        $result = $this->testConfig($configID);
59
+        if($result === 0) {
60
+            $output->writeln('The configuration is valid and the connection could be established!');
61
+        } else if($result === 1) {
62
+            $output->writeln('The configuration is invalid. Please have a look at the logs for further details.');
63
+        } else if($result === 2) {
64
+            $output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.');
65
+        } else {
66
+            $output->writeln('Your LDAP server was kidnapped by aliens.');
67
+        }
68
+    }
69 69
 
70
-	/**
71
-	 * tests the specified connection
72
-	 * @param string $configID
73
-	 * @return int
74
-	 */
75
-	protected function testConfig($configID) {
76
-		$lw = new \OCA\User_LDAP\LDAP();
77
-		$connection = new Connection($lw, $configID);
70
+    /**
71
+     * tests the specified connection
72
+     * @param string $configID
73
+     * @return int
74
+     */
75
+    protected function testConfig($configID) {
76
+        $lw = new \OCA\User_LDAP\LDAP();
77
+        $connection = new Connection($lw, $configID);
78 78
 
79
-		//ensure validation is run before we attempt the bind
80
-		$connection->getConfiguration();
79
+        //ensure validation is run before we attempt the bind
80
+        $connection->getConfiguration();
81 81
 
82
-		if(!$connection->setConfiguration(array(
83
-			'ldap_configuration_active' => 1,
84
-		))) {
85
-			return 1;
86
-		}
87
-		if($connection->bind()) {
88
-			return 0;
89
-		}
90
-		return 2;
91
-	}
82
+        if(!$connection->setConfiguration(array(
83
+            'ldap_configuration_active' => 1,
84
+        ))) {
85
+            return 1;
86
+        }
87
+        if($connection->bind()) {
88
+            return 0;
89
+        }
90
+        return 2;
91
+    }
92 92
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
 		$helper = new Helper(\OC::$server->getConfig());
51 51
 		$availableConfigs = $helper->getServerConfigurationPrefixes();
52 52
 		$configID = $input->getArgument('configID');
53
-		if(!in_array($configID, $availableConfigs)) {
53
+		if (!in_array($configID, $availableConfigs)) {
54 54
 			$output->writeln("Invalid configID");
55 55
 			return;
56 56
 		}
57 57
 
58 58
 		$result = $this->testConfig($configID);
59
-		if($result === 0) {
59
+		if ($result === 0) {
60 60
 			$output->writeln('The configuration is valid and the connection could be established!');
61
-		} else if($result === 1) {
61
+		} else if ($result === 1) {
62 62
 			$output->writeln('The configuration is invalid. Please have a look at the logs for further details.');
63
-		} else if($result === 2) {
63
+		} else if ($result === 2) {
64 64
 			$output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.');
65 65
 		} else {
66 66
 			$output->writeln('Your LDAP server was kidnapped by aliens.');
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 		//ensure validation is run before we attempt the bind
80 80
 		$connection->getConfiguration();
81 81
 
82
-		if(!$connection->setConfiguration(array(
82
+		if (!$connection->setConfiguration(array(
83 83
 			'ldap_configuration_active' => 1,
84 84
 		))) {
85 85
 			return 1;
86 86
 		}
87
-		if($connection->bind()) {
87
+		if ($connection->bind()) {
88 88
 			return 0;
89 89
 		}
90 90
 		return 2;
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/ShowRemnants.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -35,61 +35,61 @@
 block discarded – undo
35 35
 use OCP\IDateTimeFormatter;
36 36
 
37 37
 class ShowRemnants extends Command {
38
-	/** @var \OCA\User_LDAP\User\DeletedUsersIndex */
39
-	protected $dui;
38
+    /** @var \OCA\User_LDAP\User\DeletedUsersIndex */
39
+    protected $dui;
40 40
 
41
-	/** @var \OCP\IDateTimeFormatter */
42
-	protected $dateFormatter;
41
+    /** @var \OCP\IDateTimeFormatter */
42
+    protected $dateFormatter;
43 43
 
44
-	/**
45
-	 * @param DeletedUsersIndex $dui
46
-	 * @param IDateTimeFormatter $dateFormatter
47
-	 */
48
-	public function __construct(DeletedUsersIndex $dui, IDateTimeFormatter $dateFormatter) {
49
-		$this->dui = $dui;
50
-		$this->dateFormatter = $dateFormatter;
51
-		parent::__construct();
52
-	}
44
+    /**
45
+     * @param DeletedUsersIndex $dui
46
+     * @param IDateTimeFormatter $dateFormatter
47
+     */
48
+    public function __construct(DeletedUsersIndex $dui, IDateTimeFormatter $dateFormatter) {
49
+        $this->dui = $dui;
50
+        $this->dateFormatter = $dateFormatter;
51
+        parent::__construct();
52
+    }
53 53
 
54
-	protected function configure() {
55
-		$this
56
-			->setName('ldap:show-remnants')
57
-			->setDescription('shows which users are not available on LDAP anymore, but have remnants in ownCloud.')
58
-			->addOption('json', null, InputOption::VALUE_NONE, 'return JSON array instead of pretty table.');
59
-	}
54
+    protected function configure() {
55
+        $this
56
+            ->setName('ldap:show-remnants')
57
+            ->setDescription('shows which users are not available on LDAP anymore, but have remnants in ownCloud.')
58
+            ->addOption('json', null, InputOption::VALUE_NONE, 'return JSON array instead of pretty table.');
59
+    }
60 60
 
61
-	/**
62
-	 * executes the command, i.e. creeates and outputs a table of LDAP users marked as deleted
63
-	 *
64
-	 * {@inheritdoc}
65
-	 */
66
-	protected function execute(InputInterface $input, OutputInterface $output) {
67
-		/** @var \Symfony\Component\Console\Helper\Table $table */
68
-		$table = new Table($output);
69
-		$table->setHeaders(array(
70
-			'ownCloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login',
71
-			'Dir', 'Sharer'));
72
-		$rows = array();
73
-		$resultSet = $this->dui->getUsers();
74
-		foreach($resultSet as $user) {
75
-			$hAS = $user->getHasActiveShares() ? 'Y' : 'N';
76
-			$lastLogin = ($user->getLastLogin() > 0) ?
77
-				$this->dateFormatter->formatDate($user->getLastLogin()) : '-';
78
-			$rows[] = array('ocName'      => $user->getOCName(),
79
-							'displayName' => $user->getDisplayName(),
80
-							'uid'         => $user->getUID(),
81
-							'dn'          => $user->getDN(),
82
-							'lastLogin'   => $lastLogin,
83
-							'homePath'    => $user->getHomePath(),
84
-							'sharer'      => $hAS
85
-			);
86
-		}
61
+    /**
62
+     * executes the command, i.e. creeates and outputs a table of LDAP users marked as deleted
63
+     *
64
+     * {@inheritdoc}
65
+     */
66
+    protected function execute(InputInterface $input, OutputInterface $output) {
67
+        /** @var \Symfony\Component\Console\Helper\Table $table */
68
+        $table = new Table($output);
69
+        $table->setHeaders(array(
70
+            'ownCloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login',
71
+            'Dir', 'Sharer'));
72
+        $rows = array();
73
+        $resultSet = $this->dui->getUsers();
74
+        foreach($resultSet as $user) {
75
+            $hAS = $user->getHasActiveShares() ? 'Y' : 'N';
76
+            $lastLogin = ($user->getLastLogin() > 0) ?
77
+                $this->dateFormatter->formatDate($user->getLastLogin()) : '-';
78
+            $rows[] = array('ocName'      => $user->getOCName(),
79
+                            'displayName' => $user->getDisplayName(),
80
+                            'uid'         => $user->getUID(),
81
+                            'dn'          => $user->getDN(),
82
+                            'lastLogin'   => $lastLogin,
83
+                            'homePath'    => $user->getHomePath(),
84
+                            'sharer'      => $hAS
85
+            );
86
+        }
87 87
 
88
-		if ($input->getOption('json')) {
89
-			$output->writeln(json_encode($rows));			
90
-		} else {
91
-			$table->setRows($rows);
92
-			$table->render($output);
93
-		}
94
-	}
88
+        if ($input->getOption('json')) {
89
+            $output->writeln(json_encode($rows));			
90
+        } else {
91
+            $table->setRows($rows);
92
+            $table->render($output);
93
+        }
94
+    }
95 95
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
 			'Dir', 'Sharer'));
72 72
 		$rows = array();
73 73
 		$resultSet = $this->dui->getUsers();
74
-		foreach($resultSet as $user) {
74
+		foreach ($resultSet as $user) {
75 75
 			$hAS = $user->getHasActiveShares() ? 'Y' : 'N';
76 76
 			$lastLogin = ($user->getLastLogin() > 0) ?
77 77
 				$this->dateFormatter->formatDate($user->getLastLogin()) : '-';
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/CreateEmptyConfig.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -33,39 +33,39 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class CreateEmptyConfig extends Command {
36
-	/** @var \OCA\User_LDAP\Helper */
37
-	protected $helper;
36
+    /** @var \OCA\User_LDAP\Helper */
37
+    protected $helper;
38 38
 
39
-	/**
40
-	 * @param Helper $helper
41
-	 */
42
-	public function __construct(Helper $helper) {
43
-		$this->helper = $helper;
44
-		parent::__construct();
45
-	}
39
+    /**
40
+     * @param Helper $helper
41
+     */
42
+    public function __construct(Helper $helper) {
43
+        $this->helper = $helper;
44
+        parent::__construct();
45
+    }
46 46
 
47
-	protected function configure() {
48
-		$this
49
-			->setName('ldap:create-empty-config')
50
-			->setDescription('creates an empty LDAP configuration')
51
-			->addOption(
52
-				'only-print-prefix',
53
-				'p',
54
-				InputOption::VALUE_NONE,
55
-				'outputs only the prefix'
56
-			)
57
-		;
58
-	}
47
+    protected function configure() {
48
+        $this
49
+            ->setName('ldap:create-empty-config')
50
+            ->setDescription('creates an empty LDAP configuration')
51
+            ->addOption(
52
+                'only-print-prefix',
53
+                'p',
54
+                InputOption::VALUE_NONE,
55
+                'outputs only the prefix'
56
+            )
57
+        ;
58
+    }
59 59
 
60
-	protected function execute(InputInterface $input, OutputInterface $output) {
61
-		$configPrefix = $this->helper->getNextServerConfigurationPrefix();
62
-		$configHolder = new Configuration($configPrefix);
63
-		$configHolder->saveConfiguration();
60
+    protected function execute(InputInterface $input, OutputInterface $output) {
61
+        $configPrefix = $this->helper->getNextServerConfigurationPrefix();
62
+        $configHolder = new Configuration($configPrefix);
63
+        $configHolder->saveConfiguration();
64 64
 
65
-		$prose = '';
66
-		if(!$input->getOption('only-print-prefix')) {
67
-			$prose = 'Created new configuration with configID ';
68
-		}
69
-		$output->writeln($prose . "{$configPrefix}");
70
-	}
65
+        $prose = '';
66
+        if(!$input->getOption('only-print-prefix')) {
67
+            $prose = 'Created new configuration with configID ';
68
+        }
69
+        $output->writeln($prose . "{$configPrefix}");
70
+    }
71 71
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@
 block discarded – undo
63 63
 		$configHolder->saveConfiguration();
64 64
 
65 65
 		$prose = '';
66
-		if(!$input->getOption('only-print-prefix')) {
66
+		if (!$input->getOption('only-print-prefix')) {
67 67
 			$prose = 'Created new configuration with configID ';
68 68
 		}
69
-		$output->writeln($prose . "{$configPrefix}");
69
+		$output->writeln($prose."{$configPrefix}");
70 70
 	}
71 71
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/ShowConfig.php 2 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -35,77 +35,77 @@
 block discarded – undo
35 35
 use OCA\User_LDAP\Configuration;
36 36
 
37 37
 class ShowConfig extends Command {
38
-	/** @var \OCA\User_LDAP\Helper */
39
-	protected $helper;
38
+    /** @var \OCA\User_LDAP\Helper */
39
+    protected $helper;
40 40
 
41
-	/**
42
-	 * @param Helper $helper
43
-	 */
44
-	public function __construct(Helper $helper) {
45
-		$this->helper = $helper;
46
-		parent::__construct();
47
-	}
41
+    /**
42
+     * @param Helper $helper
43
+     */
44
+    public function __construct(Helper $helper) {
45
+        $this->helper = $helper;
46
+        parent::__construct();
47
+    }
48 48
 
49
-	protected function configure() {
50
-		$this
51
-			->setName('ldap:show-config')
52
-			->setDescription('shows the LDAP configuration')
53
-			->addArgument(
54
-					'configID',
55
-					InputArgument::OPTIONAL,
56
-					'will show the configuration of the specified id'
57
-				     )
58
-			->addOption(
59
-					'show-password',
60
-					null,
61
-					InputOption::VALUE_NONE,
62
-					'show ldap bind password'
63
-				     )
64
-		;
65
-	}
49
+    protected function configure() {
50
+        $this
51
+            ->setName('ldap:show-config')
52
+            ->setDescription('shows the LDAP configuration')
53
+            ->addArgument(
54
+                    'configID',
55
+                    InputArgument::OPTIONAL,
56
+                    'will show the configuration of the specified id'
57
+                        )
58
+            ->addOption(
59
+                    'show-password',
60
+                    null,
61
+                    InputOption::VALUE_NONE,
62
+                    'show ldap bind password'
63
+                        )
64
+        ;
65
+    }
66 66
 
67
-	protected function execute(InputInterface $input, OutputInterface $output) {
68
-		$availableConfigs = $this->helper->getServerConfigurationPrefixes();
69
-		$configID = $input->getArgument('configID');
70
-		if(!is_null($configID)) {
71
-			$configIDs[] = $configID;
72
-			if(!in_array($configIDs[0], $availableConfigs)) {
73
-				$output->writeln("Invalid configID");
74
-				return;
75
-			}
76
-		} else {
77
-			$configIDs = $availableConfigs;
78
-		}
67
+    protected function execute(InputInterface $input, OutputInterface $output) {
68
+        $availableConfigs = $this->helper->getServerConfigurationPrefixes();
69
+        $configID = $input->getArgument('configID');
70
+        if(!is_null($configID)) {
71
+            $configIDs[] = $configID;
72
+            if(!in_array($configIDs[0], $availableConfigs)) {
73
+                $output->writeln("Invalid configID");
74
+                return;
75
+            }
76
+        } else {
77
+            $configIDs = $availableConfigs;
78
+        }
79 79
 
80
-		$this->renderConfigs($configIDs, $output, $input->getOption('show-password'));
81
-	}
80
+        $this->renderConfigs($configIDs, $output, $input->getOption('show-password'));
81
+    }
82 82
 
83
-	/**
84
-	 * prints the LDAP configuration(s)
85
-	 * @param string[] configID(s)
86
-	 * @param OutputInterface $output
87
-	 * @param bool $withPassword      Set to TRUE to show plaintext passwords in output
88
-	 */
89
-	protected function renderConfigs($configIDs, $output, $withPassword) {
90
-		foreach($configIDs as $id) {
91
-			$configHolder = new Configuration($id);
92
-			$configuration = $configHolder->getConfiguration();
93
-			ksort($configuration);
83
+    /**
84
+     * prints the LDAP configuration(s)
85
+     * @param string[] configID(s)
86
+     * @param OutputInterface $output
87
+     * @param bool $withPassword      Set to TRUE to show plaintext passwords in output
88
+     */
89
+    protected function renderConfigs($configIDs, $output, $withPassword) {
90
+        foreach($configIDs as $id) {
91
+            $configHolder = new Configuration($id);
92
+            $configuration = $configHolder->getConfiguration();
93
+            ksort($configuration);
94 94
 
95
-			$table = new Table($output);
96
-			$table->setHeaders(array('Configuration', $id));
97
-			$rows = array();
98
-			foreach($configuration as $key => $value) {
99
-				if($key === 'ldapAgentPassword' && !$withPassword) {
100
-					$value = '***';
101
-				}
102
-				if(is_array($value)) {
103
-					$value = implode(';', $value);
104
-				}
105
-				$rows[] = array($key, $value);
106
-			}
107
-			$table->setRows($rows);
108
-			$table->render($output);
109
-		}
110
-	}
95
+            $table = new Table($output);
96
+            $table->setHeaders(array('Configuration', $id));
97
+            $rows = array();
98
+            foreach($configuration as $key => $value) {
99
+                if($key === 'ldapAgentPassword' && !$withPassword) {
100
+                    $value = '***';
101
+                }
102
+                if(is_array($value)) {
103
+                    $value = implode(';', $value);
104
+                }
105
+                $rows[] = array($key, $value);
106
+            }
107
+            $table->setRows($rows);
108
+            $table->render($output);
109
+        }
110
+    }
111 111
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	protected function execute(InputInterface $input, OutputInterface $output) {
68 68
 		$availableConfigs = $this->helper->getServerConfigurationPrefixes();
69 69
 		$configID = $input->getArgument('configID');
70
-		if(!is_null($configID)) {
70
+		if (!is_null($configID)) {
71 71
 			$configIDs[] = $configID;
72
-			if(!in_array($configIDs[0], $availableConfigs)) {
72
+			if (!in_array($configIDs[0], $availableConfigs)) {
73 73
 				$output->writeln("Invalid configID");
74 74
 				return;
75 75
 			}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param bool $withPassword      Set to TRUE to show plaintext passwords in output
88 88
 	 */
89 89
 	protected function renderConfigs($configIDs, $output, $withPassword) {
90
-		foreach($configIDs as $id) {
90
+		foreach ($configIDs as $id) {
91 91
 			$configHolder = new Configuration($id);
92 92
 			$configuration = $configHolder->getConfiguration();
93 93
 			ksort($configuration);
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 			$table = new Table($output);
96 96
 			$table->setHeaders(array('Configuration', $id));
97 97
 			$rows = array();
98
-			foreach($configuration as $key => $value) {
99
-				if($key === 'ldapAgentPassword' && !$withPassword) {
98
+			foreach ($configuration as $key => $value) {
99
+				if ($key === 'ldapAgentPassword' && !$withPassword) {
100 100
 					$value = '***';
101 101
 				}
102
-				if(is_array($value)) {
102
+				if (is_array($value)) {
103 103
 					$value = implode(';', $value);
104 104
 				}
105 105
 				$rows[] = array($key, $value);
Please login to merge, or discard this patch.
apps/user_ldap/lib/Configuration.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function __construct($configPrefix, $autoRead = true) {
103 103
 		$this->configPrefix = $configPrefix;
104
-		if($autoRead) {
104
+		if ($autoRead) {
105 105
 			$this->readConfiguration();
106 106
 		}
107 107
 	}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @return mixed|null
112 112
 	 */
113 113
 	public function __get($name) {
114
-		if(isset($this->config[$name])) {
114
+		if (isset($this->config[$name])) {
115 115
 			return $this->config[$name];
116 116
 		}
117 117
 		return null;
@@ -142,22 +142,22 @@  discard block
 block discarded – undo
142 142
 	 * @return false|null
143 143
 	 */
144 144
 	public function setConfiguration($config, &$applied = null) {
145
-		if(!is_array($config)) {
145
+		if (!is_array($config)) {
146 146
 			return false;
147 147
 		}
148 148
 
149 149
 		$cta = $this->getConfigTranslationArray();
150
-		foreach($config as $inputKey => $val) {
151
-			if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
150
+		foreach ($config as $inputKey => $val) {
151
+			if (strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
152 152
 				$key = $cta[$inputKey];
153
-			} elseif(array_key_exists($inputKey, $this->config)) {
153
+			} elseif (array_key_exists($inputKey, $this->config)) {
154 154
 				$key = $inputKey;
155 155
 			} else {
156 156
 				continue;
157 157
 			}
158 158
 
159 159
 			$setMethod = 'setValue';
160
-			switch($key) {
160
+			switch ($key) {
161 161
 				case 'ldapAgentPassword':
162 162
 					$setMethod = 'setRawValue';
163 163
 					break;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 					break;
182 182
 			}
183 183
 			$this->$setMethod($key, $val);
184
-			if(is_array($applied)) {
184
+			if (is_array($applied)) {
185 185
 				$applied[] = $inputKey;
186 186
 			}
187 187
 		}
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
 	}
190 190
 
191 191
 	public function readConfiguration() {
192
-		if(!$this->configRead && !is_null($this->configPrefix)) {
192
+		if (!$this->configRead && !is_null($this->configPrefix)) {
193 193
 			$cta = array_flip($this->getConfigTranslationArray());
194
-			foreach($this->config as $key => $val) {
195
-				if(!isset($cta[$key])) {
194
+			foreach ($this->config as $key => $val) {
195
+				if (!isset($cta[$key])) {
196 196
 					//some are determined
197 197
 					continue;
198 198
 				}
199 199
 				$dbKey = $cta[$key];
200
-				switch($key) {
200
+				switch ($key) {
201 201
 					case 'ldapBase':
202 202
 					case 'ldapBaseUsers':
203 203
 					case 'ldapBaseGroups':
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function saveConfiguration() {
242 242
 		$cta = array_flip($this->getConfigTranslationArray());
243
-		foreach($this->config as $key => $value) {
243
+		foreach ($this->config as $key => $value) {
244 244
 			switch ($key) {
245 245
 				case 'ldapAgentPassword':
246 246
 					$value = base64_encode($value);
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 				case 'ldapGroupFilterObjectclass':
256 256
 				case 'ldapGroupFilterGroups':
257 257
 				case 'ldapLoginFilterAttributes':
258
-					if(is_array($value)) {
258
+					if (is_array($value)) {
259 259
 						$value = implode("\n", $value);
260 260
 					}
261 261
 					break;
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 				case 'ldapUuidGroupAttribute':
267 267
 					continue 2;
268 268
 			}
269
-			if(is_null($value)) {
269
+			if (is_null($value)) {
270 270
 				$value = '';
271 271
 			}
272 272
 			$this->saveValue($cta[$key], $value);
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	protected function getMultiLine($varName) {
281 281
 		$value = $this->getValue($varName);
282
-		if(empty($value)) {
282
+		if (empty($value)) {
283 283
 			$value = '';
284 284
 		} else {
285 285
 			$value = preg_split('/\r\n|\r|\n/', $value);
@@ -295,21 +295,21 @@  discard block
 block discarded – undo
295 295
 	 * @param array|string $value to set
296 296
 	 */
297 297
 	protected function setMultiLine($varName, $value) {
298
-		if(empty($value)) {
298
+		if (empty($value)) {
299 299
 			$value = '';
300 300
 		} else if (!is_array($value)) {
301 301
 			$value = preg_split('/\r\n|\r|\n|;/', $value);
302
-			if($value === false) {
302
+			if ($value === false) {
303 303
 				$value = '';
304 304
 			}
305 305
 		}
306 306
 
307
-		if(!is_array($value)) {
307
+		if (!is_array($value)) {
308 308
 			$finalValue = trim($value);
309 309
 		} else {
310 310
 			$finalValue = [];
311
-			foreach($value as $key => $val) {
312
-				if(is_string($val)) {
311
+			foreach ($value as $key => $val) {
312
+				if (is_string($val)) {
313 313
 					$val = trim($val);
314 314
 					if ($val !== '') {
315 315
 						//accidental line breaks are not wanted and can cause
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 */
357 357
 	protected function getValue($varName) {
358 358
 		static $defaults;
359
-		if(is_null($defaults)) {
359
+		if (is_null($defaults)) {
360 360
 			$defaults = $this->getDefaults();
361 361
 		}
362 362
 		return \OCP\Config::getAppValue('user_ldap',
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 * @param mixed $value to set
372 372
 	 */
373 373
 	protected function setValue($varName, $value) {
374
-		if(is_string($value)) {
374
+		if (is_string($value)) {
375 375
 			$value = trim($value);
376 376
 		}
377 377
 		$this->config[$varName] = $value;
Please login to merge, or discard this patch.
Indentation   +460 added lines, -460 removed lines patch added patch discarded remove patch
@@ -36,489 +36,489 @@
 block discarded – undo
36 36
  */
37 37
 class Configuration {
38 38
 
39
-	protected $configPrefix = null;
40
-	protected $configRead = false;
39
+    protected $configPrefix = null;
40
+    protected $configRead = false;
41 41
 
42
-	//settings
43
-	protected $config = array(
44
-		'ldapHost' => null,
45
-		'ldapPort' => null,
46
-		'ldapBackupHost' => null,
47
-		'ldapBackupPort' => null,
48
-		'ldapBase' => null,
49
-		'ldapBaseUsers' => null,
50
-		'ldapBaseGroups' => null,
51
-		'ldapAgentName' => null,
52
-		'ldapAgentPassword' => null,
53
-		'ldapTLS' => null,
54
-		'turnOffCertCheck' => null,
55
-		'ldapIgnoreNamingRules' => null,
56
-		'ldapUserDisplayName' => null,
57
-		'ldapUserDisplayName2' => null,
58
-		'ldapGidNumber' => null,
59
-		'ldapUserFilterObjectclass' => null,
60
-		'ldapUserFilterGroups' => null,
61
-		'ldapUserFilter' => null,
62
-		'ldapUserFilterMode' => null,
63
-		'ldapGroupFilter' => null,
64
-		'ldapGroupFilterMode' => null,
65
-		'ldapGroupFilterObjectclass' => null,
66
-		'ldapGroupFilterGroups' => null,
67
-		'ldapGroupDisplayName' => null,
68
-		'ldapGroupMemberAssocAttr' => null,
69
-		'ldapLoginFilter' => null,
70
-		'ldapLoginFilterMode' => null,
71
-		'ldapLoginFilterEmail' => null,
72
-		'ldapLoginFilterUsername' => null,
73
-		'ldapLoginFilterAttributes' => null,
74
-		'ldapQuotaAttribute' => null,
75
-		'ldapQuotaDefault' => null,
76
-		'ldapEmailAttribute' => null,
77
-		'ldapCacheTTL' => null,
78
-		'ldapUuidUserAttribute' => 'auto',
79
-		'ldapUuidGroupAttribute' => 'auto',
80
-		'ldapOverrideMainServer' => false,
81
-		'ldapConfigurationActive' => false,
82
-		'ldapAttributesForUserSearch' => null,
83
-		'ldapAttributesForGroupSearch' => null,
84
-		'ldapExperiencedAdmin' => false,
85
-		'homeFolderNamingRule' => null,
86
-		'hasPagedResultSupport' => false,
87
-		'hasMemberOfFilterSupport' => false,
88
-		'useMemberOfToDetectMembership' => true,
89
-		'ldapExpertUsernameAttr' => null,
90
-		'ldapExpertUUIDUserAttr' => null,
91
-		'ldapExpertUUIDGroupAttr' => null,
92
-		'lastJpegPhotoLookup' => null,
93
-		'ldapNestedGroups' => false,
94
-		'ldapPagingSize' => null,
95
-		'turnOnPasswordChange' => false,
96
-		'ldapDynamicGroupMemberURL' => null,
97
-	);
42
+    //settings
43
+    protected $config = array(
44
+        'ldapHost' => null,
45
+        'ldapPort' => null,
46
+        'ldapBackupHost' => null,
47
+        'ldapBackupPort' => null,
48
+        'ldapBase' => null,
49
+        'ldapBaseUsers' => null,
50
+        'ldapBaseGroups' => null,
51
+        'ldapAgentName' => null,
52
+        'ldapAgentPassword' => null,
53
+        'ldapTLS' => null,
54
+        'turnOffCertCheck' => null,
55
+        'ldapIgnoreNamingRules' => null,
56
+        'ldapUserDisplayName' => null,
57
+        'ldapUserDisplayName2' => null,
58
+        'ldapGidNumber' => null,
59
+        'ldapUserFilterObjectclass' => null,
60
+        'ldapUserFilterGroups' => null,
61
+        'ldapUserFilter' => null,
62
+        'ldapUserFilterMode' => null,
63
+        'ldapGroupFilter' => null,
64
+        'ldapGroupFilterMode' => null,
65
+        'ldapGroupFilterObjectclass' => null,
66
+        'ldapGroupFilterGroups' => null,
67
+        'ldapGroupDisplayName' => null,
68
+        'ldapGroupMemberAssocAttr' => null,
69
+        'ldapLoginFilter' => null,
70
+        'ldapLoginFilterMode' => null,
71
+        'ldapLoginFilterEmail' => null,
72
+        'ldapLoginFilterUsername' => null,
73
+        'ldapLoginFilterAttributes' => null,
74
+        'ldapQuotaAttribute' => null,
75
+        'ldapQuotaDefault' => null,
76
+        'ldapEmailAttribute' => null,
77
+        'ldapCacheTTL' => null,
78
+        'ldapUuidUserAttribute' => 'auto',
79
+        'ldapUuidGroupAttribute' => 'auto',
80
+        'ldapOverrideMainServer' => false,
81
+        'ldapConfigurationActive' => false,
82
+        'ldapAttributesForUserSearch' => null,
83
+        'ldapAttributesForGroupSearch' => null,
84
+        'ldapExperiencedAdmin' => false,
85
+        'homeFolderNamingRule' => null,
86
+        'hasPagedResultSupport' => false,
87
+        'hasMemberOfFilterSupport' => false,
88
+        'useMemberOfToDetectMembership' => true,
89
+        'ldapExpertUsernameAttr' => null,
90
+        'ldapExpertUUIDUserAttr' => null,
91
+        'ldapExpertUUIDGroupAttr' => null,
92
+        'lastJpegPhotoLookup' => null,
93
+        'ldapNestedGroups' => false,
94
+        'ldapPagingSize' => null,
95
+        'turnOnPasswordChange' => false,
96
+        'ldapDynamicGroupMemberURL' => null,
97
+    );
98 98
 
99
-	/**
100
-	 * @param string $configPrefix
101
-	 * @param bool $autoRead
102
-	 */
103
-	public function __construct($configPrefix, $autoRead = true) {
104
-		$this->configPrefix = $configPrefix;
105
-		if($autoRead) {
106
-			$this->readConfiguration();
107
-		}
108
-	}
99
+    /**
100
+     * @param string $configPrefix
101
+     * @param bool $autoRead
102
+     */
103
+    public function __construct($configPrefix, $autoRead = true) {
104
+        $this->configPrefix = $configPrefix;
105
+        if($autoRead) {
106
+            $this->readConfiguration();
107
+        }
108
+    }
109 109
 
110
-	/**
111
-	 * @param string $name
112
-	 * @return mixed|null
113
-	 */
114
-	public function __get($name) {
115
-		if(isset($this->config[$name])) {
116
-			return $this->config[$name];
117
-		}
118
-		return null;
119
-	}
110
+    /**
111
+     * @param string $name
112
+     * @return mixed|null
113
+     */
114
+    public function __get($name) {
115
+        if(isset($this->config[$name])) {
116
+            return $this->config[$name];
117
+        }
118
+        return null;
119
+    }
120 120
 
121
-	/**
122
-	 * @param string $name
123
-	 * @param mixed $value
124
-	 */
125
-	public function __set($name, $value) {
126
-		$this->setConfiguration(array($name => $value));
127
-	}
121
+    /**
122
+     * @param string $name
123
+     * @param mixed $value
124
+     */
125
+    public function __set($name, $value) {
126
+        $this->setConfiguration(array($name => $value));
127
+    }
128 128
 
129
-	/**
130
-	 * @return array
131
-	 */
132
-	public function getConfiguration() {
133
-		return $this->config;
134
-	}
129
+    /**
130
+     * @return array
131
+     */
132
+    public function getConfiguration() {
133
+        return $this->config;
134
+    }
135 135
 
136
-	/**
137
-	 * set LDAP configuration with values delivered by an array, not read
138
-	 * from configuration. It does not save the configuration! To do so, you
139
-	 * must call saveConfiguration afterwards.
140
-	 * @param array $config array that holds the config parameters in an associated
141
-	 * array
142
-	 * @param array &$applied optional; array where the set fields will be given to
143
-	 * @return false|null
144
-	 */
145
-	public function setConfiguration($config, &$applied = null) {
146
-		if(!is_array($config)) {
147
-			return false;
148
-		}
136
+    /**
137
+     * set LDAP configuration with values delivered by an array, not read
138
+     * from configuration. It does not save the configuration! To do so, you
139
+     * must call saveConfiguration afterwards.
140
+     * @param array $config array that holds the config parameters in an associated
141
+     * array
142
+     * @param array &$applied optional; array where the set fields will be given to
143
+     * @return false|null
144
+     */
145
+    public function setConfiguration($config, &$applied = null) {
146
+        if(!is_array($config)) {
147
+            return false;
148
+        }
149 149
 
150
-		$cta = $this->getConfigTranslationArray();
151
-		foreach($config as $inputKey => $val) {
152
-			if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
153
-				$key = $cta[$inputKey];
154
-			} elseif(array_key_exists($inputKey, $this->config)) {
155
-				$key = $inputKey;
156
-			} else {
157
-				continue;
158
-			}
150
+        $cta = $this->getConfigTranslationArray();
151
+        foreach($config as $inputKey => $val) {
152
+            if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
153
+                $key = $cta[$inputKey];
154
+            } elseif(array_key_exists($inputKey, $this->config)) {
155
+                $key = $inputKey;
156
+            } else {
157
+                continue;
158
+            }
159 159
 
160
-			$setMethod = 'setValue';
161
-			switch($key) {
162
-				case 'ldapAgentPassword':
163
-					$setMethod = 'setRawValue';
164
-					break;
165
-				case 'homeFolderNamingRule':
166
-					$trimmedVal = trim($val);
167
-					if ($trimmedVal !== '' && strpos($val, 'attr:') === false) {
168
-						$val = 'attr:'.$trimmedVal;
169
-					}
170
-					break;
171
-				case 'ldapBase':
172
-				case 'ldapBaseUsers':
173
-				case 'ldapBaseGroups':
174
-				case 'ldapAttributesForUserSearch':
175
-				case 'ldapAttributesForGroupSearch':
176
-				case 'ldapUserFilterObjectclass':
177
-				case 'ldapUserFilterGroups':
178
-				case 'ldapGroupFilterObjectclass':
179
-				case 'ldapGroupFilterGroups':
180
-				case 'ldapLoginFilterAttributes':
181
-					$setMethod = 'setMultiLine';
182
-					break;
183
-			}
184
-			$this->$setMethod($key, $val);
185
-			if(is_array($applied)) {
186
-				$applied[] = $inputKey;
187
-			}
188
-		}
189
-		return null;
190
-	}
160
+            $setMethod = 'setValue';
161
+            switch($key) {
162
+                case 'ldapAgentPassword':
163
+                    $setMethod = 'setRawValue';
164
+                    break;
165
+                case 'homeFolderNamingRule':
166
+                    $trimmedVal = trim($val);
167
+                    if ($trimmedVal !== '' && strpos($val, 'attr:') === false) {
168
+                        $val = 'attr:'.$trimmedVal;
169
+                    }
170
+                    break;
171
+                case 'ldapBase':
172
+                case 'ldapBaseUsers':
173
+                case 'ldapBaseGroups':
174
+                case 'ldapAttributesForUserSearch':
175
+                case 'ldapAttributesForGroupSearch':
176
+                case 'ldapUserFilterObjectclass':
177
+                case 'ldapUserFilterGroups':
178
+                case 'ldapGroupFilterObjectclass':
179
+                case 'ldapGroupFilterGroups':
180
+                case 'ldapLoginFilterAttributes':
181
+                    $setMethod = 'setMultiLine';
182
+                    break;
183
+            }
184
+            $this->$setMethod($key, $val);
185
+            if(is_array($applied)) {
186
+                $applied[] = $inputKey;
187
+            }
188
+        }
189
+        return null;
190
+    }
191 191
 
192
-	public function readConfiguration() {
193
-		if(!$this->configRead && !is_null($this->configPrefix)) {
194
-			$cta = array_flip($this->getConfigTranslationArray());
195
-			foreach($this->config as $key => $val) {
196
-				if(!isset($cta[$key])) {
197
-					//some are determined
198
-					continue;
199
-				}
200
-				$dbKey = $cta[$key];
201
-				switch($key) {
202
-					case 'ldapBase':
203
-					case 'ldapBaseUsers':
204
-					case 'ldapBaseGroups':
205
-					case 'ldapAttributesForUserSearch':
206
-					case 'ldapAttributesForGroupSearch':
207
-					case 'ldapUserFilterObjectclass':
208
-					case 'ldapUserFilterGroups':
209
-					case 'ldapGroupFilterObjectclass':
210
-					case 'ldapGroupFilterGroups':
211
-					case 'ldapLoginFilterAttributes':
212
-						$readMethod = 'getMultiLine';
213
-						break;
214
-					case 'ldapIgnoreNamingRules':
215
-						$readMethod = 'getSystemValue';
216
-						$dbKey = $key;
217
-						break;
218
-					case 'ldapAgentPassword':
219
-						$readMethod = 'getPwd';
220
-						break;
221
-					case 'ldapUserDisplayName2':
222
-					case 'ldapGroupDisplayName':
223
-						$readMethod = 'getLcValue';
224
-						break;
225
-					case 'ldapUserDisplayName':
226
-					default:
227
-						// user display name does not lower case because
228
-						// we rely on an upper case N as indicator whether to
229
-						// auto-detect it or not. FIXME
230
-						$readMethod = 'getValue';
231
-						break;
232
-				}
233
-				$this->config[$key] = $this->$readMethod($dbKey);
234
-			}
235
-			$this->configRead = true;
236
-		}
237
-	}
192
+    public function readConfiguration() {
193
+        if(!$this->configRead && !is_null($this->configPrefix)) {
194
+            $cta = array_flip($this->getConfigTranslationArray());
195
+            foreach($this->config as $key => $val) {
196
+                if(!isset($cta[$key])) {
197
+                    //some are determined
198
+                    continue;
199
+                }
200
+                $dbKey = $cta[$key];
201
+                switch($key) {
202
+                    case 'ldapBase':
203
+                    case 'ldapBaseUsers':
204
+                    case 'ldapBaseGroups':
205
+                    case 'ldapAttributesForUserSearch':
206
+                    case 'ldapAttributesForGroupSearch':
207
+                    case 'ldapUserFilterObjectclass':
208
+                    case 'ldapUserFilterGroups':
209
+                    case 'ldapGroupFilterObjectclass':
210
+                    case 'ldapGroupFilterGroups':
211
+                    case 'ldapLoginFilterAttributes':
212
+                        $readMethod = 'getMultiLine';
213
+                        break;
214
+                    case 'ldapIgnoreNamingRules':
215
+                        $readMethod = 'getSystemValue';
216
+                        $dbKey = $key;
217
+                        break;
218
+                    case 'ldapAgentPassword':
219
+                        $readMethod = 'getPwd';
220
+                        break;
221
+                    case 'ldapUserDisplayName2':
222
+                    case 'ldapGroupDisplayName':
223
+                        $readMethod = 'getLcValue';
224
+                        break;
225
+                    case 'ldapUserDisplayName':
226
+                    default:
227
+                        // user display name does not lower case because
228
+                        // we rely on an upper case N as indicator whether to
229
+                        // auto-detect it or not. FIXME
230
+                        $readMethod = 'getValue';
231
+                        break;
232
+                }
233
+                $this->config[$key] = $this->$readMethod($dbKey);
234
+            }
235
+            $this->configRead = true;
236
+        }
237
+    }
238 238
 
239
-	/**
240
-	 * saves the current Configuration in the database
241
-	 */
242
-	public function saveConfiguration() {
243
-		$cta = array_flip($this->getConfigTranslationArray());
244
-		foreach($this->config as $key => $value) {
245
-			switch ($key) {
246
-				case 'ldapAgentPassword':
247
-					$value = base64_encode($value);
248
-					break;
249
-				case 'ldapBase':
250
-				case 'ldapBaseUsers':
251
-				case 'ldapBaseGroups':
252
-				case 'ldapAttributesForUserSearch':
253
-				case 'ldapAttributesForGroupSearch':
254
-				case 'ldapUserFilterObjectclass':
255
-				case 'ldapUserFilterGroups':
256
-				case 'ldapGroupFilterObjectclass':
257
-				case 'ldapGroupFilterGroups':
258
-				case 'ldapLoginFilterAttributes':
259
-					if(is_array($value)) {
260
-						$value = implode("\n", $value);
261
-					}
262
-					break;
263
-				//following options are not stored but detected, skip them
264
-				case 'ldapIgnoreNamingRules':
265
-				case 'hasPagedResultSupport':
266
-				case 'ldapUuidUserAttribute':
267
-				case 'ldapUuidGroupAttribute':
268
-					continue 2;
269
-			}
270
-			if(is_null($value)) {
271
-				$value = '';
272
-			}
273
-			$this->saveValue($cta[$key], $value);
274
-		}
275
-	}
239
+    /**
240
+     * saves the current Configuration in the database
241
+     */
242
+    public function saveConfiguration() {
243
+        $cta = array_flip($this->getConfigTranslationArray());
244
+        foreach($this->config as $key => $value) {
245
+            switch ($key) {
246
+                case 'ldapAgentPassword':
247
+                    $value = base64_encode($value);
248
+                    break;
249
+                case 'ldapBase':
250
+                case 'ldapBaseUsers':
251
+                case 'ldapBaseGroups':
252
+                case 'ldapAttributesForUserSearch':
253
+                case 'ldapAttributesForGroupSearch':
254
+                case 'ldapUserFilterObjectclass':
255
+                case 'ldapUserFilterGroups':
256
+                case 'ldapGroupFilterObjectclass':
257
+                case 'ldapGroupFilterGroups':
258
+                case 'ldapLoginFilterAttributes':
259
+                    if(is_array($value)) {
260
+                        $value = implode("\n", $value);
261
+                    }
262
+                    break;
263
+                //following options are not stored but detected, skip them
264
+                case 'ldapIgnoreNamingRules':
265
+                case 'hasPagedResultSupport':
266
+                case 'ldapUuidUserAttribute':
267
+                case 'ldapUuidGroupAttribute':
268
+                    continue 2;
269
+            }
270
+            if(is_null($value)) {
271
+                $value = '';
272
+            }
273
+            $this->saveValue($cta[$key], $value);
274
+        }
275
+    }
276 276
 
277
-	/**
278
-	 * @param string $varName
279
-	 * @return array|string
280
-	 */
281
-	protected function getMultiLine($varName) {
282
-		$value = $this->getValue($varName);
283
-		if(empty($value)) {
284
-			$value = '';
285
-		} else {
286
-			$value = preg_split('/\r\n|\r|\n/', $value);
287
-		}
277
+    /**
278
+     * @param string $varName
279
+     * @return array|string
280
+     */
281
+    protected function getMultiLine($varName) {
282
+        $value = $this->getValue($varName);
283
+        if(empty($value)) {
284
+            $value = '';
285
+        } else {
286
+            $value = preg_split('/\r\n|\r|\n/', $value);
287
+        }
288 288
 
289
-		return $value;
290
-	}
289
+        return $value;
290
+    }
291 291
 
292
-	/**
293
-	 * Sets multi-line values as arrays
294
-	 * 
295
-	 * @param string $varName name of config-key
296
-	 * @param array|string $value to set
297
-	 */
298
-	protected function setMultiLine($varName, $value) {
299
-		if(empty($value)) {
300
-			$value = '';
301
-		} else if (!is_array($value)) {
302
-			$value = preg_split('/\r\n|\r|\n|;/', $value);
303
-			if($value === false) {
304
-				$value = '';
305
-			}
306
-		}
292
+    /**
293
+     * Sets multi-line values as arrays
294
+     * 
295
+     * @param string $varName name of config-key
296
+     * @param array|string $value to set
297
+     */
298
+    protected function setMultiLine($varName, $value) {
299
+        if(empty($value)) {
300
+            $value = '';
301
+        } else if (!is_array($value)) {
302
+            $value = preg_split('/\r\n|\r|\n|;/', $value);
303
+            if($value === false) {
304
+                $value = '';
305
+            }
306
+        }
307 307
 
308
-		if(!is_array($value)) {
309
-			$finalValue = trim($value);
310
-		} else {
311
-			$finalValue = [];
312
-			foreach($value as $key => $val) {
313
-				if(is_string($val)) {
314
-					$val = trim($val);
315
-					if ($val !== '') {
316
-						//accidental line breaks are not wanted and can cause
317
-						// odd behaviour. Thus, away with them.
318
-						$finalValue[] = $val;
319
-					}
320
-				} else {
321
-					$finalValue[] = $val;
322
-				}
323
-			}
324
-		}
308
+        if(!is_array($value)) {
309
+            $finalValue = trim($value);
310
+        } else {
311
+            $finalValue = [];
312
+            foreach($value as $key => $val) {
313
+                if(is_string($val)) {
314
+                    $val = trim($val);
315
+                    if ($val !== '') {
316
+                        //accidental line breaks are not wanted and can cause
317
+                        // odd behaviour. Thus, away with them.
318
+                        $finalValue[] = $val;
319
+                    }
320
+                } else {
321
+                    $finalValue[] = $val;
322
+                }
323
+            }
324
+        }
325 325
 
326
-		$this->setRawValue($varName, $finalValue);
327
-	}
326
+        $this->setRawValue($varName, $finalValue);
327
+    }
328 328
 
329
-	/**
330
-	 * @param string $varName
331
-	 * @return string
332
-	 */
333
-	protected function getPwd($varName) {
334
-		return base64_decode($this->getValue($varName));
335
-	}
329
+    /**
330
+     * @param string $varName
331
+     * @return string
332
+     */
333
+    protected function getPwd($varName) {
334
+        return base64_decode($this->getValue($varName));
335
+    }
336 336
 
337
-	/**
338
-	 * @param string $varName
339
-	 * @return string
340
-	 */
341
-	protected function getLcValue($varName) {
342
-		return mb_strtolower($this->getValue($varName), 'UTF-8');
343
-	}
337
+    /**
338
+     * @param string $varName
339
+     * @return string
340
+     */
341
+    protected function getLcValue($varName) {
342
+        return mb_strtolower($this->getValue($varName), 'UTF-8');
343
+    }
344 344
 
345
-	/**
346
-	 * @param string $varName
347
-	 * @return string
348
-	 */
349
-	protected function getSystemValue($varName) {
350
-		//FIXME: if another system value is added, softcode the default value
351
-		return \OCP\Config::getSystemValue($varName, false);
352
-	}
345
+    /**
346
+     * @param string $varName
347
+     * @return string
348
+     */
349
+    protected function getSystemValue($varName) {
350
+        //FIXME: if another system value is added, softcode the default value
351
+        return \OCP\Config::getSystemValue($varName, false);
352
+    }
353 353
 
354
-	/**
355
-	 * @param string $varName
356
-	 * @return string
357
-	 */
358
-	protected function getValue($varName) {
359
-		static $defaults;
360
-		if(is_null($defaults)) {
361
-			$defaults = $this->getDefaults();
362
-		}
363
-		return \OCP\Config::getAppValue('user_ldap',
364
-										$this->configPrefix.$varName,
365
-										$defaults[$varName]);
366
-	}
354
+    /**
355
+     * @param string $varName
356
+     * @return string
357
+     */
358
+    protected function getValue($varName) {
359
+        static $defaults;
360
+        if(is_null($defaults)) {
361
+            $defaults = $this->getDefaults();
362
+        }
363
+        return \OCP\Config::getAppValue('user_ldap',
364
+                                        $this->configPrefix.$varName,
365
+                                        $defaults[$varName]);
366
+    }
367 367
 
368
-	/**
369
-	 * Sets a scalar value.
370
-	 * 
371
-	 * @param string $varName name of config key
372
-	 * @param mixed $value to set
373
-	 */
374
-	protected function setValue($varName, $value) {
375
-		if(is_string($value)) {
376
-			$value = trim($value);
377
-		}
378
-		$this->config[$varName] = $value;
379
-	}
368
+    /**
369
+     * Sets a scalar value.
370
+     * 
371
+     * @param string $varName name of config key
372
+     * @param mixed $value to set
373
+     */
374
+    protected function setValue($varName, $value) {
375
+        if(is_string($value)) {
376
+            $value = trim($value);
377
+        }
378
+        $this->config[$varName] = $value;
379
+    }
380 380
 
381
-	/**
382
-	 * Sets a scalar value without trimming.
383
-	 *
384
-	 * @param string $varName name of config key
385
-	 * @param mixed $value to set
386
-	 */
387
-	protected function setRawValue($varName, $value) {
388
-		$this->config[$varName] = $value;
389
-	}
381
+    /**
382
+     * Sets a scalar value without trimming.
383
+     *
384
+     * @param string $varName name of config key
385
+     * @param mixed $value to set
386
+     */
387
+    protected function setRawValue($varName, $value) {
388
+        $this->config[$varName] = $value;
389
+    }
390 390
 
391
-	/**
392
-	 * @param string $varName
393
-	 * @param string $value
394
-	 * @return bool
395
-	 */
396
-	protected function saveValue($varName, $value) {
397
-		\OC::$server->getConfig()->setAppValue(
398
-			'user_ldap',
399
-			$this->configPrefix.$varName,
400
-			$value
401
-		);
402
-		return true;
403
-	}
391
+    /**
392
+     * @param string $varName
393
+     * @param string $value
394
+     * @return bool
395
+     */
396
+    protected function saveValue($varName, $value) {
397
+        \OC::$server->getConfig()->setAppValue(
398
+            'user_ldap',
399
+            $this->configPrefix.$varName,
400
+            $value
401
+        );
402
+        return true;
403
+    }
404 404
 
405
-	/**
406
-	 * @return array an associative array with the default values. Keys are correspond
407
-	 * to config-value entries in the database table
408
-	 */
409
-	public function getDefaults() {
410
-		return array(
411
-			'ldap_host'                         => '',
412
-			'ldap_port'                         => '',
413
-			'ldap_backup_host'                  => '',
414
-			'ldap_backup_port'                  => '',
415
-			'ldap_override_main_server'         => '',
416
-			'ldap_dn'                           => '',
417
-			'ldap_agent_password'               => '',
418
-			'ldap_base'                         => '',
419
-			'ldap_base_users'                   => '',
420
-			'ldap_base_groups'                  => '',
421
-			'ldap_userlist_filter'              => '',
422
-			'ldap_user_filter_mode'             => 0,
423
-			'ldap_userfilter_objectclass'       => '',
424
-			'ldap_userfilter_groups'            => '',
425
-			'ldap_login_filter'                 => '',
426
-			'ldap_login_filter_mode'            => 0,
427
-			'ldap_loginfilter_email'            => 0,
428
-			'ldap_loginfilter_username'         => 1,
429
-			'ldap_loginfilter_attributes'       => '',
430
-			'ldap_group_filter'                 => '',
431
-			'ldap_group_filter_mode'            => 0,
432
-			'ldap_groupfilter_objectclass'      => '',
433
-			'ldap_groupfilter_groups'           => '',
434
-			'ldap_gid_number'                   => 'gidNumber',
435
-			'ldap_display_name'                 => 'displayName',
436
-			'ldap_user_display_name_2'			=> '',
437
-			'ldap_group_display_name'           => 'cn',
438
-			'ldap_tls'                          => 0,
439
-			'ldap_quota_def'                    => '',
440
-			'ldap_quota_attr'                   => '',
441
-			'ldap_email_attr'                   => '',
442
-			'ldap_group_member_assoc_attribute' => 'uniqueMember',
443
-			'ldap_cache_ttl'                    => 600,
444
-			'ldap_uuid_user_attribute'          => 'auto',
445
-			'ldap_uuid_group_attribute'         => 'auto',
446
-			'home_folder_naming_rule'           => '',
447
-			'ldap_turn_off_cert_check'          => 0,
448
-			'ldap_configuration_active'         => 0,
449
-			'ldap_attributes_for_user_search'   => '',
450
-			'ldap_attributes_for_group_search'  => '',
451
-			'ldap_expert_username_attr'         => '',
452
-			'ldap_expert_uuid_user_attr'        => '',
453
-			'ldap_expert_uuid_group_attr'       => '',
454
-			'has_memberof_filter_support'       => 0,
455
-			'use_memberof_to_detect_membership' => 1,
456
-			'last_jpegPhoto_lookup'             => 0,
457
-			'ldap_nested_groups'                => 0,
458
-			'ldap_paging_size'                  => 500,
459
-			'ldap_turn_on_pwd_change'           => 0,
460
-			'ldap_experienced_admin'            => 0,
461
-			'ldap_dynamic_group_member_url'     => '',
462
-		);
463
-	}
405
+    /**
406
+     * @return array an associative array with the default values. Keys are correspond
407
+     * to config-value entries in the database table
408
+     */
409
+    public function getDefaults() {
410
+        return array(
411
+            'ldap_host'                         => '',
412
+            'ldap_port'                         => '',
413
+            'ldap_backup_host'                  => '',
414
+            'ldap_backup_port'                  => '',
415
+            'ldap_override_main_server'         => '',
416
+            'ldap_dn'                           => '',
417
+            'ldap_agent_password'               => '',
418
+            'ldap_base'                         => '',
419
+            'ldap_base_users'                   => '',
420
+            'ldap_base_groups'                  => '',
421
+            'ldap_userlist_filter'              => '',
422
+            'ldap_user_filter_mode'             => 0,
423
+            'ldap_userfilter_objectclass'       => '',
424
+            'ldap_userfilter_groups'            => '',
425
+            'ldap_login_filter'                 => '',
426
+            'ldap_login_filter_mode'            => 0,
427
+            'ldap_loginfilter_email'            => 0,
428
+            'ldap_loginfilter_username'         => 1,
429
+            'ldap_loginfilter_attributes'       => '',
430
+            'ldap_group_filter'                 => '',
431
+            'ldap_group_filter_mode'            => 0,
432
+            'ldap_groupfilter_objectclass'      => '',
433
+            'ldap_groupfilter_groups'           => '',
434
+            'ldap_gid_number'                   => 'gidNumber',
435
+            'ldap_display_name'                 => 'displayName',
436
+            'ldap_user_display_name_2'			=> '',
437
+            'ldap_group_display_name'           => 'cn',
438
+            'ldap_tls'                          => 0,
439
+            'ldap_quota_def'                    => '',
440
+            'ldap_quota_attr'                   => '',
441
+            'ldap_email_attr'                   => '',
442
+            'ldap_group_member_assoc_attribute' => 'uniqueMember',
443
+            'ldap_cache_ttl'                    => 600,
444
+            'ldap_uuid_user_attribute'          => 'auto',
445
+            'ldap_uuid_group_attribute'         => 'auto',
446
+            'home_folder_naming_rule'           => '',
447
+            'ldap_turn_off_cert_check'          => 0,
448
+            'ldap_configuration_active'         => 0,
449
+            'ldap_attributes_for_user_search'   => '',
450
+            'ldap_attributes_for_group_search'  => '',
451
+            'ldap_expert_username_attr'         => '',
452
+            'ldap_expert_uuid_user_attr'        => '',
453
+            'ldap_expert_uuid_group_attr'       => '',
454
+            'has_memberof_filter_support'       => 0,
455
+            'use_memberof_to_detect_membership' => 1,
456
+            'last_jpegPhoto_lookup'             => 0,
457
+            'ldap_nested_groups'                => 0,
458
+            'ldap_paging_size'                  => 500,
459
+            'ldap_turn_on_pwd_change'           => 0,
460
+            'ldap_experienced_admin'            => 0,
461
+            'ldap_dynamic_group_member_url'     => '',
462
+        );
463
+    }
464 464
 
465
-	/**
466
-	 * @return array that maps internal variable names to database fields
467
-	 */
468
-	public function getConfigTranslationArray() {
469
-		//TODO: merge them into one representation
470
-		static $array = array(
471
-			'ldap_host'                         => 'ldapHost',
472
-			'ldap_port'                         => 'ldapPort',
473
-			'ldap_backup_host'                  => 'ldapBackupHost',
474
-			'ldap_backup_port'                  => 'ldapBackupPort',
475
-			'ldap_override_main_server'         => 'ldapOverrideMainServer',
476
-			'ldap_dn'                           => 'ldapAgentName',
477
-			'ldap_agent_password'               => 'ldapAgentPassword',
478
-			'ldap_base'                         => 'ldapBase',
479
-			'ldap_base_users'                   => 'ldapBaseUsers',
480
-			'ldap_base_groups'                  => 'ldapBaseGroups',
481
-			'ldap_userfilter_objectclass'       => 'ldapUserFilterObjectclass',
482
-			'ldap_userfilter_groups'            => 'ldapUserFilterGroups',
483
-			'ldap_userlist_filter'              => 'ldapUserFilter',
484
-			'ldap_user_filter_mode'             => 'ldapUserFilterMode',
485
-			'ldap_login_filter'                 => 'ldapLoginFilter',
486
-			'ldap_login_filter_mode'            => 'ldapLoginFilterMode',
487
-			'ldap_loginfilter_email'            => 'ldapLoginFilterEmail',
488
-			'ldap_loginfilter_username'         => 'ldapLoginFilterUsername',
489
-			'ldap_loginfilter_attributes'       => 'ldapLoginFilterAttributes',
490
-			'ldap_group_filter'                 => 'ldapGroupFilter',
491
-			'ldap_group_filter_mode'            => 'ldapGroupFilterMode',
492
-			'ldap_groupfilter_objectclass'      => 'ldapGroupFilterObjectclass',
493
-			'ldap_groupfilter_groups'           => 'ldapGroupFilterGroups',
494
-			'ldap_gid_number'                   => 'ldapGidNumber',
495
-			'ldap_display_name'                 => 'ldapUserDisplayName',
496
-			'ldap_user_display_name_2'			=> 'ldapUserDisplayName2',
497
-			'ldap_group_display_name'           => 'ldapGroupDisplayName',
498
-			'ldap_tls'                          => 'ldapTLS',
499
-			'ldap_quota_def'                    => 'ldapQuotaDefault',
500
-			'ldap_quota_attr'                   => 'ldapQuotaAttribute',
501
-			'ldap_email_attr'                   => 'ldapEmailAttribute',
502
-			'ldap_group_member_assoc_attribute' => 'ldapGroupMemberAssocAttr',
503
-			'ldap_cache_ttl'                    => 'ldapCacheTTL',
504
-			'home_folder_naming_rule'           => 'homeFolderNamingRule',
505
-			'ldap_turn_off_cert_check'          => 'turnOffCertCheck',
506
-			'ldap_configuration_active'         => 'ldapConfigurationActive',
507
-			'ldap_attributes_for_user_search'   => 'ldapAttributesForUserSearch',
508
-			'ldap_attributes_for_group_search'  => 'ldapAttributesForGroupSearch',
509
-			'ldap_expert_username_attr'         => 'ldapExpertUsernameAttr',
510
-			'ldap_expert_uuid_user_attr'        => 'ldapExpertUUIDUserAttr',
511
-			'ldap_expert_uuid_group_attr'       => 'ldapExpertUUIDGroupAttr',
512
-			'has_memberof_filter_support'       => 'hasMemberOfFilterSupport',
513
-			'use_memberof_to_detect_membership' => 'useMemberOfToDetectMembership',
514
-			'last_jpegPhoto_lookup'             => 'lastJpegPhotoLookup',
515
-			'ldap_nested_groups'                => 'ldapNestedGroups',
516
-			'ldap_paging_size'                  => 'ldapPagingSize',
517
-			'ldap_turn_on_pwd_change'           => 'turnOnPasswordChange',
518
-			'ldap_experienced_admin'            => 'ldapExperiencedAdmin',
519
-			'ldap_dynamic_group_member_url'     => 'ldapDynamicGroupMemberURL',
520
-		);
521
-		return $array;
522
-	}
465
+    /**
466
+     * @return array that maps internal variable names to database fields
467
+     */
468
+    public function getConfigTranslationArray() {
469
+        //TODO: merge them into one representation
470
+        static $array = array(
471
+            'ldap_host'                         => 'ldapHost',
472
+            'ldap_port'                         => 'ldapPort',
473
+            'ldap_backup_host'                  => 'ldapBackupHost',
474
+            'ldap_backup_port'                  => 'ldapBackupPort',
475
+            'ldap_override_main_server'         => 'ldapOverrideMainServer',
476
+            'ldap_dn'                           => 'ldapAgentName',
477
+            'ldap_agent_password'               => 'ldapAgentPassword',
478
+            'ldap_base'                         => 'ldapBase',
479
+            'ldap_base_users'                   => 'ldapBaseUsers',
480
+            'ldap_base_groups'                  => 'ldapBaseGroups',
481
+            'ldap_userfilter_objectclass'       => 'ldapUserFilterObjectclass',
482
+            'ldap_userfilter_groups'            => 'ldapUserFilterGroups',
483
+            'ldap_userlist_filter'              => 'ldapUserFilter',
484
+            'ldap_user_filter_mode'             => 'ldapUserFilterMode',
485
+            'ldap_login_filter'                 => 'ldapLoginFilter',
486
+            'ldap_login_filter_mode'            => 'ldapLoginFilterMode',
487
+            'ldap_loginfilter_email'            => 'ldapLoginFilterEmail',
488
+            'ldap_loginfilter_username'         => 'ldapLoginFilterUsername',
489
+            'ldap_loginfilter_attributes'       => 'ldapLoginFilterAttributes',
490
+            'ldap_group_filter'                 => 'ldapGroupFilter',
491
+            'ldap_group_filter_mode'            => 'ldapGroupFilterMode',
492
+            'ldap_groupfilter_objectclass'      => 'ldapGroupFilterObjectclass',
493
+            'ldap_groupfilter_groups'           => 'ldapGroupFilterGroups',
494
+            'ldap_gid_number'                   => 'ldapGidNumber',
495
+            'ldap_display_name'                 => 'ldapUserDisplayName',
496
+            'ldap_user_display_name_2'			=> 'ldapUserDisplayName2',
497
+            'ldap_group_display_name'           => 'ldapGroupDisplayName',
498
+            'ldap_tls'                          => 'ldapTLS',
499
+            'ldap_quota_def'                    => 'ldapQuotaDefault',
500
+            'ldap_quota_attr'                   => 'ldapQuotaAttribute',
501
+            'ldap_email_attr'                   => 'ldapEmailAttribute',
502
+            'ldap_group_member_assoc_attribute' => 'ldapGroupMemberAssocAttr',
503
+            'ldap_cache_ttl'                    => 'ldapCacheTTL',
504
+            'home_folder_naming_rule'           => 'homeFolderNamingRule',
505
+            'ldap_turn_off_cert_check'          => 'turnOffCertCheck',
506
+            'ldap_configuration_active'         => 'ldapConfigurationActive',
507
+            'ldap_attributes_for_user_search'   => 'ldapAttributesForUserSearch',
508
+            'ldap_attributes_for_group_search'  => 'ldapAttributesForGroupSearch',
509
+            'ldap_expert_username_attr'         => 'ldapExpertUsernameAttr',
510
+            'ldap_expert_uuid_user_attr'        => 'ldapExpertUUIDUserAttr',
511
+            'ldap_expert_uuid_group_attr'       => 'ldapExpertUUIDGroupAttr',
512
+            'has_memberof_filter_support'       => 'hasMemberOfFilterSupport',
513
+            'use_memberof_to_detect_membership' => 'useMemberOfToDetectMembership',
514
+            'last_jpegPhoto_lookup'             => 'lastJpegPhotoLookup',
515
+            'ldap_nested_groups'                => 'ldapNestedGroups',
516
+            'ldap_paging_size'                  => 'ldapPagingSize',
517
+            'ldap_turn_on_pwd_change'           => 'turnOnPasswordChange',
518
+            'ldap_experienced_admin'            => 'ldapExperiencedAdmin',
519
+            'ldap_dynamic_group_member_url'     => 'ldapDynamicGroupMemberURL',
520
+        );
521
+        return $array;
522
+    }
523 523
 
524 524
 }
Please login to merge, or discard this patch.