Completed
Branch master (69e0e2)
by Johannes
12:46
created
apps/user_ldap/lib/BackendUtility.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@
 block discarded – undo
27 27
 
28 28
 
29 29
 abstract class BackendUtility {
30
-	protected $access;
30
+    protected $access;
31 31
 
32
-	/**
33
-	 * constructor, make sure the subclasses call this one!
34
-	 * @param Access $access an instance of Access for LDAP interaction
35
-	 */
36
-	public function __construct(Access $access) {
37
-		$this->access = $access;
38
-	}
32
+    /**
33
+     * constructor, make sure the subclasses call this one!
34
+     * @param Access $access an instance of Access for LDAP interaction
35
+     */
36
+    public function __construct(Access $access) {
37
+        $this->access = $access;
38
+    }
39 39
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/WizardResult.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -28,52 +28,52 @@
 block discarded – undo
28 28
 namespace OCA\User_LDAP;
29 29
 
30 30
 class WizardResult {
31
-	protected $changes = array();
32
-	protected $options = array();
33
-	protected $markedChange = false;
31
+    protected $changes = array();
32
+    protected $options = array();
33
+    protected $markedChange = false;
34 34
 
35
-	/**
36
-	 * @param string $key
37
-	 * @param mixed $value
38
-	 */
39
-	public function addChange($key, $value) {
40
-		$this->changes[$key] = $value;
41
-	}
35
+    /**
36
+     * @param string $key
37
+     * @param mixed $value
38
+     */
39
+    public function addChange($key, $value) {
40
+        $this->changes[$key] = $value;
41
+    }
42 42
 
43
-	/**
44
-	 *
45
-	 */
46
-	public function markChange() {
47
-		$this->markedChange = true;
48
-	}
43
+    /**
44
+     *
45
+     */
46
+    public function markChange() {
47
+        $this->markedChange = true;
48
+    }
49 49
 
50
-	/**
51
-	 * @param string $key
52
-	 * @param array|string $values
53
-	 */
54
-	public function addOptions($key, $values) {
55
-		if(!is_array($values)) {
56
-			$values = array($values);
57
-		}
58
-		$this->options[$key] = $values;
59
-	}
50
+    /**
51
+     * @param string $key
52
+     * @param array|string $values
53
+     */
54
+    public function addOptions($key, $values) {
55
+        if(!is_array($values)) {
56
+            $values = array($values);
57
+        }
58
+        $this->options[$key] = $values;
59
+    }
60 60
 
61
-	/**
62
-	 * @return bool
63
-	 */
64
-	public function hasChanges() {
65
-		return (count($this->changes) > 0 || $this->markedChange);
66
-	}
61
+    /**
62
+     * @return bool
63
+     */
64
+    public function hasChanges() {
65
+        return (count($this->changes) > 0 || $this->markedChange);
66
+    }
67 67
 
68
-	/**
69
-	 * @return array
70
-	 */
71
-	public function getResultArray() {
72
-		$result = array();
73
-		$result['changes'] = $this->changes;
74
-		if(count($this->options) > 0) {
75
-			$result['options'] = $this->options;
76
-		}
77
-		return $result;
78
-	}
68
+    /**
69
+     * @return array
70
+     */
71
+    public function getResultArray() {
72
+        $result = array();
73
+        $result['changes'] = $this->changes;
74
+        if(count($this->options) > 0) {
75
+            $result['options'] = $this->options;
76
+        }
77
+        return $result;
78
+    }
79 79
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param array|string $values
53 53
 	 */
54 54
 	public function addOptions($key, $values) {
55
-		if(!is_array($values)) {
55
+		if (!is_array($values)) {
56 56
 			$values = array($values);
57 57
 		}
58 58
 		$this->options[$key] = $values;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	public function getResultArray() {
72 72
 		$result = array();
73 73
 		$result['changes'] = $this->changes;
74
-		if(count($this->options) > 0) {
74
+		if (count($this->options) > 0) {
75 75
 			$result['options'] = $this->options;
76 76
 		}
77 77
 		return $result;
Please login to merge, or discard this patch.
apps/user_ldap/lib/Proxy.php 2 patches
Indentation   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -35,174 +35,174 @@
 block discarded – undo
35 35
 use OCA\User_LDAP\User\Manager;
36 36
 
37 37
 abstract class Proxy {
38
-	static private $accesses = array();
39
-	private $ldap = null;
40
-
41
-	/** @var \OCP\ICache|null */
42
-	private $cache;
43
-
44
-	/**
45
-	 * @param ILDAPWrapper $ldap
46
-	 */
47
-	public function __construct(ILDAPWrapper $ldap) {
48
-		$this->ldap = $ldap;
49
-		$memcache = \OC::$server->getMemCacheFactory();
50
-		if($memcache->isAvailable()) {
51
-			$this->cache = $memcache->create();
52
-		}
53
-	}
54
-
55
-	/**
56
-	 * @param string $configPrefix
57
-	 */
58
-	private function addAccess($configPrefix) {
59
-		static $ocConfig;
60
-		static $fs;
61
-		static $log;
62
-		static $avatarM;
63
-		static $userMap;
64
-		static $groupMap;
65
-		static $db;
66
-		static $coreUserManager;
67
-		if(is_null($fs)) {
68
-			$ocConfig = \OC::$server->getConfig();
69
-			$fs       = new FilesystemHelper();
70
-			$log      = new LogWrapper();
71
-			$avatarM  = \OC::$server->getAvatarManager();
72
-			$db       = \OC::$server->getDatabaseConnection();
73
-			$userMap  = new UserMapping($db);
74
-			$groupMap = new GroupMapping($db);
75
-			$coreUserManager = \OC::$server->getUserManager();
76
-		}
77
-		$userManager =
78
-			new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db, $coreUserManager);
79
-		$connector = new Connection($this->ldap, $configPrefix);
80
-		$access = new Access($connector, $this->ldap, $userManager, new Helper(\OC::$server->getConfig()));
81
-		$access->setUserMapper($userMap);
82
-		$access->setGroupMapper($groupMap);
83
-		self::$accesses[$configPrefix] = $access;
84
-	}
85
-
86
-	/**
87
-	 * @param string $configPrefix
88
-	 * @return mixed
89
-	 */
90
-	protected function getAccess($configPrefix) {
91
-		if(!isset(self::$accesses[$configPrefix])) {
92
-			$this->addAccess($configPrefix);
93
-		}
94
-		return self::$accesses[$configPrefix];
95
-	}
96
-
97
-	/**
98
-	 * @param string $uid
99
-	 * @return string
100
-	 */
101
-	protected function getUserCacheKey($uid) {
102
-		return 'user-'.$uid.'-lastSeenOn';
103
-	}
104
-
105
-	/**
106
-	 * @param string $gid
107
-	 * @return string
108
-	 */
109
-	protected function getGroupCacheKey($gid) {
110
-		return 'group-'.$gid.'-lastSeenOn';
111
-	}
112
-
113
-	/**
114
-	 * @param string $id
115
-	 * @param string $method
116
-	 * @param array $parameters
117
-	 * @param bool $passOnWhen
118
-	 * @return mixed
119
-	 */
120
-	abstract protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
121
-
122
-	/**
123
-	 * @param string $id
124
-	 * @param string $method
125
-	 * @param array $parameters
126
-	 * @return mixed
127
-	 */
128
-	abstract protected function walkBackends($id, $method, $parameters);
129
-
130
-	/**
131
-	 * @param string $id
132
-	 * @return Access
133
-	 */
134
-	abstract public function getLDAPAccess($id);
135
-
136
-	/**
137
-	 * Takes care of the request to the User backend
138
-	 * @param string $id
139
-	 * @param string $method string, the method of the user backend that shall be called
140
-	 * @param array $parameters an array of parameters to be passed
141
-	 * @param bool $passOnWhen
142
-	 * @return mixed, the result of the specified method
143
-	 */
144
-	protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
145
-		$result = $this->callOnLastSeenOn($id,  $method, $parameters, $passOnWhen);
146
-		if($result === $passOnWhen) {
147
-			$result = $this->walkBackends($id, $method, $parameters);
148
-		}
149
-		return $result;
150
-	}
151
-
152
-	/**
153
-	 * @param string|null $key
154
-	 * @return string
155
-	 */
156
-	private function getCacheKey($key) {
157
-		$prefix = 'LDAP-Proxy-';
158
-		if(is_null($key)) {
159
-			return $prefix;
160
-		}
161
-		return $prefix.md5($key);
162
-	}
163
-
164
-	/**
165
-	 * @param string $key
166
-	 * @return mixed|null
167
-	 */
168
-	public function getFromCache($key) {
169
-		if(is_null($this->cache) || !$this->isCached($key)) {
170
-			return null;
171
-		}
172
-		$key = $this->getCacheKey($key);
173
-
174
-		return json_decode(base64_decode($this->cache->get($key)));
175
-	}
176
-
177
-	/**
178
-	 * @param string $key
179
-	 * @return bool
180
-	 */
181
-	public function isCached($key) {
182
-		if(is_null($this->cache)) {
183
-			return false;
184
-		}
185
-		$key = $this->getCacheKey($key);
186
-		return $this->cache->hasKey($key);
187
-	}
188
-
189
-	/**
190
-	 * @param string $key
191
-	 * @param mixed $value
192
-	 */
193
-	public function writeToCache($key, $value) {
194
-		if(is_null($this->cache)) {
195
-			return;
196
-		}
197
-		$key   = $this->getCacheKey($key);
198
-		$value = base64_encode(json_encode($value));
199
-		$this->cache->set($key, $value, '2592000');
200
-	}
201
-
202
-	public function clearCache() {
203
-		if(is_null($this->cache)) {
204
-			return;
205
-		}
206
-		$this->cache->clear($this->getCacheKey(null));
207
-	}
38
+    static private $accesses = array();
39
+    private $ldap = null;
40
+
41
+    /** @var \OCP\ICache|null */
42
+    private $cache;
43
+
44
+    /**
45
+     * @param ILDAPWrapper $ldap
46
+     */
47
+    public function __construct(ILDAPWrapper $ldap) {
48
+        $this->ldap = $ldap;
49
+        $memcache = \OC::$server->getMemCacheFactory();
50
+        if($memcache->isAvailable()) {
51
+            $this->cache = $memcache->create();
52
+        }
53
+    }
54
+
55
+    /**
56
+     * @param string $configPrefix
57
+     */
58
+    private function addAccess($configPrefix) {
59
+        static $ocConfig;
60
+        static $fs;
61
+        static $log;
62
+        static $avatarM;
63
+        static $userMap;
64
+        static $groupMap;
65
+        static $db;
66
+        static $coreUserManager;
67
+        if(is_null($fs)) {
68
+            $ocConfig = \OC::$server->getConfig();
69
+            $fs       = new FilesystemHelper();
70
+            $log      = new LogWrapper();
71
+            $avatarM  = \OC::$server->getAvatarManager();
72
+            $db       = \OC::$server->getDatabaseConnection();
73
+            $userMap  = new UserMapping($db);
74
+            $groupMap = new GroupMapping($db);
75
+            $coreUserManager = \OC::$server->getUserManager();
76
+        }
77
+        $userManager =
78
+            new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db, $coreUserManager);
79
+        $connector = new Connection($this->ldap, $configPrefix);
80
+        $access = new Access($connector, $this->ldap, $userManager, new Helper(\OC::$server->getConfig()));
81
+        $access->setUserMapper($userMap);
82
+        $access->setGroupMapper($groupMap);
83
+        self::$accesses[$configPrefix] = $access;
84
+    }
85
+
86
+    /**
87
+     * @param string $configPrefix
88
+     * @return mixed
89
+     */
90
+    protected function getAccess($configPrefix) {
91
+        if(!isset(self::$accesses[$configPrefix])) {
92
+            $this->addAccess($configPrefix);
93
+        }
94
+        return self::$accesses[$configPrefix];
95
+    }
96
+
97
+    /**
98
+     * @param string $uid
99
+     * @return string
100
+     */
101
+    protected function getUserCacheKey($uid) {
102
+        return 'user-'.$uid.'-lastSeenOn';
103
+    }
104
+
105
+    /**
106
+     * @param string $gid
107
+     * @return string
108
+     */
109
+    protected function getGroupCacheKey($gid) {
110
+        return 'group-'.$gid.'-lastSeenOn';
111
+    }
112
+
113
+    /**
114
+     * @param string $id
115
+     * @param string $method
116
+     * @param array $parameters
117
+     * @param bool $passOnWhen
118
+     * @return mixed
119
+     */
120
+    abstract protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
121
+
122
+    /**
123
+     * @param string $id
124
+     * @param string $method
125
+     * @param array $parameters
126
+     * @return mixed
127
+     */
128
+    abstract protected function walkBackends($id, $method, $parameters);
129
+
130
+    /**
131
+     * @param string $id
132
+     * @return Access
133
+     */
134
+    abstract public function getLDAPAccess($id);
135
+
136
+    /**
137
+     * Takes care of the request to the User backend
138
+     * @param string $id
139
+     * @param string $method string, the method of the user backend that shall be called
140
+     * @param array $parameters an array of parameters to be passed
141
+     * @param bool $passOnWhen
142
+     * @return mixed, the result of the specified method
143
+     */
144
+    protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
145
+        $result = $this->callOnLastSeenOn($id,  $method, $parameters, $passOnWhen);
146
+        if($result === $passOnWhen) {
147
+            $result = $this->walkBackends($id, $method, $parameters);
148
+        }
149
+        return $result;
150
+    }
151
+
152
+    /**
153
+     * @param string|null $key
154
+     * @return string
155
+     */
156
+    private function getCacheKey($key) {
157
+        $prefix = 'LDAP-Proxy-';
158
+        if(is_null($key)) {
159
+            return $prefix;
160
+        }
161
+        return $prefix.md5($key);
162
+    }
163
+
164
+    /**
165
+     * @param string $key
166
+     * @return mixed|null
167
+     */
168
+    public function getFromCache($key) {
169
+        if(is_null($this->cache) || !$this->isCached($key)) {
170
+            return null;
171
+        }
172
+        $key = $this->getCacheKey($key);
173
+
174
+        return json_decode(base64_decode($this->cache->get($key)));
175
+    }
176
+
177
+    /**
178
+     * @param string $key
179
+     * @return bool
180
+     */
181
+    public function isCached($key) {
182
+        if(is_null($this->cache)) {
183
+            return false;
184
+        }
185
+        $key = $this->getCacheKey($key);
186
+        return $this->cache->hasKey($key);
187
+    }
188
+
189
+    /**
190
+     * @param string $key
191
+     * @param mixed $value
192
+     */
193
+    public function writeToCache($key, $value) {
194
+        if(is_null($this->cache)) {
195
+            return;
196
+        }
197
+        $key   = $this->getCacheKey($key);
198
+        $value = base64_encode(json_encode($value));
199
+        $this->cache->set($key, $value, '2592000');
200
+    }
201
+
202
+    public function clearCache() {
203
+        if(is_null($this->cache)) {
204
+            return;
205
+        }
206
+        $this->cache->clear($this->getCacheKey(null));
207
+    }
208 208
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	public function __construct(ILDAPWrapper $ldap) {
48 48
 		$this->ldap = $ldap;
49 49
 		$memcache = \OC::$server->getMemCacheFactory();
50
-		if($memcache->isAvailable()) {
50
+		if ($memcache->isAvailable()) {
51 51
 			$this->cache = $memcache->create();
52 52
 		}
53 53
 	}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		static $groupMap;
65 65
 		static $db;
66 66
 		static $coreUserManager;
67
-		if(is_null($fs)) {
67
+		if (is_null($fs)) {
68 68
 			$ocConfig = \OC::$server->getConfig();
69 69
 			$fs       = new FilesystemHelper();
70 70
 			$log      = new LogWrapper();
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @return mixed
89 89
 	 */
90 90
 	protected function getAccess($configPrefix) {
91
-		if(!isset(self::$accesses[$configPrefix])) {
91
+		if (!isset(self::$accesses[$configPrefix])) {
92 92
 			$this->addAccess($configPrefix);
93 93
 		}
94 94
 		return self::$accesses[$configPrefix];
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	 * @return mixed, the result of the specified method
143 143
 	 */
144 144
 	protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
145
-		$result = $this->callOnLastSeenOn($id,  $method, $parameters, $passOnWhen);
146
-		if($result === $passOnWhen) {
145
+		$result = $this->callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
146
+		if ($result === $passOnWhen) {
147 147
 			$result = $this->walkBackends($id, $method, $parameters);
148 148
 		}
149 149
 		return $result;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	private function getCacheKey($key) {
157 157
 		$prefix = 'LDAP-Proxy-';
158
-		if(is_null($key)) {
158
+		if (is_null($key)) {
159 159
 			return $prefix;
160 160
 		}
161 161
 		return $prefix.md5($key);
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @return mixed|null
167 167
 	 */
168 168
 	public function getFromCache($key) {
169
-		if(is_null($this->cache) || !$this->isCached($key)) {
169
+		if (is_null($this->cache) || !$this->isCached($key)) {
170 170
 			return null;
171 171
 		}
172 172
 		$key = $this->getCacheKey($key);
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @return bool
180 180
 	 */
181 181
 	public function isCached($key) {
182
-		if(is_null($this->cache)) {
182
+		if (is_null($this->cache)) {
183 183
 			return false;
184 184
 		}
185 185
 		$key = $this->getCacheKey($key);
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @param mixed $value
192 192
 	 */
193 193
 	public function writeToCache($key, $value) {
194
-		if(is_null($this->cache)) {
194
+		if (is_null($this->cache)) {
195 195
 			return;
196 196
 		}
197 197
 		$key   = $this->getCacheKey($key);
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public function clearCache() {
203
-		if(is_null($this->cache)) {
203
+		if (is_null($this->cache)) {
204 204
 			return;
205 205
 		}
206 206
 		$this->cache->clear($this->getCacheKey(null));
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/UUIDFixInsert.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -32,70 +32,70 @@
 block discarded – undo
32 32
 
33 33
 class UUIDFixInsert implements IRepairStep {
34 34
 
35
-	/** @var IConfig */
36
-	protected $config;
35
+    /** @var IConfig */
36
+    protected $config;
37 37
 
38
-	/** @var UserMapping */
39
-	protected $userMapper;
38
+    /** @var UserMapping */
39
+    protected $userMapper;
40 40
 
41
-	/** @var GroupMapping */
42
-	protected $groupMapper;
41
+    /** @var GroupMapping */
42
+    protected $groupMapper;
43 43
 
44
-	/** @var IJobList */
45
-	protected $jobList;
44
+    /** @var IJobList */
45
+    protected $jobList;
46 46
 
47
-	public function __construct(IConfig $config, UserMapping $userMapper, GroupMapping $groupMapper, IJobList $jobList) {
48
-		$this->config = $config;
49
-		$this->userMapper = $userMapper;
50
-		$this->groupMapper = $groupMapper;
51
-		$this->jobList = $jobList;
52
-	}
47
+    public function __construct(IConfig $config, UserMapping $userMapper, GroupMapping $groupMapper, IJobList $jobList) {
48
+        $this->config = $config;
49
+        $this->userMapper = $userMapper;
50
+        $this->groupMapper = $groupMapper;
51
+        $this->jobList = $jobList;
52
+    }
53 53
 
54
-	/**
55
-	 * Returns the step's name
56
-	 *
57
-	 * @return string
58
-	 * @since 9.1.0
59
-	 */
60
-	public function getName() {
61
-		return 'Insert UUIDFix background job for user and group in batches';
62
-	}
54
+    /**
55
+     * Returns the step's name
56
+     *
57
+     * @return string
58
+     * @since 9.1.0
59
+     */
60
+    public function getName() {
61
+        return 'Insert UUIDFix background job for user and group in batches';
62
+    }
63 63
 
64
-	/**
65
-	 * Run repair step.
66
-	 * Must throw exception on error.
67
-	 *
68
-	 * @param IOutput $output
69
-	 * @throws \Exception in case of failure
70
-	 * @since 9.1.0
71
-	 */
72
-	public function run(IOutput $output) {
73
-		$installedVersion = $this->config->getAppValue('user_ldap', 'installed_version', '1.2.1');
74
-		if(version_compare($installedVersion, '1.2.1') !== -1) {
75
-			return;
76
-		}
64
+    /**
65
+     * Run repair step.
66
+     * Must throw exception on error.
67
+     *
68
+     * @param IOutput $output
69
+     * @throws \Exception in case of failure
70
+     * @since 9.1.0
71
+     */
72
+    public function run(IOutput $output) {
73
+        $installedVersion = $this->config->getAppValue('user_ldap', 'installed_version', '1.2.1');
74
+        if(version_compare($installedVersion, '1.2.1') !== -1) {
75
+            return;
76
+        }
77 77
 
78
-		foreach ([$this->userMapper, $this->groupMapper] as $mapper) {
79
-			$offset = 0;
80
-			$batchSize = 50;
81
-			$jobClass = $mapper instanceof UserMapping ? UUIDFixUser::class : UUIDFixGroup::class;
82
-			do {
83
-				$retry = false;
84
-				$records = $mapper->getList($offset, $batchSize);
85
-				if(count($records) === 0){
86
-					continue;
87
-				}
88
-				try {
89
-					$this->jobList->add($jobClass, ['records' => $records]);
90
-					$offset += $batchSize;
91
-				} catch (\InvalidArgumentException $e) {
92
-					if(strpos($e->getMessage(), 'Background job arguments can\'t exceed 4000') !== false) {
93
-						$batchSize = intval(floor(count($records) * 0.8));
94
-						$retry = true;
95
-					}
96
-				}
97
-			} while (count($records) === $batchSize || $retry);
98
-		}
78
+        foreach ([$this->userMapper, $this->groupMapper] as $mapper) {
79
+            $offset = 0;
80
+            $batchSize = 50;
81
+            $jobClass = $mapper instanceof UserMapping ? UUIDFixUser::class : UUIDFixGroup::class;
82
+            do {
83
+                $retry = false;
84
+                $records = $mapper->getList($offset, $batchSize);
85
+                if(count($records) === 0){
86
+                    continue;
87
+                }
88
+                try {
89
+                    $this->jobList->add($jobClass, ['records' => $records]);
90
+                    $offset += $batchSize;
91
+                } catch (\InvalidArgumentException $e) {
92
+                    if(strpos($e->getMessage(), 'Background job arguments can\'t exceed 4000') !== false) {
93
+                        $batchSize = intval(floor(count($records) * 0.8));
94
+                        $retry = true;
95
+                    }
96
+                }
97
+            } while (count($records) === $batchSize || $retry);
98
+        }
99 99
 
100
-	}
100
+    }
101 101
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function run(IOutput $output) {
73 73
 		$installedVersion = $this->config->getAppValue('user_ldap', 'installed_version', '1.2.1');
74
-		if(version_compare($installedVersion, '1.2.1') !== -1) {
74
+		if (version_compare($installedVersion, '1.2.1') !== -1) {
75 75
 			return;
76 76
 		}
77 77
 
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 			do {
83 83
 				$retry = false;
84 84
 				$records = $mapper->getList($offset, $batchSize);
85
-				if(count($records) === 0){
85
+				if (count($records) === 0) {
86 86
 					continue;
87 87
 				}
88 88
 				try {
89 89
 					$this->jobList->add($jobClass, ['records' => $records]);
90 90
 					$offset += $batchSize;
91 91
 				} catch (\InvalidArgumentException $e) {
92
-					if(strpos($e->getMessage(), 'Background job arguments can\'t exceed 4000') !== false) {
92
+					if (strpos($e->getMessage(), 'Background job arguments can\'t exceed 4000') !== false) {
93 93
 						$batchSize = intval(floor(count($records) * 0.8));
94 94
 						$retry = true;
95 95
 					}
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/UUIDFixGroup.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@
 block discarded – undo
30 30
 use OCP\IConfig;
31 31
 
32 32
 class UUIDFixGroup extends UUIDFix {
33
-	public function __construct(GroupMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
34
-		$this->mapper = $mapper;
35
-		$this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config);
36
-	}
33
+    public function __construct(GroupMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
34
+        $this->mapper = $mapper;
35
+        $this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config);
36
+    }
37 37
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/UUIDFixUser.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@
 block discarded – undo
30 30
 use OCP\IConfig;
31 31
 
32 32
 class UUIDFixUser extends UUIDFix {
33
-	public function __construct(UserMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
34
-		$this->mapper = $mapper;
35
-		$this->proxy = new Group_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config);
36
-	}
33
+    public function __construct(UserMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
34
+        $this->mapper = $mapper;
35
+        $this->proxy = new Group_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config);
36
+    }
37 37
 }
Please login to merge, or discard this patch.
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
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.
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 Nextcloud'
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 Nextcloud
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 Nextcloud'
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 Nextcloud
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.
apps/user_ldap/lib/Command/Search.php 2 patches
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.
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -37,98 +37,98 @@
 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
-			// convert the limit of groups to null. This will show all the groups available instead of
118
-			// nothing, and will match the same behaviour the search for users has.
119
-			if ($limit === 0) {
120
-				$limit = null;
121
-			}
122
-		} else {
123
-			$proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig);
124
-			$getMethod = 'getDisplayNames';
125
-			$printID = true;
126
-		}
113
+        if($input->getOption('group')) {
114
+            $proxy = new Group_Proxy($configPrefixes, $ldapWrapper);
115
+            $getMethod = 'getGroups';
116
+            $printID = false;
117
+            // convert the limit of groups to null. This will show all the groups available instead of
118
+            // nothing, and will match the same behaviour the search for users has.
119
+            if ($limit === 0) {
120
+                $limit = null;
121
+            }
122
+        } else {
123
+            $proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig);
124
+            $getMethod = 'getDisplayNames';
125
+            $printID = true;
126
+        }
127 127
 
128
-		$result = $proxy->$getMethod($input->getArgument('search'), $limit, $offset);
129
-		foreach($result as $id => $name) {
130
-			$line = $name . ($printID ? ' ('.$id.')' : '');
131
-			$output->writeln($line);
132
-		}
133
-	}
128
+        $result = $proxy->$getMethod($input->getArgument('search'), $limit, $offset);
129
+        foreach($result as $id => $name) {
130
+            $line = $name . ($printID ? ' ('.$id.')' : '');
131
+            $output->writeln($line);
132
+        }
133
+    }
134 134
 }
Please login to merge, or discard this patch.