feat: brouillons visibles uniquement par auteur + ribbon 45deg BROUILLON
This commit is contained in:
+21
-1
@@ -68,6 +68,18 @@ switch ($action) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$article['published']) {
|
||||
$author = $article['author'] ?? '';
|
||||
$currentEmail = currentUserEmail() ?? '';
|
||||
$canView = ($author !== '' && $currentEmail === $author)
|
||||
|| ($author === '' && isAdmin());
|
||||
if (!$canView) {
|
||||
http_response_code(404);
|
||||
echo 'Article introuvable.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$files = $articles->getFiles($article['uuid']);
|
||||
|
||||
// Résout les chemins de fichiers relatifs dans le contenu
|
||||
@@ -157,7 +169,15 @@ switch ($action) {
|
||||
|
||||
case 'list':
|
||||
default:
|
||||
$posts = $articles->getAll();
|
||||
$currentEmail = currentUserEmail() ?? '';
|
||||
$posts = array_values(array_filter($articles->getAll(), static function (array $a) use ($currentEmail): bool {
|
||||
if ($a['published']) {
|
||||
return true;
|
||||
}
|
||||
$author = $a['author'] ?? '';
|
||||
return ($author !== '' && $currentEmail === $author)
|
||||
|| ($author === '' && isAdmin());
|
||||
}));
|
||||
include BASE_PATH . '/templates/post_list.php';
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user