feat: view_previews debloque les avant-premieres sur accueil et article
This commit is contained in:
+5
-5
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user