mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
feat: prevent duplicate TFE submissions with logging and user feedback
- Add DuplicateThesisException (typed, carries existing thesis metadata) - Add Database::findDuplicateThesis(): matches on year + author + normalised title (exact, prefix, Levenshtein ≤10% of longer string) - ThesisCreateController::submit() runs duplicate check before any DB write and throws DuplicateThesisException on match - AppLogger::logDuplicate() writes status=duplicate entries to the JSON-lines log for audit purposes - App::flash/consumeFlash extended to support 'warning' flash type - admin/actions/formulaire.php: catches DuplicateThesisException, logs it, flashes an HTML warning toast with a clickable link to the existing thesis, and repopulates the form fields - partage/index.php: same catch block; surfaces a plain-text flash-warning banner on the student form with identifier, title, and year of the match; form is repopulated via session - toast.php: renders toast--warning variant - admin.css: .toast--warning + link colour rules - form.css: .flash-warning style for the partage form
This commit is contained in:
@@ -7,21 +7,22 @@
|
||||
* The e-mail is addressed to the confirmation e-mail field provided
|
||||
* by the student and contains a recap of every field submitted.
|
||||
*/
|
||||
class StudentEmail {
|
||||
|
||||
class StudentEmail
|
||||
{
|
||||
/**
|
||||
* Build the HTML body for the confirmation e-mail.
|
||||
*
|
||||
* @param array $thesis Thesis row (from getThesis / v_theses_full)
|
||||
* @return string HTML body
|
||||
*/
|
||||
private static function buildHtml(array $thesis): string {
|
||||
private static function buildHtml(array $thesis): string
|
||||
{
|
||||
$rows = '';
|
||||
$fields = [
|
||||
'Identifiant' => $thesis['identifier'] ?? '',
|
||||
'Titre' => $thesis['title'] ?? '',
|
||||
'Sous-titre' => $thesis['subtitle'] ?? '',
|
||||
'Auteur·ice(s)'=> $thesis['authors'] ?? '',
|
||||
'Auteur·ice(s)' => $thesis['authors'] ?? '',
|
||||
'Année' => $thesis['year'] ?? '',
|
||||
'Orientation' => $thesis['orientation'] ?? '',
|
||||
'Atelier pluridisciplinaire' => $thesis['ap_program'] ?? '',
|
||||
@@ -42,24 +43,24 @@ class StudentEmail {
|
||||
foreach ($fields as $label => $value) {
|
||||
$v = $value === '' ? '–' : htmlspecialchars((string)$value);
|
||||
$rows .= "<tr><th style='text-align:left;padding:6px 10px;border-bottom:1px solid #eee'>"
|
||||
. htmlspecialchars($label) . "</th>"
|
||||
. htmlspecialchars($label) . '</th>'
|
||||
. "<td style='padding:6px 10px;border-bottom:1px solid #eee'>{$v}</td></tr>\n";
|
||||
}
|
||||
|
||||
return <<<HTML
|
||||
<div style="font-family:system-ui,sans-serif;max-width:600px;margin:0 auto;color:#333">
|
||||
<h1 style="font-size:1.4rem;color:#222">Merci — ton TFE a bien été enregistré 🎉</h1>
|
||||
<p style="color:#555;font-size:0.95rem">
|
||||
Voici un récapitulatif de ta soumission. Tu n'as pas besoin de répondre à cet e-mail.
|
||||
</p>
|
||||
<table style="width:100%;border-collapse:collapse;margin-top:1.5rem">
|
||||
{$rows}
|
||||
</table>
|
||||
<p style="margin-top:2rem;font-size:0.85rem;color:#999">
|
||||
Plateforme xamxam · erg Bruxelles
|
||||
</p>
|
||||
</div>
|
||||
HTML;
|
||||
<div style="font-family:system-ui,sans-serif;max-width:600px;margin:0 auto;color:#333">
|
||||
<h1 style="font-size:1.4rem;color:#222">Merci — ton TFE a bien été enregistré 🎉</h1>
|
||||
<p style="color:#555;font-size:0.95rem">
|
||||
Voici un récapitulatif de ta soumission. Tu n'as pas besoin de répondre à cet e-mail.
|
||||
</p>
|
||||
<table style="width:100%;border-collapse:collapse;margin-top:1.5rem">
|
||||
{$rows}
|
||||
</table>
|
||||
<p style="margin-top:2rem;font-size:0.85rem;color:#999">
|
||||
Plateforme xamxam · erg Bruxelles
|
||||
</p>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user