@@ -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; |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $seen[$dnGroup] = 1; |
| 250 | 250 | $members = $this->access->readAttribute($dnGroup, $this->access->connection->ldapGroupMemberAssocAttr); |
| 251 | 251 | if (is_array($members)) { |
| 252 | - $fetcher = function ($memberDN, &$seen) { |
|
| 252 | + $fetcher = function($memberDN, &$seen) { |
|
| 253 | 253 | return $this->_groupMembers($memberDN, $seen); |
| 254 | 254 | }; |
| 255 | 255 | $allMembers = $this->walkNestedGroups($dnGroup, $fetcher, $members); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | return []; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - $fetcher = function ($groupDN) { |
|
| 273 | + $fetcher = function($groupDN) { |
|
| 274 | 274 | if (isset($this->cachedNestedGroups[$groupDN])) { |
| 275 | 275 | $nestedGroups = $this->cachedNestedGroups[$groupDN]; |
| 276 | 276 | } else { |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | private function walkNestedGroups(string $dn, Closure $fetcher, array $list): array { |
| 291 | - $nesting = (int)$this->access->connection->ldapNestedGroups; |
|
| 291 | + $nesting = (int) $this->access->connection->ldapNestedGroups; |
|
| 292 | 292 | // depending on the input, we either have a list of DNs or a list of LDAP records |
| 293 | 293 | // also, the output expects either DNs or records. Testing the first element should suffice. |
| 294 | 294 | $recordMode = is_array($list) && isset($list[0]) && is_array($list[0]) && isset($list[0]['dn'][0]); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | if ($nesting !== 1) { |
| 297 | 297 | if ($recordMode) { |
| 298 | 298 | // the keys are numeric, but should hold the DN |
| 299 | - return array_reduce($list, function ($transformed, $record) use ($dn) { |
|
| 299 | + return array_reduce($list, function($transformed, $record) use ($dn) { |
|
| 300 | 300 | if ($record['dn'][0] != $dn) { |
| 301 | 301 | $transformed[$record['dn'][0]] = $record; |
| 302 | 302 | } |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @throws ServerNotAvailableException |
| 330 | 330 | */ |
| 331 | 331 | public function gidNumber2Name(string $gid, string $dn) { |
| 332 | - $cacheKey = 'gidNumberToName' . $gid; |
|
| 332 | + $cacheKey = 'gidNumberToName'.$gid; |
|
| 333 | 333 | $groupName = $this->access->connection->getFromCache($cacheKey); |
| 334 | 334 | if (!is_null($groupName) && isset($groupName)) { |
| 335 | 335 | return $groupName; |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | $filter = $this->access->combineFilterWithAnd([ |
| 340 | 340 | $this->access->connection->ldapGroupFilter, |
| 341 | 341 | 'objectClass=posixGroup', |
| 342 | - $this->access->connection->ldapGidNumber . '=' . $gid |
|
| 342 | + $this->access->connection->ldapGidNumber.'='.$gid |
|
| 343 | 343 | ]); |
| 344 | 344 | return $this->getNameOfGroup($filter, $cacheKey) ?? false; |
| 345 | 345 | } |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | if ($search !== '') { |
| 420 | 420 | $filterParts[] = $this->access->getFilterPartForUserSearch($search); |
| 421 | 421 | } |
| 422 | - $filterParts[] = $this->access->connection->ldapGidNumber . '=' . $groupID; |
|
| 422 | + $filterParts[] = $this->access->connection->ldapGidNumber.'='.$groupID; |
|
| 423 | 423 | |
| 424 | 424 | return $this->access->combineFilterWithAnd($filterParts); |
| 425 | 425 | } |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | //we need to get the DN from LDAP |
| 490 | 490 | $filter = $this->access->combineFilterWithAnd([ |
| 491 | 491 | $this->access->connection->ldapGroupFilter, |
| 492 | - 'objectsid=' . $domainObjectSid . '-' . $gid |
|
| 492 | + 'objectsid='.$domainObjectSid.'-'.$gid |
|
| 493 | 493 | ]); |
| 494 | 494 | return $this->getNameOfGroup($filter, $cacheKey) ?? false; |
| 495 | 495 | } |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | if ($search !== '') { |
| 547 | 547 | $filterParts[] = $this->access->getFilterPartForUserSearch($search); |
| 548 | 548 | } |
| 549 | - $filterParts[] = 'primaryGroupID=' . $groupID; |
|
| 549 | + $filterParts[] = 'primaryGroupID='.$groupID; |
|
| 550 | 550 | |
| 551 | 551 | return $this->access->combineFilterWithAnd($filterParts); |
| 552 | 552 | } |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | try { |
| 589 | 589 | $filter = $this->prepareFilterForUsersInPrimaryGroup($groupDN, $search); |
| 590 | 590 | $users = $this->access->countUsers($filter, ['dn'], $limit, $offset); |
| 591 | - return (int)$users; |
|
| 591 | + return (int) $users; |
|
| 592 | 592 | } catch (ServerNotAvailableException $e) { |
| 593 | 593 | throw $e; |
| 594 | 594 | } catch (Exception $e) { |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | if (!$this->enabled) { |
| 628 | 628 | return []; |
| 629 | 629 | } |
| 630 | - $cacheKey = 'getUserGroups' . $uid; |
|
| 630 | + $cacheKey = 'getUserGroups'.$uid; |
|
| 631 | 631 | $userGroups = $this->access->connection->getFromCache($cacheKey); |
| 632 | 632 | if (!is_null($userGroups)) { |
| 633 | 633 | return $userGroups; |
@@ -685,8 +685,8 @@ discard block |
||
| 685 | 685 | // if possible, read out membership via memberOf. It's far faster than |
| 686 | 686 | // performing a search, which still is a fallback later. |
| 687 | 687 | // memberof doesn't support memberuid, so skip it here. |
| 688 | - if ((int)$this->access->connection->hasMemberOfFilterSupport === 1 |
|
| 689 | - && (int)$this->access->connection->useMemberOfToDetectMembership === 1 |
|
| 688 | + if ((int) $this->access->connection->hasMemberOfFilterSupport === 1 |
|
| 689 | + && (int) $this->access->connection->useMemberOfToDetectMembership === 1 |
|
| 690 | 690 | && $this->ldapGroupMemberAssocAttr !== 'memberuid' |
| 691 | 691 | && $this->ldapGroupMemberAssocAttr !== 'zimbramailforwardingaddress') { |
| 692 | 692 | $groupDNs = $this->_getGroupDNsFromMemberOf($userDN); |
@@ -778,7 +778,7 @@ discard block |
||
| 778 | 778 | } |
| 779 | 779 | $allGroups = []; |
| 780 | 780 | $seen[$dn] = true; |
| 781 | - $filter = $this->access->connection->ldapGroupMemberAssocAttr . '=' . $dn; |
|
| 781 | + $filter = $this->access->connection->ldapGroupMemberAssocAttr.'='.$dn; |
|
| 782 | 782 | |
| 783 | 783 | if ($this->ldapGroupMemberAssocAttr === 'zimbramailforwardingaddress') { |
| 784 | 784 | //in this case the member entries are email addresses |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | $groups = $this->access->fetchListOfGroups($filter, |
| 789 | 789 | [strtolower($this->access->connection->ldapGroupMemberAssocAttr), $this->access->connection->ldapGroupDisplayName, 'dn']); |
| 790 | 790 | if (is_array($groups)) { |
| 791 | - $fetcher = function ($dn, &$seen) { |
|
| 791 | + $fetcher = function($dn, &$seen) { |
|
| 792 | 792 | if (is_array($dn) && isset($dn['dn'][0])) { |
| 793 | 793 | $dn = $dn['dn'][0]; |
| 794 | 794 | } |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | return []; |
| 825 | 825 | } |
| 826 | 826 | $search = $this->access->escapeFilterPart($search, true); |
| 827 | - $cacheKey = 'usersInGroup-' . $gid . '-' . $search . '-' . $limit . '-' . $offset; |
|
| 827 | + $cacheKey = 'usersInGroup-'.$gid.'-'.$search.'-'.$limit.'-'.$offset; |
|
| 828 | 828 | // check for cache of the exact query |
| 829 | 829 | $groupUsers = $this->access->connection->getFromCache($cacheKey); |
| 830 | 830 | if (!is_null($groupUsers)) { |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | $limit = null; |
| 836 | 836 | } |
| 837 | 837 | // check for cache of the query without limit and offset |
| 838 | - $groupUsers = $this->access->connection->getFromCache('usersInGroup-' . $gid . '-' . $search); |
|
| 838 | + $groupUsers = $this->access->connection->getFromCache('usersInGroup-'.$gid.'-'.$search); |
|
| 839 | 839 | if (!is_null($groupUsers)) { |
| 840 | 840 | $groupUsers = array_slice($groupUsers, $offset, $limit); |
| 841 | 841 | $this->access->connection->writeToCache($cacheKey, $groupUsers); |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | break; |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - $cacheKey = 'userExistsOnLDAP' . $uid; |
|
| 892 | + $cacheKey = 'userExistsOnLDAP'.$uid; |
|
| 893 | 893 | $userExists = $this->access->connection->getFromCache($cacheKey); |
| 894 | 894 | if ($userExists === false) { |
| 895 | 895 | break; |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | |
| 916 | 916 | $groupUsers = array_unique(array_merge($groupUsers, $primaryUsers, $posixGroupUsers)); |
| 917 | 917 | natsort($groupUsers); |
| 918 | - $this->access->connection->writeToCache('usersInGroup-' . $gid . '-' . $search, $groupUsers); |
|
| 918 | + $this->access->connection->writeToCache('usersInGroup-'.$gid.'-'.$search, $groupUsers); |
|
| 919 | 919 | $groupUsers = array_slice($groupUsers, $offset, $limit); |
| 920 | 920 | |
| 921 | 921 | $this->access->connection->writeToCache($cacheKey, $groupUsers); |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | return $this->groupPluginManager->countUsersInGroup($gid, $search); |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - $cacheKey = 'countUsersInGroup-' . $gid . '-' . $search; |
|
| 940 | + $cacheKey = 'countUsersInGroup-'.$gid.'-'.$search; |
|
| 941 | 941 | if (!$this->enabled || !$this->groupExists($gid)) { |
| 942 | 942 | return false; |
| 943 | 943 | } |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | if (!$this->enabled) { |
| 1036 | 1036 | return []; |
| 1037 | 1037 | } |
| 1038 | - $cacheKey = 'getGroups-' . $search . '-' . $limit . '-' . $offset; |
|
| 1038 | + $cacheKey = 'getGroups-'.$search.'-'.$limit.'-'.$offset; |
|
| 1039 | 1039 | |
| 1040 | 1040 | //Check cache before driving unnecessary searches |
| 1041 | 1041 | $ldap_groups = $this->access->connection->getFromCache($cacheKey); |
@@ -1070,31 +1070,31 @@ discard block |
||
| 1070 | 1070 | * @throws ServerNotAvailableException |
| 1071 | 1071 | */ |
| 1072 | 1072 | public function groupExists($gid) { |
| 1073 | - $groupExists = $this->access->connection->getFromCache('groupExists' . $gid); |
|
| 1073 | + $groupExists = $this->access->connection->getFromCache('groupExists'.$gid); |
|
| 1074 | 1074 | if (!is_null($groupExists)) { |
| 1075 | - return (bool)$groupExists; |
|
| 1075 | + return (bool) $groupExists; |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | //getting dn, if false the group does not exist. If dn, it may be mapped |
| 1079 | 1079 | //only, requires more checking. |
| 1080 | 1080 | $dn = $this->access->groupname2dn($gid); |
| 1081 | 1081 | if (!$dn) { |
| 1082 | - $this->access->connection->writeToCache('groupExists' . $gid, false); |
|
| 1082 | + $this->access->connection->writeToCache('groupExists'.$gid, false); |
|
| 1083 | 1083 | return false; |
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | if (!$this->access->isDNPartOfBase($dn, $this->access->connection->ldapBaseGroups)) { |
| 1087 | - $this->access->connection->writeToCache('groupExists' . $gid, false); |
|
| 1087 | + $this->access->connection->writeToCache('groupExists'.$gid, false); |
|
| 1088 | 1088 | return false; |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | 1091 | //if group really still exists, we will be able to read its objectClass |
| 1092 | 1092 | if (!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapGroupFilter))) { |
| 1093 | - $this->access->connection->writeToCache('groupExists' . $gid, false); |
|
| 1093 | + $this->access->connection->writeToCache('groupExists'.$gid, false); |
|
| 1094 | 1094 | return false; |
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | - $this->access->connection->writeToCache('groupExists' . $gid, true); |
|
| 1097 | + $this->access->connection->writeToCache('groupExists'.$gid, true); |
|
| 1098 | 1098 | return true; |
| 1099 | 1099 | } |
| 1100 | 1100 | |
@@ -1127,7 +1127,7 @@ discard block |
||
| 1127 | 1127 | * compared with GroupInterface::CREATE_GROUP etc. |
| 1128 | 1128 | */ |
| 1129 | 1129 | public function implementsActions($actions) { |
| 1130 | - return (bool)((GroupInterface::COUNT_USERS | |
|
| 1130 | + return (bool) ((GroupInterface::COUNT_USERS | |
|
| 1131 | 1131 | $this->groupPluginManager->getImplementedActions()) & $actions); |
| 1132 | 1132 | } |
| 1133 | 1133 | |
@@ -1181,7 +1181,7 @@ discard block |
||
| 1181 | 1181 | if ($ret = $this->groupPluginManager->deleteGroup($gid)) { |
| 1182 | 1182 | #delete group in nextcloud internal db |
| 1183 | 1183 | $this->access->getGroupMapper()->unmap($gid); |
| 1184 | - $this->access->connection->writeToCache("groupExists" . $gid, false); |
|
| 1184 | + $this->access->connection->writeToCache("groupExists".$gid, false); |
|
| 1185 | 1185 | } |
| 1186 | 1186 | return $ret; |
| 1187 | 1187 | } |
@@ -1262,7 +1262,7 @@ discard block |
||
| 1262 | 1262 | return $this->groupPluginManager->getDisplayName($gid); |
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | - $cacheKey = 'group_getDisplayName' . $gid; |
|
| 1265 | + $cacheKey = 'group_getDisplayName'.$gid; |
|
| 1266 | 1266 | if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
| 1267 | 1267 | return $displayName; |
| 1268 | 1268 | } |