feat: delegation administration IS WORKING
This commit is contained in:
@@ -1,46 +1,49 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once __DIR__ . '/../controllers/controllerAdmin.php';
|
||||
|
||||
// Check if user is logged in and is admin
|
||||
if (!isset($_SESSION["login"]) || !$_SESSION["is_admin"]) {
|
||||
header("Location: ../index.php");
|
||||
header('Location: ../auth.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../controllers/controllerAdmin.php';
|
||||
// Récupérer les utilisateurs selon l'OU
|
||||
$users = listUsers();
|
||||
|
||||
echo "<h2>Gestion des utilisateurs</h2>";
|
||||
// Afficher le tableau des utilisateurs
|
||||
echo "<h1>Gestion des utilisateurs</h1>";
|
||||
|
||||
// Display users table
|
||||
echo "<table border='1'>
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<th>Email</th>
|
||||
<th>OU</th>
|
||||
<th>Actions</th>
|
||||
</tr>";
|
||||
|
||||
$users = listAllUsers();
|
||||
foreach ($users as $user) {
|
||||
$name = htmlspecialchars($user['cn'][0]);
|
||||
$email = htmlspecialchars($user['mail'][0] ?? 'N/A');
|
||||
$ou = htmlspecialchars($user['ou']);
|
||||
$dn = htmlspecialchars($user['distinguishedname'][0]);
|
||||
|
||||
echo "<tr>
|
||||
<td>$name</td>
|
||||
<td>$email</td>
|
||||
<td>$ou</td>
|
||||
<td>
|
||||
<form method='post' action='edit_user.php' style='display:inline;'>
|
||||
<input type='hidden' name='user_dn' value='$dn'>
|
||||
<input type='submit' value='Modifier'>
|
||||
</form>
|
||||
<form method='post' action='delete_user.php' style='display:inline;' onsubmit='return confirm(\"Confirmer la suppression ?\");'>
|
||||
<input type='hidden' name='user_dn' value='$dn'>
|
||||
<input type='submit' value='Supprimer'>
|
||||
</form>
|
||||
</td>
|
||||
</tr>";
|
||||
if (isset($_GET['ou'])) {
|
||||
echo "<h2>OU : " . htmlspecialchars(urldecode($_GET['ou'])) . "</h2>";
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
if (!empty($users)) {
|
||||
echo "<table border='1'>";
|
||||
echo "<tr>
|
||||
<th>Nom</th>
|
||||
<th>Prénom</th>
|
||||
<th>Email</th>
|
||||
<th>DN</th>
|
||||
<th>Actions</th>
|
||||
</tr>";
|
||||
|
||||
foreach ($users as $entry) {
|
||||
if (!is_array($entry)) continue;
|
||||
|
||||
echo "<tr>
|
||||
<td>" . ($entry['sn'][0] ?? '') . "</td>
|
||||
<td>" . ($entry['givenname'][0] ?? '') . "</td>
|
||||
<td>" . ($entry['mail'][0] ?? '') . "</td>
|
||||
<td>" . ($entry['distinguishedname'][0] ?? '') . "</td>
|
||||
<td>
|
||||
<a href='edit_user.php?dn=" . urlencode($entry['distinguishedname'][0]) . "'>Modifier</a>
|
||||
<a href='delete_user.php?dn=" . urlencode($entry['distinguishedname'][0]) . "' onclick='return confirm(\"Confirmer la suppression ?\")'>Supprimer</a>
|
||||
</td>
|
||||
</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "<p>Aucun utilisateur trouvé dans cette OU.</p>";
|
||||
}
|
||||
|
||||
echo "<p><a href='../views/menu.php'>Retour au menu</a></p>";
|
||||
|
||||
Reference in New Issue
Block a user