mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
- findOrCreateAuthor: always update email column (pass null when empty/falsy) so clearing an email actually persists - admin/add.php & admin/edit.php old(): add null guard before htmlspecialchars, cast to string - jury-fieldset.php: guard against old() returning array for scalar-checked jury_lecteur keys - formulaire.php: only suppress display_errors in production (not cli-server dev mode) - Removed dead contact_interne field from backoffice form (no DB column, never saved) - Removed dead contactInterne validation from ThesisCreateController - Added "— Non défini" radio option for access_type_id in admin mode for clearing - Fixed strict int-vs-string comparison breaking radio button checked detection
107 lines
5.1 KiB
PHP
107 lines
5.1 KiB
PHP
<?php
|
|
/**
|
|
* Shared partial — "Degrés d'ouverture et licences" fieldset.
|
|
*
|
|
* Renders:
|
|
* 1. Généralités (editable via form help blocks)
|
|
* 2. Radio choice: Libre / Interne / Interdit (filtered by enabled flags)
|
|
* 3. Licence dropdown + custom licence text input
|
|
* 4. CC2r checkbox
|
|
*
|
|
* Variables consumed:
|
|
* array $formData — raw form data for repopulation
|
|
* array $licenseTypes — [{id, name}]
|
|
* bool $libreEnabled — show Libre option (always true for admin)
|
|
* bool $interneEnabled — show Interne option
|
|
* bool $interditEnabled — show Interdit option
|
|
* string $generalitiesHtml — HTML content for Généralités section (editable)
|
|
* int $defaultAccessTypeId — default selected access type (default: 2)
|
|
*/
|
|
|
|
$formData = $formData ?? [];
|
|
$licenseTypes = $licenseTypes ?? [];
|
|
$libreEnabled = $libreEnabled ?? true;
|
|
$interneEnabled = $interneEnabled ?? true;
|
|
$interditEnabled = $interditEnabled ?? true;
|
|
$generalitiesHtml = $generalitiesHtml ?? '';
|
|
$defaultAccessTypeId = $defaultAccessTypeId ?? 2;
|
|
$adminMode = $adminMode ?? false;
|
|
?>
|
|
<fieldset class="licence-explanation">
|
|
<legend>Degrés d'ouverture et licences</legend>
|
|
|
|
<!-- Degré d'ouverture -->
|
|
<div class="licence-choice">
|
|
<p class="licence-prompt">J'autorise l'erg à archiver mon TFE de la manière suivante :</p>
|
|
<?php
|
|
// access_type_id may be null (meaning "not set"). Keep null to select "—" radio.
|
|
$selectedAccess = array_key_exists('access_type_id', $formData) ? $formData['access_type_id'] : $defaultAccessTypeId;
|
|
?>
|
|
|
|
<?php if ($adminMode): ?>
|
|
<div class="licence-degree">
|
|
<label class="admin-checkbox-label">
|
|
<input type="radio" name="access_type_id" value=""
|
|
hx-post="/admin/licence-fragment.php"
|
|
hx-target=".licence-license-choice"
|
|
hx-swap="outerHTML"
|
|
hx-include="closest fieldset"
|
|
<?= $selectedAccess === '' || $selectedAccess === null ? 'checked' : '' ?>>
|
|
<strong>—</strong> Non défini
|
|
</label>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($libreEnabled): ?>
|
|
<div class="licence-degree">
|
|
<label class="admin-checkbox-label">
|
|
<input type="radio" name="access_type_id" value="1"
|
|
hx-post="<?= $adminMode ? '/admin/licence-fragment.php' : '/partage/licence-fragment' ?>"
|
|
hx-target=".licence-license-choice"
|
|
hx-swap="outerHTML"
|
|
hx-include="closest fieldset"
|
|
<?= (string)$selectedAccess === '1' ? 'checked' : '' ?> <?= $adminMode ? '' : 'required' ?>>
|
|
<strong>🔓 Libre</strong> — Mon TFE est en libre accès à tout le monde sur la plateforme des TFE ainsi que dans la bibliothèque de l'erg.
|
|
</label>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($interneEnabled): ?>
|
|
<div class="licence-degree">
|
|
<label class="admin-checkbox-label">
|
|
<input type="radio" name="access_type_id" value="2"
|
|
hx-post="<?= $adminMode ? '/admin/licence-fragment.php' : '/partage/licence-fragment' ?>"
|
|
hx-target=".licence-license-choice"
|
|
hx-swap="outerHTML"
|
|
hx-include="closest fieldset"
|
|
<?= (string)$selectedAccess === '2' ? 'checked' : '' ?> <?= $adminMode ? '' : 'required' ?>>
|
|
<strong>🔒 Interne</strong> — Mon TFE n'est accessible que sur place en physique. Une note descriptive est disponible sur le site.
|
|
</label>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($interditEnabled): ?>
|
|
<div class="licence-degree">
|
|
<label class="admin-checkbox-label">
|
|
<input type="radio" name="access_type_id" value="3"
|
|
hx-post="<?= $adminMode ? '/admin/licence-fragment.php' : '/partage/licence-fragment' ?>"
|
|
hx-target=".licence-license-choice"
|
|
hx-swap="outerHTML"
|
|
hx-include="closest fieldset"
|
|
<?= (string)$selectedAccess === '3' ? 'checked' : '' ?> <?= $adminMode ? '' : 'required' ?>>
|
|
<strong>🚫 Interdit</strong> — Mon TFE n'est pas disponible en physique ni sur le site. Une note descriptive est disponible sur le site.
|
|
</label>
|
|
</div>
|
|
<?php endif; ?>
|
|
<p class="licence-note"><em>L'auteur·ice peut, à tout moment, décider de restreindre son propre choix. Iel ne peut par contre pas l'ouvrir.</em></p>
|
|
</div>
|
|
|
|
<!-- Licence — swapped via htmx when radio changes -->
|
|
<div class="licence-license-choice"
|
|
hx-post="<?= $adminMode ? '/admin/licence-fragment.php' : '/partage/licence-fragment' ?>"
|
|
hx-trigger="load"
|
|
hx-include="closest fieldset"
|
|
hx-swap="outerHTML">
|
|
</div>
|
|
</fieldset>
|