From f9d8fab120b3562760cf1e29d01cd6b458a69434 Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Wed, 8 Jul 2026 13:42:26 +0200 Subject: [PATCH] =?UTF-8?q?partage:=20lock=20Ann=C3=A9e=20field=20to=20lin?= =?UTF-8?q?k's=20locked=5Fyear=20when=20present?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a student-access share link specifies a locked_year, the Année field in the student-facing form is now pre-filled with that year and rendered as disabled+readonly, with a hidden input ensuring the value is submitted. - renderShareLinkForm() exposes from ['locked_year'] - fieldset-academic.php checks for : if set, outputs a hidden input plus the visible field locked to that value; otherwise falls back to the normal editable field --- app/public/partage/index.php | 4 ++++ .../partials/form/fieldset-academic.php | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/public/partage/index.php b/app/public/partage/index.php index dd61d7c..ee94056 100644 --- a/app/public/partage/index.php +++ b/app/public/partage/index.php @@ -317,6 +317,10 @@ function renderShareLinkForm(string $slug, array $link): void $oldFn = $shareOldFn; $withAutofocusFn = $shareWithAutofocusFn; + // Locked academic year: if the link specifies a locked year, pre-fill + // and lock the Année field so students cannot change it. + $lockedYear = $link['locked_year'] ?? null; + // Synopsis extra: inject fieldset_synopsis help block ob_start(); $helpContent = $helpFn('fieldset_synopsis'); diff --git a/app/templates/partials/form/fieldset-academic.php b/app/templates/partials/form/fieldset-academic.php index fe40e85..fbee1f0 100644 --- a/app/templates/partials/form/fieldset-academic.php +++ b/app/templates/partials/form/fieldset-academic.php @@ -15,15 +15,30 @@ $oldFn = $oldFn ?? (function_exists('old') ? 'old' : fn($k, $withAutofocusFn = $withAutofocusFn ?? fn($field, $attrs = []) => $attrs; $formData = $formData ?? []; $adminMode = $adminMode ?? false; +$lockedYear = $lockedYear ?? null; ?>
Cadre académique 2000, 'max' => date('Y') + 1]); + + if ($lockedYear !== null): + // Link specifies a locked academic year: pre-fill, disable editing. + $value = (string)$lockedYear; + $attrs['disabled'] = true; + $attrs['readonly'] = true; + // Include a hidden input so the value is still submitted when the field is disabled. + ?> + +