@@ -550,7 +550,7 @@ |
||
550 | 550 | 'ldap_default_ppolicy_dn' => 'ldapDefaultPPolicyDN', |
551 | 551 | 'ldap_ext_storage_home_attribute' => 'ldapExtStorageHomeAttribute', |
552 | 552 | 'ldap_matching_rule_in_chain_state' => 'ldapMatchingRuleInChainState', |
553 | - 'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig |
|
553 | + 'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig |
|
554 | 554 | ]; |
555 | 555 | return $array; |
556 | 556 | } |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | if (!$this->enabled) { |
102 | 102 | return false; |
103 | 103 | } |
104 | - $cacheKey = 'inGroup' . $uid . ':' . $gid; |
|
104 | + $cacheKey = 'inGroup'.$uid.':'.$gid; |
|
105 | 105 | $inGroup = $this->access->connection->getFromCache($cacheKey); |
106 | 106 | if (!is_null($inGroup)) { |
107 | - return (bool)$inGroup; |
|
107 | + return (bool) $inGroup; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | $userDN = $this->access->username2dn($uid); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | return in_array($userDN, $this->cachedGroupMembers[$gid]); |
114 | 114 | } |
115 | 115 | |
116 | - $cacheKeyMembers = 'inGroup-members:' . $gid; |
|
116 | + $cacheKeyMembers = 'inGroup-members:'.$gid; |
|
117 | 117 | $members = $this->access->connection->getFromCache($cacheKeyMembers); |
118 | 118 | if (!is_null($members)) { |
119 | 119 | $this->cachedGroupMembers[$gid] = $members; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | return []; |
242 | 242 | } |
243 | 243 | // used extensively in cron job, caching makes sense for nested groups |
244 | - $cacheKey = '_groupMembers' . $dnGroup; |
|
244 | + $cacheKey = '_groupMembers'.$dnGroup; |
|
245 | 245 | $groupMembers = $this->access->connection->getFromCache($cacheKey); |
246 | 246 | if ($groupMembers !== null) { |
247 | 247 | return $groupMembers; |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | // compatibility hack with servers supporting :1.2.840.113556.1.4.1941:, and others) |
257 | 257 | $filter = $this->access->combineFilterWithAnd([ |
258 | 258 | $this->access->connection->ldapUserFilter, |
259 | - $this->access->connection->ldapUserDisplayName . '=*', |
|
260 | - 'memberof:1.2.840.113556.1.4.1941:=' . $dnGroup |
|
259 | + $this->access->connection->ldapUserDisplayName.'=*', |
|
260 | + 'memberof:1.2.840.113556.1.4.1941:='.$dnGroup |
|
261 | 261 | ]); |
262 | 262 | $memberRecords = $this->access->fetchListOfUsers( |
263 | 263 | $filter, |
264 | 264 | $this->access->userManager->getAttributes(true) |
265 | 265 | ); |
266 | - $result = array_reduce($memberRecords, function ($carry, $record) { |
|
266 | + $result = array_reduce($memberRecords, function($carry, $record) { |
|
267 | 267 | $carry[] = $record['dn'][0]; |
268 | 268 | return $carry; |
269 | 269 | }, []); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $seen[$dnGroup] = 1; |
281 | 281 | $members = $this->access->readAttribute($dnGroup, $this->access->connection->ldapGroupMemberAssocAttr); |
282 | 282 | if (is_array($members)) { |
283 | - $fetcher = function ($memberDN, &$seen) { |
|
283 | + $fetcher = function($memberDN, &$seen) { |
|
284 | 284 | return $this->_groupMembers($memberDN, $seen); |
285 | 285 | }; |
286 | 286 | $allMembers = $this->walkNestedGroups($dnGroup, $fetcher, $members); |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | return []; |
309 | 309 | } |
310 | 310 | |
311 | - $fetcher = function ($groupDN) { |
|
311 | + $fetcher = function($groupDN) { |
|
312 | 312 | if (isset($this->cachedNestedGroups[$groupDN])) { |
313 | 313 | $nestedGroups = $this->cachedNestedGroups[$groupDN]; |
314 | 314 | } else { |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | } |
327 | 327 | |
328 | 328 | private function walkNestedGroups(string $dn, Closure $fetcher, array $list): array { |
329 | - $nesting = (int)$this->access->connection->ldapNestedGroups; |
|
329 | + $nesting = (int) $this->access->connection->ldapNestedGroups; |
|
330 | 330 | // depending on the input, we either have a list of DNs or a list of LDAP records |
331 | 331 | // also, the output expects either DNs or records. Testing the first element should suffice. |
332 | 332 | $recordMode = is_array($list) && isset($list[0]) && is_array($list[0]) && isset($list[0]['dn'][0]); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | if ($nesting !== 1) { |
335 | 335 | if ($recordMode) { |
336 | 336 | // the keys are numeric, but should hold the DN |
337 | - return array_reduce($list, function ($transformed, $record) use ($dn) { |
|
337 | + return array_reduce($list, function($transformed, $record) use ($dn) { |
|
338 | 338 | if ($record['dn'][0] != $dn) { |
339 | 339 | $transformed[$record['dn'][0]] = $record; |
340 | 340 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @throws ServerNotAvailableException |
368 | 368 | */ |
369 | 369 | public function gidNumber2Name(string $gid, string $dn) { |
370 | - $cacheKey = 'gidNumberToName' . $gid; |
|
370 | + $cacheKey = 'gidNumberToName'.$gid; |
|
371 | 371 | $groupName = $this->access->connection->getFromCache($cacheKey); |
372 | 372 | if (!is_null($groupName) && isset($groupName)) { |
373 | 373 | return $groupName; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | $filter = $this->access->combineFilterWithAnd([ |
378 | 378 | $this->access->connection->ldapGroupFilter, |
379 | 379 | 'objectClass=posixGroup', |
380 | - $this->access->connection->ldapGidNumber . '=' . $gid |
|
380 | + $this->access->connection->ldapGidNumber.'='.$gid |
|
381 | 381 | ]); |
382 | 382 | return $this->getNameOfGroup($filter, $cacheKey) ?? false; |
383 | 383 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | if ($search !== '') { |
458 | 458 | $filterParts[] = $this->access->getFilterPartForUserSearch($search); |
459 | 459 | } |
460 | - $filterParts[] = $this->access->connection->ldapGidNumber . '=' . $groupID; |
|
460 | + $filterParts[] = $this->access->connection->ldapGidNumber.'='.$groupID; |
|
461 | 461 | |
462 | 462 | return $this->access->combineFilterWithAnd($filterParts); |
463 | 463 | } |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | //we need to get the DN from LDAP |
528 | 528 | $filter = $this->access->combineFilterWithAnd([ |
529 | 529 | $this->access->connection->ldapGroupFilter, |
530 | - 'objectsid=' . $domainObjectSid . '-' . $gid |
|
530 | + 'objectsid='.$domainObjectSid.'-'.$gid |
|
531 | 531 | ]); |
532 | 532 | return $this->getNameOfGroup($filter, $cacheKey) ?? false; |
533 | 533 | } |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | if ($search !== '') { |
585 | 585 | $filterParts[] = $this->access->getFilterPartForUserSearch($search); |
586 | 586 | } |
587 | - $filterParts[] = 'primaryGroupID=' . $groupID; |
|
587 | + $filterParts[] = 'primaryGroupID='.$groupID; |
|
588 | 588 | |
589 | 589 | return $this->access->combineFilterWithAnd($filterParts); |
590 | 590 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | try { |
627 | 627 | $filter = $this->prepareFilterForUsersInPrimaryGroup($groupDN, $search); |
628 | 628 | $users = $this->access->countUsers($filter, ['dn'], $limit, $offset); |
629 | - return (int)$users; |
|
629 | + return (int) $users; |
|
630 | 630 | } catch (ServerNotAvailableException $e) { |
631 | 631 | throw $e; |
632 | 632 | } catch (Exception $e) { |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | if (!$this->enabled) { |
666 | 666 | return []; |
667 | 667 | } |
668 | - $cacheKey = 'getUserGroups' . $uid; |
|
668 | + $cacheKey = 'getUserGroups'.$uid; |
|
669 | 669 | $userGroups = $this->access->connection->getFromCache($cacheKey); |
670 | 670 | if (!is_null($userGroups)) { |
671 | 671 | return $userGroups; |
@@ -723,8 +723,8 @@ discard block |
||
723 | 723 | // if possible, read out membership via memberOf. It's far faster than |
724 | 724 | // performing a search, which still is a fallback later. |
725 | 725 | // memberof doesn't support memberuid, so skip it here. |
726 | - if ((int)$this->access->connection->hasMemberOfFilterSupport === 1 |
|
727 | - && (int)$this->access->connection->useMemberOfToDetectMembership === 1 |
|
726 | + if ((int) $this->access->connection->hasMemberOfFilterSupport === 1 |
|
727 | + && (int) $this->access->connection->useMemberOfToDetectMembership === 1 |
|
728 | 728 | && $this->ldapGroupMemberAssocAttr !== 'memberuid' |
729 | 729 | && $this->ldapGroupMemberAssocAttr !== 'zimbramailforwardingaddress') { |
730 | 730 | $groupDNs = $this->_getGroupDNsFromMemberOf($userDN); |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | } |
817 | 817 | $allGroups = []; |
818 | 818 | $seen[$dn] = true; |
819 | - $filter = $this->access->connection->ldapGroupMemberAssocAttr . '=' . $dn; |
|
819 | + $filter = $this->access->connection->ldapGroupMemberAssocAttr.'='.$dn; |
|
820 | 820 | |
821 | 821 | if ($this->ldapGroupMemberAssocAttr === 'zimbramailforwardingaddress') { |
822 | 822 | //in this case the member entries are email addresses |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | $groups = $this->access->fetchListOfGroups($filter, |
827 | 827 | [strtolower($this->access->connection->ldapGroupMemberAssocAttr), $this->access->connection->ldapGroupDisplayName, 'dn']); |
828 | 828 | if (is_array($groups)) { |
829 | - $fetcher = function ($dn, &$seen) { |
|
829 | + $fetcher = function($dn, &$seen) { |
|
830 | 830 | if (is_array($dn) && isset($dn['dn'][0])) { |
831 | 831 | $dn = $dn['dn'][0]; |
832 | 832 | } |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | return []; |
863 | 863 | } |
864 | 864 | $search = $this->access->escapeFilterPart($search, true); |
865 | - $cacheKey = 'usersInGroup-' . $gid . '-' . $search . '-' . $limit . '-' . $offset; |
|
865 | + $cacheKey = 'usersInGroup-'.$gid.'-'.$search.'-'.$limit.'-'.$offset; |
|
866 | 866 | // check for cache of the exact query |
867 | 867 | $groupUsers = $this->access->connection->getFromCache($cacheKey); |
868 | 868 | if (!is_null($groupUsers)) { |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | $limit = null; |
874 | 874 | } |
875 | 875 | // check for cache of the query without limit and offset |
876 | - $groupUsers = $this->access->connection->getFromCache('usersInGroup-' . $gid . '-' . $search); |
|
876 | + $groupUsers = $this->access->connection->getFromCache('usersInGroup-'.$gid.'-'.$search); |
|
877 | 877 | if (!is_null($groupUsers)) { |
878 | 878 | $groupUsers = array_slice($groupUsers, $offset, $limit); |
879 | 879 | $this->access->connection->writeToCache($cacheKey, $groupUsers); |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | break; |
928 | 928 | } |
929 | 929 | |
930 | - $cacheKey = 'userExistsOnLDAP' . $uid; |
|
930 | + $cacheKey = 'userExistsOnLDAP'.$uid; |
|
931 | 931 | $userExists = $this->access->connection->getFromCache($cacheKey); |
932 | 932 | if ($userExists === false) { |
933 | 933 | break; |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | |
954 | 954 | $groupUsers = array_unique(array_merge($groupUsers, $primaryUsers, $posixGroupUsers)); |
955 | 955 | natsort($groupUsers); |
956 | - $this->access->connection->writeToCache('usersInGroup-' . $gid . '-' . $search, $groupUsers); |
|
956 | + $this->access->connection->writeToCache('usersInGroup-'.$gid.'-'.$search, $groupUsers); |
|
957 | 957 | $groupUsers = array_slice($groupUsers, $offset, $limit); |
958 | 958 | |
959 | 959 | $this->access->connection->writeToCache($cacheKey, $groupUsers); |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | return $this->groupPluginManager->countUsersInGroup($gid, $search); |
976 | 976 | } |
977 | 977 | |
978 | - $cacheKey = 'countUsersInGroup-' . $gid . '-' . $search; |
|
978 | + $cacheKey = 'countUsersInGroup-'.$gid.'-'.$search; |
|
979 | 979 | if (!$this->enabled || !$this->groupExists($gid)) { |
980 | 980 | return false; |
981 | 981 | } |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | if (!$this->enabled) { |
1074 | 1074 | return []; |
1075 | 1075 | } |
1076 | - $cacheKey = 'getGroups-' . $search . '-' . $limit . '-' . $offset; |
|
1076 | + $cacheKey = 'getGroups-'.$search.'-'.$limit.'-'.$offset; |
|
1077 | 1077 | |
1078 | 1078 | //Check cache before driving unnecessary searches |
1079 | 1079 | $ldap_groups = $this->access->connection->getFromCache($cacheKey); |
@@ -1108,31 +1108,31 @@ discard block |
||
1108 | 1108 | * @throws ServerNotAvailableException |
1109 | 1109 | */ |
1110 | 1110 | public function groupExists($gid) { |
1111 | - $groupExists = $this->access->connection->getFromCache('groupExists' . $gid); |
|
1111 | + $groupExists = $this->access->connection->getFromCache('groupExists'.$gid); |
|
1112 | 1112 | if (!is_null($groupExists)) { |
1113 | - return (bool)$groupExists; |
|
1113 | + return (bool) $groupExists; |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | //getting dn, if false the group does not exist. If dn, it may be mapped |
1117 | 1117 | //only, requires more checking. |
1118 | 1118 | $dn = $this->access->groupname2dn($gid); |
1119 | 1119 | if (!$dn) { |
1120 | - $this->access->connection->writeToCache('groupExists' . $gid, false); |
|
1120 | + $this->access->connection->writeToCache('groupExists'.$gid, false); |
|
1121 | 1121 | return false; |
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | if (!$this->access->isDNPartOfBase($dn, $this->access->connection->ldapBaseGroups)) { |
1125 | - $this->access->connection->writeToCache('groupExists' . $gid, false); |
|
1125 | + $this->access->connection->writeToCache('groupExists'.$gid, false); |
|
1126 | 1126 | return false; |
1127 | 1127 | } |
1128 | 1128 | |
1129 | 1129 | //if group really still exists, we will be able to read its objectClass |
1130 | 1130 | if (!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapGroupFilter))) { |
1131 | - $this->access->connection->writeToCache('groupExists' . $gid, false); |
|
1131 | + $this->access->connection->writeToCache('groupExists'.$gid, false); |
|
1132 | 1132 | return false; |
1133 | 1133 | } |
1134 | 1134 | |
1135 | - $this->access->connection->writeToCache('groupExists' . $gid, true); |
|
1135 | + $this->access->connection->writeToCache('groupExists'.$gid, true); |
|
1136 | 1136 | return true; |
1137 | 1137 | } |
1138 | 1138 | |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | * compared with GroupInterface::CREATE_GROUP etc. |
1166 | 1166 | */ |
1167 | 1167 | public function implementsActions($actions) { |
1168 | - return (bool)((GroupInterface::COUNT_USERS | |
|
1168 | + return (bool) ((GroupInterface::COUNT_USERS | |
|
1169 | 1169 | $this->groupPluginManager->getImplementedActions()) & $actions); |
1170 | 1170 | } |
1171 | 1171 | |
@@ -1219,7 +1219,7 @@ discard block |
||
1219 | 1219 | if ($ret = $this->groupPluginManager->deleteGroup($gid)) { |
1220 | 1220 | #delete group in nextcloud internal db |
1221 | 1221 | $this->access->getGroupMapper()->unmap($gid); |
1222 | - $this->access->connection->writeToCache("groupExists" . $gid, false); |
|
1222 | + $this->access->connection->writeToCache("groupExists".$gid, false); |
|
1223 | 1223 | } |
1224 | 1224 | return $ret; |
1225 | 1225 | } |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | return $this->groupPluginManager->getDisplayName($gid); |
1301 | 1301 | } |
1302 | 1302 | |
1303 | - $cacheKey = 'group_getDisplayName' . $gid; |
|
1303 | + $cacheKey = 'group_getDisplayName'.$gid; |
|
1304 | 1304 | if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
1305 | 1305 | return $displayName; |
1306 | 1306 | } |