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:
@@ -23,6 +23,7 @@ $logger = AdminLogger::make();
|
||||
|
||||
switch ($action) {
|
||||
case 'create':
|
||||
$name = !empty($_POST['name']) ? trim($_POST['name']) : null;
|
||||
$password = !empty($_POST['password']) ? trim($_POST['password']) : null;
|
||||
$expiresRaw = !empty($_POST['expires_at']) ? trim($_POST['expires_at']) : null;
|
||||
$expiresAt = null;
|
||||
@@ -36,7 +37,7 @@ switch ($action) {
|
||||
$validObjet = ['tfe', 'thèse', 'frart'];
|
||||
$selected = is_array($objetRaw) ? array_intersect($objetRaw, $validObjet) : [];
|
||||
$objetRestriction = !empty($selected) ? implode(',', $selected) : 'tfe';
|
||||
$link = $shareLink->create(1, $password, $expiresAt, $objetRestriction);
|
||||
$link = $shareLink->create(1, $password, $expiresAt, $objetRestriction, $name);
|
||||
$logger->logLinkCreate(
|
||||
$link['slug'] ?? '',
|
||||
$password !== null,
|
||||
@@ -77,6 +78,18 @@ switch ($action) {
|
||||
}
|
||||
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:
|
||||
App::redirect('/admin/acces.php', error: 'Action inconnue.');
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user