diff --git a/app/public/admin/actions/acces-etudiante.php b/app/public/admin/actions/acces-etudiante.php index 58d3eea..aa2eab6 100644 --- a/app/public/admin/actions/acces-etudiante.php +++ b/app/public/admin/actions/acces-etudiante.php @@ -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'] ?? '', diff --git a/app/public/partage/index.php b/app/public/partage/index.php index f1e8c85..e89f2a6 100644 --- a/app/public/partage/index.php +++ b/app/public/partage/index.php @@ -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'; diff --git a/app/src/ShareLink.php b/app/src/ShareLink.php index 3fe6ca0..cd63382 100644 --- a/app/src/ShareLink.php +++ b/app/src/ShareLink.php @@ -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) diff --git a/app/templates/admin/acces-etudiante.php b/app/templates/admin/acces-etudiante.php index 8164b95..81fdc75 100644 --- a/app/templates/admin/acces-etudiante.php +++ b/app/templates/admin/acces-etudiante.php @@ -41,7 +41,7 @@ } $fullUrl = $baseUrl . '/partage/' . htmlspecialchars($link['slug']); $created = date('d/m/Y H:i', strtotime($link['created_at'])); - $expires = $link['expires_at'] ? date('d/m/Y', strtotime($link['expires_at'])) : '—'; + $expires = $link['expires_at'] ? date('d/m/Y H:i', strtotime($link['expires_at'])) : '—'; $hasPassword = !empty($link['password_hash']); ?>