1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-19 06:51:33 +02:00

[ticket/9687] Use Forms for template display and fix display for users

PHPBB3-9687
This commit is contained in:
Marc Alexander
2023-07-29 23:09:42 +02:00
parent 6048458a12
commit 1a4e6fe3e8
7 changed files with 122 additions and 52 deletions

View File

@@ -263,23 +263,15 @@ class manager
*/
public function get_bans(string $mode)
{
/** @var type_interface $ban_mode */
$ban_mode = $this->find_type($mode);
if ($ban_mode === false)
/** @var type_interface $ban_type */
$ban_type = $this->find_type($mode);
if ($ban_type === false)
{
throw new type_not_found_exception(); // TODO
throw new type_not_found_exception();
}
$this->tidy();
$sql = 'SELECT ban_id, ban_item, ban_start, ban_end, ban_reason, ban_reason_display
FROM ' . $this->bans_table . "
WHERE ban_mode = '" . $this->db->sql_escape($mode) . "'
AND (ban_end = 0 OR ban_end >= " . time() . ')';
$result = $this->db->sql_query($sql);
$rowset = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
return $rowset;
return $ban_type->get_ban_options();
}
/**

View File

@@ -100,6 +100,25 @@ abstract class base implements type_interface
return [];
}
/**
* {@inheritDoc}
*/
public function get_ban_options(): array
{
// @todo replace table constant by string
$sql = 'SELECT *
FROM ' . BANS_TABLE . '
WHERE (ban_end >= ' . time() . "
OR ban_end = 0)
AND ban_mode = '{$this->get_type()}'
ORDER BY ban_item";
$result = $this->db->sql_query($sql);
$rowset = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
return $rowset;
}
/**
* Queries users that are excluded from banning (like founders)
* from the database and saves them in $this->excluded array.

View File

@@ -100,6 +100,13 @@ interface type_interface
*/
public function get_banned_users(): array;
/**
* Get ban options mapping ban ID to an option to display to admins
*
* @return array
*/
public function get_ban_options(): array;
/**
* Prepares the given ban items before saving them in the database
*

View File

@@ -68,6 +68,32 @@ class user extends base
return $unbanned_users;
}
/**
* {@inheritDoc}
*/
public function get_ban_options(): array
{
$ban_options = [];
// @todo replace table constant by string
$sql = 'SELECT b.*, u.user_id, u.username, u.username_clean
FROM ' . 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 u.user_id = b.ban_item
ORDER BY u.username_clean ASC";
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$row['ban_item'] = $row['username'];
$ban_options[] = $row;
}
$this->db->sql_freeresult($result);
return $ban_options;
}
/**
* {@inheritDoc}
*/