From 146926758de64427dabe1eccd97cfbe6e4394d10 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 10 May 2025 23:31:18 +0500 Subject: feat: show user badges in /emotes and /system/emotes --- public/emotes/index.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'public/emotes/index.php') diff --git a/public/emotes/index.php b/public/emotes/index.php index fb09b10..1225bdd 100644 --- a/public/emotes/index.php +++ b/public/emotes/index.php @@ -329,11 +329,14 @@ if (CLIENT_REQUIRES_JSON) { $username = ANONYMOUS_DEFAULT_NAME; $link = "#"; $show_private_badge = false; + $badge = null; if ($emote->get_uploaded_by()) { - $stmt = $db->prepare("SELECT u.username, up.private_profile + $stmt = $db->prepare("SELECT u.username, up.private_profile, r.name AS role_name, r.badge_id AS role_badge_id FROM users u INNER JOIN user_preferences up ON up.id = u.id + LEFT JOIN role_assigns ra ON ra.user_id = u.id + LEFT JOIN roles r ON r.id = ra.role_id WHERE u.id = ? "); $stmt->execute([$emote->get_uploaded_by()]); @@ -343,6 +346,7 @@ if (CLIENT_REQUIRES_JSON) { $username = $row["username"]; $link = "/users.php?id=" . $emote->get_uploaded_by(); + $badge = ["role_name" => $row["role_name"], "role_badge_id" => $row["role_badge_id"]]; } } @@ -354,20 +358,32 @@ if (CLIENT_REQUIRES_JSON) { echo " (Private)"; } + if ($badge && $badge["role_badge_id"]) { + echo ' ## ' . $badge['; + } + echo ', get_created_at()); echo ' UTC">about ' . format_timestamp(time() - $emote->get_created_at()) . " ago"; ?> prepare("SELECT u.id, u.username, a.created_at FROM users u + $stmt = $db->prepare("SELECT u.id, u.username, a.created_at, r.name AS role_name, r.badge_id AS role_badge_id FROM users u INNER JOIN mod_actions a ON a.emote_id = ? + LEFT JOIN role_assigns ra ON ra.user_id = u.id + LEFT JOIN roles r ON r.id = ra.role_id WHERE u.id = a.user_id"); $stmt->execute([$emote->get_id()]); if ($row = $stmt->fetch()) { echo 'Approver'; - echo '' . $row["username"] . ', ' . $row["username"] . ''; + + if ($row["role_badge_id"]) { + echo ' ## ' . $row['; + } + + echo ', '; echo format_timestamp(strtotime($row["created_at"]) - $emote->get_created_at()) . ' after upload'; echo ''; -- cgit v1.2.3