下書き記事
諏訪子 <suwako@076.moe>、2025-12-29 17:00
コミット 113e0a00fb18c8e431d87f6428d4d30087158cac
・親 863bdab
・ファイルを見る
4個のファイル、+5 -4
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | * |
| 8 | 8 | * @return array 投稿の配列 |
| 9 | 9 | */ |
| 10 | - public function getPosts(string $section, ?\stdClass $user): array { | |
| 10 | + public function getPosts(string $section, ?\stdClass $user = null): array { | |
| 11 | 11 | $path = ROOT.$section; |
| 12 | 12 | $posts = []; |
| 13 | 13 | $isMember = $user !== NULL && $user->role !== \Roles::BANNED; |
| @@ -45,6 +45,7 @@ | ||
| 45 | 45 | $articleBody = trim($parts[1]); |
| 46 | 46 | $preview = mb_substr(strip_tags($articleBody), 0, 50).'...'; |
| 47 | 47 | $slug = basename($file, '.md'); |
| 48 | + if (isset($metadata['draft']) && !$isStaff) continue; | |
| 48 | 49 | |
| 49 | 50 | $posts[] = [ |
| 50 | 51 | 'title' => $metadata['title'] ?? '', |
| @@ -134,6 +134,7 @@ | ||
| 134 | 134 | |
| 135 | 135 | if (!$isMember && in_array('memberonly', $meta->category)) goto denyaccess; |
| 136 | 136 | if (!$isStaff && in_array('staffonly', $meta->category)) goto denyaccess; |
| 137 | + if (isset($meta->draft) && !$isStaff) goto denyaccess; | |
| 137 | 138 | |
| 138 | 139 | showpage: |
| 139 | 140 | $tmpl->addCss('news-article'); |
| @@ -6,7 +6,6 @@ | ||
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * 性別: -1 = 不明, 0 = 男性, 1 = 女性 |
| 9 | - * ロール: -1 = BAN, 0 = ユーザー, 1 = スタッフ | |
| 10 | 9 | */ |
| 11 | 10 | private \stdClass $user; |
| 12 | 11 | private \stdClass $pubUser; |
変更
util.php
| @@ -302,8 +302,8 @@ | ||
| 302 | 302 | $showname = $userData->displayname ?: $userData->username; |
| 303 | 303 | |
| 304 | 304 | $color = "<span style=\"{$style}\">{$showname}</span>"; |
| 305 | - 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>"; | |
| 306 | - | |
| 305 | + if ($userData->role & (Roles::ADMIN | Roles::STAFF)) | |
| 306 | + $color .= "<span style=\"font-size: x-small; background: #10c074; border: 1px solid #fcfcfc; border-radius: 10px; padding: 0 0.5em;\">✓</span>"; | |
| 307 | 307 | $suffix = $userData->gender === 0 ? 'くん' : ($userData->gender === 1 ? 'ちゃん' : 'さん'); |
| 308 | 308 | |
| 309 | 309 | return $color.$suffix; |