@@ -100,10 +100,10 @@ discard block |
||
| 100 | 100 | if (!$this->enabled) { |
| 101 | 101 | return false; |
| 102 | 102 | } |
| 103 | - $cacheKey = 'inGroup' . $uid . ':' . $gid; |
|
| 103 | + $cacheKey = 'inGroup'.$uid.':'.$gid; |
|
| 104 | 104 | $inGroup = $this->access->connection->getFromCache($cacheKey); |
| 105 | 105 | if (!is_null($inGroup)) { |
| 106 | - return (bool)$inGroup; |
|
| 106 | + return (bool) $inGroup; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $userDN = $this->access->username2dn($uid); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | return in_array($userDN, $this->cachedGroupMembers[$gid]); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $cacheKeyMembers = 'inGroup-members:' . $gid; |
|
| 115 | + $cacheKeyMembers = 'inGroup-members:'.$gid; |
|
| 116 | 116 | $members = $this->access->connection->getFromCache($cacheKeyMembers); |
| 117 | 117 | if (!is_null($members)) { |
| 118 | 118 | $this->cachedGroupMembers[$gid] = $members; |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | return []; |
| 252 | 252 | } |
| 253 | 253 | // used extensively in cron job, caching makes sense for nested groups |
| 254 | - $cacheKey = '_groupMembers' . $dnGroup; |
|
| 254 | + $cacheKey = '_groupMembers'.$dnGroup; |
|
| 255 | 255 | $groupMembers = $this->access->connection->getFromCache($cacheKey); |
| 256 | 256 | if ($groupMembers !== null) { |
| 257 | 257 | return $groupMembers; |
@@ -266,14 +266,14 @@ discard block |
||
| 266 | 266 | // compatibility hack with servers supporting :1.2.840.113556.1.4.1941:, and others) |
| 267 | 267 | $filter = $this->access->combineFilterWithAnd([ |
| 268 | 268 | $this->access->connection->ldapUserFilter, |
| 269 | - $this->access->connection->ldapUserDisplayName . '=*', |
|
| 270 | - 'memberof:1.2.840.113556.1.4.1941:=' . $dnGroup |
|
| 269 | + $this->access->connection->ldapUserDisplayName.'=*', |
|
| 270 | + 'memberof:1.2.840.113556.1.4.1941:='.$dnGroup |
|
| 271 | 271 | ]); |
| 272 | 272 | $memberRecords = $this->access->fetchListOfUsers( |
| 273 | 273 | $filter, |
| 274 | 274 | $this->access->userManager->getAttributes(true) |
| 275 | 275 | ); |
| 276 | - $result = array_reduce($memberRecords, function ($carry, $record) { |
|
| 276 | + $result = array_reduce($memberRecords, function($carry, $record) { |
|
| 277 | 277 | $carry[] = $record['dn'][0]; |
| 278 | 278 | return $carry; |
| 279 | 279 | }, []); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $seen[$dnGroup] = 1; |
| 291 | 291 | $members = $this->access->readAttribute($dnGroup, $this->access->connection->ldapGroupMemberAssocAttr); |
| 292 | 292 | if (is_array($members)) { |
| 293 | - $fetcher = function ($memberDN, &$seen) { |
|
| 293 | + $fetcher = function($memberDN, &$seen) { |
|
| 294 | 294 | return $this->_groupMembers($memberDN, $seen); |
| 295 | 295 | }; |
| 296 | 296 | $allMembers = $this->walkNestedGroups($dnGroup, $fetcher, $members); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | return []; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - $fetcher = function ($groupDN) { |
|
| 321 | + $fetcher = function($groupDN) { |
|
| 322 | 322 | if (isset($this->cachedNestedGroups[$groupDN])) { |
| 323 | 323 | $nestedGroups = $this->cachedNestedGroups[$groupDN]; |
| 324 | 324 | } else { |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | private function walkNestedGroups(string $dn, Closure $fetcher, array $list): array { |
| 339 | - $nesting = (int)$this->access->connection->ldapNestedGroups; |
|
| 339 | + $nesting = (int) $this->access->connection->ldapNestedGroups; |
|
| 340 | 340 | // depending on the input, we either have a list of DNs or a list of LDAP records |
| 341 | 341 | // also, the output expects either DNs or records. Testing the first element should suffice. |
| 342 | 342 | $recordMode = is_array($list) && isset($list[0]) && is_array($list[0]) && isset($list[0]['dn'][0]); |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | if ($nesting !== 1) { |
| 345 | 345 | if ($recordMode) { |
| 346 | 346 | // the keys are numeric, but should hold the DN |
| 347 | - return array_reduce($list, function ($transformed, $record) use ($dn) { |
|
| 347 | + return array_reduce($list, function($transformed, $record) use ($dn) { |
|
| 348 | 348 | if ($record['dn'][0] != $dn) { |
| 349 | 349 | $transformed[$record['dn'][0]] = $record; |
| 350 | 350 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | * @throws ServerNotAvailableException |
| 378 | 378 | */ |
| 379 | 379 | public function gidNumber2Name(string $gid, string $dn) { |
| 380 | - $cacheKey = 'gidNumberToName' . $gid; |
|
| 380 | + $cacheKey = 'gidNumberToName'.$gid; |
|
| 381 | 381 | $groupName = $this->access->connection->getFromCache($cacheKey); |
| 382 | 382 | if (!is_null($groupName) && isset($groupName)) { |
| 383 | 383 | return $groupName; |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | $filter = $this->access->combineFilterWithAnd([ |
| 388 | 388 | $this->access->connection->ldapGroupFilter, |
| 389 | 389 | 'objectClass=posixGroup', |
| 390 | - $this->access->connection->ldapGidNumber . '=' . $gid |
|
| 390 | + $this->access->connection->ldapGidNumber.'='.$gid |
|
| 391 | 391 | ]); |
| 392 | 392 | return $this->getNameOfGroup($filter, $cacheKey) ?? false; |
| 393 | 393 | } |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | if ($search !== '') { |
| 468 | 468 | $filterParts[] = $this->access->getFilterPartForUserSearch($search); |
| 469 | 469 | } |
| 470 | - $filterParts[] = $this->access->connection->ldapGidNumber . '=' . $groupID; |
|
| 470 | + $filterParts[] = $this->access->connection->ldapGidNumber.'='.$groupID; |
|
| 471 | 471 | |
| 472 | 472 | return $this->access->combineFilterWithAnd($filterParts); |
| 473 | 473 | } |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | //we need to get the DN from LDAP |
| 538 | 538 | $filter = $this->access->combineFilterWithAnd([ |
| 539 | 539 | $this->access->connection->ldapGroupFilter, |
| 540 | - 'objectsid=' . $domainObjectSid . '-' . $gid |
|
| 540 | + 'objectsid='.$domainObjectSid.'-'.$gid |
|
| 541 | 541 | ]); |
| 542 | 542 | return $this->getNameOfGroup($filter, $cacheKey) ?? false; |
| 543 | 543 | } |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | if ($search !== '') { |
| 595 | 595 | $filterParts[] = $this->access->getFilterPartForUserSearch($search); |
| 596 | 596 | } |
| 597 | - $filterParts[] = 'primaryGroupID=' . $groupID; |
|
| 597 | + $filterParts[] = 'primaryGroupID='.$groupID; |
|
| 598 | 598 | |
| 599 | 599 | return $this->access->combineFilterWithAnd($filterParts); |
| 600 | 600 | } |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | try { |
| 637 | 637 | $filter = $this->prepareFilterForUsersInPrimaryGroup($groupDN, $search); |
| 638 | 638 | $users = $this->access->countUsers($filter, ['dn'], $limit, $offset); |
| 639 | - return (int)$users; |
|
| 639 | + return (int) $users; |
|
| 640 | 640 | } catch (ServerNotAvailableException $e) { |
| 641 | 641 | throw $e; |
| 642 | 642 | } catch (Exception $e) { |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | if (!$this->enabled) { |
| 676 | 676 | return []; |
| 677 | 677 | } |
| 678 | - $cacheKey = 'getUserGroups' . $uid; |
|
| 678 | + $cacheKey = 'getUserGroups'.$uid; |
|
| 679 | 679 | $userGroups = $this->access->connection->getFromCache($cacheKey); |
| 680 | 680 | if (!is_null($userGroups)) { |
| 681 | 681 | return $userGroups; |
@@ -733,8 +733,8 @@ discard block |
||
| 733 | 733 | // if possible, read out membership via memberOf. It's far faster than |
| 734 | 734 | // performing a search, which still is a fallback later. |
| 735 | 735 | // memberof doesn't support memberuid, so skip it here. |
| 736 | - if ((int)$this->access->connection->hasMemberOfFilterSupport === 1 |
|
| 737 | - && (int)$this->access->connection->useMemberOfToDetectMembership === 1 |
|
| 736 | + if ((int) $this->access->connection->hasMemberOfFilterSupport === 1 |
|
| 737 | + && (int) $this->access->connection->useMemberOfToDetectMembership === 1 |
|
| 738 | 738 | && $this->ldapGroupMemberAssocAttr !== 'memberuid' |
| 739 | 739 | && $this->ldapGroupMemberAssocAttr !== 'zimbramailforwardingaddress') { |
| 740 | 740 | $groupDNs = $this->_getGroupDNsFromMemberOf($userDN); |
@@ -826,14 +826,14 @@ discard block |
||
| 826 | 826 | } |
| 827 | 827 | $allGroups = []; |
| 828 | 828 | $seen[$dn] = true; |
| 829 | - $filter = $this->access->connection->ldapGroupMemberAssocAttr . '=' . $dn; |
|
| 829 | + $filter = $this->access->connection->ldapGroupMemberAssocAttr.'='.$dn; |
|
| 830 | 830 | |
| 831 | 831 | if ($this->ldapGroupMemberAssocAttr === 'zimbramailforwardingaddress') { |
| 832 | 832 | //in this case the member entries are email addresses |
| 833 | 833 | $filter .= '@*'; |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | - $nesting = (int)$this->access->connection->ldapNestedGroups; |
|
| 836 | + $nesting = (int) $this->access->connection->ldapNestedGroups; |
|
| 837 | 837 | if ($nesting === 0) { |
| 838 | 838 | $filter = $this->access->combineFilterWithAnd([$filter, $this->access->connection->ldapGroupFilter]); |
| 839 | 839 | } |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | $groups = $this->access->fetchListOfGroups($filter, |
| 842 | 842 | [strtolower($this->access->connection->ldapGroupMemberAssocAttr), $this->access->connection->ldapGroupDisplayName, 'dn']); |
| 843 | 843 | if (is_array($groups)) { |
| 844 | - $fetcher = function ($dn, &$seen) { |
|
| 844 | + $fetcher = function($dn, &$seen) { |
|
| 845 | 845 | if (is_array($dn) && isset($dn['dn'][0])) { |
| 846 | 846 | $dn = $dn['dn'][0]; |
| 847 | 847 | } |
@@ -877,7 +877,7 @@ discard block |
||
| 877 | 877 | return []; |
| 878 | 878 | } |
| 879 | 879 | $search = $this->access->escapeFilterPart($search, true); |
| 880 | - $cacheKey = 'usersInGroup-' . $gid . '-' . $search . '-' . $limit . '-' . $offset; |
|
| 880 | + $cacheKey = 'usersInGroup-'.$gid.'-'.$search.'-'.$limit.'-'.$offset; |
|
| 881 | 881 | // check for cache of the exact query |
| 882 | 882 | $groupUsers = $this->access->connection->getFromCache($cacheKey); |
| 883 | 883 | if (!is_null($groupUsers)) { |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | $limit = null; |
| 889 | 889 | } |
| 890 | 890 | // check for cache of the query without limit and offset |
| 891 | - $groupUsers = $this->access->connection->getFromCache('usersInGroup-' . $gid . '-' . $search); |
|
| 891 | + $groupUsers = $this->access->connection->getFromCache('usersInGroup-'.$gid.'-'.$search); |
|
| 892 | 892 | if (!is_null($groupUsers)) { |
| 893 | 893 | $groupUsers = array_slice($groupUsers, $offset, $limit); |
| 894 | 894 | $this->access->connection->writeToCache($cacheKey, $groupUsers); |
@@ -943,7 +943,7 @@ discard block |
||
| 943 | 943 | break; |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | - $cacheKey = 'userExistsOnLDAP' . $uid; |
|
| 946 | + $cacheKey = 'userExistsOnLDAP'.$uid; |
|
| 947 | 947 | $userExists = $this->access->connection->getFromCache($cacheKey); |
| 948 | 948 | if ($userExists === false) { |
| 949 | 949 | break; |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | |
| 970 | 970 | $groupUsers = array_unique(array_merge($groupUsers, $primaryUsers, $posixGroupUsers)); |
| 971 | 971 | natsort($groupUsers); |
| 972 | - $this->access->connection->writeToCache('usersInGroup-' . $gid . '-' . $search, $groupUsers); |
|
| 972 | + $this->access->connection->writeToCache('usersInGroup-'.$gid.'-'.$search, $groupUsers); |
|
| 973 | 973 | $groupUsers = array_slice($groupUsers, $offset, $limit); |
| 974 | 974 | |
| 975 | 975 | $this->access->connection->writeToCache($cacheKey, $groupUsers); |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | return $this->groupPluginManager->countUsersInGroup($gid, $search); |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | - $cacheKey = 'countUsersInGroup-' . $gid . '-' . $search; |
|
| 994 | + $cacheKey = 'countUsersInGroup-'.$gid.'-'.$search; |
|
| 995 | 995 | if (!$this->enabled || !$this->groupExists($gid)) { |
| 996 | 996 | return false; |
| 997 | 997 | } |
@@ -1090,7 +1090,7 @@ discard block |
||
| 1090 | 1090 | return []; |
| 1091 | 1091 | } |
| 1092 | 1092 | $search = $this->access->escapeFilterPart($search, true); |
| 1093 | - $cacheKey = 'getGroups-' . $search . '-' . $limit . '-' . $offset; |
|
| 1093 | + $cacheKey = 'getGroups-'.$search.'-'.$limit.'-'.$offset; |
|
| 1094 | 1094 | |
| 1095 | 1095 | //Check cache before driving unnecessary searches |
| 1096 | 1096 | $ldap_groups = $this->access->connection->getFromCache($cacheKey); |
@@ -1125,31 +1125,31 @@ discard block |
||
| 1125 | 1125 | * @throws ServerNotAvailableException |
| 1126 | 1126 | */ |
| 1127 | 1127 | public function groupExists($gid) { |
| 1128 | - $groupExists = $this->access->connection->getFromCache('groupExists' . $gid); |
|
| 1128 | + $groupExists = $this->access->connection->getFromCache('groupExists'.$gid); |
|
| 1129 | 1129 | if (!is_null($groupExists)) { |
| 1130 | - return (bool)$groupExists; |
|
| 1130 | + return (bool) $groupExists; |
|
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | 1133 | //getting dn, if false the group does not exist. If dn, it may be mapped |
| 1134 | 1134 | //only, requires more checking. |
| 1135 | 1135 | $dn = $this->access->groupname2dn($gid); |
| 1136 | 1136 | if (!$dn) { |
| 1137 | - $this->access->connection->writeToCache('groupExists' . $gid, false); |
|
| 1137 | + $this->access->connection->writeToCache('groupExists'.$gid, false); |
|
| 1138 | 1138 | return false; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | if (!$this->access->isDNPartOfBase($dn, $this->access->connection->ldapBaseGroups)) { |
| 1142 | - $this->access->connection->writeToCache('groupExists' . $gid, false); |
|
| 1142 | + $this->access->connection->writeToCache('groupExists'.$gid, false); |
|
| 1143 | 1143 | return false; |
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | 1146 | //if group really still exists, we will be able to read its objectClass |
| 1147 | 1147 | if (!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapGroupFilter))) { |
| 1148 | - $this->access->connection->writeToCache('groupExists' . $gid, false); |
|
| 1148 | + $this->access->connection->writeToCache('groupExists'.$gid, false); |
|
| 1149 | 1149 | return false; |
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | - $this->access->connection->writeToCache('groupExists' . $gid, true); |
|
| 1152 | + $this->access->connection->writeToCache('groupExists'.$gid, true); |
|
| 1153 | 1153 | return true; |
| 1154 | 1154 | } |
| 1155 | 1155 | |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | * compared with GroupInterface::CREATE_GROUP etc. |
| 1183 | 1183 | */ |
| 1184 | 1184 | public function implementsActions($actions) { |
| 1185 | - return (bool)((GroupInterface::COUNT_USERS | |
|
| 1185 | + return (bool) ((GroupInterface::COUNT_USERS | |
|
| 1186 | 1186 | $this->groupPluginManager->getImplementedActions()) & $actions); |
| 1187 | 1187 | } |
| 1188 | 1188 | |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | if ($ret = $this->groupPluginManager->deleteGroup($gid)) { |
| 1237 | 1237 | #delete group in nextcloud internal db |
| 1238 | 1238 | $this->access->getGroupMapper()->unmap($gid); |
| 1239 | - $this->access->connection->writeToCache("groupExists" . $gid, false); |
|
| 1239 | + $this->access->connection->writeToCache("groupExists".$gid, false); |
|
| 1240 | 1240 | } |
| 1241 | 1241 | return $ret; |
| 1242 | 1242 | } |
@@ -1317,7 +1317,7 @@ discard block |
||
| 1317 | 1317 | return $this->groupPluginManager->getDisplayName($gid); |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | - $cacheKey = 'group_getDisplayName' . $gid; |
|
| 1320 | + $cacheKey = 'group_getDisplayName'.$gid; |
|
| 1321 | 1321 | if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
| 1322 | 1322 | return $displayName; |
| 1323 | 1323 | } |