mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Fix edit form: is_published reset, contact decoupling, note label, author name case
- Fix #1: Add is_published to getThesisRawFields() SELECT so the publish checkbox stays checked when editing an already-published TFE. - Fix #2: Rename 'Note contextuelle' → 'Note contextuelle relative à soutenance' in all templates and StudentEmail. - Fix #3: Update findOrCreateAuthor to also UPDATE the author name when a record is found by name (fixes inability to capitalise names). - Fix #4/#5: Decouple contact_interne (private author email) from contact_visible (public contact on TFE page). Add migration 037 to add contact_visible TEXT column to theses table and rebuild v_theses_full view. Update all controllers, templates, and DB methods to treat them independently. - Fix #6: Investigated libre→interne restriction — no code barrier found; likely resolved by is_published fix.
This commit is contained in:
@@ -148,6 +148,7 @@ class ThesisCreateController
|
||||
'subtitle' => $data['subtitle'],
|
||||
'synopsis' => $data['synopsis'],
|
||||
'context_note' => $data['contextNote'],
|
||||
'contact_visible' => $data['contactVisible'] ?? '',
|
||||
'baiu_link' => $data['lien'],
|
||||
'license_id' => $data['licenseId'],
|
||||
'license_custom' => $data['licenseCustom'],
|
||||
@@ -310,12 +311,17 @@ class ThesisCreateController
|
||||
if ($contactInterne !== '') {
|
||||
$mail = $contactInterne;
|
||||
}
|
||||
// contact_public: respected if present (admin form); defaults to true for student forms
|
||||
// where the spec says contact is always visible when provided.
|
||||
// contact_visible: what appears publicly on the TFE page
|
||||
// In admin mode: from contact_visible field. In student mode: from mail field.
|
||||
$contactVisible = trim($post['contact_visible'] ?? '');
|
||||
if ($contactVisible === '' && $mail !== '') {
|
||||
$contactVisible = $mail;
|
||||
}
|
||||
// showContact for backwards compat
|
||||
if (array_key_exists('contact_public', $post)) {
|
||||
$showContact = !empty($post['contact_public']);
|
||||
} else {
|
||||
$showContact = $mail !== '';
|
||||
$showContact = $contactVisible !== '';
|
||||
}
|
||||
|
||||
$annee = filter_var($post['année'] ?? '', FILTER_VALIDATE_INT);
|
||||
@@ -528,6 +534,7 @@ class ThesisCreateController
|
||||
return compact(
|
||||
'authorNames',
|
||||
'mail',
|
||||
'contactVisible',
|
||||
'showContact',
|
||||
'annee',
|
||||
'orientationId',
|
||||
|
||||
@@ -108,6 +108,7 @@ class ThesisEditController
|
||||
$currentLicenseId = $rawRow['license_id'] ?? null;
|
||||
$currentAccessTypeId = $rawRow['access_type_id'] ?? null;
|
||||
$currentContextNote = $rawRow['context_note'] ?? '';
|
||||
$currentContactVisible = $rawRow['contact_visible'] ?? '';
|
||||
|
||||
// Author contact info (from view)
|
||||
$contactInterne = $thesis['contact_interne'] ?? '';
|
||||
@@ -130,6 +131,7 @@ class ThesisEditController
|
||||
'currentLicenseId' => $currentLicenseId,
|
||||
'currentAccessTypeId' => $currentAccessTypeId,
|
||||
'currentContextNote' => $currentContextNote,
|
||||
'currentContactVisible' => $currentContactVisible,
|
||||
'contactInterne' => $contactInterne,
|
||||
'contactPublic' => $contactPublic,
|
||||
'currentRaw' => $rawRow,
|
||||
@@ -206,6 +208,7 @@ class ThesisEditController
|
||||
'finality_id' => ($v = intval($post['finality'] ?? 0)) > 0 ? $v : null,
|
||||
'synopsis' => trim($post['synopsis'] ?? ''),
|
||||
'context_note' => trim($post['context_note'] ?? ''),
|
||||
'contact_visible' => trim($post['contact_visible'] ?? ''),
|
||||
'baiu_link' => trim($post['lien'] ?? ''),
|
||||
'license_id' => filter_var($post['license_id'] ?? '', FILTER_VALIDATE_INT) ?: null,
|
||||
'access_type_id' => filter_var($post['access_type_id'] ?? '', FILTER_VALIDATE_INT) ?: null,
|
||||
@@ -232,10 +235,9 @@ class ThesisEditController
|
||||
|
||||
// ── 2. Authors (alphabetically sorted) ─────────────────────────────
|
||||
$authorsRaw = trim($post['auteurice'] ?? '');
|
||||
$showContact = !empty($post['contact_public']);
|
||||
// contact_interne (backoffice) takes precedence over mail (tfe-info fieldset)
|
||||
// contact_interne = private email of the first author (backoffice field)
|
||||
$contactInterne = trim($post['contact_interne'] ?? '');
|
||||
$firstAuthorEmail = $contactInterne !== '' ? $contactInterne : ($post['mail'] ?? null);
|
||||
$firstAuthorEmail = $contactInterne !== '' ? $contactInterne : null;
|
||||
$authorNames = [];
|
||||
if ($authorsRaw !== '') {
|
||||
$authorNames = array_values(array_filter(array_map('trim', explode(',', $authorsRaw)), fn ($n) => $n !== ''));
|
||||
@@ -246,7 +248,7 @@ class ThesisEditController
|
||||
$authorEntries[] = [
|
||||
'name' => $name,
|
||||
'email' => $i === 0 ? $firstAuthorEmail : null,
|
||||
'show_contact' => $i === 0 ? $showContact : false,
|
||||
'show_contact' => $i === 0,
|
||||
];
|
||||
}
|
||||
$this->db->setThesisAuthors($thesisId, $authorEntries);
|
||||
|
||||
@@ -1037,8 +1037,8 @@ class Database
|
||||
$cleanEmail = null; // don't steal another author's email
|
||||
}
|
||||
}
|
||||
$updateStmt = $this->pdo->prepare('UPDATE authors SET email = ?, show_contact = ? WHERE id = ?');
|
||||
$updateStmt->execute([$cleanEmail, $showContact ? 1 : 0, $author['id']]);
|
||||
$updateStmt = $this->pdo->prepare('UPDATE authors SET name = ?, email = ?, show_contact = ? WHERE id = ?');
|
||||
$updateStmt->execute([$name, $cleanEmail, $showContact ? 1 : 0, $author['id']]);
|
||||
return $author['id'];
|
||||
}
|
||||
|
||||
@@ -2007,7 +2007,7 @@ class Database
|
||||
public function getThesisRawFields(int $thesisId): ?array
|
||||
{
|
||||
$stmt = $this->pdo->prepare(
|
||||
'SELECT license_id, license_custom, access_type_id, context_note, remarks, jury_points, exemplaire_baiu, exemplaire_erg, cc2r FROM theses WHERE id = ? LIMIT 1'
|
||||
'SELECT license_id, license_custom, access_type_id, context_note, contact_visible, remarks, jury_points, exemplaire_baiu, exemplaire_erg, cc2r, is_published FROM theses WHERE id = ? LIMIT 1'
|
||||
);
|
||||
$stmt->execute([$thesisId]);
|
||||
$row = $stmt->fetch();
|
||||
@@ -2140,6 +2140,7 @@ class Database
|
||||
finality_id = ?,
|
||||
synopsis = ?,
|
||||
context_note = ?,
|
||||
contact_visible = ?,
|
||||
baiu_link = ?,
|
||||
license_id = ?,
|
||||
license_custom = ?,
|
||||
@@ -2170,6 +2171,7 @@ class Database
|
||||
$finality,
|
||||
$data['synopsis'],
|
||||
!empty($data['context_note']) ? $data['context_note'] : null,
|
||||
!empty($data['contact_visible']) ? $data['contact_visible'] : null,
|
||||
!empty($data['baiu_link']) ? $data['baiu_link'] : null,
|
||||
$license,
|
||||
!empty($data['license_custom']) ? $data['license_custom'] : null,
|
||||
@@ -2215,7 +2217,7 @@ class Database
|
||||
INSERT INTO theses (
|
||||
identifier, title, subtitle, year,
|
||||
orientation_id, ap_program_id, finality_id,
|
||||
synopsis, context_note,
|
||||
synopsis, context_note, contact_visible,
|
||||
baiu_link, license_id, license_custom,
|
||||
access_type_id,
|
||||
objet,
|
||||
@@ -2224,7 +2226,7 @@ class Database
|
||||
exemplaire_baiu, exemplaire_erg,
|
||||
cc2r,
|
||||
submitted_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
|
||||
');
|
||||
|
||||
$validObjet = ['tfe', 'thèse', 'frart'];
|
||||
@@ -2246,6 +2248,7 @@ class Database
|
||||
$finality ? (int)$finality : null,
|
||||
$data['synopsis'],
|
||||
!empty($data['context_note']) ? $data['context_note'] : null,
|
||||
!empty($data['contact_visible']) ? $data['contact_visible'] : null,
|
||||
!empty($data['baiu_link']) ? $data['baiu_link'] : null,
|
||||
$license ? (int)$license : null,
|
||||
!empty($data['license_custom']) ? $data['license_custom'] : null,
|
||||
|
||||
@@ -28,7 +28,7 @@ class StudentEmail
|
||||
'Atelier pluridisciplinaire' => $thesis['ap_program'] ?? '',
|
||||
'Finalité' => $thesis['finality_type'] ?? '',
|
||||
'Synopsis' => $thesis['synopsis'] ?? '',
|
||||
'Note contextuelle' => $thesis['context_note'] ?? '',
|
||||
'Note contextuelle relative à soutenance' => $thesis['context_note'] ?? '',
|
||||
'Langue(s)' => $thesis['languages'] ?? '',
|
||||
'Format(s)' => $thesis['formats'] ?? '',
|
||||
'Mots-clés' => $thesis['keywords'] ?? '',
|
||||
|
||||
Reference in New Issue
Block a user