Rename Liens étudiant·e, add link name + edit dialog

- Rename 'Accès étudiant·e' → 'Liens étudiant·e' in acces.php
- Add 'name' column to share_links (schema.sql + ALTER TABLE migration)
- ShareLink::create() now accepts optional  parameter
- Add ShareLink::update() method for name/password/expiration
- Add 'update' action to acces-etudiante.php controller
- Remove Visiter (play) button; row click opens link in new tab
- Add edit dialog with name, password, expiration fields
- Add pen icon button to open edit dialog per row
- Add Nom column to table (also in archived links section)
This commit is contained in:
Pontoporeia
2026-05-09 20:39:41 +02:00
parent 7711557d08
commit b6908f7453
6 changed files with 137 additions and 27 deletions

View File

@@ -2,11 +2,11 @@
<h1>Accès</h1>
<!-- ══════════════════════════════════════════════════════════════
LIENS D'ACCÈS ÉTUDIANT·E
LIENS ÉTUDIANT·E
══════════════════════════════════════════════════════════════ -->
<section aria-labelledby="acces-liens-title">
<div class="admin-list-toolbar">
<h2 id="acces-liens-title">Accès étudiant·e</h2>
<h2 id="acces-liens-title">Liens étudiant·e</h2>
<div class="admin-list-toolbar__right">
<button type="button" class="btn btn--primary btn--sm" id="open-create-dialog">
+ Créer un lien
@@ -15,11 +15,12 @@
</div>
<?php if (empty($links)): ?>
<p class="admin-empty">Aucun lien d'accès créé. Cliquez sur « Créer un lien » pour générer un lien partageable.</p>
<p class="admin-empty">Aucun lien créé. Cliquez sur « Créer un lien » pour générer un lien partageable.</p>
<?php else: ?>
<table>
<thead>
<tr>
<th scope="col">Nom</th>
<th scope="col">Lien</th>
<th scope="col">Objet</th>
<th scope="col">Année</th>
@@ -44,8 +45,13 @@
$linkName = $link['name'] ?? '';
$linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
$linkLockedYear = $link['locked_year'] ?? null;
%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision)
\\\\\\\ to: vumvtlyz 95fdf9fe "Rename Liens étudiant·e, add link name + edit dialog" (rebased revision)
+ $linkName = $link['name'] ?? '';
+ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
?>
<tr>
<tr class="admin-table-row" onclick="event.stopPropagation(); window.open('/partage/<?= urlencode($link['slug']) ?>', '_blank')" style="cursor:pointer">
<td><?= htmlspecialchars($linkName ?: '—') ?></td>
<td>
<code style="font-size:var(--step--2);color:var(--text-secondary);"><?= htmlspecialchars($link['slug']) ?></code>
<input type="hidden" id="url-<?= $link['id'] ?>" value="<?= $fullUrl ?>">
@@ -79,15 +85,15 @@
<td><?= $created ?></td>
<td class="admin-actions-col">
<div class="admin-actions">
<a href="/partage/<?= urlencode($link['slug']) ?>" target="_blank" rel="noopener"
class="admin-icon-btn admin-icon-btn--view" title="Visiter le formulaire">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256"><path d="M232.4,114.49,88.32,26.35a16,16,0,0,0-16.2-.3A15.86,15.86,0,0,0,64,39.87V216.13A15.94,15.94,0,0,0,80,232a16.07,16.07,0,0,0,8.36-2.35L232.4,141.51a15.81,15.81,0,0,0,0-27ZM80,215.94V40l143.83,88Z"></path></svg>
</a>
<button type="button" class="admin-icon-btn admin-icon-btn--edit" title="Éditer"
onclick="event.stopPropagation(); openEditDialog(<?= $link['id'] ?>, <?= htmlspecialchars(json_encode($linkName), ENT_QUOTES) ?>, <?= $hasLinkPassword ? 'true' : 'false' ?>, <?= htmlspecialchars(json_encode($linkExpiresVal), ENT_QUOTES) ?>)">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256"><path d="M248,92.68a15.86,15.86,0,0,0-4.69-11.31L174.63,12.68a16,16,0,0,0-22.63,0L123.57,41.11l-58,21.77A16.06,16.06,0,0,0,55.35,75.23L32.11,214.68A8,8,0,0,0,40,224a8.4,8.4,0,0,0,1.32-.11l139.44-23.24a16,16,0,0,0,12.35-10.17l21.77-58L243.31,104A15.87,15.87,0,0,0,248,92.68Zm-69.87,92.19L63.32,204l47.37-47.37a28,28,0,1,0-11.32-11.32L52,192.7,71.13,77.86,126,57.29,198.7,130ZM112,132a12,12,0,1,1,12,12A12,12,0,0,1,112,132Zm96-15.32L139.31,48l24-24L232,92.68Z"></path></svg>
</button>
<button type="button" class="admin-icon-btn admin-icon-btn--copy" title="Copier l'URL"
onclick="copyUrl(<?= $link['id'] ?>)">
onclick="event.stopPropagation(); copyUrl(<?= $link['id'] ?>)">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256"><path d="M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"></path></svg>
</button>
<form method="post" action="actions/acces-etudiante.php" class="publish-form">
<form method="post" action="actions/acces-etudiante.php" class="publish-form" onclick="event.stopPropagation()">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
<input type="hidden" name="action" value="toggle">
<input type="hidden" name="id" value="<?= $link['id'] ?>">
@@ -101,12 +107,8 @@
<?php endif; ?>
</button>
</form>
<button type="button" class="admin-icon-btn admin-icon-btn--key" title="Modifier le mot de passe"
onclick="openPasswordDialog(<?= $link['id'] ?>, <?= $hasLinkPassword ? 'true' : 'false' ?>)">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256"><path d="M216.57,39.43A80,80,0,0,0,83.91,120.78L28.69,176A15.86,15.86,0,0,0,24,187.31V216a16,16,0,0,0,16,16H72a8,8,0,0,0,8-8V208H96a8,8,0,0,0,8-8V184h16a8,8,0,0,0,5.66-2.34l9.56-9.57A79.73,79.73,0,0,0,160,176h.1A80,80,0,0,0,216.57,39.43ZM224,98.1c-1.09,34.09-29.75,61.86-63.89,61.9H160a63.7,63.7,0,0,1-23.65-4.51,8,8,0,0,0-8.84,1.68L116.69,168H96a8,8,0,0,0-8,8v16H72a8,8,0,0,0-8,8v16H40V187.31l58.83-58.82a8,8,0,0,0,1.68-8.84A63.72,63.72,0,0,1,96,95.92c0-34.14,27.81-62.8,61.9-63.89A64,64,0,0,1,224,98.1ZM192,76a12,12,0,1,1-12-12A12,12,0,0,1,192,76Z"></path></svg>
</button>
<form method="post" action="actions/acces-etudiante.php" class="publish-form"
id="archive-link-form-<?= $link['id'] ?>">
id="archive-link-form-<?= $link['id'] ?>" onclick="event.stopPropagation()">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
<input type="hidden" name="action" value="archive">
<input type="hidden" name="id" value="<?= $link['id'] ?>">
@@ -131,6 +133,7 @@
<table style="margin-top:var(--space-s);opacity:0.75;">
<thead>
<tr>
<th scope="col">Nom</th>
<th scope="col">Lien</th>
<th scope="col">Objet</th>
<th scope="col">Utilisations</th>
@@ -145,6 +148,7 @@
$expires = $link['expires_at'] ? date('d/m/Y H:i', strtotime($link['expires_at'])) : '-';
?>
<tr>
<td><?= htmlspecialchars($link['name'] ?? '—') ?></td>
<td>
<code style="font-size:var(--step--2);color:var(--text-secondary);text-decoration:line-through;"><?= htmlspecialchars($link['slug']) ?></code>
</td>
@@ -311,13 +315,18 @@
<!-- ═══════════════════════ CREATE DIALOG ═══════════════════════ -->
<dialog id="create-dialog" class="admin-dialog" aria-labelledby="create-dialog-title">
<div class="admin-dialog__header">
<h2 id="create-dialog-title">Créer un lien d'accès</h2>
<h2 id="create-dialog-title">Créer un lien</h2>
<button type="button" class="admin-dialog__close" aria-label="Fermer"
onclick="document.getElementById('create-dialog').close()">&#x2715;</button>
</div>
<form method="post" action="actions/acces-etudiante.php" class="admin-form">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
<input type="hidden" name="action" value="create">
<fieldset>
<legend>Nom (optionnel)</legend>
<input type="text" name="name" placeholder="Ex: Lien promo 2025">
<small>Donnez un nom pour identifier facilement ce lien.</small>
</fieldset>
<fieldset>
<legend>Type d'objet</legend>
<label style="display:flex;align-items:center;gap:var(--space-2xs);font-weight:400;">
@@ -336,12 +345,10 @@
<div>
<label for="create-password">Mot de passe (optionnel)</label>
<input type="password" id="create-password" name="password" autocomplete="new-password">
<small>Laissez vide pour un lien sans mot de passe.</small>
</div>
<div>
<label for="create-expires">Expiration (optionnel)</label>
<input type="datetime-local" id="create-expires" name="expires_at">
<small>Laissez vide pour qu'il n'expire jamais.</small>
</div>
</fieldset>
<div class="admin-form-footer">
@@ -352,7 +359,40 @@
</form>
</dialog>
<!-- ═══════════════════════ PASSWORD DIALOG ═══════════════════════ -->
<!-- ═══════════════════════ EDIT DIALOG ═══════════════════════ -->
<dialog id="edit-dialog" class="admin-dialog" aria-labelledby="edit-dialog-title">
<div class="admin-dialog__header">
<h2 id="edit-dialog-title">Modifier le lien</h2>
<button type="button" class="admin-dialog__close" aria-label="Fermer"
onclick="document.getElementById('edit-dialog').close()">&#x2715;</button>
</div>
<form method="post" action="actions/acces-etudiante.php" class="admin-form">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
<input type="hidden" name="action" value="update">
<input type="hidden" name="id" id="edit-link-id" value="">
<div>
<label for="edit-name">Nom</label>
<input type="text" id="edit-name" name="name" placeholder="Ex: Lien promo 2025">
</div>
<div>
<label for="edit-password">Mot de passe (laisser vide pour ne pas changer)</label>
<input type="password" id="edit-password" name="password" autocomplete="new-password" placeholder="Laisser vide pour conserver">
<small>Entrez un nouveau mot de passe ou laissez vide pour ne pas modifier.</small>
</div>
<div>
<label for="edit-expires">Expiration</label>
<input type="datetime-local" id="edit-expires" name="expires_at">
<small>Laissez vide pour qu'il n'expire jamais.</small>
</div>
<div class="admin-form-footer">
<button type="submit" class="btn btn--primary">Enregistrer</button>
<button type="button" class="btn btn--secondary"
onclick="document.getElementById('edit-dialog').close()">Annuler</button>
</div>
</form>
</dialog>
<!-- ═══════════════════════ PASSWORD DIALOG (kept for backward compat) ═══════════════════════ -->
<dialog id="password-dialog" class="admin-dialog" aria-labelledby="password-dialog-title">
<div class="admin-dialog__header">
<h2 id="password-dialog-title">Mot de passe</h2>
@@ -430,12 +470,19 @@ function copyUrl(id) {
const input = document.getElementById('url-' + id);
navigator.clipboard.writeText(input.value).then(() => {
const btn = event.target.closest('button');
const orig = btn.textContent;
btn.textContent = '✓ Copié';
setTimeout(() => { btn.textContent = orig; }, 1200);
if (btn) { const orig = btn.getAttribute('title') || ''; btn.setAttribute('title', '✓ Copié'); setTimeout(() => btn.setAttribute('title', orig), 1200); }
});
}
function openEditDialog(id, name, hasPassword, expiresVal) {
document.getElementById('edit-link-id').value = id;
document.getElementById('edit-name').value = name || '';
document.getElementById('edit-password').value = '';
document.getElementById('edit-password').placeholder = hasPassword ? 'Laisser vide pour conserver' : 'Laisser vide pour ne pas en mettre';
document.getElementById('edit-expires').value = expiresVal || '';
document.getElementById('edit-dialog').showModal();
}
function openPasswordDialog(id, hasPassword) {
document.getElementById('password-link-id').value = id;
const info = document.getElementById('password-current-info');