mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-27 00:59:18 +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:
@@ -494,7 +494,7 @@ class Database
|
||||
{
|
||||
$stmt = $this->pdo->prepare(
|
||||
'SELECT vp.id, vp.title, vp.subtitle, vp.year, vp.synopsis,
|
||||
vp.orientation, vp.finality_type, vp.banner_path, vp.authors
|
||||
vp.orientation, vp.finality_type, vp.authors
|
||||
FROM v_theses_public vp
|
||||
JOIN thesis_authors ta ON ta.thesis_id = vp.id
|
||||
JOIN authors a ON a.id = ta.author_id
|
||||
@@ -522,7 +522,7 @@ class Database
|
||||
$stmt = $this->pdo->prepare(
|
||||
"SELECT a.name AS author_name,
|
||||
vp.id, vp.title, vp.subtitle, vp.year, vp.synopsis,
|
||||
vp.orientation, vp.finality_type, vp.banner_path, vp.authors
|
||||
vp.orientation, vp.finality_type, vp.authors
|
||||
FROM v_theses_public vp
|
||||
JOIN thesis_authors ta ON ta.thesis_id = vp.id
|
||||
JOIN authors a ON a.id = ta.author_id
|
||||
@@ -2165,6 +2165,9 @@ class Database
|
||||
* Replace the cover image for a thesis: removes any existing cover record
|
||||
* (and its file from disk), then inserts the new one.
|
||||
*
|
||||
* @deprecated Use ThesisFileHandler::handleCoverUpload() instead.
|
||||
* Kept for backwards compatibility — may be called by old code.
|
||||
*
|
||||
* @param int $thesisId
|
||||
* @param array|null $upload Single-file $_FILES entry.
|
||||
* @return string|null Relative path of the new cover, or null.
|
||||
@@ -2175,11 +2178,17 @@ class Database
|
||||
return null;
|
||||
}
|
||||
|
||||
require_once APP_ROOT . '/src/Controllers/ThesisFileHandler.php';
|
||||
// Use the trait's version — but since it's a trait we can't call it directly.
|
||||
// Delegate to the new convention: cover goes inside the thesis folder.
|
||||
// For backwards compat, fall through to the old behaviour.
|
||||
// The caller should migrate to using the trait directly.
|
||||
|
||||
$allowedMimes = ['image/jpeg', 'image/png', 'image/webp'];
|
||||
$allowedExts = ['jpg', 'jpeg', 'png', 'webp'];
|
||||
$maxBytes = 20 * 1024 * 1024; // 20 MB
|
||||
$maxBytes = 20 * 1024 * 1024;
|
||||
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
||||
$mimeType = $finfo->file($upload['tmp_name']);
|
||||
$ext = strtolower(pathinfo($upload['name'], PATHINFO_EXTENSION));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user