nuage de tags sur la liste, suppression dropdown navbar, rôles/droits sur le profil
This commit is contained in:
@@ -33,6 +33,51 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$pdo = dbPdo();
|
||||
$_profileRoles = [];
|
||||
if ($pdo) {
|
||||
$st = $pdo->prepare(
|
||||
'SELECT r.name, r.label, COALESCE(array_agg(rc.capability) FILTER (WHERE rc.capability IS NOT NULL), \'{}\') AS caps
|
||||
FROM user_roles ur
|
||||
JOIN roles r ON r.id = ur.role_id
|
||||
LEFT JOIN role_capabilities rc ON rc.role_id = r.id
|
||||
WHERE ur.user_email = :email
|
||||
GROUP BY r.id, r.name, r.label
|
||||
ORDER BY r.name'
|
||||
);
|
||||
$st->execute([':email' => currentUserEmail()]);
|
||||
$_profileRoles = $st->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
if (!empty($_profileRoles)): ?>
|
||||
<div class="col-md-6 col-lg-8 mt-4 mt-md-0">
|
||||
<h2 class="h6 text-muted mb-3">Rôles & droits</h2>
|
||||
<?php foreach ($_profileRoles as $_role):
|
||||
$_caps = array_filter(
|
||||
explode(',', trim((string)$_role['caps'], '{}')),
|
||||
static fn ($c) => $c !== ''
|
||||
);
|
||||
?>
|
||||
<div class="card mb-3">
|
||||
<div class="card-header d-flex align-items-center gap-2 py-2">
|
||||
<strong><?= htmlspecialchars($_role['label']) ?></strong>
|
||||
<code class="text-muted small"><?= htmlspecialchars($_role['name']) ?></code>
|
||||
</div>
|
||||
<?php if (!empty($_caps)): ?>
|
||||
<ul class="list-group list-group-flush small">
|
||||
<?php foreach ($_caps as $_cap):
|
||||
$_label = KNOWN_CAPABILITIES[trim($_cap)] ?? trim($_cap); ?>
|
||||
<li class="list-group-item py-1"><?= htmlspecialchars($_label) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php else: ?>
|
||||
<div class="card-body py-2 small text-muted">Aucun droit associé à ce rôle.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user