mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
fix: add help email, preserve file names on validation error, license fix
The share link (partage) form does not expose a license field and does not send access_type_id (defaults to 2/Interne). Server-side validation was unconditionally requiring a license for non-admin submissions, causing all share link submissions to fail. Now the license check is gated on adminMode=false AND accessTypeId=1 (Libre), matching the client-side HTMX fragment behaviour in licence-fragment.php. Also fixed a use-before-definition where accessTypeId was referenced before being assigned. Student form improvements: - Add xamxam@erg.be mailto link at top of form - On validation error, append "Si le problème persiste, envoyez un e-mail à xamxam@erg.be" to the flash message - Preserve uploaded file names across validation redirects: store in session (share_primed_files_<slug>), display as warning on form re-render so the student knows which files to re-select - License: only required for non-admin when access_type_id=1 (Libre), not for Interne (2) or Interdit (3). Fixes share link submissions failing with "Veuillez sélectionner une licence". Also fixed use-before-definition of accessTypeId.
This commit is contained in:
@@ -88,9 +88,9 @@ class TfeControllerTestable extends TfeController
|
||||
|
||||
class ThesisCreateControllerTestable extends ThesisCreateController
|
||||
{
|
||||
public function testDetectFileType(string $mimeType, string $ext, string $name): string
|
||||
public function testDetectFileType(string $mimeType, string $ext): string
|
||||
{
|
||||
return $this->detectFileType($mimeType, $ext, $name);
|
||||
return $this->detectFileType($mimeType, $ext);
|
||||
}
|
||||
|
||||
public function testGenerateAuthorSlug(string $name): string
|
||||
@@ -278,33 +278,33 @@ try {
|
||||
// ── B3: detectFileType ────────────────────────────────────────────────────
|
||||
echo "B3: detectFileType — mime-based detection\n";
|
||||
$cases = [
|
||||
['text/vtt', 'vtt', 'caption.vtt', 'caption'],
|
||||
['audio/mpeg', 'mp3', 'track.mp3', 'audio'],
|
||||
['audio/ogg', 'ogg', 'track.ogg', 'audio'],
|
||||
['video/mp4', 'mp4', 'film.mp4', 'video'],
|
||||
['video/webm', 'webm', 'film.webm', 'video'],
|
||||
['application/pdf', 'pdf', 'report.pdf', 'main'],
|
||||
['image/jpeg', 'jpg', 'photo.jpg', 'image'],
|
||||
['image/png', 'png', 'photo.png', 'image'],
|
||||
['application/zip', 'zip', 'archive.zip', 'other'],
|
||||
['text/vtt', 'vtt', 'caption'],
|
||||
['audio/mpeg', 'mp3', 'audio'],
|
||||
['audio/ogg', 'ogg', 'audio'],
|
||||
['video/mp4', 'mp4', 'video'],
|
||||
['video/webm', 'webm', 'video'],
|
||||
['application/pdf', 'pdf', 'main'],
|
||||
['image/jpeg', 'jpg', 'image'],
|
||||
['image/png', 'png', 'image'],
|
||||
['application/zip', 'zip', 'other'],
|
||||
];
|
||||
foreach ($cases as [$mime, $ext, $name, $expected]) {
|
||||
$actual = $createCtrl->testDetectFileType($mime, $ext, $name);
|
||||
plAssertEq($expected, $actual, "$name ($mime) → $expected");
|
||||
foreach ($cases as [$mime, $ext, $expected]) {
|
||||
$actual = $createCtrl->testDetectFileType($mime, $ext);
|
||||
plAssertEq($expected, $actual, "$mime / $ext → $expected");
|
||||
}
|
||||
echo "\n";
|
||||
|
||||
echo "B4: detectFileType — extension-based fallback\n";
|
||||
// application/octet-stream with known extensions
|
||||
$cases = [
|
||||
['application/octet-stream', 'mp3', 'track.mp3', 'audio'],
|
||||
['application/octet-stream', 'mp4', 'video.mp4', 'video'],
|
||||
['application/octet-stream', 'pdf', 'doc.pdf', 'main'],
|
||||
['application/octet-stream', 'webp', 'img.webp', 'image'],
|
||||
['application/octet-stream', 'vtt', 'subs.vtt', 'caption'],
|
||||
['application/octet-stream', 'mp3', 'audio'],
|
||||
['application/octet-stream', 'mp4', 'video'],
|
||||
['application/octet-stream', 'pdf', 'main'],
|
||||
['application/octet-stream', 'webp', 'image'],
|
||||
['application/octet-stream', 'vtt', 'caption'],
|
||||
];
|
||||
foreach ($cases as [$mime, $ext, $name, $expected]) {
|
||||
$actual = $createCtrl->testDetectFileType($mime, $ext, $name);
|
||||
foreach ($cases as [$mime, $ext, $expected]) {
|
||||
$actual = $createCtrl->testDetectFileType($mime, $ext);
|
||||
plAssertEq($expected, $actual, "octet-stream + .$ext → $expected");
|
||||
}
|
||||
echo "\n";
|
||||
|
||||
Reference in New Issue
Block a user