mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Root cause: SQLite uses BINARY collation, so WHERE name = ? is case-sensitive. When changing 'john doe' to 'John Doe', the name lookup failed and fell through to the email path which didn't update the name. The previous fix only added UPDATE in the name-match branch. Fixes in findOrCreateAuthor: 1. Accept optional $idHint parameter — when known (edit flow), update directly by ID (fastest, zero ambiguity) 2. Add COLLATE NOCASE to the name lookup (fallback path) 3. Add UPDATE in the email fallback path too setThesisAuthors now fetches existing author_ids before deletion and passes them as position-based hints, so identity is always preserved.
139 lines
7.9 KiB
PHP
139 lines
7.9 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/fragments/licence.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/fragments/licence.php' : '/partage/fragments/licence.php' ?>"
|
||
hx-target=".licence-license-choice"
|
||
hx-swap="outerHTML"
|
||
hx-include="closest fieldset"
|
||
<?= (string)$selectedAccess === '1' ? 'checked' : '' ?> <?= $adminMode ? '' : 'required' ?>>
|
||
<strong>🔓 Libre</strong>
|
||
<br>
|
||
</label>
|
||
<details>
|
||
<summary> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"></path></svg> Info</summary>
|
||
<p>
|
||
Mon TFE est en libre accès à tout le monde sur la plateforme des TFE ainsi que dans la bibliothèque de l’erg. Je suis conscient des responsabilités et obligations légales qui viennent avec une diffusion externe – et acquiesce avoir lu la documentation prévue à cet effet par l'erg, ainsi qu'avoir discuté des enjeux d'une publication avec l'équipe pédagogique. J'accepte de partager mes droits de diffusion avec l'erg, ce uniquement dans le cadre d'une diffusion sur la plateforme xamxam.
|
||
</p>
|
||
</details>
|
||
</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/fragments/licence.php' : '/partage/fragments/licence.php' ?>"
|
||
hx-target=".licence-license-choice"
|
||
hx-swap="outerHTML"
|
||
hx-include="closest fieldset"
|
||
<?= (string)$selectedAccess === '2' ? 'checked' : '' ?> <?= $adminMode ? '' : 'required' ?>>
|
||
<strong>🔒 Interne</strong>
|
||
</label>
|
||
<br>
|
||
<details>
|
||
<summary> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"></path></svg> Info</summary>
|
||
<p>
|
||
Mon TFE et ma note d'intention ne sont accessibles que sur place en physique ainsi que sur la plateforme xamxam par la communauté erg. Une note descriptive est disponible sur le site à toustes. J’autorise une (ré-)utilisation et diffusion dans un contexte académique et didactique au sein de l'erg.
|
||
</p>
|
||
</details>
|
||
|
||
</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/fragments/licence.php' : '/partage/fragments/licence.php' ?>"
|
||
hx-target=".licence-license-choice"
|
||
hx-swap="outerHTML"
|
||
hx-include="closest fieldset"
|
||
<?= (string)$selectedAccess === '3' ? 'checked' : '' ?> <?= $adminMode ? '' : 'required' ?>>
|
||
<strong>🚫 Interdit</strong>
|
||
|
||
</label>
|
||
<br>
|
||
<details>
|
||
<summary> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"></path></svg> Info</summary>
|
||
<p>
|
||
Mon TFE n’est pas disponible en physique ni sur le site. Une note descriptive est disponible sur le site.
|
||
</p>
|
||
</details>
|
||
</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>
|
||
|
||
<!-- Seed saved licence values for the initial htmx load.
|
||
These are overridden by visible inputs inside .licence-license-choice
|
||
once htmx renders them — later DOM order wins in POST. -->
|
||
<input type="hidden" name="license_id" value="<?= htmlspecialchars((string)($formData['license_id'] ?? '')) ?>">
|
||
<input type="hidden" name="license_custom" value="<?= htmlspecialchars($formData['license_custom'] ?? '') ?>">
|
||
<input type="hidden" name="cc2r" value="<?= !empty($formData['cc2r']) ? '1' : '' ?>">
|
||
<?php $wantLicense = !empty($formData['license_id']) || !empty($formData['license_custom']); ?>
|
||
<input type="hidden" name="want_license" value="<?= $wantLicense ? '1' : '' ?>">
|
||
|
||
<!-- Licence — swapped via htmx when radio changes -->
|
||
<div class="licence-license-choice"
|
||
hx-post="<?= $adminMode ? '/admin/fragments/licence.php' : '/partage/fragments/licence.php' ?>"
|
||
hx-trigger="load"
|
||
hx-include="closest fieldset"
|
||
hx-swap="outerHTML">
|
||
</div>
|
||
</fieldset>
|