link creation: fieldset with checkboxes for objet restriction, TFE checked by default

link creation: fieldset with checkboxes for objet restriction, TFE checked by default; password/expiration in second fieldset 'Accès'
This commit is contained in:
Pontoporeia
2026-05-09 16:11:11 +02:00
parent 21c2b55bfb
commit 013317c97f
5 changed files with 37 additions and 39 deletions

View File

@@ -32,8 +32,10 @@ switch ($action) {
App::redirect('/admin/acces.php', error: "La date d'expiration doit être dans le futur.");
}
}
$objetRaw = $_POST['objet_restriction'] ?? '';
$objetRestriction = in_array($objetRaw, ['tfe', 'thèse', 'frart'], true) ? $objetRaw : null;
$objetRaw = $_POST['objet_restriction'] ?? ['tfe'];
$validObjet = ['tfe', 'thèse', 'frart'];
$selected = is_array($objetRaw) ? array_intersect($objetRaw, $validObjet) : [];
$objetRestriction = !empty($selected) ? implode(',', $selected) : 'tfe';
$link = $shareLink->create(1, $password, $expiresAt, $objetRestriction);
$logger->logLinkCreate(
$link['slug'] ?? '',

View File

@@ -249,8 +249,8 @@ function renderShareLinkForm(string $slug, array $link): void
// Determine allowed objet values for this link
$siteSettings = Database::getInstance()->getAllSettings();
$objetRestriction = $link['objet_restriction'] ?? null;
if ($objetRestriction !== null) {
$allowedObjet = [$objetRestriction];
if ($objetRestriction !== null && $objetRestriction !== '') {
$allowedObjet = explode(',', $objetRestriction);
} else {
$allowedObjet = ['tfe'];
if (($siteSettings['objet_these_enabled'] ?? '1') === '1') $allowedObjet[] = 'thèse';