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:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TfeController
|
||||
*
|
||||
@@ -74,11 +75,11 @@ class TfeController
|
||||
// Access type (1 = open, 2 = restricted, 3 = forbidden)
|
||||
$accessTypeId = $this->db->getThesisAccessTypeId($thesisId) ?? 1;
|
||||
$isInterdit = ($accessTypeId === 3);
|
||||
|
||||
|
||||
// Check if restricted files feature is enabled and user has access
|
||||
$restrictedEnabled = $this->db->isRestrictedFilesEnabled();
|
||||
$hasRestrictedAccess = false;
|
||||
|
||||
|
||||
if ($restrictedEnabled && $accessTypeId === 2) {
|
||||
// Check for cookie-based access
|
||||
$cookieToken = $_COOKIE['tfe_access_' . $thesisId] ?? null;
|
||||
@@ -86,7 +87,7 @@ class TfeController
|
||||
$hasRestrictedAccess = $this->db->hasValidCookieAccess($cookieToken, $thesisId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If access is restricted and user doesn't have valid access, hide files
|
||||
$shouldHideFiles = ($restrictedEnabled && $accessTypeId === 2 && !$hasRestrictedAccess);
|
||||
|
||||
@@ -209,7 +210,9 @@ class TfeController
|
||||
|
||||
foreach ($jury as $member) {
|
||||
$name = $member['name'] ?? '';
|
||||
if ($name === '') continue;
|
||||
if ($name === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch ($member['role']) {
|
||||
case 'president':
|
||||
|
||||
Reference in New Issue
Block a user