Skip to content

Commit 6ec3f3c

Browse files
committed
remove cache from pi-mgmt
1 parent 1e19673 commit 6ec3f3c

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

resources/lib/UnityLDAP.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,19 @@ public function getPIGroupGIDsWithMemberUID($uid)
321321
);
322322
}
323323

324+
public function getAllPIGroupOwnerEntries()
325+
{
326+
$gids = array_map(fn($x) => $x["cn"][0], $this->pi_groupOU->getChildrenArray(["cn"]));
327+
$owner_uids = array_map(fn($x) => UnityGroup::getUIDFromPIUID($x), $gids);
328+
$owner_entries = $this->getAllUsersEntries();
329+
foreach ($owner_entries as $i => $entry) {
330+
if (!in_array($entry["uid"][0], $owner_uids)) {
331+
unset($owner_entries[$i]);
332+
}
333+
}
334+
return $owner_entries;
335+
}
336+
324337
/** Returns an assosiative array where keys are UIDs and values are lists of PI GIDs */
325338
public function getAllUID2PIGIDs()
326339
{

webroot/admin/pi-mgmt.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,14 @@
109109
<td>Actions</td>
110110
</tr>
111111

112-
<?php
113-
$accounts = $LDAP->getAllPIGroups($SQL, $MAILER, $REDIS, $WEBHOOK);
114-
115-
usort($accounts, function ($a, $b) {
116-
return strcmp($a->getPIUID(), $b->getPIUID());
117-
});
118-
119-
foreach ($accounts as $pi_group) {
120-
$pi_user = $pi_group->getOwner();
121-
112+
<?php
113+
$owner_entries = $LDAP->getAllPIGroupOwnerEntries();
114+
usort($owner_entries, fn($a, $b) => strcmp($a["cn"][0], $b["cn"][0]));
115+
foreach ($owner_entries as $entry) {
122116
echo "<tr class='expandable'>";
123-
echo "<td><button class='btnExpand'>&#9654;</button>" . $pi_user->getFirstname() .
124-
" " . $pi_user->getLastname() . "</td>";
125-
echo "<td>" . $pi_group->getPIUID() . "</td>";
126-
echo "<td><a href='mailto:" . $pi_user->getMail() . "'>" . $pi_user->getMail() . "</a></td>";
117+
echo "<td><button class='btnExpand'>&#9654;</button>" . $entry["gecos"][0] . "</td>";
118+
echo "<td>" . UnityGroup::getPIUIDfromUID($entry["uid"][0]) . "</td>";
119+
echo "<td><a href='mailto:" . $entry["mail"][0] . "'>" . $entry["mail"][0] . "</a></td>";
127120
echo "</tr>";
128121
}
129122
?>

0 commit comments

Comments
 (0)