ロールの追加、性別もクラス化、テスト記事忘れた
This commit is contained in:
19
util.php
19
util.php
@@ -33,8 +33,19 @@ class Roles {
|
||||
public const int MEMBER = 1 << 0; // 1
|
||||
public const int NINTENDONDA = 1 << 1; // 2
|
||||
public const int PLAYSTATIONNDA = 1 << 2; // 4
|
||||
public const int STAFF = 1 << 3; // 8
|
||||
public const int ADMIN = 1 << 7; // 128
|
||||
public const int FULLNDA = 1 << 3; // 8 (NINTENDONDA + PLAYSTATIONNDA)
|
||||
public const int SUBSCRIBER = 1 << 4; // 16
|
||||
public const int NSUBSCRIBER = 1 << 5; // 32 (NINTENDNDA + SUBSCRIBER)
|
||||
public const int PSUBSCRIBER = 1 << 6; // 64 (PLAYSTATIONNDA + SUBSCRIBER)
|
||||
public const int FSUBSCRIBER = 1 << 7; // 128 (NINTENDNDA + PLAYSTATIONNDA + SUBSCRIBER)
|
||||
public const int STAFF = 1 << 8; // 256
|
||||
public const int ADMIN = 1 << 9; // 512
|
||||
}
|
||||
|
||||
class Gender {
|
||||
public const int UNKNOWN = -1; // 不明
|
||||
public const int MALE = 0; // 男性
|
||||
public const int FEMALE = 1; // 女性
|
||||
}
|
||||
|
||||
$colorPalette = [
|
||||
@@ -296,7 +307,7 @@ function namecolor(\stdClass $userData): string {
|
||||
$female = "#F185C9";
|
||||
$ungender = "#7C60B0";
|
||||
|
||||
$gender = 'color: '.($userData->gender === 0 ? $male : ($userData->gender === 1 ? $female : $ungender)).';';
|
||||
$gender = 'color: '.($userData->gender === Gender::MALE ? $male : ($userData->gender === Gender::FEMALE ? $female : $ungender)).';';
|
||||
$style = $userData->namecolor ?: ($userData->role !== Roles::BANNED ? $gender : 'color: '.$ban.';');
|
||||
|
||||
$showname = $userData->displayname ?: $userData->username;
|
||||
@@ -304,7 +315,7 @@ function namecolor(\stdClass $userData): string {
|
||||
$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>";
|
||||
$suffix = $userData->gender === 0 ? 'くん' : ($userData->gender === 1 ? 'ちゃん' : 'さん');
|
||||
$suffix = $userData->gender === Gender::MALE ? 'くん' : ($userData->gender === Gender::FEMALE ? 'ちゃん' : 'さん');
|
||||
|
||||
return $color.$suffix;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user