mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
1. note_intention: Delete old file only when a genuinely new upload arrives
(32-char hex file_id), not when the FilePond pool preserves an existing
file by sending its DB integer ID. Previously the DB integer ID
triggered $hasNewNote=true, which deleted the existing note_intention
from disk+DB, then handleFilePondSingleFile couldn't re-process it
because the regex requires a hex pattern. Same fix applied to cover.
2. All file deletions now use deleteThesisFileToTrash() which renames
files to tmp/_trash/ instead of unlinking. The trash preserves
original filenames prefixed with DB id for traceability. Skips
website URLs and PeerTube refs (no disk file).
3. Storage prefix changed from theses/ to documents/ to reflect that
the folder holds all document types (determined by file_type in DB).
MediaController visibility gate supports both prefixes for backward
compat with existing files.
4. File browser + relink feature for orphaned files:
- /admin/fragments/file-browser.php — HTMX tree browser for
storage/documents/ and storage/theses/
- /admin/actions/filepond/relink.php — POST endpoint that inserts
a thesis_files row pointing to existing on-disk file
- Per-pool "📂 Relier" buttons (edit mode only)
- JS: XamxamOpenFileBrowser / XamxamRelinkFile with FilePond integration
- CSS: .relink-modal dialog + .file-browser tree styles
256 lines
15 KiB
PHP
256 lines
15 KiB
PHP
<?php
|
|
/**
|
|
* Jury composition fieldset partial.
|
|
*
|
|
* Variables consumed (all optional — defaults to empty/add-mode):
|
|
* $juryPromoteur string|null Promoteur interne name (single or primary)
|
|
* $juryPromoteurs array [{name: string}] Multiple promoteurs internes
|
|
* $juryPromoteurUlb string|null Promoteur ULB name (single or primary)
|
|
* $juryPromoteursUlb array [{name: string}] Multiple promoteurs ULB
|
|
* $lecteursInternes array [{name: string}]
|
|
* $lecteursExternes array [{name: string}]
|
|
* $juryPresident string|null (Deprecated — no longer displayed)
|
|
* $showPromoteurUlb bool Show ULB promoteur field (default: true)
|
|
* $promoteurUlbConditional bool If true, field is hidden unless finality=Approfondi
|
|
* callable|null $oldFn — callable($key, $default='') to retrieve old/current values;
|
|
* falls back to the global old() function when null.
|
|
* array $formData — raw form data array (used for jury repopulation).
|
|
*
|
|
* In add-mode repopulation: if $oldFn is provided and values are null, populate from it.
|
|
*/
|
|
|
|
$juryPromoteur = $juryPromoteur ?? null;
|
|
$juryPromoteurs = $juryPromoteurs ?? [];
|
|
$juryPromoteurUlb = $juryPromoteurUlb ?? null;
|
|
$juryPromoteursUlb = $juryPromoteursUlb ?? [];
|
|
$lecteursInternes = $lecteursInternes ?? [];
|
|
$lecteursExternes = $lecteursExternes ?? [];
|
|
$showPromoteurUlb = $showPromoteurUlb ?? true;
|
|
$promoteurUlbConditional = $promoteurUlbConditional ?? false;
|
|
$adminMode = $adminMode ?? false;
|
|
$oldFn = $oldFn ?? (function_exists('old') ? 'old' : fn($k, $d = '') => $d);
|
|
|
|
// Add-mode repopulation from flash data
|
|
$addMode = ($juryPromoteur === null && empty($juryPromoteurs) && $juryPromoteurUlb === null && empty($juryPromoteursUlb) && empty($lecteursInternes) && empty($lecteursExternes));
|
|
if ($addMode) {
|
|
// jury_promoteur may be array (new form) or scalar (legacy)
|
|
$promoteursOld = $oldFn('jury_promoteur');
|
|
if (is_array($promoteursOld)) {
|
|
foreach ($promoteursOld as $name) {
|
|
$name = trim($name ?? '');
|
|
if ($name !== '') $juryPromoteurs[] = ['name' => $name];
|
|
}
|
|
} elseif (is_string($promoteursOld) && trim($promoteursOld) !== '') {
|
|
$juryPromoteur = $promoteursOld;
|
|
}
|
|
// jury_promoteur_ulb_name may be array (new form) or scalar (legacy)
|
|
$promoteursUlbOld = $oldFn('jury_promoteur_ulb_name');
|
|
if (is_array($promoteursUlbOld)) {
|
|
foreach ($promoteursUlbOld as $name) {
|
|
$name = trim($name ?? '');
|
|
if ($name !== '') $juryPromoteursUlb[] = ['name' => $name];
|
|
}
|
|
} elseif (is_string($promoteursUlbOld) && trim($promoteursUlbOld) !== '') {
|
|
$juryPromoteurUlb = $promoteursUlbOld;
|
|
}
|
|
for ($i = 0; $i < 10; $i++) {
|
|
$n = $oldFn("jury_lecteur_interne:$i");
|
|
if (is_string($n) && $n !== '') $lecteursInternes[] = ['name' => $n];
|
|
}
|
|
for ($i = 0; $i < 10; $i++) {
|
|
$n = $oldFn("jury_lecteur_externe:$i");
|
|
if (is_string($n) && $n !== '') $lecteursExternes[] = ['name' => $n];
|
|
}
|
|
}
|
|
?>
|
|
<fieldset>
|
|
<legend>Composition du jury</legend>
|
|
|
|
<!-- Promoteur·ice(s) interne -->
|
|
<fieldset class="admin-jury-lecteurs" data-jury-autocomplete data-jury-hx-post="<?= $adminMode ? '/admin/fragments/pill-search.php' : '/partage/fragments/pill-search.php' ?>" data-jury-role="promoteur_interne">
|
|
<legend>Promoteur·ice(s) interne<?= $adminMode ? '' : ' <span class="asterisk">*</span>' ?></legend>
|
|
<div id="jury-promoteur-interne-list" class="admin-jury-list">
|
|
<?php if (empty($juryPromoteurs) && $juryPromoteur === null): ?>
|
|
<div class="admin-jury-entry">
|
|
<input type="text" name="jury_promoteur[]" placeholder="Nom" <?= $adminMode ? '' : 'required' ?>
|
|
id="jury_promoteur" aria-label="Promoteur·ice interne 1 — nom" autocomplete="off">
|
|
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
|
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
|
</div>
|
|
<?php elseif (!empty($juryPromoteurs)): ?>
|
|
<?php foreach ($juryPromoteurs as $pi => $pm): ?>
|
|
<div class="admin-jury-entry">
|
|
<input type="text" name="jury_promoteur[]"
|
|
value="<?= htmlspecialchars($pm['name']) ?>" placeholder="Nom"
|
|
<?= (!$adminMode && $pi === 0) ? 'required' : '' ?>
|
|
aria-label="Promoteur·ice interne <?= $pi + 1 ?> — nom" autocomplete="off">
|
|
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
|
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<div class="admin-jury-entry">
|
|
<input type="text" name="jury_promoteur[]"
|
|
value="<?= htmlspecialchars($juryPromoteur ?? '') ?>" placeholder="Nom" <?= $adminMode ? '' : 'required' ?>
|
|
aria-label="Promoteur·ice interne 1 — nom" autocomplete="off">
|
|
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
|
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<button type="button" class="btn btn--secondary admin-add-jury-btn"
|
|
onclick="addJuryRow('jury-promoteur-interne-list', 'jury_promoteur[]', 'Promoteur·ice interne')">
|
|
+ Ajouter un·e promoteur·ice interne
|
|
</button>
|
|
</fieldset>
|
|
|
|
<?php if ($showPromoteurUlb): ?>
|
|
<!-- Promoteur·ice(s) ULB -->
|
|
<fieldset class="admin-jury-lecteurs" id="jury-promoteur-ulb-row"<?= $promoteurUlbConditional ? ' style="display:none"' : '' ?> data-jury-autocomplete data-jury-hx-post="<?= $adminMode ? '/admin/fragments/pill-search.php' : '/partage/fragments/pill-search.php' ?>" data-jury-role="promoteur_externe">
|
|
<legend>Promoteur·ice(s) ULB<span id="jury-ulb-asterisk" style="display:none"> <span class="asterisk">*</span></span></legend>
|
|
<div id="jury-promoteur-ulb-list" class="admin-jury-list">
|
|
<?php if (empty($juryPromoteursUlb) && $juryPromoteurUlb === null): ?>
|
|
<div class="admin-jury-entry">
|
|
<input type="text" name="jury_promoteur_ulb_name[]" placeholder="Nom"
|
|
aria-label="Promoteur·ice ULB 1 — nom" autocomplete="off">
|
|
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
|
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
|
</div>
|
|
<?php elseif (!empty($juryPromoteursUlb)): ?>
|
|
<?php foreach ($juryPromoteursUlb as $pi => $pm): ?>
|
|
<div class="admin-jury-entry">
|
|
<input type="text" name="jury_promoteur_ulb_name[]"
|
|
value="<?= htmlspecialchars($pm['name']) ?>" placeholder="Nom"
|
|
aria-label="Promoteur·ice ULB <?= $pi + 1 ?> — nom" autocomplete="off">
|
|
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
|
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<div class="admin-jury-entry">
|
|
<input type="text" name="jury_promoteur_ulb_name[]"
|
|
value="<?= htmlspecialchars($juryPromoteurUlb ?? '') ?>" placeholder="Nom"
|
|
aria-label="Promoteur·ice ULB 1 — nom" autocomplete="off">
|
|
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
|
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<button type="button" class="btn btn--secondary admin-add-jury-btn"
|
|
onclick="addJuryRow('jury-promoteur-ulb-list', 'jury_promoteur_ulb_name[]', 'Promoteur·ice ULB')">
|
|
+ Ajouter un·e promoteur·ice ULB
|
|
</button>
|
|
</fieldset>
|
|
<?php if ($promoteurUlbConditional): ?>
|
|
<script>
|
|
(function() {
|
|
try {
|
|
var finalitySelect = document.querySelector('select[name="finality"]');
|
|
var ulbRow = document.getElementById('jury-promoteur-ulb-row');
|
|
if (!finalitySelect || !ulbRow) return;
|
|
var ulbAsterisk = document.getElementById('jury-ulb-asterisk');
|
|
function isApprofondiSelected() {
|
|
var opt = finalitySelect.options[finalitySelect.selectedIndex];
|
|
if (!opt) return false;
|
|
return (opt.textContent || opt.text || '').toLowerCase().includes('approfondi');
|
|
}
|
|
function toggleUlb() {
|
|
var show = isApprofondiSelected();
|
|
ulbRow.style.display = show ? '' : 'none';
|
|
if (ulbAsterisk) ulbAsterisk.style.display = show ? '' : 'none';
|
|
var inputs = ulbRow.querySelectorAll('input[name="jury_promoteur_ulb_name[]"]');
|
|
inputs.forEach(function(inp, idx) {
|
|
inp.required = <?= $adminMode ? 'false' : 'show && idx === 0' ?>;
|
|
inp.disabled = !show;
|
|
if (!show) inp.value = '';
|
|
});
|
|
}
|
|
finalitySelect.addEventListener('change', toggleUlb);
|
|
toggleUlb();
|
|
} catch(e) { console.error('jury ULB toggle:', e); }
|
|
})();
|
|
</script>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
|
|
<!-- Lecteur·ice(s) interne -->
|
|
<fieldset class="admin-jury-lecteurs" data-jury-autocomplete data-jury-hx-post="<?= $adminMode ? '/admin/fragments/pill-search.php' : '/partage/fragments/pill-search.php' ?>" data-jury-role="lecteur_interne">
|
|
<legend>Lecteur·ice(s) interne<?= $adminMode ? '' : ' <span class="asterisk">*</span>' ?></legend>
|
|
<div id="jury-lecteurs-internes-list" class="admin-jury-list">
|
|
<?php if (empty($lecteursInternes)): ?>
|
|
<div class="admin-jury-entry">
|
|
<input type="text" name="jury_lecteur_interne[]" placeholder="Nom" <?= $adminMode ? '' : 'required' ?>
|
|
aria-label="Lecteur·ice interne 1 — nom" autocomplete="off">
|
|
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
|
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
|
</div>
|
|
<?php else: ?>
|
|
<?php foreach ($lecteursInternes as $li => $lm): ?>
|
|
<div class="admin-jury-entry">
|
|
<input type="text" name="jury_lecteur_interne[]"
|
|
value="<?= htmlspecialchars($lm['name']) ?>" placeholder="Nom"
|
|
<?= (!$adminMode && $li === 0) ? 'required' : '' ?>
|
|
aria-label="Lecteur·ice interne <?= $li + 1 ?> — nom" autocomplete="off">
|
|
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
|
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<button type="button" class="btn btn--secondary admin-add-jury-btn"
|
|
onclick="addJuryRow('jury-lecteurs-internes-list', 'jury_lecteur_interne[]', 'Lecteur·ice interne')">
|
|
+ Ajouter un·e lecteur·ice interne
|
|
</button>
|
|
</fieldset>
|
|
|
|
<!-- Lecteur·ice(s) externe -->
|
|
<fieldset class="admin-jury-lecteurs" data-jury-autocomplete data-jury-hx-post="<?= $adminMode ? '/admin/fragments/pill-search.php' : '/partage/fragments/pill-search.php' ?>" data-jury-role="lecteur_externe">
|
|
<legend>Lecteur·ice(s) externe<?= $adminMode ? '' : ' <span class="asterisk">*</span>' ?></legend>
|
|
<div id="jury-lecteurs-externes-list" class="admin-jury-list">
|
|
<?php if (empty($lecteursExternes)): ?>
|
|
<div class="admin-jury-entry">
|
|
<input type="text" name="jury_lecteur_externe[]" placeholder="Nom" <?= $adminMode ? '' : 'required' ?>
|
|
aria-label="Lecteur·ice externe 1 — nom" autocomplete="off">
|
|
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
|
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
|
</div>
|
|
<?php else: ?>
|
|
<?php foreach ($lecteursExternes as $li => $lm): ?>
|
|
<div class="admin-jury-entry">
|
|
<input type="text" name="jury_lecteur_externe[]"
|
|
value="<?= htmlspecialchars($lm['name']) ?>" placeholder="Nom"
|
|
<?= (!$adminMode && $li === 0) ? 'required' : '' ?>
|
|
aria-label="Lecteur·ice externe <?= $li + 1 ?> — nom" autocomplete="off">
|
|
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
|
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<button type="button" class="btn btn--secondary admin-add-jury-btn"
|
|
onclick="addJuryRow('jury-lecteurs-externes-list', 'jury_lecteur_externe[]', 'Lecteur·ice externe')">
|
|
+ Ajouter un·e lecteur·ice externe
|
|
</button>
|
|
</fieldset>
|
|
|
|
</fieldset>
|
|
|
|
<script>
|
|
function addJuryRow(listId, inputName, roleLabel) {
|
|
var list = document.getElementById(listId);
|
|
if (!list) return;
|
|
var n = list.querySelectorAll('.admin-jury-entry').length + 1;
|
|
var div = document.createElement('div');
|
|
div.className = 'admin-jury-entry';
|
|
div.innerHTML = '<input type="text" name="' + inputName + '" placeholder="Nom" autocomplete="off"'
|
|
+ ' aria-label="' + roleLabel + ' ' + n + ' \u2014 nom">'
|
|
+ '<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"'
|
|
+ ' onclick="removeJuryRow(this)" aria-label="Supprimer">'
|
|
+ '<span aria-hidden="true">\u2715</span></button>';
|
|
list.appendChild(div);
|
|
}
|
|
function removeJuryRow(btn) {
|
|
btn.closest('.admin-jury-entry').remove();
|
|
}
|
|
</script>
|