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

@@ -54,9 +54,12 @@ class ShareLink
$slug = self::generateSlug();
$passwordHash = $password !== null ? password_hash($password, PASSWORD_BCRYPT) : null;
$validObjet = ['tfe', 'thèse', 'frart'];
$objetRestriction = ($objetRestriction !== null && in_array($objetRestriction, $validObjet, true))
? $objetRestriction
: null;
if ($objetRestriction !== null && $objetRestriction !== '') {
$parts = array_intersect(explode(',', $objetRestriction), $validObjet);
$objetRestriction = !empty($parts) ? implode(',', $parts) : 'tfe';
} else {
$objetRestriction = 'tfe';
}
$stmt = $this->db->getConnection()->prepare(
'INSERT INTO share_links (slug, objet_restriction, password_hash, is_active, created_by, expires_at)