feat: Allow setting custom ban reason when banning users (#2094)
Some checks are pending
Continuous Integration / Nightly builds 📦 (push) Waiting to run
Continuous Integration / 🎉 Deploy (push) Waiting to run
PHPMD / Run PHPMD scanning (push) Waiting to run

* feat: Allow setting custom ban reason when banning users

* Updated

* Update usercp_viewprofile.tpl

* Update usercp_viewprofile.tpl
This commit is contained in:
Roman Kelesidis 2025-08-20 13:13:26 +03:00 committed by GitHub
commit 16e28a5c41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 21 additions and 9 deletions

View file

@ -29,7 +29,11 @@ if ($submit) {
}
if (!getBanInfo((int)$this_userdata['user_id'])) {
$sql = 'INSERT INTO ' . BB_BANLIST . ' (ban_userid) VALUES (' . $this_userdata['user_id'] . ')';
$ban_reason = '';
if (!empty($_POST['ban_reason'])) {
$ban_reason = trim($_POST['ban_reason']);
}
$sql = 'INSERT INTO ' . BB_BANLIST . ' (ban_userid, ban_reason) VALUES (' . $this_userdata['user_id'] . ', "' . DB()->escape($ban_reason) . '")';
if (!DB()->sql_query($sql)) {
bb_die('Could not insert ban_userid info into database');
}

View file

@ -83,7 +83,7 @@ if ($bb_cfg['ratio_null_enabled'] && $btu = get_bt_userdata($profiledata['user_i
if ($banInfo = getBanInfo((int)$profiledata['user_id'])) {
$template->assign_block_vars('ban', [
'IS_BANNED' => true,
'BAN_REASON' => $banInfo['ban_reason']
'BAN_REASON' => IS_ADMIN ? $banInfo['ban_reason'] : '',
]);
}

View file

@ -13,6 +13,10 @@
<td class="row1">{L_USERNAME}:</td>
<td class="row2"><input type="text" class="post" name="username" maxlength="50" size="20" /> <input type="hidden" name="mode" value="edit" />{S_HIDDEN_FIELDS} <input type="submit" name="usersubmit" value="{L_FIND_USERNAME}" class="liteoption" onClick="window.open('{U_SEARCH_USER}', '_bbsearch', 'HEIGHT=250,resizable=yes,WIDTH=400');return false;" /></td>
</tr>
<tr>
<td class="row1">{L_REASON}:</td>
<td class="row2"><input type="text" class="post" name="ban_reason" maxlength="255" size="80" /></td>
</tr>
<tr>
<th colspan="2">{L_UNBAN_USERNAME}</th>
</tr>

View file

@ -229,6 +229,16 @@ ajax.callback.group_membership = function(data) {
{RANK_IMAGE}
<!-- ENDIF -->
</p>
<!-- BEGIN ban -->
<hr/>
<!-- IF ban.IS_BANNED -->
<b title="{L_BANNED_USERS}" class="warnColor2">{L_BANNED}</b>
<!-- ENDIF -->
<!-- IF ban.BAN_REASON -->
<div class="mrg_4">{L_REASON}: {ban.BAN_REASON}</div>
<!-- ENDIF -->
<hr/>
<!-- END ban -->
<!-- IF BIRTHDAY_ICON --><div class="mrg_8">{BIRTHDAY_ICON}</div><!-- ENDIF -->
<h4 class="cat border bw_TB">{L_CONTACT}&nbsp;{USERNAME}</span></h4>
@ -300,9 +310,6 @@ ajax.callback.group_membership = function(data) {
<th>{L_USERNAME}:</th>
<td id="username">
<span class="editable bold">{USERNAME}</span>
<!-- BEGIN ban -->
<!-- IF ban.IS_BANNED -->(<b title="{L_BANNED_USERS}" style="color: red;">{L_BANNED}</b>)<!-- ENDIF -->
<!-- END ban -->
</td>
</tr>
<!-- IF SHOW_ROLE -->

View file

@ -738,10 +738,7 @@ for ($i = 0; $i < $total_posts; $i++) {
// Ban information
if ($banInfo = getBanInfo((int)$poster_id)) {
$template->assign_block_vars('postrow.ban', [
'IS_BANNED' => true,
'BAN_REASON' => $banInfo['ban_reason']
]);
$template->assign_block_vars('postrow.ban', ['IS_BANNED' => true]);
}
if (isset($postrow[$i]['post_attachment']) && $is_auth['auth_download'] && function_exists('display_post_attachments')) {