下書き記事

諏訪子 <suwako@076.moe>、2025-12-29 17:00
コミット 113e0a00fb18c8e431d87f6428d4d30087158cac ・親 863bdab ・ファイルを見る

4個のファイル、+5 -4

@@ -7,7 +7,7 @@
77 *
88 * @return array 投稿の配列
99 */
10- public function getPosts(string $section, ?\stdClass $user): array {
10+ public function getPosts(string $section, ?\stdClass $user = null): array {
1111 $path = ROOT.$section;
1212 $posts = [];
1313 $isMember = $user !== NULL && $user->role !== \Roles::BANNED;
@@ -45,6 +45,7 @@
4545 $articleBody = trim($parts[1]);
4646 $preview = mb_substr(strip_tags($articleBody), 0, 50).'...';
4747 $slug = basename($file, '.md');
48+ if (isset($metadata['draft']) && !$isStaff) continue;
4849
4950 $posts[] = [
5051 'title' => $metadata['title'] ?? '',
@@ -134,6 +134,7 @@
134134
135135 if (!$isMember && in_array('memberonly', $meta->category)) goto denyaccess;
136136 if (!$isStaff && in_array('staffonly', $meta->category)) goto denyaccess;
137+ if (isset($meta->draft) && !$isStaff) goto denyaccess;
137138
138139 showpage:
139140 $tmpl->addCss('news-article');
@@ -6,7 +6,6 @@
66
77 /**
88 * 性別: -1 = 不明, 0 = 男性, 1 = 女性
9- * ロール: -1 = BAN, 0 = ユーザー, 1 = スタッフ
109 */
1110 private \stdClass $user;
1211 private \stdClass $pubUser;
変更 util.php
@@ -302,8 +302,8 @@
302302 $showname = $userData->displayname ?: $userData->username;
303303
304304 $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>";
307307 $suffix = $userData->gender === 0 ? 'くん' : ($userData->gender === 1 ? 'ちゃん' : 'さん');
308308
309309 return $color.$suffix;