mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus: [ticket/13119] Remove unused globals and use the request class [ticket/13119] Add events to ACP's ban module [ticket/13119] Add events to MCP's ban module
This commit is contained in:
commit
d644de5217
2 changed files with 155 additions and 38 deletions
|
@ -25,14 +25,13 @@ class acp_ban
|
||||||
|
|
||||||
function main($id, $mode)
|
function main($id, $mode)
|
||||||
{
|
{
|
||||||
global $config, $db, $user, $auth, $template, $cache;
|
global $user, $template, $request, $phpbb_dispatcher;
|
||||||
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
|
global $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||||
|
|
||||||
$bansubmit = (isset($_POST['bansubmit'])) ? true : false;
|
$bansubmit = $request->is_set_post('bansubmit');
|
||||||
$unbansubmit = (isset($_POST['unbansubmit'])) ? true : false;
|
$unbansubmit = $request->is_set_post('unbansubmit');
|
||||||
$current_time = time();
|
|
||||||
|
|
||||||
$user->add_lang(array('acp/ban', 'acp/users'));
|
$user->add_lang(array('acp/ban', 'acp/users'));
|
||||||
$this->tpl_name = 'acp_ban';
|
$this->tpl_name = 'acp_ban';
|
||||||
|
@ -48,23 +47,79 @@ class acp_ban
|
||||||
if ($bansubmit)
|
if ($bansubmit)
|
||||||
{
|
{
|
||||||
// Grab the list of entries
|
// Grab the list of entries
|
||||||
$ban = utf8_normalize_nfc(request_var('ban', '', true));
|
$ban = $request->variable('ban', '', true);
|
||||||
$ban_len = request_var('banlength', 0);
|
$ban_length = $request->variable('banlength', 0);
|
||||||
$ban_len_other = request_var('banlengthother', '');
|
$ban_length_other = $request->variable('banlengthother', '');
|
||||||
$ban_exclude = request_var('banexclude', 0);
|
$ban_exclude = $request->variable('banexclude', 0);
|
||||||
$ban_reason = utf8_normalize_nfc(request_var('banreason', '', true));
|
$ban_reason = $request->variable('banreason', '', true);
|
||||||
$ban_give_reason = utf8_normalize_nfc(request_var('bangivereason', '', true));
|
$ban_give_reason = $request->variable('bangivereason', '', true);
|
||||||
|
|
||||||
if ($ban)
|
if ($ban)
|
||||||
{
|
{
|
||||||
user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
|
$abort_ban = false;
|
||||||
|
/**
|
||||||
|
* Use this event to modify the ban details before the ban is performed
|
||||||
|
*
|
||||||
|
* @event core.acp_ban_before
|
||||||
|
* @var string mode One of the following: user, ip, email
|
||||||
|
* @var string ban Either string or array with usernames, ips or email addresses
|
||||||
|
* @var int ban_length Ban length in minutes
|
||||||
|
* @var string ban_length_other Ban length as a date (YYYY-MM-DD)
|
||||||
|
* @var bool ban_exclude Are we banning or excluding from another ban
|
||||||
|
* @var string ban_reason Ban reason displayed to moderators
|
||||||
|
* @var string ban_give_reason Ban reason displayed to the banned user
|
||||||
|
* @var mixed abort_ban Either false, or an error message that is displayed to the user.
|
||||||
|
* If a string is given the bans are not issued.
|
||||||
|
* @since 3.1.0-RC5
|
||||||
|
*/
|
||||||
|
$vars = array(
|
||||||
|
'mode',
|
||||||
|
'ban',
|
||||||
|
'ban_length',
|
||||||
|
'ban_length_other',
|
||||||
|
'ban_exclude',
|
||||||
|
'ban_reason',
|
||||||
|
'ban_give_reason',
|
||||||
|
'abort_ban',
|
||||||
|
);
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.acp_ban_before', compact($vars)));
|
||||||
|
|
||||||
|
if ($abort_ban)
|
||||||
|
{
|
||||||
|
trigger_error($abort_ban . adm_back_link($this->u_action));
|
||||||
|
}
|
||||||
|
user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this event to perform actions after the ban has been performed
|
||||||
|
*
|
||||||
|
* @event core.acp_ban_after
|
||||||
|
* @var string mode One of the following: user, ip, email
|
||||||
|
* @var string ban Either string or array with usernames, ips or email addresses
|
||||||
|
* @var int ban_length Ban length in minutes
|
||||||
|
* @var string ban_length_other Ban length as a date (YYYY-MM-DD)
|
||||||
|
* @var bool ban_exclude Are we banning or excluding from another ban
|
||||||
|
* @var string ban_reason Ban reason displayed to moderators
|
||||||
|
* @var string ban_give_reason Ban reason displayed to the banned user
|
||||||
|
* @since 3.1.0-RC5
|
||||||
|
*/
|
||||||
|
$vars = array(
|
||||||
|
'mode',
|
||||||
|
'ban',
|
||||||
|
'ban_length',
|
||||||
|
'ban_length_other',
|
||||||
|
'ban_exclude',
|
||||||
|
'ban_reason',
|
||||||
|
'ban_give_reason',
|
||||||
|
);
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.acp_ban_after', compact($vars)));
|
||||||
|
|
||||||
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action));
|
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($unbansubmit)
|
else if ($unbansubmit)
|
||||||
{
|
{
|
||||||
$ban = request_var('unban', array(''));
|
$ban = $request->variable('unban', array(''));
|
||||||
|
|
||||||
if ($ban)
|
if ($ban)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@ class mcp_ban
|
||||||
|
|
||||||
function main($id, $mode)
|
function main($id, $mode)
|
||||||
{
|
{
|
||||||
global $config, $db, $user, $auth, $template, $cache;
|
global $db, $user, $auth, $template, $request, $phpbb_dispatcher;
|
||||||
global $phpbb_root_path, $phpEx;
|
global $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||||
|
@ -33,9 +33,8 @@ class mcp_ban
|
||||||
// Include the admin banning interface...
|
// Include the admin banning interface...
|
||||||
include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx);
|
include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx);
|
||||||
|
|
||||||
$bansubmit = (isset($_POST['bansubmit'])) ? true : false;
|
$bansubmit = $request->is_set_post('bansubmit');
|
||||||
$unbansubmit = (isset($_POST['unbansubmit'])) ? true : false;
|
$unbansubmit = $request->is_set_post('unbansubmit');
|
||||||
$current_time = time();
|
|
||||||
|
|
||||||
$user->add_lang(array('acp/ban', 'acp/users'));
|
$user->add_lang(array('acp/ban', 'acp/users'));
|
||||||
$this->tpl_name = 'mcp_ban';
|
$this->tpl_name = 'mcp_ban';
|
||||||
|
@ -44,44 +43,107 @@ class mcp_ban
|
||||||
if ($bansubmit)
|
if ($bansubmit)
|
||||||
{
|
{
|
||||||
// Grab the list of entries
|
// Grab the list of entries
|
||||||
$ban = request_var('ban', '', ($mode === 'user') ? true : false);
|
$ban = $request->variable('ban', '', $mode === 'user');
|
||||||
|
$ban_length = $request->variable('banlength', 0);
|
||||||
if ($mode === 'user')
|
$ban_length_other = $request->variable('banlengthother', '');
|
||||||
{
|
$ban_exclude = $request->variable('banexclude', 0);
|
||||||
$ban = utf8_normalize_nfc($ban);
|
$ban_reason = $request->variable('banreason', '', true);
|
||||||
}
|
$ban_give_reason = $request->variable('bangivereason', '', true);
|
||||||
|
|
||||||
$ban_len = request_var('banlength', 0);
|
|
||||||
$ban_len_other = request_var('banlengthother', '');
|
|
||||||
$ban_exclude = request_var('banexclude', 0);
|
|
||||||
$ban_reason = utf8_normalize_nfc(request_var('banreason', '', true));
|
|
||||||
$ban_give_reason = utf8_normalize_nfc(request_var('bangivereason', '', true));
|
|
||||||
|
|
||||||
if ($ban)
|
if ($ban)
|
||||||
{
|
{
|
||||||
if (confirm_box(true))
|
if (confirm_box(true))
|
||||||
{
|
{
|
||||||
user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
|
$abort_ban = false;
|
||||||
|
/**
|
||||||
|
* Use this event to modify the ban details before the ban is performed
|
||||||
|
*
|
||||||
|
* @event core.mcp_ban_before
|
||||||
|
* @var string mode One of the following: user, ip, email
|
||||||
|
* @var string ban Either string or array with usernames, ips or email addresses
|
||||||
|
* @var int ban_length Ban length in minutes
|
||||||
|
* @var string ban_length_other Ban length as a date (YYYY-MM-DD)
|
||||||
|
* @var bool ban_exclude Are we banning or excluding from another ban
|
||||||
|
* @var string ban_reason Ban reason displayed to moderators
|
||||||
|
* @var string ban_give_reason Ban reason displayed to the banned user
|
||||||
|
* @var mixed abort_ban Either false, or an error message that is displayed to the user.
|
||||||
|
* If a string is given the bans are not issued.
|
||||||
|
* @since 3.1.0-RC5
|
||||||
|
*/
|
||||||
|
$vars = array(
|
||||||
|
'mode',
|
||||||
|
'ban',
|
||||||
|
'ban_length',
|
||||||
|
'ban_length_other',
|
||||||
|
'ban_exclude',
|
||||||
|
'ban_reason',
|
||||||
|
'ban_give_reason',
|
||||||
|
'abort_ban',
|
||||||
|
);
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_before', compact($vars)));
|
||||||
|
|
||||||
|
if ($abort_ban)
|
||||||
|
{
|
||||||
|
trigger_error($abort_ban);
|
||||||
|
}
|
||||||
|
user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this event to perform actions after the ban has been performed
|
||||||
|
*
|
||||||
|
* @event core.mcp_ban_after
|
||||||
|
* @var string mode One of the following: user, ip, email
|
||||||
|
* @var string ban Either string or array with usernames, ips or email addresses
|
||||||
|
* @var int ban_length Ban length in minutes
|
||||||
|
* @var string ban_length_other Ban length as a date (YYYY-MM-DD)
|
||||||
|
* @var bool ban_exclude Are we banning or excluding from another ban
|
||||||
|
* @var string ban_reason Ban reason displayed to moderators
|
||||||
|
* @var string ban_give_reason Ban reason displayed to the banned user
|
||||||
|
* @since 3.1.0-RC5
|
||||||
|
*/
|
||||||
|
$vars = array(
|
||||||
|
'mode',
|
||||||
|
'ban',
|
||||||
|
'ban_length',
|
||||||
|
'ban_length_other',
|
||||||
|
'ban_exclude',
|
||||||
|
'ban_reason',
|
||||||
|
'ban_give_reason',
|
||||||
|
);
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_after', compact($vars)));
|
||||||
|
|
||||||
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
|
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
|
$hidden_fields = array(
|
||||||
'mode' => $mode,
|
'mode' => $mode,
|
||||||
'ban' => $ban,
|
'ban' => $ban,
|
||||||
'bansubmit' => true,
|
'bansubmit' => true,
|
||||||
'banlength' => $ban_len,
|
'banlength' => $ban_length,
|
||||||
'banlengthother' => $ban_len_other,
|
'banlengthother' => $ban_length_other,
|
||||||
'banexclude' => $ban_exclude,
|
'banexclude' => $ban_exclude,
|
||||||
'banreason' => $ban_reason,
|
'banreason' => $ban_reason,
|
||||||
'bangivereason' => $ban_give_reason)));
|
'bangivereason' => $ban_give_reason,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this event to pass data from the ban form to the confirmation screen
|
||||||
|
*
|
||||||
|
* @event core.mcp_ban_confirm
|
||||||
|
* @var array hidden_fields Hidden fields that are passed through the confirm screen
|
||||||
|
* @since 3.1.0-RC5
|
||||||
|
*/
|
||||||
|
$vars = array('hidden_fields');
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_confirm', compact($vars)));
|
||||||
|
|
||||||
|
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($hidden_fields));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($unbansubmit)
|
else if ($unbansubmit)
|
||||||
{
|
{
|
||||||
$ban = request_var('unban', array(''));
|
$ban = $request->variable('unban', array(''));
|
||||||
|
|
||||||
if ($ban)
|
if ($ban)
|
||||||
{
|
{
|
||||||
|
@ -157,9 +219,9 @@ class mcp_ban
|
||||||
}
|
}
|
||||||
|
|
||||||
// As a "service" we will check if any post id is specified and populate the username of the poster id if given
|
// As a "service" we will check if any post id is specified and populate the username of the poster id if given
|
||||||
$post_id = request_var('p', 0);
|
$post_id = $request->variable('p', 0);
|
||||||
$user_id = request_var('u', 0);
|
$user_id = $request->variable('u', 0);
|
||||||
$username = $pre_fill = false;
|
$pre_fill = false;
|
||||||
|
|
||||||
if ($user_id && $user_id <> ANONYMOUS)
|
if ($user_id && $user_id <> ANONYMOUS)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue