From 079185992356785ff22cb9171e83bcc69071a974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B8nstantine=20Kovalensky?= <45331093+kovalensky@users.noreply.github.com> Date: Mon, 25 Dec 2023 23:07:47 +0400 Subject: [PATCH] Show user's ban status (#1258) --- library/includes/ucp/viewprofile.php | 6 ++++++ src/Legacy/SqlDb.php | 2 +- styles/templates/default/css/main_content.css | 11 +++++++++++ styles/templates/default/usercp_viewprofile.tpl | 1 + styles/templates/default/viewtopic.tpl | 1 + viewtopic.php | 10 ++++++++-- 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/library/includes/ucp/viewprofile.php b/library/includes/ucp/viewprofile.php index 9436688ee..172f7ee39 100644 --- a/library/includes/ucp/viewprofile.php +++ b/library/includes/ucp/viewprofile.php @@ -74,12 +74,18 @@ if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) { $signature = bbcode2html($signature); } +$user_banned = false; +if (DB()->fetch_row('SELECT ban_userid FROM ' . BB_BANLIST . " WHERE ban_userid = {$profiledata['user_id']} LIMIT 1")) { + $user_banned = true; +} + $template->assign_vars([ 'PAGE_TITLE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), 'USERNAME' => $profiledata['username'], 'PROFILE_USER_ID' => $profiledata['user_id'], 'PROFILE_USER' => $profile_user_id, 'USER_REGDATE' => bb_date($profiledata['user_regdate'], 'Y-m-d H:i', false), + 'BANNED' => $user_banned, 'POSTER_RANK' => ($poster_rank) ? "" . $poster_rank . "" : $lang['USER'], 'RANK_IMAGE' => $rank_image, 'RANK_SELECT' => $rank_select, diff --git a/src/Legacy/SqlDb.php b/src/Legacy/SqlDb.php index f92d0e424..428bbdb22 100644 --- a/src/Legacy/SqlDb.php +++ b/src/Legacy/SqlDb.php @@ -889,7 +889,7 @@ class SqlDb $q_time = ($this->cur_query_time >= 10) ? round($this->cur_query_time, 0) : sprintf('%.4f', $this->cur_query_time); $msg = []; $msg[] = round($this->sql_starttime); - $msg[] = date('m-d H:i:s', $this->sql_starttime); + $msg[] = date('m-d H:i:s', (int)$this->sql_starttime); $msg[] = sprintf('%-6s', $q_time); $msg[] = sprintf('%05d', getmypid()); $msg[] = $this->db_server; diff --git a/styles/templates/default/css/main_content.css b/styles/templates/default/css/main_content.css index b0aa45b31..f74d6426f 100644 --- a/styles/templates/default/css/main_content.css +++ b/styles/templates/default/css/main_content.css @@ -489,6 +489,17 @@ a.postLink:visited { line-height: 110%; } +.poster-banned { + background:#f6f6f6; + border:1px solid #b71c1c; + padding:4px; + border-radius:2px; + font-size:11px; + font-weight:bold; + letter-spacing:1px; + text-align:center +} + .poster_info .avatar { margin: 5px 0 4px; max-width: 100px; diff --git a/styles/templates/default/usercp_viewprofile.tpl b/styles/templates/default/usercp_viewprofile.tpl index 8e61e1357..98085beeb 100644 --- a/styles/templates/default/usercp_viewprofile.tpl +++ b/styles/templates/default/usercp_viewprofile.tpl @@ -295,6 +295,7 @@ ajax.callback.index_data = function(data) {
{postrow.POSTER_NAME} ®
+{L_BANNED}
{postrow.POSTER_RANK}
{postrow.RANK_IMAGE}
{postrow.POSTER_AVATAR}
diff --git a/viewtopic.php b/viewtopic.php index e721014f9..3e988acf5 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -317,13 +317,15 @@ if ($t_data['topic_show_first_post'] && $start) { u.user_opt, u.user_gender, u.user_birthday, p.*, g.group_name, g.group_description, g.group_id, g.group_signature, g.avatar_ext_id as rg_avatar_id, u2.username as mc_username, u2.user_rank as mc_user_rank, - h.post_html, IF(h.post_html IS NULL, pt.post_text, NULL) AS post_text + h.post_html, IF(h.post_html IS NULL, pt.post_text, NULL) AS post_text, + ban.ban_userid FROM " . BB_POSTS . " p LEFT JOIN " . BB_USERS . " u ON(u.user_id = p.poster_id) LEFT JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = p.post_id) LEFT JOIN " . BB_POSTS_HTML . " h ON(h.post_id = p.post_id) LEFT JOIN " . BB_USERS . " u2 ON(u2.user_id = p.mc_user_id) LEFT JOIN " . BB_GROUPS . " g ON(g.group_id = p.poster_rg_id) + LEFT JOIN " . BB_BANLIST . " ban ON(ban.ban_userid = u.user_id) WHERE p.post_id = {$t_data['topic_first_post_id']} LIMIT 1 @@ -338,13 +340,15 @@ $sql = " u.user_opt, u.user_gender, u.user_birthday, p.*, g.group_name, g.group_description, g.group_id, g.group_signature, g.avatar_ext_id as rg_avatar_id, u2.username as mc_username, u2.user_rank as mc_user_rank, - h.post_html, IF(h.post_html IS NULL, pt.post_text, NULL) AS post_text + h.post_html, IF(h.post_html IS NULL, pt.post_text, NULL) AS post_text, + ban.ban_userid FROM " . BB_POSTS . " p LEFT JOIN " . BB_USERS . " u ON(u.user_id = p.poster_id) LEFT JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = p.post_id) LEFT JOIN " . BB_POSTS_HTML . " h ON(h.post_id = p.post_id) LEFT JOIN " . BB_USERS . " u2 ON(u2.user_id = p.mc_user_id) LEFT JOIN " . BB_GROUPS . " g ON(g.group_id = p.poster_rg_id) + LEFT JOIN " . BB_BANLIST . " ban ON(ban.ban_userid = u.user_id) WHERE p.topic_id = $topic_id $limit_posts_time GROUP BY p.post_id @@ -591,6 +595,7 @@ for ($i = 0; $i < $total_posts; $i++) { $poster_rank = $rank_image = ''; $user_rank = $postrow[$i]['user_rank']; + $user_ban_status = $postrow[$i]['ban_userid']; if (!$user->opt_js['h_rnk_i'] and isset($ranks[$user_rank])) { $rank_image = ($bb_cfg['show_rank_image'] && $ranks[$user_rank]['rank_image']) ? '