下書き記事

This commit is contained in:
2025-12-29 17:00:55 +09:00
parent 863bdabf59
commit 113e0a00fb
4 changed files with 5 additions and 4 deletions

View File

@@ -7,7 +7,7 @@ class BlogPost {
*
* @return array 投稿の配列
*/
public function getPosts(string $section, ?\stdClass $user): array {
public function getPosts(string $section, ?\stdClass $user = null): array {
$path = ROOT.$section;
$posts = [];
$isMember = $user !== NULL && $user->role !== \Roles::BANNED;
@@ -45,6 +45,7 @@ class BlogPost {
$articleBody = trim($parts[1]);
$preview = mb_substr(strip_tags($articleBody), 0, 50).'...';
$slug = basename($file, '.md');
if (isset($metadata['draft']) && !$isStaff) continue;
$posts[] = [
'title' => $metadata['title'] ?? '',

View File

@@ -134,6 +134,7 @@ class Home extends BlogPost {
if (!$isMember && in_array('memberonly', $meta->category)) goto denyaccess;
if (!$isStaff && in_array('staffonly', $meta->category)) goto denyaccess;
if (isset($meta->draft) && !$isStaff) goto denyaccess;
showpage:
$tmpl->addCss('news-article');

View File

@@ -6,7 +6,6 @@ class Auth {
/**
* 性別: -1 = 不明, 0 = 男性, 1 = 女性
* ロール: -1 = BAN, 0 = ユーザー, 1 = スタッフ
*/
private \stdClass $user;
private \stdClass $pubUser;

View File

@@ -302,8 +302,8 @@ function namecolor(\stdClass $userData): string {
$showname = $userData->displayname ?: $userData->username;
$color = "<span style=\"{$style}\">{$showname}</span>";
if ($userData->role & (Roles::ADMIN | Roles::STAFF)) $color .= "<span style=\"font-size: x-small; background: #10c074; border: 1px solid #fcfcfc; border-radius: 10px; padding: 0 0.5em;\">✓</span>";
if ($userData->role & (Roles::ADMIN | Roles::STAFF))
$color .= "<span style=\"font-size: x-small; background: #10c074; border: 1px solid #fcfcfc; border-radius: 10px; padding: 0 0.5em;\">✓</span>";
$suffix = $userData->gender === 0 ? 'くん' : ($userData->gender === 1 ? 'ちゃん' : 'さん');
return $color.$suffix;