mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-10 10:44:20 +02:00
[ticket/9687] Add separate column for user_id
PHPBB3-9687
This commit is contained in:
@@ -307,9 +307,12 @@ class manager
|
||||
$manual_modes[] = $ban_mode;
|
||||
continue;
|
||||
}
|
||||
|
||||
$where_column = $user_column == 'user_id' ? 'b.ban_userid' : 'b.ban_item';
|
||||
|
||||
$where_array[] = ['AND',
|
||||
[
|
||||
['b.ban_item', '=', 'u.' . $user_column],
|
||||
[$where_column, '=', 'u.' . $user_column],
|
||||
['b.ban_mode', '=', "'{$ban_mode->get_type()}'"],
|
||||
],
|
||||
];
|
||||
|
@@ -73,40 +73,21 @@ class user extends base
|
||||
public function get_ban_options(): array
|
||||
{
|
||||
$ban_options = [];
|
||||
$ban_data = [];
|
||||
$user_ids = [];
|
||||
|
||||
$sql = 'SELECT b.*
|
||||
FROM ' . $this->bans_table . ' b
|
||||
$sql = 'SELECT b.*, u.user_id, u.username, u.username_clean
|
||||
FROM ' . $this->bans_table . ' b, ' . $this->users_table . ' u
|
||||
WHERE (b.ban_end >= ' . time() . "
|
||||
OR b.ban_end = 0)
|
||||
AND b.ban_mode = '{$this->get_type()}'";
|
||||
AND b.ban_userid = u.user_id
|
||||
AND b.ban_mode = '{$this->get_type()}'
|
||||
ORDER BY username_clean";
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$user_ids[] = $row['ban_item'];
|
||||
$ban_data[$row['ban_item']] = $row;
|
||||
$ban_options[] = $row;
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (count($user_ids))
|
||||
{
|
||||
// Grab usernames for banned user IDs
|
||||
$sql = 'SELECT user_id, username, username_clean
|
||||
FROM ' . $this->users_table . '
|
||||
WHERE ' . $this->db->sql_in_set('user_id', $user_ids) . '
|
||||
ORDER BY username_clean';
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$ban_options[] = array_merge(
|
||||
$ban_data[$row['user_id']],
|
||||
$row
|
||||
);
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
return $ban_options;
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,7 @@ class ban_table_p1 extends migration
|
||||
$this->table_prefix . 'bans' => [
|
||||
'COLUMNS' => [
|
||||
'ban_id' => ['ULINT', null, 'auto_increment'],
|
||||
'ban_userid' => ['ULINT', 0],
|
||||
'ban_mode' => ['VCHAR', ''],
|
||||
'ban_item' => ['STEXT_UNI', ''],
|
||||
'ban_start' => ['TIMESTAMP', 0],
|
||||
@@ -38,6 +39,7 @@ class ban_table_p1 extends migration
|
||||
],
|
||||
'PRIMARY_KEY' => 'ban_id',
|
||||
'KEYS' => [
|
||||
'ban_userid' => ['INDEX', 'ban_userid'],
|
||||
'ban_end' => ['INDEX', 'ban_end'],
|
||||
],
|
||||
],
|
||||
@@ -113,6 +115,7 @@ class ban_table_p1 extends migration
|
||||
|
||||
$bans[] = [
|
||||
'ban_mode' => $mode,
|
||||
'ban_userid' => $row['ban_userid'],
|
||||
'ban_item' => $item,
|
||||
'ban_start' => $row['ban_start'],
|
||||
'ban_end' => $row['ban_end'],
|
||||
@@ -150,7 +153,7 @@ class ban_table_p1 extends migration
|
||||
$processed_rows++;
|
||||
|
||||
$bans[] = [
|
||||
'ban_userid' => ($row['ban_mode'] === 'user') ? (int) $row['ban_item'] : 0,
|
||||
'ban_userid' => (int) $row['ban_userid'],
|
||||
'ban_ip' => ($row['ban_mode'] === 'ip') ? $row['ban_item'] : '',
|
||||
'ban_email' => ($row['ban_mode'] === 'email') ? $row['ban_item'] : '',
|
||||
'ban_start' => $row['ban_start'],
|
||||
|
@@ -1209,8 +1209,8 @@ class session
|
||||
|
||||
$contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx);
|
||||
$message = sprintf($this->lang[$message], $till_date, '<a href="' . $contact_link . '">', '</a>');
|
||||
$message .= ($ban_row['reason']) ? '<br /><br />' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['reason']) : '';
|
||||
$message .= '<br /><br /><em>' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . '</em>';
|
||||
$message .= ($ban_row['reason']) ? '<br><br>' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['reason']) : '';
|
||||
$message .= '<br><br><em>' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . '</em>';
|
||||
|
||||
// A very special case... we are within the cron script which is not supposed to print out the ban message... show blank page
|
||||
if (defined('IN_CRON'))
|
||||
|
Reference in New Issue
Block a user