Accueil et tableau de bord : lire les groupes requis, plus requires_adherent (#9)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V2csyno8m71DJFKYM1vgzV
This commit is contained in:
Cédrix 2026-11-01 00:33:25 +01:00
parent 9882e3155e
commit 392c24fe74
No known key found for this signature in database
2 changed files with 12 additions and 7 deletions

View file

@ -93,20 +93,25 @@ require __DIR__ . '/views/layout.php';
<h2>Mes services</h2>
<div class="grid">
<?php foreach ($services as $s): if (!$s['visible']) continue;
$accessible = !$s['requires_adherent'] || $is_adherent;
// Les groupes requis ont remplacé requires_adherent (supprimé par
// _service_normalize) ; une cotisation à jour dans Dolibarr vaut
// toujours le groupe des adhérents.
$restreint = !empty($s['groups']);
$accessible = service_accessible($s, $user['groups'] ?? [], (bool)($user['is_admin'] ?? false))
|| ($is_adherent && in_array(ADHERENT_GROUP, $s['groups'], true));
?>
<div class="service-card <?= $accessible ? '' : 'locked' ?>">
<div class="service-header">
<strong><?= htmlspecialchars($s['name']) ?></strong>
<?php if ($s['requires_adherent']): ?>
<span class="badge"><?= $accessible ? 'Adhérent' : 'Adhérent requis' ?></span>
<?php if ($restreint): ?>
<span class="badge"><?= $accessible ? 'Réservé' : 'Accès restreint' ?></span>
<?php endif; ?>
</div>
<p><?= htmlspecialchars($s['description']) ?></p>
<?php if ($accessible): ?>
<a href="<?= htmlspecialchars($s['url']) ?>" target="_blank" rel="noopener">Accéder</a>
<?php else: ?>
<span class="text-muted small">Adhésion requise</span>
<span class="text-muted small"><?= in_array(ADHERENT_GROUP, $s['groups'], true) ? 'Adhésion requise' : 'Accès restreint' ?></span>
<?php endif; ?>
</div>
<?php endforeach; ?>

View file

@ -144,11 +144,11 @@ document.addEventListener('keydown', e => { if (e.key === 'Escape') closeEventMo
<div class="grid">
<?php foreach ($services as $s): if (!$s['visible']) continue;
$can_access = service_accessible($s, $user_groups, $is_admin); ?>
<div class="service-card <?= $s['requires_adherent'] ? 'adherent-only' : '' ?> <?= (!$can_access) ? 'locked' : '' ?>">
<div class="service-card <?= !empty($s['groups']) ? 'adherent-only' : '' ?> <?= (!$can_access) ? 'locked' : '' ?>">
<div class="service-header">
<strong><?= htmlspecialchars($s['name']) ?></strong>
<?php if ($s['requires_adherent']): ?>
<span class="badge">Adhérent</span>
<?php if (!empty($s['groups'])): ?>
<span class="badge"><?= in_array(ADHERENT_GROUP, $s['groups'], true) ? 'Adhérent' : 'Réservé' ?></span>
<?php endif; ?>
</div>
<?php if ($s['description']): ?>