アクセス許可管理
This commit is contained in:
@@ -7,9 +7,11 @@ class BlogPost {
|
||||
*
|
||||
* @return array 投稿の配列
|
||||
*/
|
||||
public function getPosts(string $section): array {
|
||||
public function getPosts(string $section, ?\stdClass $user): array {
|
||||
$path = ROOT.$section;
|
||||
$posts = [];
|
||||
$isMember = $user !== NULL;
|
||||
$isStaff = $user !== NULL && $user->role === 1;
|
||||
|
||||
if (!is_dir($path)) return $posts;
|
||||
$files = glob($path.'/*.md');
|
||||
@@ -51,7 +53,7 @@ class BlogPost {
|
||||
'thumborient' => $metadata['thumborient'] ?? '',
|
||||
'category' => $metadata['category'] ?? [],
|
||||
'uuid' => $metadata['uuid'] ?? '',
|
||||
'preview' => $preview,
|
||||
'preview' => ((!$isMember && in_array('memberonly', $metadata['category'])) || (!$isStaff && in_array('staffonly', $metadata['category'])) ? '未許可' : $preview),
|
||||
'slug' => $slug,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user