feat: view_previews debloque les avant-premieres sur accueil et article

This commit is contained in:
Cedric Abonnel
2026-05-12 23:06:00 +02:00
parent c83b27624c
commit 98ec65f800
8 changed files with 384 additions and 11 deletions
+5 -5
View File
@@ -514,9 +514,9 @@ switch ($action) {
}
}
// Avant-première : publié mais date future → réservé aux connectés
// Avant-première : publié mais date future → réservé aux utilisateurs avec view_previews
if ($article['published'] && strtotime((string)($article['published_at'] ?? '')) > time()) {
if (!isLoggedIn()) {
if (!hasCapability('view_previews')) {
http_response_code(404);
echo 'Article introuvable.';
exit;
@@ -565,7 +565,7 @@ switch ($action) {
if (trim($a['category'] ?? '') !== $articleCat) {
continue;
}
if (strtotime((string)($a['published_at'] ?? '')) > time() && !isLoggedIn()) {
if (strtotime((string)($a['published_at'] ?? '')) > time() && !hasCapability('view_previews')) {
continue;
}
$relatedArticles[] = $a;
@@ -588,7 +588,7 @@ switch ($action) {
if ($a['uuid'] === $article['uuid']) {
return false;
}
if (strtotime((string)($a['published_at'] ?? '')) > time() && !isLoggedIn()) {
if (strtotime((string)($a['published_at'] ?? '')) > time() && !hasCapability('view_previews')) {
return false;
}
$cat = trim($a['category'] ?? '');
@@ -1836,7 +1836,7 @@ switch ($action) {
if ($cat !== '' && in_array($cat, $privateCats, true) && !isLoggedIn()) {
return false;
}
if (strtotime((string)($a['published_at'] ?? '')) > time() && !isLoggedIn()) {
if (strtotime((string)($a['published_at'] ?? '')) > time() && !hasCapability('view_previews')) {
return false;
}
return true;