Completed
Push — master ( 0256f6...5411d6 )
by Morris
22:12 queued 06:46
created
apps/user_ldap/lib/Group_Proxy.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function __construct($serverConfigPrefixes, ILDAPWrapper $ldap, GroupPluginManager $groupPluginManager) {
38 38
 		parent::__construct($ldap);
39
-		foreach($serverConfigPrefixes as $configPrefix) {
39
+		foreach ($serverConfigPrefixes as $configPrefix) {
40 40
 			$this->backends[$configPrefix] =
41 41
 				new \OCA\User_LDAP\Group_LDAP($this->getAccess($configPrefix), $groupPluginManager);
42
-			if(is_null($this->refBackend)) {
42
+			if (is_null($this->refBackend)) {
43 43
 				$this->refBackend = &$this->backends[$configPrefix];
44 44
 			}
45 45
 		}
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	protected function walkBackends($gid, $method, $parameters) {
56 56
 		$cacheKey = $this->getGroupCacheKey($gid);
57
-		foreach($this->backends as $configPrefix => $backend) {
58
-			if($result = call_user_func_array(array($backend, $method), $parameters)) {
57
+		foreach ($this->backends as $configPrefix => $backend) {
58
+			if ($result = call_user_func_array(array($backend, $method), $parameters)) {
59 59
 				$this->writeToCache($cacheKey, $configPrefix);
60 60
 				return $result;
61 61
 			}
@@ -72,20 +72,20 @@  discard block
 block discarded – undo
72 72
 	 * @return mixed, the result of the method or false
73 73
 	 */
74 74
 	protected function callOnLastSeenOn($gid, $method, $parameters, $passOnWhen) {
75
-		$cacheKey = $this->getGroupCacheKey($gid);;
75
+		$cacheKey = $this->getGroupCacheKey($gid); ;
76 76
 		$prefix = $this->getFromCache($cacheKey);
77 77
 		//in case the uid has been found in the past, try this stored connection first
78
-		if(!is_null($prefix)) {
79
-			if(isset($this->backends[$prefix])) {
78
+		if (!is_null($prefix)) {
79
+			if (isset($this->backends[$prefix])) {
80 80
 				$result = call_user_func_array(array($this->backends[$prefix], $method), $parameters);
81
-				if($result === $passOnWhen) {
81
+				if ($result === $passOnWhen) {
82 82
 					//not found here, reset cache to null if group vanished
83 83
 					//because sometimes methods return false with a reason
84 84
 					$groupExists = call_user_func_array(
85 85
 						array($this->backends[$prefix], 'groupExists'),
86 86
 						array($gid)
87 87
 					);
88
-					if(!$groupExists) {
88
+					if (!$groupExists) {
89 89
 						$this->writeToCache($cacheKey, null);
90 90
 					}
91 91
 				}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	public function getUserGroups($uid) {
119 119
 		$groups = array();
120 120
 
121
-		foreach($this->backends as $backend) {
121
+		foreach ($this->backends as $backend) {
122 122
 			$backendGroups = $backend->getUserGroups($uid);
123 123
 			if (is_array($backendGroups)) {
124 124
 				$groups = array_merge($groups, $backendGroups);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
136 136
 		$users = array();
137 137
 
138
-		foreach($this->backends as $backend) {
138
+		foreach ($this->backends as $backend) {
139 139
 			$backendUsers = $backend->usersInGroup($gid, $search, $limit, $offset);
140 140
 			if (is_array($backendUsers)) {
141 141
 				$users = array_merge($users, $backendUsers);
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	public function getGroups($search = '', $limit = -1, $offset = 0) {
221 221
 		$groups = array();
222 222
 
223
-		foreach($this->backends as $backend) {
223
+		foreach ($this->backends as $backend) {
224 224
 			$backendGroups = $backend->getGroups($search, $limit, $offset);
225 225
 			if (is_array($backendGroups)) {
226 226
 				$groups = array_merge($groups, $backendGroups);
Please login to merge, or discard this patch.
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -27,248 +27,248 @@
 block discarded – undo
27 27
 namespace OCA\User_LDAP;
28 28
 
29 29
 class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP {
30
-	private $backends = array();
31
-	private $refBackend = null;
30
+    private $backends = array();
31
+    private $refBackend = null;
32 32
 
33
-	/**
34
-	 * Constructor
35
-	 * @param string[] $serverConfigPrefixes array containing the config Prefixes
36
-	 */
37
-	public function __construct($serverConfigPrefixes, ILDAPWrapper $ldap, GroupPluginManager $groupPluginManager) {
38
-		parent::__construct($ldap);
39
-		foreach($serverConfigPrefixes as $configPrefix) {
40
-			$this->backends[$configPrefix] =
41
-				new \OCA\User_LDAP\Group_LDAP($this->getAccess($configPrefix), $groupPluginManager);
42
-			if(is_null($this->refBackend)) {
43
-				$this->refBackend = &$this->backends[$configPrefix];
44
-			}
45
-		}
46
-	}
33
+    /**
34
+     * Constructor
35
+     * @param string[] $serverConfigPrefixes array containing the config Prefixes
36
+     */
37
+    public function __construct($serverConfigPrefixes, ILDAPWrapper $ldap, GroupPluginManager $groupPluginManager) {
38
+        parent::__construct($ldap);
39
+        foreach($serverConfigPrefixes as $configPrefix) {
40
+            $this->backends[$configPrefix] =
41
+                new \OCA\User_LDAP\Group_LDAP($this->getAccess($configPrefix), $groupPluginManager);
42
+            if(is_null($this->refBackend)) {
43
+                $this->refBackend = &$this->backends[$configPrefix];
44
+            }
45
+        }
46
+    }
47 47
 
48
-	/**
49
-	 * Tries the backends one after the other until a positive result is returned from the specified method
50
-	 * @param string $gid the gid connected to the request
51
-	 * @param string $method the method of the group backend that shall be called
52
-	 * @param array $parameters an array of parameters to be passed
53
-	 * @return mixed, the result of the method or false
54
-	 */
55
-	protected function walkBackends($gid, $method, $parameters) {
56
-		$cacheKey = $this->getGroupCacheKey($gid);
57
-		foreach($this->backends as $configPrefix => $backend) {
58
-			if($result = call_user_func_array(array($backend, $method), $parameters)) {
59
-				$this->writeToCache($cacheKey, $configPrefix);
60
-				return $result;
61
-			}
62
-		}
63
-		return false;
64
-	}
48
+    /**
49
+     * Tries the backends one after the other until a positive result is returned from the specified method
50
+     * @param string $gid the gid connected to the request
51
+     * @param string $method the method of the group backend that shall be called
52
+     * @param array $parameters an array of parameters to be passed
53
+     * @return mixed, the result of the method or false
54
+     */
55
+    protected function walkBackends($gid, $method, $parameters) {
56
+        $cacheKey = $this->getGroupCacheKey($gid);
57
+        foreach($this->backends as $configPrefix => $backend) {
58
+            if($result = call_user_func_array(array($backend, $method), $parameters)) {
59
+                $this->writeToCache($cacheKey, $configPrefix);
60
+                return $result;
61
+            }
62
+        }
63
+        return false;
64
+    }
65 65
 
66
-	/**
67
-	 * Asks the backend connected to the server that supposely takes care of the gid from the request.
68
-	 * @param string $gid the gid connected to the request
69
-	 * @param string $method the method of the group backend that shall be called
70
-	 * @param array $parameters an array of parameters to be passed
71
-	 * @param mixed $passOnWhen the result matches this variable
72
-	 * @return mixed, the result of the method or false
73
-	 */
74
-	protected function callOnLastSeenOn($gid, $method, $parameters, $passOnWhen) {
75
-		$cacheKey = $this->getGroupCacheKey($gid);;
76
-		$prefix = $this->getFromCache($cacheKey);
77
-		//in case the uid has been found in the past, try this stored connection first
78
-		if(!is_null($prefix)) {
79
-			if(isset($this->backends[$prefix])) {
80
-				$result = call_user_func_array(array($this->backends[$prefix], $method), $parameters);
81
-				if($result === $passOnWhen) {
82
-					//not found here, reset cache to null if group vanished
83
-					//because sometimes methods return false with a reason
84
-					$groupExists = call_user_func_array(
85
-						array($this->backends[$prefix], 'groupExists'),
86
-						array($gid)
87
-					);
88
-					if(!$groupExists) {
89
-						$this->writeToCache($cacheKey, null);
90
-					}
91
-				}
92
-				return $result;
93
-			}
94
-		}
95
-		return false;
96
-	}
66
+    /**
67
+     * Asks the backend connected to the server that supposely takes care of the gid from the request.
68
+     * @param string $gid the gid connected to the request
69
+     * @param string $method the method of the group backend that shall be called
70
+     * @param array $parameters an array of parameters to be passed
71
+     * @param mixed $passOnWhen the result matches this variable
72
+     * @return mixed, the result of the method or false
73
+     */
74
+    protected function callOnLastSeenOn($gid, $method, $parameters, $passOnWhen) {
75
+        $cacheKey = $this->getGroupCacheKey($gid);;
76
+        $prefix = $this->getFromCache($cacheKey);
77
+        //in case the uid has been found in the past, try this stored connection first
78
+        if(!is_null($prefix)) {
79
+            if(isset($this->backends[$prefix])) {
80
+                $result = call_user_func_array(array($this->backends[$prefix], $method), $parameters);
81
+                if($result === $passOnWhen) {
82
+                    //not found here, reset cache to null if group vanished
83
+                    //because sometimes methods return false with a reason
84
+                    $groupExists = call_user_func_array(
85
+                        array($this->backends[$prefix], 'groupExists'),
86
+                        array($gid)
87
+                    );
88
+                    if(!$groupExists) {
89
+                        $this->writeToCache($cacheKey, null);
90
+                    }
91
+                }
92
+                return $result;
93
+            }
94
+        }
95
+        return false;
96
+    }
97 97
 
98
-	/**
99
-	 * is user in group?
100
-	 * @param string $uid uid of the user
101
-	 * @param string $gid gid of the group
102
-	 * @return bool
103
-	 *
104
-	 * Checks whether the user is member of a group or not.
105
-	 */
106
-	public function inGroup($uid, $gid) {
107
-		return $this->handleRequest($gid, 'inGroup', array($uid, $gid));
108
-	}
98
+    /**
99
+     * is user in group?
100
+     * @param string $uid uid of the user
101
+     * @param string $gid gid of the group
102
+     * @return bool
103
+     *
104
+     * Checks whether the user is member of a group or not.
105
+     */
106
+    public function inGroup($uid, $gid) {
107
+        return $this->handleRequest($gid, 'inGroup', array($uid, $gid));
108
+    }
109 109
 
110
-	/**
111
-	 * Get all groups a user belongs to
112
-	 * @param string $uid Name of the user
113
-	 * @return string[] with group names
114
-	 *
115
-	 * This function fetches all groups a user belongs to. It does not check
116
-	 * if the user exists at all.
117
-	 */
118
-	public function getUserGroups($uid) {
119
-		$groups = array();
110
+    /**
111
+     * Get all groups a user belongs to
112
+     * @param string $uid Name of the user
113
+     * @return string[] with group names
114
+     *
115
+     * This function fetches all groups a user belongs to. It does not check
116
+     * if the user exists at all.
117
+     */
118
+    public function getUserGroups($uid) {
119
+        $groups = array();
120 120
 
121
-		foreach($this->backends as $backend) {
122
-			$backendGroups = $backend->getUserGroups($uid);
123
-			if (is_array($backendGroups)) {
124
-				$groups = array_merge($groups, $backendGroups);
125
-			}
126
-		}
121
+        foreach($this->backends as $backend) {
122
+            $backendGroups = $backend->getUserGroups($uid);
123
+            if (is_array($backendGroups)) {
124
+                $groups = array_merge($groups, $backendGroups);
125
+            }
126
+        }
127 127
 
128
-		return $groups;
129
-	}
128
+        return $groups;
129
+    }
130 130
 
131
-	/**
132
-	 * get a list of all users in a group
133
-	 * @return string[] with user ids
134
-	 */
135
-	public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
136
-		$users = array();
131
+    /**
132
+     * get a list of all users in a group
133
+     * @return string[] with user ids
134
+     */
135
+    public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
136
+        $users = array();
137 137
 
138
-		foreach($this->backends as $backend) {
139
-			$backendUsers = $backend->usersInGroup($gid, $search, $limit, $offset);
140
-			if (is_array($backendUsers)) {
141
-				$users = array_merge($users, $backendUsers);
142
-			}
143
-		}
138
+        foreach($this->backends as $backend) {
139
+            $backendUsers = $backend->usersInGroup($gid, $search, $limit, $offset);
140
+            if (is_array($backendUsers)) {
141
+                $users = array_merge($users, $backendUsers);
142
+            }
143
+        }
144 144
 
145
-		return $users;
146
-	}
145
+        return $users;
146
+    }
147 147
 
148
-	/**
149
-	 * @param string $gid
150
-	 * @return bool
151
-	 */
152
-	public function createGroup($gid) {
153
-		return $this->handleRequest(
154
-			$gid, 'createGroup', array($gid));
155
-	}
148
+    /**
149
+     * @param string $gid
150
+     * @return bool
151
+     */
152
+    public function createGroup($gid) {
153
+        return $this->handleRequest(
154
+            $gid, 'createGroup', array($gid));
155
+    }
156 156
 
157
-	/**
158
-	 * delete a group
159
-	 * @param string $gid gid of the group to delete
160
-	 * @return bool
161
-	 */
162
-	public function deleteGroup($gid) {
163
-		return $this->handleRequest(
164
-			$gid, 'deleteGroup', array($gid));
165
-	}
157
+    /**
158
+     * delete a group
159
+     * @param string $gid gid of the group to delete
160
+     * @return bool
161
+     */
162
+    public function deleteGroup($gid) {
163
+        return $this->handleRequest(
164
+            $gid, 'deleteGroup', array($gid));
165
+    }
166 166
 
167
-	/**
168
-	 * Add a user to a group
169
-	 * @param string $uid Name of the user to add to group
170
-	 * @param string $gid Name of the group in which add the user
171
-	 * @return bool
172
-	 *
173
-	 * Adds a user to a group.
174
-	 */
175
-	public function addToGroup($uid, $gid) {
176
-		return $this->handleRequest(
177
-			$gid, 'addToGroup', array($uid, $gid));
178
-	}
167
+    /**
168
+     * Add a user to a group
169
+     * @param string $uid Name of the user to add to group
170
+     * @param string $gid Name of the group in which add the user
171
+     * @return bool
172
+     *
173
+     * Adds a user to a group.
174
+     */
175
+    public function addToGroup($uid, $gid) {
176
+        return $this->handleRequest(
177
+            $gid, 'addToGroup', array($uid, $gid));
178
+    }
179 179
 
180
-	/**
181
-	 * Removes a user from a group
182
-	 * @param string $uid Name of the user to remove from group
183
-	 * @param string $gid Name of the group from which remove the user
184
-	 * @return bool
185
-	 *
186
-	 * removes the user from a group.
187
-	 */
188
-	public function removeFromGroup($uid, $gid) {
189
-		return $this->handleRequest(
190
-			$gid, 'removeFromGroup', array($uid, $gid));
191
-	}
180
+    /**
181
+     * Removes a user from a group
182
+     * @param string $uid Name of the user to remove from group
183
+     * @param string $gid Name of the group from which remove the user
184
+     * @return bool
185
+     *
186
+     * removes the user from a group.
187
+     */
188
+    public function removeFromGroup($uid, $gid) {
189
+        return $this->handleRequest(
190
+            $gid, 'removeFromGroup', array($uid, $gid));
191
+    }
192 192
 
193
-	/**
194
-	 * returns the number of users in a group, who match the search term
195
-	 * @param string $gid the internal group name
196
-	 * @param string $search optional, a search string
197
-	 * @return int|bool
198
-	 */
199
-	public function countUsersInGroup($gid, $search = '') {
200
-		return $this->handleRequest(
201
-			$gid, 'countUsersInGroup', array($gid, $search));
202
-	}
193
+    /**
194
+     * returns the number of users in a group, who match the search term
195
+     * @param string $gid the internal group name
196
+     * @param string $search optional, a search string
197
+     * @return int|bool
198
+     */
199
+    public function countUsersInGroup($gid, $search = '') {
200
+        return $this->handleRequest(
201
+            $gid, 'countUsersInGroup', array($gid, $search));
202
+    }
203 203
 
204
-	/**
205
-	 * get an array with group details
206
-	 * @param string $gid
207
-	 * @return array|false
208
-	 */
209
-	public function getGroupDetails($gid) {
210
-		return $this->handleRequest(
211
-			$gid, 'getGroupDetails', array($gid));
212
-	}
204
+    /**
205
+     * get an array with group details
206
+     * @param string $gid
207
+     * @return array|false
208
+     */
209
+    public function getGroupDetails($gid) {
210
+        return $this->handleRequest(
211
+            $gid, 'getGroupDetails', array($gid));
212
+    }
213 213
 
214
-	/**
215
-	 * get a list of all groups
216
-	 * @return string[] with group names
217
-	 *
218
-	 * Returns a list with all groups
219
-	 */
220
-	public function getGroups($search = '', $limit = -1, $offset = 0) {
221
-		$groups = array();
214
+    /**
215
+     * get a list of all groups
216
+     * @return string[] with group names
217
+     *
218
+     * Returns a list with all groups
219
+     */
220
+    public function getGroups($search = '', $limit = -1, $offset = 0) {
221
+        $groups = array();
222 222
 
223
-		foreach($this->backends as $backend) {
224
-			$backendGroups = $backend->getGroups($search, $limit, $offset);
225
-			if (is_array($backendGroups)) {
226
-				$groups = array_merge($groups, $backendGroups);
227
-			}
228
-		}
223
+        foreach($this->backends as $backend) {
224
+            $backendGroups = $backend->getGroups($search, $limit, $offset);
225
+            if (is_array($backendGroups)) {
226
+                $groups = array_merge($groups, $backendGroups);
227
+            }
228
+        }
229 229
 
230
-		return $groups;
231
-	}
230
+        return $groups;
231
+    }
232 232
 
233
-	/**
234
-	 * check if a group exists
235
-	 * @param string $gid
236
-	 * @return bool
237
-	 */
238
-	public function groupExists($gid) {
239
-		return $this->handleRequest($gid, 'groupExists', array($gid));
240
-	}
233
+    /**
234
+     * check if a group exists
235
+     * @param string $gid
236
+     * @return bool
237
+     */
238
+    public function groupExists($gid) {
239
+        return $this->handleRequest($gid, 'groupExists', array($gid));
240
+    }
241 241
 
242
-	/**
243
-	 * Check if backend implements actions
244
-	 * @param int $actions bitwise-or'ed actions
245
-	 * @return boolean
246
-	 *
247
-	 * Returns the supported actions as int to be
248
-	 * compared with \OCP\GroupInterface::CREATE_GROUP etc.
249
-	 */
250
-	public function implementsActions($actions) {
251
-		//it's the same across all our user backends obviously
252
-		return $this->refBackend->implementsActions($actions);
253
-	}
242
+    /**
243
+     * Check if backend implements actions
244
+     * @param int $actions bitwise-or'ed actions
245
+     * @return boolean
246
+     *
247
+     * Returns the supported actions as int to be
248
+     * compared with \OCP\GroupInterface::CREATE_GROUP etc.
249
+     */
250
+    public function implementsActions($actions) {
251
+        //it's the same across all our user backends obviously
252
+        return $this->refBackend->implementsActions($actions);
253
+    }
254 254
 
255
-	/**
256
-	 * Return access for LDAP interaction.
257
-	 * @param string $gid
258
-	 * @return Access instance of Access for LDAP interaction
259
-	 */
260
-	public function getLDAPAccess($gid) {
261
-		return $this->handleRequest($gid, 'getLDAPAccess', [$gid]);
262
-	}
255
+    /**
256
+     * Return access for LDAP interaction.
257
+     * @param string $gid
258
+     * @return Access instance of Access for LDAP interaction
259
+     */
260
+    public function getLDAPAccess($gid) {
261
+        return $this->handleRequest($gid, 'getLDAPAccess', [$gid]);
262
+    }
263 263
 
264
-	/**
265
-	 * Return a new LDAP connection for the specified group.
266
-	 * The connection needs to be closed manually.
267
-	 * @param string $gid
268
-	 * @return resource of the LDAP connection
269
-	 */
270
-	public function getNewLDAPConnection($gid) {
271
-		return $this->handleRequest($gid, 'getNewLDAPConnection', array($gid));
272
-	}
264
+    /**
265
+     * Return a new LDAP connection for the specified group.
266
+     * The connection needs to be closed manually.
267
+     * @param string $gid
268
+     * @return resource of the LDAP connection
269
+     */
270
+    public function getNewLDAPConnection($gid) {
271
+        return $this->handleRequest($gid, 'getNewLDAPConnection', array($gid));
272
+    }
273 273
 
274 274
 }
Please login to merge, or discard this patch.
lib/public/IGroupManager.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -45,103 +45,103 @@
 block discarded – undo
45 45
  * @since 8.0.0
46 46
  */
47 47
 interface IGroupManager {
48
-	/**
49
-	 * Checks whether a given backend is used
50
-	 *
51
-	 * @param string $backendClass Full classname including complete namespace
52
-	 * @return bool
53
-	 * @since 8.1.0
54
-	 */
55
-	public function isBackendUsed($backendClass);
48
+    /**
49
+     * Checks whether a given backend is used
50
+     *
51
+     * @param string $backendClass Full classname including complete namespace
52
+     * @return bool
53
+     * @since 8.1.0
54
+     */
55
+    public function isBackendUsed($backendClass);
56 56
 
57
-	/**
58
-	 * @param \OCP\GroupInterface $backend
59
-	 * @since 8.0.0
60
-	 */
61
-	public function addBackend($backend);
57
+    /**
58
+     * @param \OCP\GroupInterface $backend
59
+     * @since 8.0.0
60
+     */
61
+    public function addBackend($backend);
62 62
 
63
-	/**
64
-	 * @since 8.0.0
65
-	 */
66
-	public function clearBackends();
63
+    /**
64
+     * @since 8.0.0
65
+     */
66
+    public function clearBackends();
67 67
 
68
-	/**
69
-	 * Get the active backends
70
-	 * @return \OCP\GroupInterface[]
71
-	 * @since 13.0.0
72
-	 */
73
-	public function getBackends();
68
+    /**
69
+     * Get the active backends
70
+     * @return \OCP\GroupInterface[]
71
+     * @since 13.0.0
72
+     */
73
+    public function getBackends();
74 74
 
75
-	/**
76
-	 * @param string $gid
77
-	 * @return \OCP\IGroup
78
-	 * @since 8.0.0
79
-	 */
80
-	public function get($gid);
75
+    /**
76
+     * @param string $gid
77
+     * @return \OCP\IGroup
78
+     * @since 8.0.0
79
+     */
80
+    public function get($gid);
81 81
 
82
-	/**
83
-	 * @param string $gid
84
-	 * @return bool
85
-	 * @since 8.0.0
86
-	 */
87
-	public function groupExists($gid);
82
+    /**
83
+     * @param string $gid
84
+     * @return bool
85
+     * @since 8.0.0
86
+     */
87
+    public function groupExists($gid);
88 88
 
89
-	/**
90
-	 * @param string $gid
91
-	 * @return \OCP\IGroup
92
-	 * @since 8.0.0
93
-	 */
94
-	public function createGroup($gid);
89
+    /**
90
+     * @param string $gid
91
+     * @return \OCP\IGroup
92
+     * @since 8.0.0
93
+     */
94
+    public function createGroup($gid);
95 95
 
96
-	/**
97
-	 * @param string $search
98
-	 * @param int $limit
99
-	 * @param int $offset
100
-	 * @return \OCP\IGroup[]
101
-	 * @since 8.0.0
102
-	 */
103
-	public function search($search, $limit = null, $offset = null);
96
+    /**
97
+     * @param string $search
98
+     * @param int $limit
99
+     * @param int $offset
100
+     * @return \OCP\IGroup[]
101
+     * @since 8.0.0
102
+     */
103
+    public function search($search, $limit = null, $offset = null);
104 104
 
105
-	/**
106
-	 * @param \OCP\IUser|null $user
107
-	 * @return \OCP\IGroup[]
108
-	 * @since 8.0.0
109
-	 */
110
-	public function getUserGroups(IUser $user = null);
105
+    /**
106
+     * @param \OCP\IUser|null $user
107
+     * @return \OCP\IGroup[]
108
+     * @since 8.0.0
109
+     */
110
+    public function getUserGroups(IUser $user = null);
111 111
 
112
-	/**
113
-	 * @param \OCP\IUser $user
114
-	 * @return array with group names
115
-	 * @since 8.0.0
116
-	 */
117
-	public function getUserGroupIds(IUser $user);
112
+    /**
113
+     * @param \OCP\IUser $user
114
+     * @return array with group names
115
+     * @since 8.0.0
116
+     */
117
+    public function getUserGroupIds(IUser $user);
118 118
 
119
-	/**
120
-	 * get a list of all display names in a group
121
-	 *
122
-	 * @param string $gid
123
-	 * @param string $search
124
-	 * @param int $limit
125
-	 * @param int $offset
126
-	 * @return array an array of display names (value) and user ids (key)
127
-	 * @since 8.0.0
128
-	 */
129
-	public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0);
119
+    /**
120
+     * get a list of all display names in a group
121
+     *
122
+     * @param string $gid
123
+     * @param string $search
124
+     * @param int $limit
125
+     * @param int $offset
126
+     * @return array an array of display names (value) and user ids (key)
127
+     * @since 8.0.0
128
+     */
129
+    public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0);
130 130
 
131
-	/**
132
-	 * Checks if a userId is in the admin group
133
-	 * @param string $userId
134
-	 * @return bool if admin
135
-	 * @since 8.0.0
136
-	 */
137
-	public function isAdmin($userId);
131
+    /**
132
+     * Checks if a userId is in the admin group
133
+     * @param string $userId
134
+     * @return bool if admin
135
+     * @since 8.0.0
136
+     */
137
+    public function isAdmin($userId);
138 138
 
139
-	/**
140
-	 * Checks if a userId is in a group
141
-	 * @param string $userId
142
-	 * @param string $group
143
-	 * @return bool if in group
144
-	 * @since 8.0.0
145
-	 */
146
-	public function isInGroup($userId, $group);
139
+    /**
140
+     * Checks if a userId is in a group
141
+     * @param string $userId
142
+     * @param string $group
143
+     * @return bool if in group
144
+     * @since 8.0.0
145
+     */
146
+    public function isInGroup($userId, $group);
147 147
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/UUIDFixUser.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@
 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
-		$groupPluginManager = \OC::$server->query('LDAPGroupPluginManager');
36
-		$this->proxy = new Group_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $groupPluginManager);
37
-	}
33
+    public function __construct(UserMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
34
+        $this->mapper = $mapper;
35
+        $groupPluginManager = \OC::$server->query('LDAPGroupPluginManager');
36
+        $this->proxy = new Group_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $groupPluginManager);
37
+    }
38 38
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/ILDAPWrapper.php 1 patch
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -29,192 +29,192 @@
 block discarded – undo
29 29
 
30 30
 interface ILDAPWrapper {
31 31
 
32
-	//LDAP functions in use
33
-
34
-	/**
35
-	 * Bind to LDAP directory
36
-	 * @param resource $link LDAP link resource
37
-	 * @param string $dn an RDN to log in with
38
-	 * @param string $password the password
39
-	 * @return bool true on success, false otherwise
40
-	 *
41
-	 * with $dn and $password as null a anonymous bind is attempted.
42
-	 */
43
-	public function bind($link, $dn, $password);
44
-
45
-	/**
46
-	 * connect to an LDAP server
47
-	 * @param string $host The host to connect to
48
-	 * @param string $port The port to connect to
49
-	 * @return mixed a link resource on success, otherwise false
50
-	 */
51
-	public function connect($host, $port);
52
-
53
-	/**
54
-	 * Send LDAP pagination control
55
-	 * @param resource $link LDAP link resource
56
-	 * @param int $pageSize number of results per page
57
-	 * @param bool $isCritical Indicates whether the pagination is critical of not.
58
-	 * @param string $cookie structure sent by LDAP server
59
-	 * @return bool true on success, false otherwise
60
-	 */
61
-	public function controlPagedResult($link, $pageSize, $isCritical, $cookie);
62
-
63
-	/**
64
-	 * Retrieve the LDAP pagination cookie
65
-	 * @param resource $link LDAP link resource
66
-	 * @param resource $result LDAP result resource
67
-	 * @param string $cookie structure sent by LDAP server
68
-	 * @return bool true on success, false otherwise
69
-	 *
70
-	 * Corresponds to ldap_control_paged_result_response
71
-	 */
72
-	public function controlPagedResultResponse($link, $result, &$cookie);
73
-
74
-	/**
75
-	 * Count the number of entries in a search
76
-	 * @param resource $link LDAP link resource
77
-	 * @param resource $result LDAP result resource
78
-	 * @return int|false number of results on success, false otherwise
79
-	 */
80
-	public function countEntries($link, $result);
81
-
82
-	/**
83
-	 * Return the LDAP error number of the last LDAP command
84
-	 * @param resource $link LDAP link resource
85
-	 * @return int error code
86
-	 */
87
-	public function errno($link);
88
-
89
-	/**
90
-	 * Return the LDAP error message of the last LDAP command
91
-	 * @param resource $link LDAP link resource
92
-	 * @return string error message
93
-	 */
94
-	public function error($link);
95
-
96
-	/**
97
-	 * Splits DN into its component parts
98
-	 * @param string $dn
99
-	 * @param int @withAttrib
100
-	 * @return array|false
101
-	 * @link http://www.php.net/manual/en/function.ldap-explode-dn.php
102
-	 */
103
-	public function explodeDN($dn, $withAttrib);
104
-
105
-	/**
106
-	 * Return first result id
107
-	 * @param resource $link LDAP link resource
108
-	 * @param resource $result LDAP result resource
109
-	 * @return Resource an LDAP search result resource
110
-	 * */
111
-	public function firstEntry($link, $result);
112
-
113
-	/**
114
-	 * Get attributes from a search result entry
115
-	 * @param resource $link LDAP link resource
116
-	 * @param resource $result LDAP result resource
117
-	 * @return array containing the results, false on error
118
-	 * */
119
-	public function getAttributes($link, $result);
120
-
121
-	/**
122
-	 * Get the DN of a result entry
123
-	 * @param resource $link LDAP link resource
124
-	 * @param resource $result LDAP result resource
125
-	 * @return string containing the DN, false on error
126
-	 */
127
-	public function getDN($link, $result);
128
-
129
-	/**
130
-	 * Get all result entries
131
-	 * @param resource $link LDAP link resource
132
-	 * @param resource $result LDAP result resource
133
-	 * @return array containing the results, false on error
134
-	 */
135
-	public function getEntries($link, $result);
136
-
137
-	/**
138
-	 * Return next result id
139
-	 * @param resource $link LDAP link resource
140
-	 * @param resource $result LDAP entry result resource
141
-	 * @return resource an LDAP search result resource
142
-	 * */
143
-	public function nextEntry($link, $result);
144
-
145
-	/**
146
-	 * Read an entry
147
-	 * @param resource $link LDAP link resource
148
-	 * @param array $baseDN The DN of the entry to read from
149
-	 * @param string $filter An LDAP filter
150
-	 * @param array $attr array of the attributes to read
151
-	 * @return resource an LDAP search result resource
152
-	 */
153
-	public function read($link, $baseDN, $filter, $attr);
154
-
155
-	/**
156
-	 * Search LDAP tree
157
-	 * @param resource $link LDAP link resource
158
-	 * @param string $baseDN The DN of the entry to read from
159
-	 * @param string $filter An LDAP filter
160
-	 * @param array $attr array of the attributes to read
161
-	 * @param int $attrsOnly optional, 1 if only attribute types shall be returned
162
-	 * @param int $limit optional, limits the result entries
163
-	 * @return resource|false an LDAP search result resource, false on error
164
-	 */
165
-	public function search($link, $baseDN, $filter, $attr, $attrsOnly = 0, $limit = 0);
166
-
167
-	/**
168
-	 * Replace the value of a userPassword by $password
169
-	 * @param resource $link LDAP link resource
170
-	 * @param string $userDN the DN of the user whose password is to be replaced
171
-	 * @param string $password the new value for the userPassword
172
-	 * @return bool true on success, false otherwise
173
-	 */
174
-	public function modReplace($link, $userDN, $password);
175
-
176
-	/**
177
-	 * Sets the value of the specified option to be $value
178
-	 * @param resource $link LDAP link resource
179
-	 * @param string $option a defined LDAP Server option
180
-	 * @param int $value the new value for the option
181
-	 * @return bool true on success, false otherwise
182
-	 */
183
-	public function setOption($link, $option, $value);
184
-
185
-	/**
186
-	 * establish Start TLS
187
-	 * @param resource $link LDAP link resource
188
-	 * @return bool true on success, false otherwise
189
-	 */
190
-	public function startTls($link);
191
-
192
-	/**
193
-	 * Unbind from LDAP directory
194
-	 * @param resource $link LDAP link resource
195
-	 * @return bool true on success, false otherwise
196
-	 */
197
-	public function unbind($link);
198
-
199
-	//additional required methods in Nextcloud
200
-
201
-	/**
202
-	 * Checks whether the server supports LDAP
203
-	 * @return bool true if it the case, false otherwise
204
-	 * */
205
-	public function areLDAPFunctionsAvailable();
206
-
207
-	/**
208
-	 * Checks whether PHP supports LDAP Paged Results
209
-	 * @return bool true if it the case, false otherwise
210
-	 * */
211
-	public function hasPagedResultSupport();
212
-
213
-	/**
214
-	 * Checks whether the submitted parameter is a resource
215
-	 * @param resource $resource the resource variable to check
216
-	 * @return bool true if it is a resource, false otherwise
217
-	 */
218
-	public function isResource($resource);
32
+    //LDAP functions in use
33
+
34
+    /**
35
+     * Bind to LDAP directory
36
+     * @param resource $link LDAP link resource
37
+     * @param string $dn an RDN to log in with
38
+     * @param string $password the password
39
+     * @return bool true on success, false otherwise
40
+     *
41
+     * with $dn and $password as null a anonymous bind is attempted.
42
+     */
43
+    public function bind($link, $dn, $password);
44
+
45
+    /**
46
+     * connect to an LDAP server
47
+     * @param string $host The host to connect to
48
+     * @param string $port The port to connect to
49
+     * @return mixed a link resource on success, otherwise false
50
+     */
51
+    public function connect($host, $port);
52
+
53
+    /**
54
+     * Send LDAP pagination control
55
+     * @param resource $link LDAP link resource
56
+     * @param int $pageSize number of results per page
57
+     * @param bool $isCritical Indicates whether the pagination is critical of not.
58
+     * @param string $cookie structure sent by LDAP server
59
+     * @return bool true on success, false otherwise
60
+     */
61
+    public function controlPagedResult($link, $pageSize, $isCritical, $cookie);
62
+
63
+    /**
64
+     * Retrieve the LDAP pagination cookie
65
+     * @param resource $link LDAP link resource
66
+     * @param resource $result LDAP result resource
67
+     * @param string $cookie structure sent by LDAP server
68
+     * @return bool true on success, false otherwise
69
+     *
70
+     * Corresponds to ldap_control_paged_result_response
71
+     */
72
+    public function controlPagedResultResponse($link, $result, &$cookie);
73
+
74
+    /**
75
+     * Count the number of entries in a search
76
+     * @param resource $link LDAP link resource
77
+     * @param resource $result LDAP result resource
78
+     * @return int|false number of results on success, false otherwise
79
+     */
80
+    public function countEntries($link, $result);
81
+
82
+    /**
83
+     * Return the LDAP error number of the last LDAP command
84
+     * @param resource $link LDAP link resource
85
+     * @return int error code
86
+     */
87
+    public function errno($link);
88
+
89
+    /**
90
+     * Return the LDAP error message of the last LDAP command
91
+     * @param resource $link LDAP link resource
92
+     * @return string error message
93
+     */
94
+    public function error($link);
95
+
96
+    /**
97
+     * Splits DN into its component parts
98
+     * @param string $dn
99
+     * @param int @withAttrib
100
+     * @return array|false
101
+     * @link http://www.php.net/manual/en/function.ldap-explode-dn.php
102
+     */
103
+    public function explodeDN($dn, $withAttrib);
104
+
105
+    /**
106
+     * Return first result id
107
+     * @param resource $link LDAP link resource
108
+     * @param resource $result LDAP result resource
109
+     * @return Resource an LDAP search result resource
110
+     * */
111
+    public function firstEntry($link, $result);
112
+
113
+    /**
114
+     * Get attributes from a search result entry
115
+     * @param resource $link LDAP link resource
116
+     * @param resource $result LDAP result resource
117
+     * @return array containing the results, false on error
118
+     * */
119
+    public function getAttributes($link, $result);
120
+
121
+    /**
122
+     * Get the DN of a result entry
123
+     * @param resource $link LDAP link resource
124
+     * @param resource $result LDAP result resource
125
+     * @return string containing the DN, false on error
126
+     */
127
+    public function getDN($link, $result);
128
+
129
+    /**
130
+     * Get all result entries
131
+     * @param resource $link LDAP link resource
132
+     * @param resource $result LDAP result resource
133
+     * @return array containing the results, false on error
134
+     */
135
+    public function getEntries($link, $result);
136
+
137
+    /**
138
+     * Return next result id
139
+     * @param resource $link LDAP link resource
140
+     * @param resource $result LDAP entry result resource
141
+     * @return resource an LDAP search result resource
142
+     * */
143
+    public function nextEntry($link, $result);
144
+
145
+    /**
146
+     * Read an entry
147
+     * @param resource $link LDAP link resource
148
+     * @param array $baseDN The DN of the entry to read from
149
+     * @param string $filter An LDAP filter
150
+     * @param array $attr array of the attributes to read
151
+     * @return resource an LDAP search result resource
152
+     */
153
+    public function read($link, $baseDN, $filter, $attr);
154
+
155
+    /**
156
+     * Search LDAP tree
157
+     * @param resource $link LDAP link resource
158
+     * @param string $baseDN The DN of the entry to read from
159
+     * @param string $filter An LDAP filter
160
+     * @param array $attr array of the attributes to read
161
+     * @param int $attrsOnly optional, 1 if only attribute types shall be returned
162
+     * @param int $limit optional, limits the result entries
163
+     * @return resource|false an LDAP search result resource, false on error
164
+     */
165
+    public function search($link, $baseDN, $filter, $attr, $attrsOnly = 0, $limit = 0);
166
+
167
+    /**
168
+     * Replace the value of a userPassword by $password
169
+     * @param resource $link LDAP link resource
170
+     * @param string $userDN the DN of the user whose password is to be replaced
171
+     * @param string $password the new value for the userPassword
172
+     * @return bool true on success, false otherwise
173
+     */
174
+    public function modReplace($link, $userDN, $password);
175
+
176
+    /**
177
+     * Sets the value of the specified option to be $value
178
+     * @param resource $link LDAP link resource
179
+     * @param string $option a defined LDAP Server option
180
+     * @param int $value the new value for the option
181
+     * @return bool true on success, false otherwise
182
+     */
183
+    public function setOption($link, $option, $value);
184
+
185
+    /**
186
+     * establish Start TLS
187
+     * @param resource $link LDAP link resource
188
+     * @return bool true on success, false otherwise
189
+     */
190
+    public function startTls($link);
191
+
192
+    /**
193
+     * Unbind from LDAP directory
194
+     * @param resource $link LDAP link resource
195
+     * @return bool true on success, false otherwise
196
+     */
197
+    public function unbind($link);
198
+
199
+    //additional required methods in Nextcloud
200
+
201
+    /**
202
+     * Checks whether the server supports LDAP
203
+     * @return bool true if it the case, false otherwise
204
+     * */
205
+    public function areLDAPFunctionsAvailable();
206
+
207
+    /**
208
+     * Checks whether PHP supports LDAP Paged Results
209
+     * @return bool true if it the case, false otherwise
210
+     * */
211
+    public function hasPagedResultSupport();
212
+
213
+    /**
214
+     * Checks whether the submitted parameter is a resource
215
+     * @param resource $resource the resource variable to check
216
+     * @return bool true if it is a resource, false otherwise
217
+     */
218
+    public function isResource($resource);
219 219
 
220 220
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/IGroupLDAP.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,20 +26,20 @@
 block discarded – undo
26 26
 
27 27
 interface IGroupLDAP {
28 28
 
29
-	//Used by LDAPProvider
29
+    //Used by LDAPProvider
30 30
 
31
-	/**
32
-	 * Return access for LDAP interaction.
33
-	 * @param string $gid
34
-	 * @return Access instance of Access for LDAP interaction
35
-	 */
36
-	public function getLDAPAccess($gid);
31
+    /**
32
+     * Return access for LDAP interaction.
33
+     * @param string $gid
34
+     * @return Access instance of Access for LDAP interaction
35
+     */
36
+    public function getLDAPAccess($gid);
37 37
 
38
-	/**
39
-	 * Return a new LDAP connection for the specified group.
40
-	 * @param string $gid
41
-	 * @return resource of the LDAP connection
42
-	 */
43
-	public function getNewLDAPConnection($gid);
38
+    /**
39
+     * Return a new LDAP connection for the specified group.
40
+     * @param string $gid
41
+     * @return resource of the LDAP connection
42
+     */
43
+    public function getNewLDAPConnection($gid);
44 44
 
45 45
 }
Please login to merge, or discard this patch.
apps/user_ldap/appinfo/register_command.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,15 +34,15 @@  discard block
 block discarded – undo
34 34
 $helper = new Helper(\OC::$server->getConfig());
35 35
 $ocConfig = \OC::$server->getConfig();
36 36
 $uBackend = new User_Proxy(
37
-	$helper->getServerConfigurationPrefixes(true),
38
-	new LDAP(),
39
-	$ocConfig,
40
-	\OC::$server->getNotificationManager(),
41
-	\OC::$server->getUserSession(),
42
-	\OC::$server->query('LDAPUserPluginManager')
37
+    $helper->getServerConfigurationPrefixes(true),
38
+    new LDAP(),
39
+    $ocConfig,
40
+    \OC::$server->getNotificationManager(),
41
+    \OC::$server->getUserSession(),
42
+    \OC::$server->query('LDAPUserPluginManager')
43 43
 );
44 44
 $deletedUsersIndex = new DeletedUsersIndex(
45
-	$ocConfig, $dbConnection, $userMapping
45
+    $ocConfig, $dbConnection, $userMapping
46 46
 );
47 47
 
48 48
 $application->add(new OCA\User_LDAP\Command\ShowConfig($helper));
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 $application->add(new OCA\User_LDAP\Command\DeleteConfig($helper));
53 53
 $application->add(new OCA\User_LDAP\Command\Search($ocConfig));
54 54
 $application->add(new OCA\User_LDAP\Command\ShowRemnants(
55
-	$deletedUsersIndex, \OC::$server->getDateTimeFormatter())
55
+    $deletedUsersIndex, \OC::$server->getDateTimeFormatter())
56 56
 );
57 57
 $application->add(new OCA\User_LDAP\Command\CheckUser(
58
-	$uBackend, $helper, $deletedUsersIndex, $userMapping)
58
+    $uBackend, $helper, $deletedUsersIndex, $userMapping)
59 59
 );
Please login to merge, or discard this patch.
apps/user_ldap/appinfo/app.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -30,50 +30,50 @@
 block discarded – undo
30 30
  */
31 31
 
32 32
 \OC::$server->registerService('LDAPUserPluginManager', function() {
33
-	return new OCA\User_LDAP\UserPluginManager();
33
+    return new OCA\User_LDAP\UserPluginManager();
34 34
 });
35 35
 \OC::$server->registerService('LDAPGroupPluginManager', function() {
36
-	return new OCA\User_LDAP\GroupPluginManager();
36
+    return new OCA\User_LDAP\GroupPluginManager();
37 37
 });
38 38
 
39 39
 $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
40 40
 $configPrefixes = $helper->getServerConfigurationPrefixes(true);
41 41
 if(count($configPrefixes) > 0) {
42
-	$ldapWrapper = new OCA\User_LDAP\LDAP();
43
-	$ocConfig = \OC::$server->getConfig();
44
-	$notificationManager = \OC::$server->getNotificationManager();
45
-	$notificationManager->registerNotifier(function() {
46
-		return new \OCA\User_LDAP\Notification\Notifier(
47
-			\OC::$server->getL10NFactory()
48
-		);
49
-	}, function() {
50
-		$l = \OC::$server->getL10N('user_ldap');
51
-		return [
52
-			'id' => 'user_ldap',
53
-			'name' => $l->t('LDAP user and group backend'),
54
-		];
55
-	});
56
-	$userSession = \OC::$server->getUserSession();
42
+    $ldapWrapper = new OCA\User_LDAP\LDAP();
43
+    $ocConfig = \OC::$server->getConfig();
44
+    $notificationManager = \OC::$server->getNotificationManager();
45
+    $notificationManager->registerNotifier(function() {
46
+        return new \OCA\User_LDAP\Notification\Notifier(
47
+            \OC::$server->getL10NFactory()
48
+        );
49
+    }, function() {
50
+        $l = \OC::$server->getL10N('user_ldap');
51
+        return [
52
+            'id' => 'user_ldap',
53
+            'name' => $l->t('LDAP user and group backend'),
54
+        ];
55
+    });
56
+    $userSession = \OC::$server->getUserSession();
57 57
 
58
-	$userPluginManager = \OC::$server->query('LDAPUserPluginManager');
59
-	$groupPluginManager = \OC::$server->query('LDAPGroupPluginManager');
58
+    $userPluginManager = \OC::$server->query('LDAPUserPluginManager');
59
+    $groupPluginManager = \OC::$server->query('LDAPGroupPluginManager');
60 60
 
61
-	$userBackend  = new OCA\User_LDAP\User_Proxy(
62
-		$configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession, $userPluginManager
63
-	);
64
-	$groupBackend  = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper, $groupPluginManager);
65
-	// register user backend
66
-	OC_User::useBackend($userBackend);
61
+    $userBackend  = new OCA\User_LDAP\User_Proxy(
62
+        $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession, $userPluginManager
63
+    );
64
+    $groupBackend  = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper, $groupPluginManager);
65
+    // register user backend
66
+    OC_User::useBackend($userBackend);
67 67
 
68
-	// Hook to allow plugins to work on registered backends
69
-	OC::$server->getEventDispatcher()->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded');
68
+    // Hook to allow plugins to work on registered backends
69
+    OC::$server->getEventDispatcher()->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded');
70 70
 
71
-	\OC::$server->getGroupManager()->addBackend($groupBackend);
71
+    \OC::$server->getGroupManager()->addBackend($groupBackend);
72 72
 }
73 73
 
74 74
 \OCP\Util::connectHook(
75
-	'\OCA\Files_Sharing\API\Server2Server',
76
-	'preLoginNameUsedAsUserName',
77
-	'\OCA\User_LDAP\Helper',
78
-	'loginName2UserName'
75
+    '\OCA\Files_Sharing\API\Server2Server',
76
+    'preLoginNameUsedAsUserName',
77
+    '\OCA\User_LDAP\Helper',
78
+    'loginName2UserName'
79 79
 );
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
 $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
40 40
 $configPrefixes = $helper->getServerConfigurationPrefixes(true);
41
-if(count($configPrefixes) > 0) {
41
+if (count($configPrefixes) > 0) {
42 42
 	$ldapWrapper = new OCA\User_LDAP\LDAP();
43 43
 	$ocConfig = \OC::$server->getConfig();
44 44
 	$notificationManager = \OC::$server->getNotificationManager();
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	$userPluginManager = \OC::$server->query('LDAPUserPluginManager');
59 59
 	$groupPluginManager = \OC::$server->query('LDAPGroupPluginManager');
60 60
 
61
-	$userBackend  = new OCA\User_LDAP\User_Proxy(
61
+	$userBackend = new OCA\User_LDAP\User_Proxy(
62 62
 		$configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession, $userPluginManager
63 63
 	);
64
-	$groupBackend  = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper, $groupPluginManager);
64
+	$groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper, $groupPluginManager);
65 65
 	// register user backend
66 66
 	OC_User::useBackend($userBackend);
67 67
 
Please login to merge, or discard this patch.
apps/user_ldap/lib/User_Proxy.php 2 patches
Indentation   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -37,314 +37,314 @@
 block discarded – undo
37 37
 use OCP\Notification\IManager as INotificationManager;
38 38
 
39 39
 class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, IUserLDAP {
40
-	private $backends = array();
41
-	private $refBackend = null;
40
+    private $backends = array();
41
+    private $refBackend = null;
42 42
 
43
-	/**
44
-	 * Constructor
45
-	 *
46
-	 * @param array $serverConfigPrefixes array containing the config Prefixes
47
-	 * @param ILDAPWrapper $ldap
48
-	 * @param IConfig $ocConfig
49
-	 * @param INotificationManager $notificationManager
50
-	 * @param IUserSession $userSession
51
-	 */
52
-	public function __construct(array $serverConfigPrefixes, ILDAPWrapper $ldap, IConfig $ocConfig,
53
-		INotificationManager $notificationManager, IUserSession $userSession,
54
-								UserPluginManager $userPluginManager) {
55
-		parent::__construct($ldap);
56
-		foreach($serverConfigPrefixes as $configPrefix) {
57
-			$this->backends[$configPrefix] =
58
-				new User_LDAP($this->getAccess($configPrefix), $ocConfig, $notificationManager, $userSession, $userPluginManager);
43
+    /**
44
+     * Constructor
45
+     *
46
+     * @param array $serverConfigPrefixes array containing the config Prefixes
47
+     * @param ILDAPWrapper $ldap
48
+     * @param IConfig $ocConfig
49
+     * @param INotificationManager $notificationManager
50
+     * @param IUserSession $userSession
51
+     */
52
+    public function __construct(array $serverConfigPrefixes, ILDAPWrapper $ldap, IConfig $ocConfig,
53
+        INotificationManager $notificationManager, IUserSession $userSession,
54
+                                UserPluginManager $userPluginManager) {
55
+        parent::__construct($ldap);
56
+        foreach($serverConfigPrefixes as $configPrefix) {
57
+            $this->backends[$configPrefix] =
58
+                new User_LDAP($this->getAccess($configPrefix), $ocConfig, $notificationManager, $userSession, $userPluginManager);
59 59
 
60
-			if(is_null($this->refBackend)) {
61
-				$this->refBackend = &$this->backends[$configPrefix];
62
-			}
63
-		}
64
-	}
60
+            if(is_null($this->refBackend)) {
61
+                $this->refBackend = &$this->backends[$configPrefix];
62
+            }
63
+        }
64
+    }
65 65
 
66
-	/**
67
-	 * Tries the backends one after the other until a positive result is returned from the specified method
68
-	 * @param string $uid the uid connected to the request
69
-	 * @param string $method the method of the user backend that shall be called
70
-	 * @param array $parameters an array of parameters to be passed
71
-	 * @return mixed the result of the method or false
72
-	 */
73
-	protected function walkBackends($uid, $method, $parameters) {
74
-		$cacheKey = $this->getUserCacheKey($uid);
75
-		foreach($this->backends as $configPrefix => $backend) {
76
-			$instance = $backend;
77
-			if(!method_exists($instance, $method)
78
-				&& method_exists($this->getAccess($configPrefix), $method)) {
79
-				$instance = $this->getAccess($configPrefix);
80
-			}
81
-			if($result = call_user_func_array(array($instance, $method), $parameters)) {
82
-				$this->writeToCache($cacheKey, $configPrefix);
83
-				return $result;
84
-			}
85
-		}
86
-		return false;
87
-	}
66
+    /**
67
+     * Tries the backends one after the other until a positive result is returned from the specified method
68
+     * @param string $uid the uid connected to the request
69
+     * @param string $method the method of the user backend that shall be called
70
+     * @param array $parameters an array of parameters to be passed
71
+     * @return mixed the result of the method or false
72
+     */
73
+    protected function walkBackends($uid, $method, $parameters) {
74
+        $cacheKey = $this->getUserCacheKey($uid);
75
+        foreach($this->backends as $configPrefix => $backend) {
76
+            $instance = $backend;
77
+            if(!method_exists($instance, $method)
78
+                && method_exists($this->getAccess($configPrefix), $method)) {
79
+                $instance = $this->getAccess($configPrefix);
80
+            }
81
+            if($result = call_user_func_array(array($instance, $method), $parameters)) {
82
+                $this->writeToCache($cacheKey, $configPrefix);
83
+                return $result;
84
+            }
85
+        }
86
+        return false;
87
+    }
88 88
 
89
-	/**
90
-	 * Asks the backend connected to the server that supposely takes care of the uid from the request.
91
-	 * @param string $uid the uid connected to the request
92
-	 * @param string $method the method of the user backend that shall be called
93
-	 * @param array $parameters an array of parameters to be passed
94
-	 * @param mixed $passOnWhen the result matches this variable
95
-	 * @return mixed the result of the method or false
96
-	 */
97
-	protected function callOnLastSeenOn($uid, $method, $parameters, $passOnWhen) {
98
-		$cacheKey = $this->getUserCacheKey($uid);
99
-		$prefix = $this->getFromCache($cacheKey);
100
-		//in case the uid has been found in the past, try this stored connection first
101
-		if(!is_null($prefix)) {
102
-			if(isset($this->backends[$prefix])) {
103
-				$instance = $this->backends[$prefix];
104
-				if(!method_exists($instance, $method)
105
-					&& method_exists($this->getAccess($prefix), $method)) {
106
-					$instance = $this->getAccess($prefix);
107
-				}
108
-				$result = call_user_func_array(array($instance, $method), $parameters);
109
-				if($result === $passOnWhen) {
110
-					//not found here, reset cache to null if user vanished
111
-					//because sometimes methods return false with a reason
112
-					$userExists = call_user_func_array(
113
-						array($this->backends[$prefix], 'userExists'),
114
-						array($uid)
115
-					);
116
-					if(!$userExists) {
117
-						$this->writeToCache($cacheKey, null);
118
-					}
119
-				}
120
-				return $result;
121
-			}
122
-		}
123
-		return false;
124
-	}
89
+    /**
90
+     * Asks the backend connected to the server that supposely takes care of the uid from the request.
91
+     * @param string $uid the uid connected to the request
92
+     * @param string $method the method of the user backend that shall be called
93
+     * @param array $parameters an array of parameters to be passed
94
+     * @param mixed $passOnWhen the result matches this variable
95
+     * @return mixed the result of the method or false
96
+     */
97
+    protected function callOnLastSeenOn($uid, $method, $parameters, $passOnWhen) {
98
+        $cacheKey = $this->getUserCacheKey($uid);
99
+        $prefix = $this->getFromCache($cacheKey);
100
+        //in case the uid has been found in the past, try this stored connection first
101
+        if(!is_null($prefix)) {
102
+            if(isset($this->backends[$prefix])) {
103
+                $instance = $this->backends[$prefix];
104
+                if(!method_exists($instance, $method)
105
+                    && method_exists($this->getAccess($prefix), $method)) {
106
+                    $instance = $this->getAccess($prefix);
107
+                }
108
+                $result = call_user_func_array(array($instance, $method), $parameters);
109
+                if($result === $passOnWhen) {
110
+                    //not found here, reset cache to null if user vanished
111
+                    //because sometimes methods return false with a reason
112
+                    $userExists = call_user_func_array(
113
+                        array($this->backends[$prefix], 'userExists'),
114
+                        array($uid)
115
+                    );
116
+                    if(!$userExists) {
117
+                        $this->writeToCache($cacheKey, null);
118
+                    }
119
+                }
120
+                return $result;
121
+            }
122
+        }
123
+        return false;
124
+    }
125 125
 
126
-	/**
127
-	 * Check if backend implements actions
128
-	 * @param int $actions bitwise-or'ed actions
129
-	 * @return boolean
130
-	 *
131
-	 * Returns the supported actions as int to be
132
-	 * compared with \OC\User\Backend::CREATE_USER etc.
133
-	 */
134
-	public function implementsActions($actions) {
135
-		//it's the same across all our user backends obviously
136
-		return $this->refBackend->implementsActions($actions);
137
-	}
126
+    /**
127
+     * Check if backend implements actions
128
+     * @param int $actions bitwise-or'ed actions
129
+     * @return boolean
130
+     *
131
+     * Returns the supported actions as int to be
132
+     * compared with \OC\User\Backend::CREATE_USER etc.
133
+     */
134
+    public function implementsActions($actions) {
135
+        //it's the same across all our user backends obviously
136
+        return $this->refBackend->implementsActions($actions);
137
+    }
138 138
 
139
-	/**
140
-	 * Backend name to be shown in user management
141
-	 * @return string the name of the backend to be shown
142
-	 */
143
-	public function getBackendName() {
144
-		return $this->refBackend->getBackendName();
145
-	}
139
+    /**
140
+     * Backend name to be shown in user management
141
+     * @return string the name of the backend to be shown
142
+     */
143
+    public function getBackendName() {
144
+        return $this->refBackend->getBackendName();
145
+    }
146 146
 
147
-	/**
148
-	 * Get a list of all users
149
-	 *
150
-	 * @param string $search
151
-	 * @param null|int $limit
152
-	 * @param null|int $offset
153
-	 * @return string[] an array of all uids
154
-	 */
155
-	public function getUsers($search = '', $limit = 10, $offset = 0) {
156
-		//we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends
157
-		$users = array();
158
-		foreach($this->backends as $backend) {
159
-			$backendUsers = $backend->getUsers($search, $limit, $offset);
160
-			if (is_array($backendUsers)) {
161
-				$users = array_merge($users, $backendUsers);
162
-			}
163
-		}
164
-		return $users;
165
-	}
147
+    /**
148
+     * Get a list of all users
149
+     *
150
+     * @param string $search
151
+     * @param null|int $limit
152
+     * @param null|int $offset
153
+     * @return string[] an array of all uids
154
+     */
155
+    public function getUsers($search = '', $limit = 10, $offset = 0) {
156
+        //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends
157
+        $users = array();
158
+        foreach($this->backends as $backend) {
159
+            $backendUsers = $backend->getUsers($search, $limit, $offset);
160
+            if (is_array($backendUsers)) {
161
+                $users = array_merge($users, $backendUsers);
162
+            }
163
+        }
164
+        return $users;
165
+    }
166 166
 
167
-	/**
168
-	 * check if a user exists
169
-	 * @param string $uid the username
170
-	 * @return boolean
171
-	 */
172
-	public function userExists($uid) {
173
-		return $this->handleRequest($uid, 'userExists', array($uid));
174
-	}
167
+    /**
168
+     * check if a user exists
169
+     * @param string $uid the username
170
+     * @return boolean
171
+     */
172
+    public function userExists($uid) {
173
+        return $this->handleRequest($uid, 'userExists', array($uid));
174
+    }
175 175
 
176
-	/**
177
-	 * check if a user exists on LDAP
178
-	 * @param string|\OCA\User_LDAP\User\User $user either the Nextcloud user
179
-	 * name or an instance of that user
180
-	 * @return boolean
181
-	 */
182
-	public function userExistsOnLDAP($user) {
183
-		$id = ($user instanceof User) ? $user->getUsername() : $user;
184
-		return $this->handleRequest($id, 'userExistsOnLDAP', array($user));
185
-	}
176
+    /**
177
+     * check if a user exists on LDAP
178
+     * @param string|\OCA\User_LDAP\User\User $user either the Nextcloud user
179
+     * name or an instance of that user
180
+     * @return boolean
181
+     */
182
+    public function userExistsOnLDAP($user) {
183
+        $id = ($user instanceof User) ? $user->getUsername() : $user;
184
+        return $this->handleRequest($id, 'userExistsOnLDAP', array($user));
185
+    }
186 186
 
187
-	/**
188
-	 * Check if the password is correct
189
-	 * @param string $uid The username
190
-	 * @param string $password The password
191
-	 * @return bool
192
-	 *
193
-	 * Check if the password is correct without logging in the user
194
-	 */
195
-	public function checkPassword($uid, $password) {
196
-		return $this->handleRequest($uid, 'checkPassword', array($uid, $password));
197
-	}
187
+    /**
188
+     * Check if the password is correct
189
+     * @param string $uid The username
190
+     * @param string $password The password
191
+     * @return bool
192
+     *
193
+     * Check if the password is correct without logging in the user
194
+     */
195
+    public function checkPassword($uid, $password) {
196
+        return $this->handleRequest($uid, 'checkPassword', array($uid, $password));
197
+    }
198 198
 
199
-	/**
200
-	 * returns the username for the given login name, if available
201
-	 *
202
-	 * @param string $loginName
203
-	 * @return string|false
204
-	 */
205
-	public function loginName2UserName($loginName) {
206
-		$id = 'LOGINNAME,' . $loginName;
207
-		return $this->handleRequest($id, 'loginName2UserName', array($loginName));
208
-	}
199
+    /**
200
+     * returns the username for the given login name, if available
201
+     *
202
+     * @param string $loginName
203
+     * @return string|false
204
+     */
205
+    public function loginName2UserName($loginName) {
206
+        $id = 'LOGINNAME,' . $loginName;
207
+        return $this->handleRequest($id, 'loginName2UserName', array($loginName));
208
+    }
209 209
 	
210
-	/**
211
-	 * returns the username for the given LDAP DN, if available
212
-	 *
213
-	 * @param string $dn
214
-	 * @return string|false with the username
215
-	 */
216
-	public function dn2UserName($dn) {
217
-		$id = 'DN,' . $dn;
218
-		return $this->handleRequest($id, 'dn2UserName', array($dn));
219
-	}
210
+    /**
211
+     * returns the username for the given LDAP DN, if available
212
+     *
213
+     * @param string $dn
214
+     * @return string|false with the username
215
+     */
216
+    public function dn2UserName($dn) {
217
+        $id = 'DN,' . $dn;
218
+        return $this->handleRequest($id, 'dn2UserName', array($dn));
219
+    }
220 220
 
221
-	/**
222
-	 * get the user's home directory
223
-	 * @param string $uid the username
224
-	 * @return boolean
225
-	 */
226
-	public function getHome($uid) {
227
-		return $this->handleRequest($uid, 'getHome', array($uid));
228
-	}
221
+    /**
222
+     * get the user's home directory
223
+     * @param string $uid the username
224
+     * @return boolean
225
+     */
226
+    public function getHome($uid) {
227
+        return $this->handleRequest($uid, 'getHome', array($uid));
228
+    }
229 229
 
230
-	/**
231
-	 * get display name of the user
232
-	 * @param string $uid user ID of the user
233
-	 * @return string display name
234
-	 */
235
-	public function getDisplayName($uid) {
236
-		return $this->handleRequest($uid, 'getDisplayName', array($uid));
237
-	}
230
+    /**
231
+     * get display name of the user
232
+     * @param string $uid user ID of the user
233
+     * @return string display name
234
+     */
235
+    public function getDisplayName($uid) {
236
+        return $this->handleRequest($uid, 'getDisplayName', array($uid));
237
+    }
238 238
 
239
-	/**
240
-	 * set display name of the user
241
-	 *
242
-	 * @param string $uid user ID of the user
243
-	 * @param string $displayName new display name
244
-	 * @return string display name
245
-	 */
246
-	public function setDisplayName($uid, $displayName) {
247
-		return $this->handleRequest($uid, 'setDisplayName', array($uid, $displayName));
248
-	}
239
+    /**
240
+     * set display name of the user
241
+     *
242
+     * @param string $uid user ID of the user
243
+     * @param string $displayName new display name
244
+     * @return string display name
245
+     */
246
+    public function setDisplayName($uid, $displayName) {
247
+        return $this->handleRequest($uid, 'setDisplayName', array($uid, $displayName));
248
+    }
249 249
 
250
-	/**
251
-	 * checks whether the user is allowed to change his avatar in Nextcloud
252
-	 * @param string $uid the Nextcloud user name
253
-	 * @return boolean either the user can or cannot
254
-	 */
255
-	public function canChangeAvatar($uid) {
256
-		return $this->handleRequest($uid, 'canChangeAvatar', array($uid));
257
-	}
250
+    /**
251
+     * checks whether the user is allowed to change his avatar in Nextcloud
252
+     * @param string $uid the Nextcloud user name
253
+     * @return boolean either the user can or cannot
254
+     */
255
+    public function canChangeAvatar($uid) {
256
+        return $this->handleRequest($uid, 'canChangeAvatar', array($uid));
257
+    }
258 258
 
259
-	/**
260
-	 * Get a list of all display names and user ids.
261
-	 * @param string $search
262
-	 * @param string|null $limit
263
-	 * @param string|null $offset
264
-	 * @return array an array of all displayNames (value) and the corresponding uids (key)
265
-	 */
266
-	public function getDisplayNames($search = '', $limit = null, $offset = null) {
267
-		//we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends
268
-		$users = array();
269
-		foreach($this->backends as $backend) {
270
-			$backendUsers = $backend->getDisplayNames($search, $limit, $offset);
271
-			if (is_array($backendUsers)) {
272
-				$users = $users + $backendUsers;
273
-			}
274
-		}
275
-		return $users;
276
-	}
259
+    /**
260
+     * Get a list of all display names and user ids.
261
+     * @param string $search
262
+     * @param string|null $limit
263
+     * @param string|null $offset
264
+     * @return array an array of all displayNames (value) and the corresponding uids (key)
265
+     */
266
+    public function getDisplayNames($search = '', $limit = null, $offset = null) {
267
+        //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends
268
+        $users = array();
269
+        foreach($this->backends as $backend) {
270
+            $backendUsers = $backend->getDisplayNames($search, $limit, $offset);
271
+            if (is_array($backendUsers)) {
272
+                $users = $users + $backendUsers;
273
+            }
274
+        }
275
+        return $users;
276
+    }
277 277
 
278
-	/**
279
-	 * delete a user
280
-	 * @param string $uid The username of the user to delete
281
-	 * @return bool
282
-	 *
283
-	 * Deletes a user
284
-	 */
285
-	public function deleteUser($uid) {
286
-		return $this->handleRequest($uid, 'deleteUser', array($uid));
287
-	}
278
+    /**
279
+     * delete a user
280
+     * @param string $uid The username of the user to delete
281
+     * @return bool
282
+     *
283
+     * Deletes a user
284
+     */
285
+    public function deleteUser($uid) {
286
+        return $this->handleRequest($uid, 'deleteUser', array($uid));
287
+    }
288 288
 	
289
-	/**
290
-	 * Set password
291
-	 * @param string $uid The username
292
-	 * @param string $password The new password
293
-	 * @return bool
294
-	 *
295
-	 */
296
-	public function setPassword($uid, $password) {
297
-		return $this->handleRequest($uid, 'setPassword', array($uid, $password));
298
-	}
289
+    /**
290
+     * Set password
291
+     * @param string $uid The username
292
+     * @param string $password The new password
293
+     * @return bool
294
+     *
295
+     */
296
+    public function setPassword($uid, $password) {
297
+        return $this->handleRequest($uid, 'setPassword', array($uid, $password));
298
+    }
299 299
 
300
-	/**
301
-	 * @return bool
302
-	 */
303
-	public function hasUserListings() {
304
-		return $this->refBackend->hasUserListings();
305
-	}
300
+    /**
301
+     * @return bool
302
+     */
303
+    public function hasUserListings() {
304
+        return $this->refBackend->hasUserListings();
305
+    }
306 306
 
307
-	/**
308
-	 * Count the number of users
309
-	 * @return int|bool
310
-	 */
311
-	public function countUsers() {
312
-		$users = false;
313
-		foreach($this->backends as $backend) {
314
-			$backendUsers = $backend->countUsers();
315
-			if ($backendUsers !== false) {
316
-				$users += $backendUsers;
317
-			}
318
-		}
319
-		return $users;
320
-	}
307
+    /**
308
+     * Count the number of users
309
+     * @return int|bool
310
+     */
311
+    public function countUsers() {
312
+        $users = false;
313
+        foreach($this->backends as $backend) {
314
+            $backendUsers = $backend->countUsers();
315
+            if ($backendUsers !== false) {
316
+                $users += $backendUsers;
317
+            }
318
+        }
319
+        return $users;
320
+    }
321 321
 
322
-	/**
323
-	 * Return access for LDAP interaction.
324
-	 * @param string $uid
325
-	 * @return Access instance of Access for LDAP interaction
326
-	 */
327
-	public function getLDAPAccess($uid) {
328
-		return $this->handleRequest($uid, 'getLDAPAccess', array($uid));
329
-	}
322
+    /**
323
+     * Return access for LDAP interaction.
324
+     * @param string $uid
325
+     * @return Access instance of Access for LDAP interaction
326
+     */
327
+    public function getLDAPAccess($uid) {
328
+        return $this->handleRequest($uid, 'getLDAPAccess', array($uid));
329
+    }
330 330
 	
331
-	/**
332
-	 * Return a new LDAP connection for the specified user.
333
-	 * The connection needs to be closed manually.
334
-	 * @param string $uid
335
-	 * @return resource of the LDAP connection
336
-	 */
337
-	public function getNewLDAPConnection($uid) {
338
-		return $this->handleRequest($uid, 'getNewLDAPConnection', array($uid));
339
-	}
331
+    /**
332
+     * Return a new LDAP connection for the specified user.
333
+     * The connection needs to be closed manually.
334
+     * @param string $uid
335
+     * @return resource of the LDAP connection
336
+     */
337
+    public function getNewLDAPConnection($uid) {
338
+        return $this->handleRequest($uid, 'getNewLDAPConnection', array($uid));
339
+    }
340 340
 
341
-	/**
342
-	 * Creates a new user in LDAP
343
-	 * @param $username
344
-	 * @param $password
345
-	 * @return bool
346
-	 */
347
-	public function createUser($username, $password) {
348
-		return $this->handleRequest($username, 'createUser', array($username,$password));
349
-	}
341
+    /**
342
+     * Creates a new user in LDAP
343
+     * @param $username
344
+     * @param $password
345
+     * @return bool
346
+     */
347
+    public function createUser($username, $password) {
348
+        return $this->handleRequest($username, 'createUser', array($username,$password));
349
+    }
350 350
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 		INotificationManager $notificationManager, IUserSession $userSession,
54 54
 								UserPluginManager $userPluginManager) {
55 55
 		parent::__construct($ldap);
56
-		foreach($serverConfigPrefixes as $configPrefix) {
56
+		foreach ($serverConfigPrefixes as $configPrefix) {
57 57
 			$this->backends[$configPrefix] =
58 58
 				new User_LDAP($this->getAccess($configPrefix), $ocConfig, $notificationManager, $userSession, $userPluginManager);
59 59
 
60
-			if(is_null($this->refBackend)) {
60
+			if (is_null($this->refBackend)) {
61 61
 				$this->refBackend = &$this->backends[$configPrefix];
62 62
 			}
63 63
 		}
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	protected function walkBackends($uid, $method, $parameters) {
74 74
 		$cacheKey = $this->getUserCacheKey($uid);
75
-		foreach($this->backends as $configPrefix => $backend) {
75
+		foreach ($this->backends as $configPrefix => $backend) {
76 76
 			$instance = $backend;
77
-			if(!method_exists($instance, $method)
77
+			if (!method_exists($instance, $method)
78 78
 				&& method_exists($this->getAccess($configPrefix), $method)) {
79 79
 				$instance = $this->getAccess($configPrefix);
80 80
 			}
81
-			if($result = call_user_func_array(array($instance, $method), $parameters)) {
81
+			if ($result = call_user_func_array(array($instance, $method), $parameters)) {
82 82
 				$this->writeToCache($cacheKey, $configPrefix);
83 83
 				return $result;
84 84
 			}
@@ -98,22 +98,22 @@  discard block
 block discarded – undo
98 98
 		$cacheKey = $this->getUserCacheKey($uid);
99 99
 		$prefix = $this->getFromCache($cacheKey);
100 100
 		//in case the uid has been found in the past, try this stored connection first
101
-		if(!is_null($prefix)) {
102
-			if(isset($this->backends[$prefix])) {
101
+		if (!is_null($prefix)) {
102
+			if (isset($this->backends[$prefix])) {
103 103
 				$instance = $this->backends[$prefix];
104
-				if(!method_exists($instance, $method)
104
+				if (!method_exists($instance, $method)
105 105
 					&& method_exists($this->getAccess($prefix), $method)) {
106 106
 					$instance = $this->getAccess($prefix);
107 107
 				}
108 108
 				$result = call_user_func_array(array($instance, $method), $parameters);
109
-				if($result === $passOnWhen) {
109
+				if ($result === $passOnWhen) {
110 110
 					//not found here, reset cache to null if user vanished
111 111
 					//because sometimes methods return false with a reason
112 112
 					$userExists = call_user_func_array(
113 113
 						array($this->backends[$prefix], 'userExists'),
114 114
 						array($uid)
115 115
 					);
116
-					if(!$userExists) {
116
+					if (!$userExists) {
117 117
 						$this->writeToCache($cacheKey, null);
118 118
 					}
119 119
 				}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	public function getUsers($search = '', $limit = 10, $offset = 0) {
156 156
 		//we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends
157 157
 		$users = array();
158
-		foreach($this->backends as $backend) {
158
+		foreach ($this->backends as $backend) {
159 159
 			$backendUsers = $backend->getUsers($search, $limit, $offset);
160 160
 			if (is_array($backendUsers)) {
161 161
 				$users = array_merge($users, $backendUsers);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @return string|false
204 204
 	 */
205 205
 	public function loginName2UserName($loginName) {
206
-		$id = 'LOGINNAME,' . $loginName;
206
+		$id = 'LOGINNAME,'.$loginName;
207 207
 		return $this->handleRequest($id, 'loginName2UserName', array($loginName));
208 208
 	}
209 209
 	
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @return string|false with the username
215 215
 	 */
216 216
 	public function dn2UserName($dn) {
217
-		$id = 'DN,' . $dn;
217
+		$id = 'DN,'.$dn;
218 218
 		return $this->handleRequest($id, 'dn2UserName', array($dn));
219 219
 	}
220 220
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	public function getDisplayNames($search = '', $limit = null, $offset = null) {
267 267
 		//we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends
268 268
 		$users = array();
269
-		foreach($this->backends as $backend) {
269
+		foreach ($this->backends as $backend) {
270 270
 			$backendUsers = $backend->getDisplayNames($search, $limit, $offset);
271 271
 			if (is_array($backendUsers)) {
272 272
 				$users = $users + $backendUsers;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 */
311 311
 	public function countUsers() {
312 312
 		$users = false;
313
-		foreach($this->backends as $backend) {
313
+		foreach ($this->backends as $backend) {
314 314
 			$backendUsers = $backend->countUsers();
315 315
 			if ($backendUsers !== false) {
316 316
 				$users += $backendUsers;
@@ -345,6 +345,6 @@  discard block
 block discarded – undo
345 345
 	 * @return bool
346 346
 	 */
347 347
 	public function createUser($username, $password) {
348
-		return $this->handleRequest($username, 'createUser', array($username,$password));
348
+		return $this->handleRequest($username, 'createUser', array($username, $password));
349 349
 	}
350 350
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Jobs/CleanUp.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -40,197 +40,197 @@
 block discarded – undo
40 40
  * @package OCA\User_LDAP\Jobs;
41 41
  */
42 42
 class CleanUp extends TimedJob {
43
-	/** @var int $limit amount of users that should be checked per run */
44
-	protected $limit = 50;
45
-
46
-	/** @var int $defaultIntervalMin default interval in minutes */
47
-	protected $defaultIntervalMin = 51;
48
-
49
-	/** @var User_LDAP|User_Proxy $userBackend */
50
-	protected $userBackend;
51
-
52
-	/** @var \OCP\IConfig $ocConfig */
53
-	protected $ocConfig;
54
-
55
-	/** @var \OCP\IDBConnection $db */
56
-	protected $db;
57
-
58
-	/** @var Helper $ldapHelper */
59
-	protected $ldapHelper;
60
-
61
-	/** @var \OCA\User_LDAP\Mapping\UserMapping */
62
-	protected $mapping;
63
-
64
-	/** @var \OCA\User_LDAP\User\DeletedUsersIndex */
65
-	protected $dui;
66
-
67
-	public function __construct() {
68
-		$minutes = \OC::$server->getConfig()->getSystemValue(
69
-			'ldapUserCleanupInterval', strval($this->defaultIntervalMin));
70
-		$this->setInterval(intval($minutes) * 60);
71
-	}
72
-
73
-	/**
74
-	 * assigns the instances passed to run() to the class properties
75
-	 * @param array $arguments
76
-	 */
77
-	public function setArguments($arguments) {
78
-		//Dependency Injection is not possible, because the constructor will
79
-		//only get values that are serialized to JSON. I.e. whatever we would
80
-		//pass in app.php we do add here, except something else is passed e.g.
81
-		//in tests.
82
-
83
-		if(isset($arguments['helper'])) {
84
-			$this->ldapHelper = $arguments['helper'];
85
-		} else {
86
-			$this->ldapHelper = new Helper(\OC::$server->getConfig());
87
-		}
88
-
89
-		if(isset($arguments['ocConfig'])) {
90
-			$this->ocConfig = $arguments['ocConfig'];
91
-		} else {
92
-			$this->ocConfig = \OC::$server->getConfig();
93
-		}
94
-
95
-		if(isset($arguments['userBackend'])) {
96
-			$this->userBackend = $arguments['userBackend'];
97
-		} else {
98
-			$this->userBackend =  new User_Proxy(
99
-				$this->ldapHelper->getServerConfigurationPrefixes(true),
100
-				new LDAP(),
101
-				$this->ocConfig,
102
-				\OC::$server->getNotificationManager(),
103
-				\OC::$server->getUserSession(),
104
-				\OC::$server->query('LDAPUserPluginManager')
105
-			);
106
-		}
107
-
108
-		if(isset($arguments['db'])) {
109
-			$this->db = $arguments['db'];
110
-		} else {
111
-			$this->db = \OC::$server->getDatabaseConnection();
112
-		}
113
-
114
-		if(isset($arguments['mapping'])) {
115
-			$this->mapping = $arguments['mapping'];
116
-		} else {
117
-			$this->mapping = new UserMapping($this->db);
118
-		}
119
-
120
-		if(isset($arguments['deletedUsersIndex'])) {
121
-			$this->dui = $arguments['deletedUsersIndex'];
122
-		} else {
123
-			$this->dui = new DeletedUsersIndex(
124
-				$this->ocConfig, $this->db, $this->mapping);
125
-		}
126
-	}
127
-
128
-	/**
129
-	 * makes the background job do its work
130
-	 * @param array $argument
131
-	 */
132
-	public function run($argument) {
133
-		$this->setArguments($argument);
134
-
135
-		if(!$this->isCleanUpAllowed()) {
136
-			return;
137
-		}
138
-		$users = $this->mapping->getList($this->getOffset(), $this->limit);
139
-		if(!is_array($users)) {
140
-			//something wrong? Let's start from the beginning next time and
141
-			//abort
142
-			$this->setOffset(true);
143
-			return;
144
-		}
145
-		$resetOffset = $this->isOffsetResetNecessary(count($users));
146
-		$this->checkUsers($users);
147
-		$this->setOffset($resetOffset);
148
-	}
149
-
150
-	/**
151
-	 * checks whether next run should start at 0 again
152
-	 * @param int $resultCount
153
-	 * @return bool
154
-	 */
155
-	public function isOffsetResetNecessary($resultCount) {
156
-		return ($resultCount < $this->limit) ? true : false;
157
-	}
158
-
159
-	/**
160
-	 * checks whether cleaning up LDAP users is allowed
161
-	 * @return bool
162
-	 */
163
-	public function isCleanUpAllowed() {
164
-		try {
165
-			if($this->ldapHelper->haveDisabledConfigurations()) {
166
-				return false;
167
-			}
168
-		} catch (\Exception $e) {
169
-			return false;
170
-		}
171
-
172
-		$enabled = $this->isCleanUpEnabled();
173
-
174
-		return $enabled;
175
-	}
176
-
177
-	/**
178
-	 * checks whether clean up is enabled by configuration
179
-	 * @return bool
180
-	 */
181
-	private function isCleanUpEnabled() {
182
-		return (bool)$this->ocConfig->getSystemValue(
183
-			'ldapUserCleanupInterval', strval($this->defaultIntervalMin));
184
-	}
185
-
186
-	/**
187
-	 * checks users whether they are still existing
188
-	 * @param array $users result from getMappedUsers()
189
-	 */
190
-	private function checkUsers(array $users) {
191
-		foreach($users as $user) {
192
-			$this->checkUser($user);
193
-		}
194
-	}
195
-
196
-	/**
197
-	 * checks whether a user is still existing in LDAP
198
-	 * @param string[] $user
199
-	 */
200
-	private function checkUser(array $user) {
201
-		if($this->userBackend->userExistsOnLDAP($user['name'])) {
202
-			//still available, all good
203
-
204
-			return;
205
-		}
206
-
207
-		$this->dui->markUser($user['name']);
208
-	}
209
-
210
-	/**
211
-	 * gets the offset to fetch users from the mappings table
212
-	 * @return int
213
-	 */
214
-	private function getOffset() {
215
-		return intval($this->ocConfig->getAppValue('user_ldap', 'cleanUpJobOffset', 0));
216
-	}
217
-
218
-	/**
219
-	 * sets the new offset for the next run
220
-	 * @param bool $reset whether the offset should be set to 0
221
-	 */
222
-	public function setOffset($reset = false) {
223
-		$newOffset = $reset ? 0 :
224
-			$this->getOffset() + $this->limit;
225
-		$this->ocConfig->setAppValue('user_ldap', 'cleanUpJobOffset', $newOffset);
226
-	}
227
-
228
-	/**
229
-	 * returns the chunk size (limit in DB speak)
230
-	 * @return int
231
-	 */
232
-	public function getChunkSize() {
233
-		return $this->limit;
234
-	}
43
+    /** @var int $limit amount of users that should be checked per run */
44
+    protected $limit = 50;
45
+
46
+    /** @var int $defaultIntervalMin default interval in minutes */
47
+    protected $defaultIntervalMin = 51;
48
+
49
+    /** @var User_LDAP|User_Proxy $userBackend */
50
+    protected $userBackend;
51
+
52
+    /** @var \OCP\IConfig $ocConfig */
53
+    protected $ocConfig;
54
+
55
+    /** @var \OCP\IDBConnection $db */
56
+    protected $db;
57
+
58
+    /** @var Helper $ldapHelper */
59
+    protected $ldapHelper;
60
+
61
+    /** @var \OCA\User_LDAP\Mapping\UserMapping */
62
+    protected $mapping;
63
+
64
+    /** @var \OCA\User_LDAP\User\DeletedUsersIndex */
65
+    protected $dui;
66
+
67
+    public function __construct() {
68
+        $minutes = \OC::$server->getConfig()->getSystemValue(
69
+            'ldapUserCleanupInterval', strval($this->defaultIntervalMin));
70
+        $this->setInterval(intval($minutes) * 60);
71
+    }
72
+
73
+    /**
74
+     * assigns the instances passed to run() to the class properties
75
+     * @param array $arguments
76
+     */
77
+    public function setArguments($arguments) {
78
+        //Dependency Injection is not possible, because the constructor will
79
+        //only get values that are serialized to JSON. I.e. whatever we would
80
+        //pass in app.php we do add here, except something else is passed e.g.
81
+        //in tests.
82
+
83
+        if(isset($arguments['helper'])) {
84
+            $this->ldapHelper = $arguments['helper'];
85
+        } else {
86
+            $this->ldapHelper = new Helper(\OC::$server->getConfig());
87
+        }
88
+
89
+        if(isset($arguments['ocConfig'])) {
90
+            $this->ocConfig = $arguments['ocConfig'];
91
+        } else {
92
+            $this->ocConfig = \OC::$server->getConfig();
93
+        }
94
+
95
+        if(isset($arguments['userBackend'])) {
96
+            $this->userBackend = $arguments['userBackend'];
97
+        } else {
98
+            $this->userBackend =  new User_Proxy(
99
+                $this->ldapHelper->getServerConfigurationPrefixes(true),
100
+                new LDAP(),
101
+                $this->ocConfig,
102
+                \OC::$server->getNotificationManager(),
103
+                \OC::$server->getUserSession(),
104
+                \OC::$server->query('LDAPUserPluginManager')
105
+            );
106
+        }
107
+
108
+        if(isset($arguments['db'])) {
109
+            $this->db = $arguments['db'];
110
+        } else {
111
+            $this->db = \OC::$server->getDatabaseConnection();
112
+        }
113
+
114
+        if(isset($arguments['mapping'])) {
115
+            $this->mapping = $arguments['mapping'];
116
+        } else {
117
+            $this->mapping = new UserMapping($this->db);
118
+        }
119
+
120
+        if(isset($arguments['deletedUsersIndex'])) {
121
+            $this->dui = $arguments['deletedUsersIndex'];
122
+        } else {
123
+            $this->dui = new DeletedUsersIndex(
124
+                $this->ocConfig, $this->db, $this->mapping);
125
+        }
126
+    }
127
+
128
+    /**
129
+     * makes the background job do its work
130
+     * @param array $argument
131
+     */
132
+    public function run($argument) {
133
+        $this->setArguments($argument);
134
+
135
+        if(!$this->isCleanUpAllowed()) {
136
+            return;
137
+        }
138
+        $users = $this->mapping->getList($this->getOffset(), $this->limit);
139
+        if(!is_array($users)) {
140
+            //something wrong? Let's start from the beginning next time and
141
+            //abort
142
+            $this->setOffset(true);
143
+            return;
144
+        }
145
+        $resetOffset = $this->isOffsetResetNecessary(count($users));
146
+        $this->checkUsers($users);
147
+        $this->setOffset($resetOffset);
148
+    }
149
+
150
+    /**
151
+     * checks whether next run should start at 0 again
152
+     * @param int $resultCount
153
+     * @return bool
154
+     */
155
+    public function isOffsetResetNecessary($resultCount) {
156
+        return ($resultCount < $this->limit) ? true : false;
157
+    }
158
+
159
+    /**
160
+     * checks whether cleaning up LDAP users is allowed
161
+     * @return bool
162
+     */
163
+    public function isCleanUpAllowed() {
164
+        try {
165
+            if($this->ldapHelper->haveDisabledConfigurations()) {
166
+                return false;
167
+            }
168
+        } catch (\Exception $e) {
169
+            return false;
170
+        }
171
+
172
+        $enabled = $this->isCleanUpEnabled();
173
+
174
+        return $enabled;
175
+    }
176
+
177
+    /**
178
+     * checks whether clean up is enabled by configuration
179
+     * @return bool
180
+     */
181
+    private function isCleanUpEnabled() {
182
+        return (bool)$this->ocConfig->getSystemValue(
183
+            'ldapUserCleanupInterval', strval($this->defaultIntervalMin));
184
+    }
185
+
186
+    /**
187
+     * checks users whether they are still existing
188
+     * @param array $users result from getMappedUsers()
189
+     */
190
+    private function checkUsers(array $users) {
191
+        foreach($users as $user) {
192
+            $this->checkUser($user);
193
+        }
194
+    }
195
+
196
+    /**
197
+     * checks whether a user is still existing in LDAP
198
+     * @param string[] $user
199
+     */
200
+    private function checkUser(array $user) {
201
+        if($this->userBackend->userExistsOnLDAP($user['name'])) {
202
+            //still available, all good
203
+
204
+            return;
205
+        }
206
+
207
+        $this->dui->markUser($user['name']);
208
+    }
209
+
210
+    /**
211
+     * gets the offset to fetch users from the mappings table
212
+     * @return int
213
+     */
214
+    private function getOffset() {
215
+        return intval($this->ocConfig->getAppValue('user_ldap', 'cleanUpJobOffset', 0));
216
+    }
217
+
218
+    /**
219
+     * sets the new offset for the next run
220
+     * @param bool $reset whether the offset should be set to 0
221
+     */
222
+    public function setOffset($reset = false) {
223
+        $newOffset = $reset ? 0 :
224
+            $this->getOffset() + $this->limit;
225
+        $this->ocConfig->setAppValue('user_ldap', 'cleanUpJobOffset', $newOffset);
226
+    }
227
+
228
+    /**
229
+     * returns the chunk size (limit in DB speak)
230
+     * @return int
231
+     */
232
+    public function getChunkSize() {
233
+        return $this->limit;
234
+    }
235 235
 
236 236
 }
Please login to merge, or discard this patch.