mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
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:
6
TODO.md
6
TODO.md
@@ -52,3 +52,9 @@
|
|||||||
- [x] Tags page: back button, admin-main--list, no padding, icon buttons, #admin-table-wrap
|
- [x] Tags page: back button, admin-main--list, no padding, icon buttons, #admin-table-wrap
|
||||||
- [x] Move #bulk-actions into fixed-height #bulk-meta-bar at top, prevent layout shift
|
- [x] Move #bulk-actions into fixed-height #bulk-meta-bar at top, prevent layout shift
|
||||||
- [x] Credits: move Iconographie below Typographies
|
- [x] Credits: move Iconographie below Typographies
|
||||||
|
- [x] Rename Accès étudiant·e → Liens étudiant·e
|
||||||
|
- [x] Add 'name' column to share_links (schema + migration + model)
|
||||||
|
- [x] Add edit dialog for share links (edit name, password, expiration)
|
||||||
|
- [x] Row click opens link in new tab, remove Visiter button
|
||||||
|
- [x] Add update action to acces-etudiante.php controller
|
||||||
|
- [x] Add ShareLink::update() method
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ $logger = AdminLogger::make();
|
|||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'create':
|
case 'create':
|
||||||
|
$name = !empty($_POST['name']) ? trim($_POST['name']) : null;
|
||||||
$password = !empty($_POST['password']) ? trim($_POST['password']) : null;
|
$password = !empty($_POST['password']) ? trim($_POST['password']) : null;
|
||||||
$expiresRaw = !empty($_POST['expires_at']) ? trim($_POST['expires_at']) : null;
|
$expiresRaw = !empty($_POST['expires_at']) ? trim($_POST['expires_at']) : null;
|
||||||
$expiresAt = null;
|
$expiresAt = null;
|
||||||
@@ -36,7 +37,7 @@ switch ($action) {
|
|||||||
$validObjet = ['tfe', 'thèse', 'frart'];
|
$validObjet = ['tfe', 'thèse', 'frart'];
|
||||||
$selected = is_array($objetRaw) ? array_intersect($objetRaw, $validObjet) : [];
|
$selected = is_array($objetRaw) ? array_intersect($objetRaw, $validObjet) : [];
|
||||||
$objetRestriction = !empty($selected) ? implode(',', $selected) : 'tfe';
|
$objetRestriction = !empty($selected) ? implode(',', $selected) : 'tfe';
|
||||||
$link = $shareLink->create(1, $password, $expiresAt, $objetRestriction);
|
$link = $shareLink->create(1, $password, $expiresAt, $objetRestriction, $name);
|
||||||
$logger->logLinkCreate(
|
$logger->logLinkCreate(
|
||||||
$link['slug'] ?? '',
|
$link['slug'] ?? '',
|
||||||
$password !== null,
|
$password !== null,
|
||||||
@@ -77,6 +78,18 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'update':
|
||||||
|
if ($id > 0) {
|
||||||
|
$name = isset($_POST['name']) ? trim($_POST['name']) : null;
|
||||||
|
$password = isset($_POST['password']) ? trim($_POST['password']) : null;
|
||||||
|
$expiresRaw = isset($_POST['expires_at']) ? trim($_POST['expires_at']) : null;
|
||||||
|
$shareLink->update($id, $name, $password, $expiresRaw);
|
||||||
|
App::redirect('/admin/acces.php', success: 'Lien mis à jour.');
|
||||||
|
} else {
|
||||||
|
App::redirect('/admin/acces.php', error: 'Lien introuvable.');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
App::redirect('/admin/acces.php', error: 'Action inconnue.');
|
App::redirect('/admin/acces.php', error: 'Action inconnue.');
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -29,12 +29,26 @@ class Database
|
|||||||
$this->pdo->exec('PRAGMA journal_mode = WAL');
|
$this->pdo->exec('PRAGMA journal_mode = WAL');
|
||||||
$this->pdo->exec('PRAGMA synchronous = NORMAL');
|
$this->pdo->exec('PRAGMA synchronous = NORMAL');
|
||||||
$this->pdo->exec('PRAGMA cache_size = -8000');
|
$this->pdo->exec('PRAGMA cache_size = -8000');
|
||||||
|
$this->runMigrations();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
error_log('Database connection failed: ' . $e->getMessage());
|
error_log('Database connection failed: ' . $e->getMessage());
|
||||||
throw new Exception('Impossible de se connecter à la base de données.');
|
throw new Exception('Impossible de se connecter à la base de données.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run one-off schema migrations.
|
||||||
|
*/
|
||||||
|
private function runMigrations(): void
|
||||||
|
{
|
||||||
|
// Add 'name' column to share_links if missing
|
||||||
|
try {
|
||||||
|
$this->pdo->exec("ALTER TABLE share_links ADD COLUMN name TEXT");
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
// Column already exists — ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine database path.
|
* Determine database path.
|
||||||
* Priority: explicit override → APP_ROOT /storage/xamxam.db.
|
* Priority: explicit override → APP_ROOT /storage/xamxam.db.
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class ShareLink
|
|||||||
* @param string|null $expiresAt ISO-8601 expiration date, null = never expires
|
* @param string|null $expiresAt ISO-8601 expiration date, null = never expires
|
||||||
* @return array|null The created link row
|
* @return array|null The created link row
|
||||||
*/
|
*/
|
||||||
public function create(int $createdBy, ?string $password = null, ?string $expiresAt = null, ?string $objetRestriction = null): ?array
|
public function create(int $createdBy, ?string $password = null, ?string $expiresAt = null, ?string $objetRestriction = null, ?string $name = null): ?array
|
||||||
{
|
{
|
||||||
$slug = self::generateSlug();
|
$slug = self::generateSlug();
|
||||||
$passwordHash = $password !== null ? password_hash($password, PASSWORD_BCRYPT) : null;
|
$passwordHash = $password !== null ? password_hash($password, PASSWORD_BCRYPT) : null;
|
||||||
@@ -62,10 +62,10 @@ class ShareLink
|
|||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->db->getConnection()->prepare(
|
$stmt = $this->db->getConnection()->prepare(
|
||||||
'INSERT INTO share_links (slug, objet_restriction, password_hash, is_active, created_by, expires_at)
|
'INSERT INTO share_links (slug, name, objet_restriction, password_hash, is_active, created_by, expires_at)
|
||||||
VALUES (?, ?, ?, 1, ?, ?)'
|
VALUES (?, ?, ?, ?, 1, ?, ?)'
|
||||||
);
|
);
|
||||||
$stmt->execute([$slug, $objetRestriction, $passwordHash, $createdBy, $expiresAt]);
|
$stmt->execute([$slug, $name, $objetRestriction, $passwordHash, $createdBy, $expiresAt]);
|
||||||
|
|
||||||
return $this->findBySlug($slug);
|
return $this->findBySlug($slug);
|
||||||
}
|
}
|
||||||
@@ -185,6 +185,35 @@ class ShareLink
|
|||||||
)->execute([$id]);
|
)->execute([$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a share link (name, password, expiration).
|
||||||
|
*/
|
||||||
|
public function update(int $id, ?string $name = null, ?string $password = null, ?string $expiresAt = null): void
|
||||||
|
{
|
||||||
|
$pdo = $this->db->getConnection();
|
||||||
|
$fields = [];
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
if ($name !== null) {
|
||||||
|
$fields[] = 'name = ?';
|
||||||
|
$params[] = $name;
|
||||||
|
}
|
||||||
|
if ($password !== null) {
|
||||||
|
$fields[] = 'password_hash = ?';
|
||||||
|
$params[] = $password !== '' ? password_hash($password, PASSWORD_BCRYPT) : null;
|
||||||
|
}
|
||||||
|
if ($expiresAt !== null) {
|
||||||
|
$expiresAtVal = $expiresAt !== '' ? date('Y-m-d H:i:s', strtotime($expiresAt)) : null;
|
||||||
|
$fields[] = 'expires_at = ?';
|
||||||
|
$params[] = $expiresAtVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($fields)) {
|
||||||
|
$params[] = $id;
|
||||||
|
$pdo->prepare('UPDATE share_links SET ' . implode(', ', $fields) . ' WHERE id = ?')->execute($params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── Validation ────────────────────────────────────────────────────────────
|
// ── Validation ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -338,6 +338,7 @@ INSERT OR IGNORE INTO pages (slug, title, content) VALUES
|
|||||||
CREATE TABLE IF NOT EXISTS share_links (
|
CREATE TABLE IF NOT EXISTS share_links (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
slug TEXT NOT NULL UNIQUE, -- Format: YYYYMMDD-<random>, e.g. 20260416-a3f9k2
|
slug TEXT NOT NULL UNIQUE, -- Format: YYYYMMDD-<random>, e.g. 20260416-a3f9k2
|
||||||
|
name TEXT, -- user-defined label (optional)
|
||||||
objet_restriction TEXT CHECK (objet_restriction IN ('tfe', 'thèse', 'frart')), -- NULL = no restriction
|
objet_restriction TEXT CHECK (objet_restriction IN ('tfe', 'thèse', 'frart')), -- NULL = no restriction
|
||||||
password_hash TEXT, -- bcrypt hash; NULL = no password required
|
password_hash TEXT, -- bcrypt hash; NULL = no password required
|
||||||
is_active INTEGER NOT NULL DEFAULT 1, -- 1 = active, 0 = disabled
|
is_active INTEGER NOT NULL DEFAULT 1, -- 1 = active, 0 = disabled
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
<h1>Accès</h1>
|
<h1>Accès</h1>
|
||||||
|
|
||||||
<!-- ══════════════════════════════════════════════════════════════
|
<!-- ══════════════════════════════════════════════════════════════
|
||||||
LIENS D'ACCÈS ÉTUDIANT·E
|
LIENS ÉTUDIANT·E
|
||||||
══════════════════════════════════════════════════════════════ -->
|
══════════════════════════════════════════════════════════════ -->
|
||||||
<section aria-labelledby="acces-liens-title">
|
<section aria-labelledby="acces-liens-title">
|
||||||
<div class="admin-list-toolbar">
|
<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">
|
<div class="admin-list-toolbar__right">
|
||||||
<button type="button" class="btn btn--primary btn--sm" id="open-create-dialog">
|
<button type="button" class="btn btn--primary btn--sm" id="open-create-dialog">
|
||||||
+ Créer un lien
|
+ Créer un lien
|
||||||
@@ -15,11 +15,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (empty($links)): ?>
|
<?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: ?>
|
<?php else: ?>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th scope="col">Nom</th>
|
||||||
<th scope="col">Lien</th>
|
<th scope="col">Lien</th>
|
||||||
<th scope="col">Objet</th>
|
<th scope="col">Objet</th>
|
||||||
<th scope="col">Année</th>
|
<th scope="col">Année</th>
|
||||||
@@ -44,8 +45,13 @@
|
|||||||
$linkName = $link['name'] ?? '';
|
$linkName = $link['name'] ?? '';
|
||||||
$linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
|
$linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
|
||||||
$linkLockedYear = $link['locked_year'] ?? null;
|
$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>
|
<td>
|
||||||
<code style="font-size:var(--step--2);color:var(--text-secondary);"><?= htmlspecialchars($link['slug']) ?></code>
|
<code style="font-size:var(--step--2);color:var(--text-secondary);"><?= htmlspecialchars($link['slug']) ?></code>
|
||||||
<input type="hidden" id="url-<?= $link['id'] ?>" value="<?= $fullUrl ?>">
|
<input type="hidden" id="url-<?= $link['id'] ?>" value="<?= $fullUrl ?>">
|
||||||
@@ -79,15 +85,15 @@
|
|||||||
<td><?= $created ?></td>
|
<td><?= $created ?></td>
|
||||||
<td class="admin-actions-col">
|
<td class="admin-actions-col">
|
||||||
<div class="admin-actions">
|
<div class="admin-actions">
|
||||||
<a href="/partage/<?= urlencode($link['slug']) ?>" target="_blank" rel="noopener"
|
<button type="button" class="admin-icon-btn admin-icon-btn--edit" title="Éditer"
|
||||||
class="admin-icon-btn admin-icon-btn--view" title="Visiter le formulaire">
|
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="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>
|
<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>
|
||||||
</a>
|
</button>
|
||||||
<button type="button" class="admin-icon-btn admin-icon-btn--copy" title="Copier l'URL"
|
<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>
|
<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>
|
</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="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
|
||||||
<input type="hidden" name="action" value="toggle">
|
<input type="hidden" name="action" value="toggle">
|
||||||
<input type="hidden" name="id" value="<?= $link['id'] ?>">
|
<input type="hidden" name="id" value="<?= $link['id'] ?>">
|
||||||
@@ -101,12 +107,8 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</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"
|
<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="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
|
||||||
<input type="hidden" name="action" value="archive">
|
<input type="hidden" name="action" value="archive">
|
||||||
<input type="hidden" name="id" value="<?= $link['id'] ?>">
|
<input type="hidden" name="id" value="<?= $link['id'] ?>">
|
||||||
@@ -131,6 +133,7 @@
|
|||||||
<table style="margin-top:var(--space-s);opacity:0.75;">
|
<table style="margin-top:var(--space-s);opacity:0.75;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th scope="col">Nom</th>
|
||||||
<th scope="col">Lien</th>
|
<th scope="col">Lien</th>
|
||||||
<th scope="col">Objet</th>
|
<th scope="col">Objet</th>
|
||||||
<th scope="col">Utilisations</th>
|
<th scope="col">Utilisations</th>
|
||||||
@@ -145,6 +148,7 @@
|
|||||||
$expires = $link['expires_at'] ? date('d/m/Y H:i', strtotime($link['expires_at'])) : '-';
|
$expires = $link['expires_at'] ? date('d/m/Y H:i', strtotime($link['expires_at'])) : '-';
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><?= htmlspecialchars($link['name'] ?? '—') ?></td>
|
||||||
<td>
|
<td>
|
||||||
<code style="font-size:var(--step--2);color:var(--text-secondary);text-decoration:line-through;"><?= htmlspecialchars($link['slug']) ?></code>
|
<code style="font-size:var(--step--2);color:var(--text-secondary);text-decoration:line-through;"><?= htmlspecialchars($link['slug']) ?></code>
|
||||||
</td>
|
</td>
|
||||||
@@ -311,13 +315,18 @@
|
|||||||
<!-- ═══════════════════════ CREATE DIALOG ═══════════════════════ -->
|
<!-- ═══════════════════════ CREATE DIALOG ═══════════════════════ -->
|
||||||
<dialog id="create-dialog" class="admin-dialog" aria-labelledby="create-dialog-title">
|
<dialog id="create-dialog" class="admin-dialog" aria-labelledby="create-dialog-title">
|
||||||
<div class="admin-dialog__header">
|
<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"
|
<button type="button" class="admin-dialog__close" aria-label="Fermer"
|
||||||
onclick="document.getElementById('create-dialog').close()">✕</button>
|
onclick="document.getElementById('create-dialog').close()">✕</button>
|
||||||
</div>
|
</div>
|
||||||
<form method="post" action="actions/acces-etudiante.php" class="admin-form">
|
<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="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
|
||||||
<input type="hidden" name="action" value="create">
|
<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>
|
<fieldset>
|
||||||
<legend>Type d'objet</legend>
|
<legend>Type d'objet</legend>
|
||||||
<label style="display:flex;align-items:center;gap:var(--space-2xs);font-weight:400;">
|
<label style="display:flex;align-items:center;gap:var(--space-2xs);font-weight:400;">
|
||||||
@@ -336,12 +345,10 @@
|
|||||||
<div>
|
<div>
|
||||||
<label for="create-password">Mot de passe (optionnel)</label>
|
<label for="create-password">Mot de passe (optionnel)</label>
|
||||||
<input type="password" id="create-password" name="password" autocomplete="new-password">
|
<input type="password" id="create-password" name="password" autocomplete="new-password">
|
||||||
<small>Laissez vide pour un lien sans mot de passe.</small>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="create-expires">Expiration (optionnel)</label>
|
<label for="create-expires">Expiration (optionnel)</label>
|
||||||
<input type="datetime-local" id="create-expires" name="expires_at">
|
<input type="datetime-local" id="create-expires" name="expires_at">
|
||||||
<small>Laissez vide pour qu'il n'expire jamais.</small>
|
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="admin-form-footer">
|
<div class="admin-form-footer">
|
||||||
@@ -352,7 +359,40 @@
|
|||||||
</form>
|
</form>
|
||||||
</dialog>
|
</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()">✕</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">
|
<dialog id="password-dialog" class="admin-dialog" aria-labelledby="password-dialog-title">
|
||||||
<div class="admin-dialog__header">
|
<div class="admin-dialog__header">
|
||||||
<h2 id="password-dialog-title">Mot de passe</h2>
|
<h2 id="password-dialog-title">Mot de passe</h2>
|
||||||
@@ -430,12 +470,19 @@ function copyUrl(id) {
|
|||||||
const input = document.getElementById('url-' + id);
|
const input = document.getElementById('url-' + id);
|
||||||
navigator.clipboard.writeText(input.value).then(() => {
|
navigator.clipboard.writeText(input.value).then(() => {
|
||||||
const btn = event.target.closest('button');
|
const btn = event.target.closest('button');
|
||||||
const orig = btn.textContent;
|
if (btn) { const orig = btn.getAttribute('title') || ''; btn.setAttribute('title', '✓ Copié'); setTimeout(() => btn.setAttribute('title', orig), 1200); }
|
||||||
btn.textContent = '✓ Copié';
|
|
||||||
setTimeout(() => { btn.textContent = 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) {
|
function openPasswordDialog(id, hasPassword) {
|
||||||
document.getElementById('password-link-id').value = id;
|
document.getElementById('password-link-id').value = id;
|
||||||
const info = document.getElementById('password-current-info');
|
const info = document.getElementById('password-current-info');
|
||||||
|
|||||||
Reference in New Issue
Block a user