From fdb53b23fbb4509619ff35982cd453362594a566 Mon Sep 17 00:00:00 2001 From: n-aleha Date: Thu, 22 May 2014 22:48:49 +0300 Subject: [PATCH 1/2] [ticket/12584] Add event core.mcp_warn_user_before/after Event for when warning a user from MCP. PHPBB3-12584 --- phpBB/includes/mcp/mcp_warn.php | 51 +++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 4275182d26..57d0aed94d 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -318,7 +318,7 @@ class mcp_warn function mcp_warn_user_view($action) { global $phpEx, $phpbb_root_path, $config, $module; - global $template, $db, $user, $auth; + global $template, $db, $user, $auth, $phpbb_dispatcher; $user_id = request_var('u', 0); $username = request_var('username', '', true); @@ -376,16 +376,57 @@ class mcp_warn { if (check_form_key('mcp_warn')) { - add_warning($user_row, $warning, $notify); - $msg = $user->lang['USER_WARNING_ADDED']; + $s_mcp_warn_user = true; + + /** + * Event for before warning a user from MCP. + * + * @event core.mcp_warn_user_before + * @var array user_row The entire user row + * @var string warning The warning message + * @var bool notify If true, we notify the user for the warning + * @var bool s_mcp_warn_user If true, we add the warning else we omit it + * @since 3.1.0-b4 + */ + $vars = array( + 'user_row', + 'warning', + 'notify', + 's_mcp_warn_user', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_before', compact($vars))); + + if ($s_mcp_warn_user) + { + add_warning($user_row, $warning, $notify); + $message = $user->lang['USER_WARNING_ADDED']; + + /** + * Event for after warning a user from MCP. + * + * @event core.mcp_warn_user_after + * @var array user_row The entire user row + * @var string warning The warning message + * @var bool notify If true, the user was notified for the warning + * @var string message Message displayed to the moderator + * @since 3.1.0-b4 + */ + $vars = array( + 'user_row', + 'warning', + 'notify', + 'message', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_after', compact($vars))); + } } else { - $msg = $user->lang['FORM_INVALID']; + $message = $user->lang['FORM_INVALID']; } $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); meta_refresh(2, $redirect); - trigger_error($msg . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); + trigger_error($message . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); } // Generate the appropriate user information for the user we are looking at From 62cb7e0c1064b5724c60a24a9052416556879305 Mon Sep 17 00:00:00 2001 From: n-aleha Date: Sun, 25 May 2014 22:05:34 +0300 Subject: [PATCH 2/2] [ticket/12584] Redirect only on non-empty $message PHPBB3-12584 --- phpBB/includes/mcp/mcp_warn.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 57d0aed94d..9f368727f6 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -424,9 +424,13 @@ class mcp_warn { $message = $user->lang['FORM_INVALID']; } - $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); - meta_refresh(2, $redirect); - trigger_error($message . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); + + if (!empty($message)) + { + $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); + meta_refresh(2, $redirect); + trigger_error($message . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); + } } // Generate the appropriate user information for the user we are looking at