mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/9687] Use Forms for template display and fix display for users
PHPBB3-9687
This commit is contained in:
parent
6048458a12
commit
1a4e6fe3e8
7 changed files with 122 additions and 52 deletions
|
@ -11,11 +11,11 @@
|
||||||
<script>
|
<script>
|
||||||
// <![CDATA[
|
// <![CDATA[
|
||||||
|
|
||||||
var ban_length = new Array();
|
const ban_length = [];
|
||||||
ban_length[-1] = '';
|
ban_length[-1] = '';
|
||||||
var ban_reason = new Array();
|
const ban_reason = [];
|
||||||
ban_reason[-1] = '';
|
ban_reason[-1] = '';
|
||||||
var ban_give_reason = new Array();
|
const ban_give_reason = [];
|
||||||
ban_give_reason[-1] = '';
|
ban_give_reason[-1] = '';
|
||||||
|
|
||||||
<!-- BEGIN bans -->
|
<!-- BEGIN bans -->
|
||||||
|
@ -43,6 +43,19 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const $unbanSelect = document.getElementById('unban');
|
||||||
|
if ($unbanSelect) {
|
||||||
|
$unbanSelect.addEventListener('change', function () {
|
||||||
|
if (this.selectedIndex > -1) {
|
||||||
|
display_details(this.options[this.selectedIndex].value);
|
||||||
|
} else {
|
||||||
|
display_details(-1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ]]>
|
// ]]>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -85,44 +98,41 @@
|
||||||
|
|
||||||
<p>{L_UNBAN_EXPLAIN}</p>
|
<p>{L_UNBAN_EXPLAIN}</p>
|
||||||
|
|
||||||
<form id="acp_unban" method="post" action="{U_ACTION}">
|
<form id="acp_unban" method="post" action="{{ U_ACTION }}">
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{L_UNBAN_TITLE}</legend>
|
<legend>{{ lang('UNBAN_TITLE') }}</legend>
|
||||||
|
|
||||||
<!-- IF S_BANNED_OPTIONS -->
|
{% if BANNED_SELECT %}
|
||||||
<dl>
|
<dl>
|
||||||
<dt><label for="unban">{L_BAN_CELL}{L_COLON}</label></dt>
|
<dt><label for="unban">{{ lang('BAN_CELL') ~ lang('COLON') }}</label></dt>
|
||||||
<dd><select id="unban" name="unban[]" multiple="multiple" size="10" style="width: 50%" onchange="if (this.selectedIndex > -1) display_details(this.options[this.selectedIndex].value); else display_details(-1);">{BANNED_OPTIONS}</select></dd>
|
<dd>
|
||||||
|
{{ FormsSelect(BANNED_SELECT) }}
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><label for="unbanlength">{L_BAN_LENGTH}{L_COLON}</label></dt>
|
<dt><label for="unbanlength">{{ lang('BAN_LENGTH') ~ lang('COLON') }}</label></dt>
|
||||||
<dd><input style="border: 0;" type="text" class="text full" readonly="readonly" name="unbanlength" id="unbanlength" /></dd>
|
<dd><input style="border: 0;" type="text" class="text full" readonly="readonly" name="unbanlength" id="unbanlength" /></dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><label for="unbanreason">{L_BAN_REASON}{L_COLON}</label></dt>
|
<dt><label for="unbanreason">{{ lang('BAN_REASON') ~ lang('COLON') }}</label></dt>
|
||||||
<dd><textarea style="border: 0;" class="text full" readonly="readonly" name="unbanreason" id="unbanreason" rows="5" cols="80"> </textarea></dd>
|
<dd><textarea style="border: 0;" class="text full" readonly="readonly" name="unbanreason" id="unbanreason" rows="5" cols="80"> </textarea></dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><label for="unbangivereason">{L_BAN_GIVE_REASON}{L_COLON}</label></dt>
|
<dt><label for="unbangivereason">{{ lang('BAN_GIVE_REASON') ~ lang('COLON') }}</label></dt>
|
||||||
<dd><textarea style="border: 0;" class="text full" readonly="readonly" name="unbangivereason" id="unbangivereason" rows="5" cols="80"> </textarea></dd>
|
<dd><textarea style="border: 0;" class="text full" readonly="readonly" name="unbangivereason" id="unbangivereason" rows="5" cols="80"> </textarea></dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<p class="submit-buttons">
|
<p class="submit-buttons">
|
||||||
<input class="button1" type="submit" id="unbansubmit" name="unbansubmit" value="{L_SUBMIT}" />
|
<input class="button1" type="submit" id="unbansubmit" name="unbansubmit" value="{{ lang('SUBMIT') }}" />
|
||||||
<input class="button2" type="reset" id="unbanreset" name="unbanreset" value="{L_RESET}" />
|
<input class="button2" type="reset" id="unbanreset" name="unbanreset" value="{{ lang('RESET') }}" />
|
||||||
</p>
|
</p>
|
||||||
{S_FORM_TOKEN}
|
{% else %}
|
||||||
</fieldset>
|
<p>{{ lang('NO_BAN_CELL') }}</p>
|
||||||
|
{% endif %}
|
||||||
<!-- ELSE -->
|
{{ S_FORM_TOKEN }}
|
||||||
|
|
||||||
<p>{L_NO_BAN_CELL}</p>
|
|
||||||
{S_FORM_TOKEN}
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<!-- ENDIF -->
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<!-- INCLUDE overall_footer.html -->
|
<!-- INCLUDE overall_footer.html -->
|
||||||
|
|
|
@ -288,6 +288,10 @@ li {
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.w-50 {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) {
|
@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) {
|
||||||
#wrap,
|
#wrap,
|
||||||
#page-body,
|
#page-body,
|
||||||
|
|
|
@ -3156,33 +3156,37 @@ function display_ban_end_options()
|
||||||
*/
|
*/
|
||||||
function display_ban_options($mode)
|
function display_ban_options($mode)
|
||||||
{
|
{
|
||||||
global $user, $template, $phpbb_container;
|
global $language, $user, $template, $phpbb_container;
|
||||||
|
|
||||||
/** @var \phpbb\ban\manager $ban_manager */
|
/** @var \phpbb\ban\manager $ban_manager */
|
||||||
$ban_manager = $phpbb_container->get('ban.manager');
|
$ban_manager = $phpbb_container->get('ban.manager');
|
||||||
$ban_rows = $ban_manager->get_bans($mode);
|
$ban_rows = $ban_manager->get_bans($mode);
|
||||||
|
|
||||||
$banned_options = array();
|
$banned_options = [];
|
||||||
|
|
||||||
foreach ($ban_rows as $ban_row)
|
foreach ($ban_rows as $ban_row)
|
||||||
{
|
{
|
||||||
$banned_options[] = '<option value="' . $ban_row['ban_id'] . '">' . $ban_row['ban_item'] . '</option>';
|
$banned_options[] = [
|
||||||
|
'value' => $ban_row['ban_id'],
|
||||||
|
'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;
|
||||||
|
|
||||||
if ($time_length == 0)
|
if ($time_length == 0)
|
||||||
{
|
{
|
||||||
// Banned permanently
|
// Banned permanently
|
||||||
$ban_length = $user->lang['PERMANENT'];
|
$ban_length = $language->lang('PERMANENT');
|
||||||
}
|
}
|
||||||
else if (isset($ban_end_text[$time_length]))
|
else if (isset($ban_end_text[$time_length]))
|
||||||
{
|
{
|
||||||
// Banned for a given duration
|
// Banned for a given duration
|
||||||
$ban_length = $user->lang('BANNED_UNTIL_DURATION', $ban_end_text[$time_length], $user->format_date($ban_row['ban_end'], false, true));
|
$ban_length = $language->lang('BANNED_UNTIL_DURATION', $ban_end_text[$time_length], $user->format_date($ban_row['ban_end'], false, true));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Banned until given date
|
// Banned until given date
|
||||||
$ban_length = $user->lang('BANNED_UNTIL_DATE', $user->format_date($ban_row['ban_end'], false, true));
|
$ban_length = $language->lang('BANNED_UNTIL_DATE', $user->format_date($ban_row['ban_end'], false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->assign_block_vars('bans', array(
|
$template->assign_block_vars('bans', array(
|
||||||
|
@ -3196,16 +3200,24 @@ function display_ban_options($mode)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = '';
|
if (count($banned_options))
|
||||||
if ($banned_options)
|
|
||||||
{
|
{
|
||||||
$options .= '<optgroup label="' . $user->lang['OPTIONS_BANNED'] . '">';
|
$banned_select = [
|
||||||
$options .= implode('', $banned_options);
|
'tag' => 'select',
|
||||||
$options .= '</optgroup>';
|
'name' => 'unban[]',
|
||||||
}
|
'id' => 'unban',
|
||||||
|
'class' => 'w-50',
|
||||||
|
'multiple' => true,
|
||||||
|
'size' => 10,
|
||||||
|
'data' => [
|
||||||
|
'onchange' => 'display_details',
|
||||||
|
],
|
||||||
|
'options' => [[
|
||||||
|
'label' => $language->lang('OPTIONS_BANNED'),
|
||||||
|
'options' => $banned_options,
|
||||||
|
]],
|
||||||
|
];
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(['BANNED_SELECT' => $banned_select]);
|
||||||
'S_BANNED_OPTIONS' => (bool) $banned_options,
|
}
|
||||||
'BANNED_OPTIONS' => $options,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,23 +263,15 @@ class manager
|
||||||
*/
|
*/
|
||||||
public function get_bans(string $mode)
|
public function get_bans(string $mode)
|
||||||
{
|
{
|
||||||
/** @var type_interface $ban_mode */
|
/** @var type_interface $ban_type */
|
||||||
$ban_mode = $this->find_type($mode);
|
$ban_type = $this->find_type($mode);
|
||||||
if ($ban_mode === false)
|
if ($ban_type === false)
|
||||||
{
|
{
|
||||||
throw new type_not_found_exception(); // TODO
|
throw new type_not_found_exception();
|
||||||
}
|
}
|
||||||
$this->tidy();
|
$this->tidy();
|
||||||
|
|
||||||
$sql = 'SELECT ban_id, ban_item, ban_start, ban_end, ban_reason, ban_reason_display
|
return $ban_type->get_ban_options();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -100,6 +100,25 @@ abstract class base implements type_interface
|
||||||
return [];
|
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)
|
* Queries users that are excluded from banning (like founders)
|
||||||
* from the database and saves them in $this->excluded array.
|
* from the database and saves them in $this->excluded array.
|
||||||
|
|
|
@ -100,6 +100,13 @@ interface type_interface
|
||||||
*/
|
*/
|
||||||
public function get_banned_users(): array;
|
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
|
* Prepares the given ban items before saving them in the database
|
||||||
*
|
*
|
||||||
|
|
|
@ -68,6 +68,32 @@ class user extends base
|
||||||
return $unbanned_users;
|
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}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue