Skip to content

Commit 4297feb

Browse files
authored
replace getAllPIGroupOwnerAttributes with (getAllPIGroupOwnerGIDs + getUsersAttributes) (#435)
1 parent 58a0fe0 commit 4297feb

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

resources/lib/UnityLDAP.php

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -256,33 +256,12 @@ public function getPIGroupGIDsWithMemberUID(string $uid): array
256256
);
257257
}
258258

259-
public function getAllPIGroupOwnerAttributes(
260-
array $attributes,
261-
array $default_values = [],
262-
): array {
263-
// get the PI groups, filter for just the GIDs, then map the GIDs to owner UIDs
264-
$owner_uids = array_map(
265-
fn($x) => UnityGroup::GID2OwnerUID($x),
266-
array_map(fn($x) => $x["cn"][0], $this->pi_groupOU->getChildrenArrayStrict(["cn"])),
267-
);
268-
$owner_attributes = $this->getQualifiedUsersAttributes($attributes, $default_values);
269-
foreach ($owner_attributes as $i => $attributes) {
270-
if (!in_array($attributes["uid"][0], $owner_uids)) {
271-
unset($owner_attributes[$i]);
272-
}
273-
}
274-
$owner_attributes = array_values($owner_attributes); // reindex
275-
$owners_not_found = array_diff(
276-
$owner_uids,
277-
array_map(fn($x) => $x["uid"][0], $owner_attributes),
259+
public function getAllPIGroupOwnerUIDs(): array
260+
{
261+
return array_map(
262+
fn($x) => UnityGroup::GID2OwnerUID($x["cn"][0]),
263+
$this->pi_groupOU->getChildrenArrayStrict(["cn"]),
278264
);
279-
if (count($owners_not_found) > 0) {
280-
UnityHTTPD::errorLog(
281-
"warning",
282-
"PI group owners not found: " . \jsonEncode($owners_not_found) . "\n",
283-
);
284-
}
285-
return $owner_attributes;
286265
}
287266

288267
/**

webroot/admin/pi-mgmt.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ class="filterSearch"
115115
</tr>
116116

117117
<?php
118-
$owner_attributes = $LDAP->getAllPIGroupOwnerAttributes(
118+
$owner_uids = $LDAP->getAllPIGroupOwnerUIDs();
119+
$owner_attributes = $LDAP->getUsersAttributes(
120+
$owner_uids,
119121
["uid", "gecos", "mail"],
120122
default_values: ["gecos" => "(not found)", "mail" => "(not found)"]
121123
);

0 commit comments

Comments
 (0)