mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/9687] Improve labeling in acp for user bans
PHPBB3-9687
This commit is contained in:
parent
d7389809aa
commit
54bb32bba5
5 changed files with 78 additions and 4 deletions
|
@ -3168,7 +3168,7 @@ function display_ban_options($mode)
|
||||||
{
|
{
|
||||||
$banned_options[] = [
|
$banned_options[] = [
|
||||||
'value' => $ban_row['ban_id'],
|
'value' => $ban_row['ban_id'],
|
||||||
'label' => $ban_row['ban_item'],
|
'label' => $ban_row['label'] ?? $ban_row['ban_item'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$time_length = ($ban_row['ban_end']) ? ($ban_row['ban_end'] - $ban_row['ban_start']) / 60 : 0;
|
$time_length = ($ban_row['ban_end']) ? ($ban_row['ban_end'] - $ban_row['ban_start']) / 60 : 0;
|
||||||
|
|
|
@ -126,6 +126,7 @@ class manager
|
||||||
$insert_array[] = [
|
$insert_array[] = [
|
||||||
'ban_mode' => $mode,
|
'ban_mode' => $mode,
|
||||||
'ban_item' => $ban_item,
|
'ban_item' => $ban_item,
|
||||||
|
'ban_userid' => $mode === 'user' ? $ban_item : 0,
|
||||||
'ban_start' => $start->getTimestamp(),
|
'ban_start' => $start->getTimestamp(),
|
||||||
'ban_end' => $end->getTimestamp(),
|
'ban_end' => $end->getTimestamp(),
|
||||||
'ban_reason' => $reason,
|
'ban_reason' => $reason,
|
||||||
|
|
|
@ -84,6 +84,7 @@ class user extends base
|
||||||
$result = $this->db->sql_query($sql);
|
$result = $this->db->sql_query($sql);
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
|
$row['label'] = $row['username'];
|
||||||
$ban_options[] = $row;
|
$ban_options[] = $row;
|
||||||
}
|
}
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
|
@ -261,8 +261,9 @@ class ban_manager_test extends \phpbb_session_test_case
|
||||||
'ban_mode' => 'user',
|
'ban_mode' => 'user',
|
||||||
'ban_userid' => 4,
|
'ban_userid' => 4,
|
||||||
'user_id' => '4',
|
'user_id' => '4',
|
||||||
'username' => '',
|
'username' => 'ipv6_user',
|
||||||
'username_clean' => 'ipv6_user',
|
'username_clean' => 'ipv6_user',
|
||||||
|
'label' => 'ipv6_user',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -650,8 +651,9 @@ class ban_manager_test extends \phpbb_session_test_case
|
||||||
'ban_reason_display' => '1',
|
'ban_reason_display' => '1',
|
||||||
'ban_mode' => 'user',
|
'ban_mode' => 'user',
|
||||||
'user_id' => '4',
|
'user_id' => '4',
|
||||||
'username' => '',
|
'username' => 'ipv6_user',
|
||||||
'username_clean' => 'ipv6_user',
|
'username_clean' => 'ipv6_user',
|
||||||
|
'label' => 'ipv6_user',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -691,9 +693,73 @@ class ban_manager_test extends \phpbb_session_test_case
|
||||||
$ban_type_ip = $this->phpbb_container->get('ban.type.ip');
|
$ban_type_ip = $this->phpbb_container->get('ban.type.ip');
|
||||||
$base_type_reflection = new \ReflectionClass(\phpbb\ban\type\base::class);
|
$base_type_reflection = new \ReflectionClass(\phpbb\ban\type\base::class);
|
||||||
$after_unban = $base_type_reflection->getMethod('after_unban');
|
$after_unban = $base_type_reflection->getMethod('after_unban');
|
||||||
$this->assertEquals(['foo'], $after_unban->invoke($ban_type_ip, ['items' => ['foo']]));
|
$this->assertEquals([], $after_unban->invoke($ban_type_ip, ['items' => ['foo']]));
|
||||||
|
|
||||||
$check = $base_type_reflection->getMethod('check');
|
$check = $base_type_reflection->getMethod('check');
|
||||||
$this->assertFalse($check->invoke($ban_type_ip, [], []));
|
$this->assertFalse($check->invoke($ban_type_ip, [], []));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function data_get_ban_message(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'end' => 0,
|
||||||
|
],
|
||||||
|
'foobar',
|
||||||
|
'http://foo.bar',
|
||||||
|
'You have been <strong>permanently</strong> banned from this board.<br><br>Please contact the <a href="http://foo.bar">Board Administrator</a> for more information.<br><br><em>BAN_TRIGGERED_BY_FOOBAR</em>',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'end' => 1,
|
||||||
|
],
|
||||||
|
'foobar',
|
||||||
|
'http://foo.bar',
|
||||||
|
'You have been banned from this board until <strong></strong>.<br><br>Please contact the <a href="http://foo.bar">Board Administrator</a> for more information.<br><br><em>BAN_TRIGGERED_BY_FOOBAR</em>',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'end' => 1,
|
||||||
|
'reason' => 'just because',
|
||||||
|
],
|
||||||
|
'foobar',
|
||||||
|
'http://foo.bar',
|
||||||
|
'You have been banned from this board until <strong></strong>.<br><br>Please contact the <a href="http://foo.bar">Board Administrator</a> for more information.<br><br>Reason given for ban: <strong>just because</strong><br><br><em>BAN_TRIGGERED_BY_FOOBAR</em>',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider data_get_ban_message
|
||||||
|
*/
|
||||||
|
public function test_get_ban_message($ban_row, $ban_triggered_by, $contact_link, $expected)
|
||||||
|
{
|
||||||
|
$this->assertEquals($expected, $this->ban_manager->get_ban_message($ban_row, $ban_triggered_by, $contact_link));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_get_ban_options_user()
|
||||||
|
{
|
||||||
|
$foo = $this->ban_manager->get_bans('user');
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'ban_id' => 4,
|
||||||
|
'ban_userid' => '4',
|
||||||
|
'ban_mode' => 'user',
|
||||||
|
'ban_item' => '4',
|
||||||
|
'ban_start' => '1111',
|
||||||
|
'ban_end' => '0',
|
||||||
|
'ban_reason' => 'HAHAHA',
|
||||||
|
'ban_reason_display' => '1',
|
||||||
|
'user_id' => '4',
|
||||||
|
'username' => 'ipv6_user',
|
||||||
|
'username_clean' => 'ipv6_user',
|
||||||
|
'label' => 'ipv6_user',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
$foo
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<dataset>
|
<dataset>
|
||||||
<table name="phpbb_users">
|
<table name="phpbb_users">
|
||||||
<column>user_id</column>
|
<column>user_id</column>
|
||||||
|
<column>username</column>
|
||||||
<column>username_clean</column>
|
<column>username_clean</column>
|
||||||
<column>user_permissions</column>
|
<column>user_permissions</column>
|
||||||
<column>user_sig</column>
|
<column>user_sig</column>
|
||||||
|
@ -11,6 +12,7 @@
|
||||||
<row>
|
<row>
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
<value>anonymous</value>
|
<value>anonymous</value>
|
||||||
|
<value>anonymous</value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value></value>
|
<value></value>
|
||||||
|
@ -20,6 +22,7 @@
|
||||||
<row>
|
<row>
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
<value>founder</value>
|
<value>founder</value>
|
||||||
|
<value>founder</value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value>admin@foo.bar</value>
|
<value>admin@foo.bar</value>
|
||||||
|
@ -29,6 +32,7 @@
|
||||||
<row>
|
<row>
|
||||||
<value>3</value>
|
<value>3</value>
|
||||||
<value>normal_user</value>
|
<value>normal_user</value>
|
||||||
|
<value>normal_user</value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value>normal_user@foo.bar</value>
|
<value>normal_user@foo.bar</value>
|
||||||
|
@ -38,6 +42,7 @@
|
||||||
<row>
|
<row>
|
||||||
<value>4</value>
|
<value>4</value>
|
||||||
<value>ipv6_user</value>
|
<value>ipv6_user</value>
|
||||||
|
<value>ipv6_user</value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value>normal_user@foo.bar</value>
|
<value>normal_user@foo.bar</value>
|
||||||
|
@ -47,6 +52,7 @@
|
||||||
<row>
|
<row>
|
||||||
<value>5</value>
|
<value>5</value>
|
||||||
<value>another_user</value>
|
<value>another_user</value>
|
||||||
|
<value>another_user</value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value></value>
|
<value></value>
|
||||||
<value>bar@example.org</value>
|
<value>bar@example.org</value>
|
||||||
|
|
Loading…
Add table
Reference in a new issue