Rename author_email→contact_interne, author_show_contact→contact_public across view/controllers/templates

- v_theses_full: author_email→contact_interne, author_show_contact→contact_public
- Updated schema.sql and live DB view
- Renamed all PHP variables: currentAuthorEmail→contactInterne, currentAuthorShowContact→contactPublic
- Restored contact_interne backoffice field with proper wiring (takes precedence over mail field)
- Updated admin/add.php, admin/edit.php, partage/index.php, public/tfe.php templates
This commit is contained in:
Pontoporeia
2026-05-10 03:02:53 +02:00
parent 8a4b2541fb
commit fa30aab368
10 changed files with 55 additions and 21 deletions

View File

@@ -75,5 +75,8 @@
- [x] Fix: formulaire.php unconditionally suppresses display_errors even in dev mode - [x] Fix: formulaire.php unconditionally suppresses display_errors even in dev mode
- [x] Fix: access_type_id radio has no "none" option — added "— Non défini" radio for admin mode - [x] Fix: access_type_id radio has no "none" option — added "— Non défini" radio for admin mode
- [x] Fix: radio button checked detection broken (int vs string strict comparison in fieldset-licence-explanation.php) - [x] Fix: radio button checked detection broken (int vs string strict comparison in fieldset-licence-explanation.php)
- [x] Rename author_email → contact_interne in v_theses_full view, controllers, forms, and templates
- [x] Rename author_show_contact → contact_public in v_theses_full view
- [x] Restore contact_interne backoffice field with proper variable name, wire to save (takes precedence over mail)
- [x] Fix: htmlspecialchars(null) crash in old() on admin/add.php and admin/edit.php (null values in form data) - [x] Fix: htmlspecialchars(null) crash in old() on admin/add.php and admin/edit.php (null values in form data)
- [x] Fix: jury-fieldset.php old() return type confusion (array vs string) for jury_lecteur:_interne:_externe keys - [x] Fix: jury-fieldset.php old() return type confusion (array vs string) for jury_lecteur:_interne:_externe keys

View File

@@ -337,8 +337,8 @@ function renderShareLinkForm(string $slug, array $link): void
// Context / backoffice not shown in partage // Context / backoffice not shown in partage
$currentRaw = []; $currentRaw = [];
$currentAuthorEmail = null; $contactInterne = null;
$currentAuthorShowContact = false; $contactPublic = false;
$currentContextNote = null; $currentContextNote = null;
?> ?>
<!DOCTYPE html> <!DOCTYPE html>

View File

@@ -323,7 +323,12 @@ class ThesisCreateController
throw new Exception("Le champ 'Nom/Prénom/Pseudo' est requis."); throw new Exception("Le champ 'Nom/Prénom/Pseudo' est requis.");
} }
$mail = !empty($post['mail']) ? $this->sanitiseString($post['mail']) : ''; // contact_interne (backoffice) takes precedence over mail (tfe-info fieldset)
$contactInterne = trim($post['contact_interne'] ?? '');
$mail = !empty($post['mail']) ? $this->sanitiseString($post['mail']) : '';
if ($contactInterne !== '') {
$mail = $contactInterne;
}
// contact_public: respected if present (admin form); defaults to true for student forms // contact_public: respected if present (admin form); defaults to true for student forms
// where the spec says contact is always visible when provided. // where the spec says contact is always visible when provided.
if (array_key_exists('contact_public', $post)) { if (array_key_exists('contact_public', $post)) {

View File

@@ -106,8 +106,8 @@ class ThesisEditController
$currentContextNote = $rawRow['context_note'] ?? ''; $currentContextNote = $rawRow['context_note'] ?? '';
// Author contact info (from view) // Author contact info (from view)
$currentAuthorEmail = $thesis['author_email'] ?? ''; $contactInterne = $thesis['contact_interne'] ?? '';
$currentAuthorShowContact = (bool)($thesis['author_show_contact'] ?? false); $contactPublic = (bool)($thesis['contact_public'] ?? false);
return [ return [
'thesis' => $thesis, 'thesis' => $thesis,
@@ -126,8 +126,8 @@ class ThesisEditController
'currentLicenseId' => $currentLicenseId, 'currentLicenseId' => $currentLicenseId,
'currentAccessTypeId' => $currentAccessTypeId, 'currentAccessTypeId' => $currentAccessTypeId,
'currentContextNote' => $currentContextNote, 'currentContextNote' => $currentContextNote,
'currentAuthorEmail' => $currentAuthorEmail, 'contactInterne' => $contactInterne,
'currentAuthorShowContact' => $currentAuthorShowContact, 'contactPublic' => $contactPublic,
'currentRaw' => $rawRow, 'currentRaw' => $rawRow,
'pageTitle' => 'Éditer TFE - ' . htmlspecialchars($thesis['title']), 'pageTitle' => 'Éditer TFE - ' . htmlspecialchars($thesis['title']),
]; ];
@@ -219,6 +219,9 @@ class ThesisEditController
// ── 2. Authors (alphabetically sorted) ───────────────────────────── // ── 2. Authors (alphabetically sorted) ─────────────────────────────
$authorsRaw = trim($post['auteurice'] ?? ''); $authorsRaw = trim($post['auteurice'] ?? '');
$showContact = !empty($post['contact_public']); $showContact = !empty($post['contact_public']);
// contact_interne (backoffice) takes precedence over mail (tfe-info fieldset)
$contactInterne = trim($post['contact_interne'] ?? '');
$firstAuthorEmail = $contactInterne !== '' ? $contactInterne : ($post['mail'] ?? null);
$authorNames = []; $authorNames = [];
if ($authorsRaw !== '') { if ($authorsRaw !== '') {
$authorNames = array_values(array_filter(array_map('trim', explode(',', $authorsRaw)), fn ($n) => $n !== '')); $authorNames = array_values(array_filter(array_map('trim', explode(',', $authorsRaw)), fn ($n) => $n !== ''));
@@ -228,7 +231,7 @@ class ThesisEditController
foreach ($authorNames as $i => $name) { foreach ($authorNames as $i => $name) {
$authorEntries[] = [ $authorEntries[] = [
'name' => $name, 'name' => $name,
'email' => $i === 0 ? ($post['mail'] ?? null) : null, 'email' => $i === 0 ? $firstAuthorEmail : null,
'show_contact' => $i === 0 ? $showContact : false, 'show_contact' => $i === 0 ? $showContact : false,
]; ];
} }

View File

@@ -529,8 +529,8 @@ SELECT
GROUP_CONCAT(DISTINCT fmt.name) as formats, GROUP_CONCAT(DISTINCT fmt.name) as formats,
GROUP_CONCAT(DISTINCT tg.name) as keywords, GROUP_CONCAT(DISTINCT tg.name) as keywords,
-- First author's email and contact-visibility flag -- First author's email and contact-visibility flag
(SELECT a2.email FROM authors a2 JOIN thesis_authors ta2 ON a2.id = ta2.author_id WHERE ta2.thesis_id = t.id ORDER BY ta2.author_order LIMIT 1) as author_email, (SELECT a2.email FROM authors a2 JOIN thesis_authors ta2 ON a2.id = ta2.author_id WHERE ta2.thesis_id = t.id ORDER BY ta2.author_order LIMIT 1) as contact_interne,
(SELECT a2.show_contact FROM authors a2 JOIN thesis_authors ta2 ON a2.id = ta2.author_id WHERE ta2.thesis_id = t.id ORDER BY ta2.author_order LIMIT 1) as author_show_contact (SELECT a2.show_contact FROM authors a2 JOIN thesis_authors ta2 ON a2.id = ta2.author_id WHERE ta2.thesis_id = t.id ORDER BY ta2.author_order LIMIT 1) as contact_public
FROM theses t FROM theses t
LEFT JOIN orientations o ON t.orientation_id = o.id LEFT JOIN orientations o ON t.orientation_id = o.id
LEFT JOIN ap_programs ap ON t.ap_program_id = ap.id LEFT JOIN ap_programs ap ON t.ap_program_id = ap.id

View File

@@ -74,6 +74,19 @@
+%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision) +%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision)
+\\\\\\\ to: vpwuyvyv f513921d "Fix: email clearing in findOrCreateAuthor, htmlspecialchars(null) crash in old(), dead contact_interne field, access_type_id radio clearing" (rebased revision) +\\\\\\\ to: vpwuyvyv f513921d "Fix: email clearing in findOrCreateAuthor, htmlspecialchars(null) crash in old(), dead contact_interne field, access_type_id radio clearing" (rebased revision)
++ $linkName = $link['name'] ?? ''; ++ $linkName = $link['name'] ?? '';
++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
%%%%%%%%%%%%%%%%%%% diff from: vpwuyvyv f513921d "Fix: email clearing in findOrCreateAuthor, htmlspecialchars(null) crash in old(), dead contact_interne field, access_type_id radio clearing" (rebased revision)
\\\\\\\\\\\\\\\\\\\ to: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision)
- $linkName = $link['name'] ?? '';
- $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
%%%%%%%%%%%%%%%%%%% diff from: somsyvxz 14a3cd10 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebase destination)
\\\\\\\\\\\\\\\\\\\ to: pntwsqvs baf8b60c "Rename author_email→contact_interne, author_show_contact→contact_public across view/controllers/templates" (rebased revision)
$linkName = $link['name'] ?? '';
$linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
$linkLockedYear = $link['locked_year'] ?? null;
+%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision)
+\\\\\\\ to: pntwsqvs dd95b4d3 "Rename author_email→contact_interne, author_show_contact→contact_public across view/controllers/templates" (rebased revision)
++ $linkName = $link['name'] ?? '';
++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; ++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
?> ?>
<tr class="admin-table-row" onclick="event.stopPropagation(); window.open('/partage/<?= urlencode($link['slug']) ?>', '_blank')" style="cursor:pointer"> <tr class="admin-table-row" onclick="event.stopPropagation(); window.open('/partage/<?= urlencode($link['slug']) ?>', '_blank')" style="cursor:pointer">

View File

@@ -39,8 +39,8 @@
// Backoffice (add mode: null → falls back to formData) // Backoffice (add mode: null → falls back to formData)
$currentRaw = []; $currentRaw = [];
$currentAuthorEmail = null; $contactInterne = null;
$currentAuthorShowContact = false; $contactPublic = false;
$currentContextNote = null; $currentContextNote = null;
include APP_ROOT . '/templates/partials/form/form.php'; include APP_ROOT . '/templates/partials/form/form.php';

View File

@@ -7,7 +7,7 @@
'titre' => $thesis['title'], 'titre' => $thesis['title'],
'subtitle' => $thesis['subtitle'] ?? '', 'subtitle' => $thesis['subtitle'] ?? '',
'auteurice' => $thesis['authors'] ?? '', 'auteurice' => $thesis['authors'] ?? '',
'mail' => $currentAuthorEmail ?? '', 'mail' => $contactInterne ?? '',
'synopsis' => $thesis['synopsis'] ?? '', 'synopsis' => $thesis['synopsis'] ?? '',
'tag' => $thesis['keywords'] ?? '', 'tag' => $thesis['keywords'] ?? '',
'année' => $thesis['year'], 'année' => $thesis['year'],
@@ -15,7 +15,8 @@
'ap' => $thesis['ap_program'], 'ap' => $thesis['ap_program'],
'finality' => $thesis['finality_type'], 'finality' => $thesis['finality_type'],
'lien' => $thesis['baiu_link'] ?? '', 'lien' => $thesis['baiu_link'] ?? '',
'contact_public' => $currentAuthorShowContact ?? false, 'contact_public' => $contactPublic ?? false,
'contact_interne' => $contactInterne ?? '',
]); ]);
$oldFn = fn(string $key, string $default = '') => $oldFn = fn(string $key, string $default = '') =>
isset($editFormData[$key]) && !is_array($editFormData[$key]) isset($editFormData[$key]) && !is_array($editFormData[$key])

View File

@@ -45,8 +45,8 @@
* array $currentFiles — existing thesis files for edit mode * array $currentFiles — existing thesis files for edit mode
* ?string $currentContextNote — existing context note for edit mode * ?string $currentContextNote — existing context note for edit mode
* array $currentRaw — raw thesis row for edit mode * array $currentRaw — raw thesis row for edit mode
* ?string $currentAuthorShowContact — author show_contact flag for edit mode * ?string $contactPublic — contact visibility flag for edit mode
* ?string $currentAuthorEmail — author email for edit mode * ?string $contactInterne — contact email for edit mode
* *
* Website: * Website:
* string $existingWebsiteUrl * string $existingWebsiteUrl
@@ -159,7 +159,7 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
<label class="admin-checkbox-label"> <label class="admin-checkbox-label">
<input type="checkbox" name="contact_public" value="1" <input type="checkbox" name="contact_public" value="1"
<?= !empty($formData["contact_public"]) || <?= !empty($formData["contact_public"]) ||
($currentAuthorShowContact ?? false) ($contactPublic ?? false)
? "checked" ? "checked"
: "" ?>> : "" ?>>
Rendre le contact visible publiquement sur la fiche du TFE Rendre le contact visible publiquement sur la fiche du TFE
@@ -511,7 +511,16 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
<small>Case logistique : cocher si un exemplaire physique est disponible à l'ERG.</small> <small>Case logistique : cocher si un exemplaire physique est disponible à l'ERG.</small>
</div> </div>
<!-- 7. Publication --> <!-- 7. Contact interne -->
<div class="admin-form-group">
<label for="contact_interne">Contact interne :</label>
<input type="email" id="contact_interne" name="contact_interne"
value="<?= htmlspecialchars($contactInterne ?? $formData['contact_interne'] ?? '') ?>"
placeholder="ton.email@exemple.be">
<small>Adresse de contact interne (non visible publiquement). Peut être laissé vide.</small>
</div>
<!-- 8. Publication -->
<div class="admin-form-group"> <div class="admin-form-group">
<label class="admin-checkbox-label"> <label class="admin-checkbox-label">
<input type="checkbox" name="is_published" value="1" <input type="checkbox" name="is_published" value="1"

View File

@@ -226,14 +226,14 @@
<?php endif; ?> <?php endif; ?>
<?php if ( <?php if (
!empty($data["author_email"]) && !empty($data["contact_interne"]) &&
!empty($data["author_show_contact"]) !empty($data["contact_public"])
): ?> ): ?>
<div> <div>
<dt>Contact :</dt> <dt>Contact :</dt>
<dd> <dd>
<?php <?php
$_contact = $data["author_email"]; $_contact = $data["contact_interne"];
$_isUrl = $_isUrl =
filter_var($_contact, FILTER_VALIDATE_URL) !== filter_var($_contact, FILTER_VALIDATE_URL) !==
false; false;