Packet-Fence/admin/configuration/role_function.php
2025-06-28 06:23:17 +05:30

23 lines
1.1 KiB
PHP

<?php
function displayRoles($roles, $parentId = '0', $level = 0) {
foreach ($roles as $role) {
if ($role['parent_id'] == $parentId || ($parentId == '0' && $role['parent_id'] == '-')) {
$rowClass = $level > 0 ? 'child' : 'parent';
$indentClass = $level > 0 ? 'indent' : '';
echo "<tr class='{$rowClass}'>";
echo "<td class='{$indentClass}' style='padding-left: " . ($level * 30) . "px;'>" . htmlspecialchars($role['id']) . "</td>";
echo "<td>" . htmlspecialchars($role['notes']) . "</td>";
echo "<td>" . htmlspecialchars($role['parent_id']) . "</td>";
echo "<td>" . htmlspecialchars($role['max_nodes_per_pid']) . "</td>";
echo "<td><button class='btn_modify' data-pid='" . htmlspecialchars($role['id']) . "'>Modify</button></td>";
echo "<td><button class='btn_delete' data-pid='" . htmlspecialchars($role['id']) . "'>Delete</button></td>";
echo "</tr>";
// Recursive call to display child roles
displayRoles($roles, $role['id'], $level + 1);
}
}
}
?>