Skip to content

Commit 4babdc0

Browse files
committed
formatting
Signed-off-by: Arthur Schiwon <[email protected]>
1 parent ab550d6 commit 4babdc0

8 files changed

Lines changed: 254 additions & 144 deletions

File tree

apps/user_ldap/lib/Access.php

Lines changed: 83 additions & 50 deletions
Large diffs are not rendered by default.

apps/user_ldap/lib/Group_LDAP.php

Lines changed: 59 additions & 37 deletions
Large diffs are not rendered by default.

apps/user_ldap/lib/Group_Proxy.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet
3636

3737
/**
3838
* Constructor
39+
*
3940
* @param string[] $serverConfigPrefixes array containing the config Prefixes
4041
*/
4142
public function __construct($serverConfigPrefixes, ILDAPWrapper $ldap, GroupPluginManager $groupPluginManager) {
@@ -51,6 +52,7 @@ public function __construct($serverConfigPrefixes, ILDAPWrapper $ldap, GroupPlug
5152

5253
/**
5354
* Tries the backends one after the other until a positive result is returned from the specified method
55+
*
5456
* @param string $gid the gid connected to the request
5557
* @param string $method the method of the group backend that shall be called
5658
* @param array $parameters an array of parameters to be passed
@@ -60,7 +62,7 @@ protected function walkBackends($gid, $method, $parameters) {
6062
$cacheKey = $this->getGroupCacheKey($gid);
6163
foreach ($this->backends as $configPrefix => $backend) {
6264
if ($result = call_user_func_array([$backend, $method], $parameters)) {
63-
if(!$this->isSingleBackend()) {
65+
if (!$this->isSingleBackend()) {
6466
$this->writeToCache($cacheKey, $configPrefix);
6567
}
6668
return $result;
@@ -71,6 +73,7 @@ protected function walkBackends($gid, $method, $parameters) {
7173

7274
/**
7375
* Asks the backend connected to the server that supposely takes care of the gid from the request.
76+
*
7477
* @param string $gid the gid connected to the request
7578
* @param string $method the method of the group backend that shall be called
7679
* @param array $parameters an array of parameters to be passed
@@ -107,6 +110,7 @@ protected function activeBackends(): int {
107110

108111
/**
109112
* is user in group?
113+
*
110114
* @param string $uid uid of the user
111115
* @param string $gid gid of the group
112116
* @return bool
@@ -119,6 +123,7 @@ public function inGroup($uid, $gid) {
119123

120124
/**
121125
* Get all groups a user belongs to
126+
*
122127
* @param string $uid Name of the user
123128
* @return string[] with group names
124129
*
@@ -140,6 +145,7 @@ public function getUserGroups($uid) {
140145

141146
/**
142147
* get a list of all users in a group
148+
*
143149
* @return string[] with user ids
144150
*/
145151
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
@@ -166,6 +172,7 @@ public function createGroup($gid) {
166172

167173
/**
168174
* delete a group
175+
*
169176
* @param string $gid gid of the group to delete
170177
* @return bool
171178
*/
@@ -176,6 +183,7 @@ public function deleteGroup($gid) {
176183

177184
/**
178185
* Add a user to a group
186+
*
179187
* @param string $uid Name of the user to add to group
180188
* @param string $gid Name of the group in which add the user
181189
* @return bool
@@ -189,6 +197,7 @@ public function addToGroup($uid, $gid) {
189197

190198
/**
191199
* Removes a user from a group
200+
*
192201
* @param string $uid Name of the user to remove from group
193202
* @param string $gid Name of the group from which remove the user
194203
* @return bool
@@ -202,6 +211,7 @@ public function removeFromGroup($uid, $gid) {
202211

203212
/**
204213
* returns the number of users in a group, who match the search term
214+
*
205215
* @param string $gid the internal group name
206216
* @param string $search optional, a search string
207217
* @return int|bool
@@ -213,6 +223,7 @@ public function countUsersInGroup($gid, $search = '') {
213223

214224
/**
215225
* get an array with group details
226+
*
216227
* @param string $gid
217228
* @return array|false
218229
*/
@@ -223,6 +234,7 @@ public function getGroupDetails($gid) {
223234

224235
/**
225236
* get a list of all groups
237+
*
226238
* @return string[] with group names
227239
*
228240
* Returns a list with all groups
@@ -242,6 +254,7 @@ public function getGroups($search = '', $limit = -1, $offset = 0) {
242254

243255
/**
244256
* check if a group exists
257+
*
245258
* @param string $gid
246259
* @return bool
247260
*/
@@ -251,6 +264,7 @@ public function groupExists($gid) {
251264

252265
/**
253266
* Check if backend implements actions
267+
*
254268
* @param int $actions bitwise-or'ed actions
255269
* @return boolean
256270
*
@@ -264,6 +278,7 @@ public function implementsActions($actions) {
264278

265279
/**
266280
* Return access for LDAP interaction.
281+
*
267282
* @param string $gid
268283
* @return Access instance of Access for LDAP interaction
269284
*/
@@ -274,6 +289,7 @@ public function getLDAPAccess($gid) {
274289
/**
275290
* Return a new LDAP connection for the specified group.
276291
* The connection needs to be closed manually.
292+
*
277293
* @param string $gid
278294
* @return resource of the LDAP connection
279295
*/

apps/user_ldap/lib/Helper.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function __construct(IConfig $config) {
5757

5858
/**
5959
* returns prefixes for each saved LDAP/AD server configuration.
60+
*
6061
* @param bool $activeConfigurations optional, whether only active configuration shall be
6162
* retrieved, defaults to false
6263
* @return array with a list of the available prefixes
@@ -97,6 +98,7 @@ public function getServerConfigurationPrefixes($activeConfigurations = false) {
9798
/**
9899
*
99100
* determines the host for every configured connection
101+
*
100102
* @return array an array with configprefix as keys
101103
*
102104
*/
@@ -149,6 +151,7 @@ private function getServersConfig($value) {
149151

150152
/**
151153
* deletes a given saved LDAP/AD server configuration.
154+
*
152155
* @param string $prefix the configuration prefix of the config to delete
153156
* @return bool true on success, false otherwise
154157
*/
@@ -166,11 +169,11 @@ public function deleteServerConfiguration($prefix) {
166169
DELETE
167170
FROM `*PREFIX*appconfig`
168171
WHERE `configkey` LIKE ?
169-
'.$saveOtherConfigurations.'
172+
' . $saveOtherConfigurations . '
170173
AND `appid` = \'user_ldap\'
171174
AND `configkey` NOT IN (\'enabled\', \'installed_version\', \'types\', \'bgjUpdateGroupsLastRun\')
172175
');
173-
$delRows = $query->execute([$prefix.'%']);
176+
$delRows = $query->execute([$prefix . '%']);
174177

175178
if ($delRows === null) {
176179
return false;
@@ -185,8 +188,9 @@ public function deleteServerConfiguration($prefix) {
185188

186189
/**
187190
* checks whether there is one or more disabled LDAP configurations
188-
* @throws \Exception
191+
*
189192
* @return bool
193+
* @throws \Exception
190194
*/
191195
public function haveDisabledConfigurations() {
192196
$all = $this->getServerConfigurationPrefixes(false);
@@ -201,6 +205,7 @@ public function haveDisabledConfigurations() {
201205

202206
/**
203207
* extracts the domain from a given URL
208+
*
204209
* @param string $url the URL
205210
* @return string|false domain as string on success, false otherwise
206211
*/
@@ -234,6 +239,7 @@ public function setLDAPProvider() {
234239

235240
/**
236241
* sanitizes a DN received from the LDAP server
242+
*
237243
* @param array $dn the DN in question
238244
* @return array|string the sanitized DN
239245
*/
@@ -247,12 +253,12 @@ public function sanitizeDN($dn) {
247253
return $result;
248254
}
249255

250-
if(!is_string($dn)) {
256+
if (!is_string($dn)) {
251257
throw new \LogicException('String expected ' . \gettype($dn) . ' given');
252258
}
253259

254260
if (($sanitizedDn = $this->sanitizeDnCache->get($dn)) !== null) {
255-
return $sanitizedDn;
261+
return $sanitizedDn;
256262
}
257263

258264
//OID sometimes gives back DNs with whitespace after the comma
@@ -274,9 +280,9 @@ public function sanitizeDN($dn) {
274280
'\;' => '\5c3B',
275281
'\"' => '\5c22',
276282
'\#' => '\5c23',
277-
'(' => '\28',
278-
')' => '\29',
279-
'*' => '\2A',
283+
'(' => '\28',
284+
')' => '\29',
285+
'*' => '\2A',
280286
];
281287
$sanitizedDn = str_replace(array_keys($replacements), array_values($replacements), $sanitizedDn);
282288
$this->sanitizeDnCache->set($dn, $sanitizedDn);
@@ -286,6 +292,7 @@ public function sanitizeDN($dn) {
286292

287293
/**
288294
* converts a stored DN so it can be used as base parameter for LDAP queries, internally we store them for usage in LDAP filters
295+
*
289296
* @param string $dn the DN
290297
* @return string
291298
*/
@@ -316,7 +323,7 @@ public static function loginName2UserName($param) {
316323
$userSession = \OC::$server->getUserSession();
317324
$userPluginManager = \OC::$server->query('LDAPUserPluginManager');
318325

319-
$userBackend = new User_Proxy(
326+
$userBackend = new User_Proxy(
320327
$configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession, $userPluginManager
321328
);
322329
$uid = $userBackend->loginName2UserName($param['uid']);

0 commit comments

Comments
 (0)