Skip to content

Commit 39cd429

Browse files
committed
rename "arrays" to "attributes", make attribute getters consistent
1 parent 3d7f3b3 commit 39cd429

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

resources/lib/UnityLDAP.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -257,20 +257,20 @@ public function getAllUsers($UnitySQL, $UnityMailer, $UnityRedis, $UnityWebhook,
257257
return $out;
258258
}
259259

260-
public function getAllUsersArrays($attributes = [])
260+
public function getAllUsersAttributes($attributes = [])
261261
{
262-
$include_uids = $this->getAllUsersUIDs();
263-
$user_arrays = $this->baseOU->getChildrenArray(
262+
$include_uids = $this->getAllUsersAttributes();
263+
$user_attributes = $this->baseOU->getChildrenArray(
264264
$attributes,
265265
true, // recursive
266266
"objectClass=posixAccount"
267267
);
268-
foreach ($user_arrays as $i => $array) {
269-
if (!in_array($array["uid"][0], $include_uids)) {
270-
unset($user_arrays[$i]);
268+
foreach ($user_attributes as $i => $attributes) {
269+
if (!in_array($attributes["uid"][0], $include_uids)) {
270+
unset($user_attributes[$i]);
271271
}
272272
}
273-
return $user_arrays;
273+
return $user_attributes;
274274
}
275275

276276
public function getAllPIGroups($UnitySQL, $UnityMailer, $UnityRedis, $UnityWebhook, $ignorecache = false)
@@ -305,9 +305,9 @@ public function getAllPIGroups($UnitySQL, $UnityMailer, $UnityRedis, $UnityWebho
305305
return $out;
306306
}
307307

308-
public function getAllPIGroupsArrays()
308+
public function getAllPIGroupsAttributes($attributes = [])
309309
{
310-
return $this->pi_groupOU->getChildrenArray([], true);
310+
return $this->pi_groupOU->getChildrenArray($attributes);
311311
}
312312

313313
public function getPIGroupGIDsWithMemberUID($uid)
@@ -322,7 +322,7 @@ public function getPIGroupGIDsWithMemberUID($uid)
322322
);
323323
}
324324

325-
public function getAllPIGroupOwnerArrays($attributes = [])
325+
public function getAllPIGroupOwnerAttributes($attributes = [])
326326
{
327327
// get the PI groups, filter for just the GIDs, then map the GIDs to owner UIDs
328328
$owner_uids = array_map(
@@ -332,13 +332,13 @@ public function getAllPIGroupOwnerArrays($attributes = [])
332332
$this->pi_groupOU->getChildrenArray(["cn"]),
333333
),
334334
);
335-
$owner_arrays = $this->getAllUsersArrays($attributes);
336-
foreach ($owner_arrays as $i => $array) {
337-
if (!in_array($array["uid"][0], $owner_uids)) {
338-
unset($owner_arrays[$i]);
335+
$owner_attributes = $this->getAllUsersAttributes($attributes);
336+
foreach ($owner_attributes as $i => $attributes) {
337+
if (!in_array($attributes["uid"][0], $owner_uids)) {
338+
unset($owner_attributes[$i]);
339339
}
340340
}
341-
return $owner_arrays;
341+
return $owner_attributes;
342342
}
343343

344344
/** Returns an assosiative array where keys are UIDs and values are arrays of PI GIDs */
@@ -348,7 +348,7 @@ public function getAllUID2PIGIDs()
348348
$uids = $this->getAllUsersUIDs();
349349
$uid2pigids = array_combine($uids, array_fill(0, count($uids), []));
350350
// for each PI group, append that GID to the member list for each of its member UIDs
351-
foreach ($this->getAllPIGroupsArrays() as $array) {
351+
foreach ($this->getAllPIGroupsAttributes(["cn", "memberuid"]) as $array) {
352352
$gid = $array["cn"][0];
353353
foreach ($array["memberuid"] as $uid) {
354354
array_push($uid2pigids[$uid], $gid);
@@ -388,9 +388,9 @@ public function getAllOrgGroups($UnitySQL, $UnityMailer, $UnityRedis, $UnityWebh
388388
return $out;
389389
}
390390

391-
public function getAllOrgGroupsArrays()
391+
public function getAllOrgGroupsAttributes($attributes = [])
392392
{
393-
return $this->org_groupOU->getChildrenArray([], true);
393+
return $this->org_groupOU->getChildrenArray($attributes, true);
394394
}
395395

396396
public function getUserEntry($uid)

webroot/admin/pi-mgmt.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@
108108
</tr>
109109

110110
<?php
111-
$owner_arrays = $LDAP->getAllPIGroupOwnerArrays(["uid", "gecos", "mail"]);
112-
usort($owner_arrays, fn($a, $b) => strcmp($a["uid"][0], $b["uid"][0]));
113-
foreach ($owner_arrays as $array) {
111+
$owner_attributes = $LDAP->getAllPIGroupOwnerAttributes(["uid", "gecos", "mail"]);
112+
usort($owner_attributes, fn($a, $b) => strcmp($a["uid"][0], $b["uid"][0]));
113+
foreach ($owner_attributes as $attributes) {
114114
echo "<tr class='expandable'>";
115-
echo "<td><button class='btnExpand'>&#9654;</button>" . $array["gecos"][0] . "</td>";
116-
echo "<td>" . UnityGroup::getPIUIDfromUID($array["uid"][0]) . "</td>";
117-
echo "<td><a href='mailto:" . $array["mail"][0] . "'>" . $array["mail"][0] . "</a></td>";
115+
echo "<td><button class='btnExpand'>&#9654;</button>" . $attributes["gecos"][0] . "</td>";
116+
echo "<td>" . UnityGroup::getPIUIDfromUID($attributes["uid"][0]) . "</td>";
117+
echo "<td><a href='mailto:" . $attributes["mail"][0] . "'>" . $attributes["mail"][0] . "</a></td>";
118118
echo "</tr>";
119119
}
120120
?>

webroot/admin/user-mgmt.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@
3838

3939
<?php
4040
$UID2PIGIDs = $LDAP->getAllUID2PIGIDs();
41-
$user_arrays = $LDAP->getAllUsersArrays(["uid", "gecos", "o", "mail"]);
42-
usort($user_arrays, fn ($a, $b) => strcmp($a["uid"][0], $b["uid"][0]));
43-
foreach ($user_arrays as $array) {
44-
$uid = $array["uid"][0];
41+
$user_attributes = $LDAP->getAllUsersAttributes(["uid", "gecos", "o", "mail"]);
42+
usort($user_attributes, fn ($a, $b) => strcmp($a["uid"][0], $b["uid"][0]));
43+
foreach ($user_attributes as $attributes) {
44+
$uid = $attributes["uid"][0];
4545
if ($SQL->accDeletionRequestExists($uid)) {
4646
echo "<tr style='color:grey; font-style: italic'>";
4747
} else {
4848
echo "<tr>";
4949
}
50-
echo "<td>" . $array["gecos"][0] . "</td>";
50+
echo "<td>" . $attributes["gecos"][0] . "</td>";
5151
echo "<td>" . $uid . "</td>";
52-
echo "<td>" . $array["o"][0] . "</td>";
53-
echo "<td><a href='mailto:" . $array["mail"][0] . "'>" . $array["mail"][0] . "</a></td>";
52+
echo "<td>" . $attributes["o"][0] . "</td>";
53+
echo "<td><a href='mailto:" . $attributes["mail"][0] . "'>" . $attributes["mail"][0] . "</a></td>";
5454
echo "<td>";
5555
foreach ($UID2PIGIDs[$uid] as $gid) {
5656
echo "<p>$gid</p>";

0 commit comments

Comments
 (0)