mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
feat: jury composition + banner image upload
- migration 004: thesis_supervisors.role + is_external; view adds jury_president/jury_promoteurs/jury_lecteurs - migration 005: theses.banner_path; view exposes t.banner_path and t.license_id - Database: getThesisJury(), setThesisJury(), setBannerPath() - admin/add.php: jury fieldset (président/promoteur/lecteurs + externe checkboxes, JS add/remove rows); banner file input - admin/edit.php: jury fieldset pre-populated from DB; banner preview + remove checkbox + upload; multipart form - admin/actions/formulaire.php: parse jury fields → setThesisJury(); banner upload to banners/ - tfe.php: three conditional jury rows (président·e, promoteur·ice, lecteur·ices) - schema.sql: updated thesis_supervisors, theses, v_theses_full, v_theses_public definitions - admin.css: fieldset, jury-row, jury-entry, btn-remove styles
This commit is contained in:
@@ -731,6 +731,60 @@ class Database {
|
||||
return $this->getLicenseTypes();
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// JURY METHODS
|
||||
// ========================================================================
|
||||
|
||||
/**
|
||||
* Fetch all jury members for a thesis, with role and is_external flag.
|
||||
*/
|
||||
public function getThesisJury(int $thesisId): array {
|
||||
$stmt = $this->pdo->prepare("
|
||||
SELECT s.id, s.name, ts.role, ts.is_external, ts.supervisor_order
|
||||
FROM thesis_supervisors ts
|
||||
JOIN supervisors s ON s.id = ts.supervisor_id
|
||||
WHERE ts.thesis_id = ?
|
||||
ORDER BY ts.supervisor_order
|
||||
");
|
||||
$stmt->execute([$thesisId]);
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the entire jury for a thesis in a single transaction.
|
||||
* $juryMembers: array of ['name' => string, 'role' => string, 'is_external' => int]
|
||||
*/
|
||||
public function setThesisJury(int $thesisId, array $juryMembers): void {
|
||||
$this->pdo->prepare("DELETE FROM thesis_supervisors WHERE thesis_id = ?")->execute([$thesisId]);
|
||||
$stmt = $this->pdo->prepare("
|
||||
INSERT INTO thesis_supervisors (thesis_id, supervisor_id, role, is_external, supervisor_order)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
");
|
||||
foreach ($juryMembers as $order => $member) {
|
||||
$name = trim($member['name'] ?? '');
|
||||
if ($name === '') continue;
|
||||
$supervisorId = $this->findOrCreateSupervisor($name);
|
||||
$role = in_array($member['role'], ['president', 'promoteur', 'lecteur'])
|
||||
? $member['role'] : 'promoteur';
|
||||
$isExternal = isset($member['is_external']) ? (int)$member['is_external'] : 0;
|
||||
$stmt->execute([$thesisId, $supervisorId, $role, $isExternal, $order + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// BANNER METHODS
|
||||
// ========================================================================
|
||||
|
||||
/**
|
||||
* Set (or clear) the banner_path for a thesis.
|
||||
*/
|
||||
public function setBannerPath(int $thesisId, ?string $path): void {
|
||||
$stmt = $this->pdo->prepare(
|
||||
"UPDATE theses SET banner_path = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?"
|
||||
);
|
||||
$stmt->execute([$path, $thesisId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a thesis file record
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user