From 9a5de3fc1e3cccff612ea40e900a5825552279a1 Mon Sep 17 00:00:00 2001 From: lavigor Date: Mon, 31 Aug 2015 22:32:25 +0300 Subject: [PATCH 1/3] [ticket/14134] Send warning notification PM in user's language. PHPBB3-14134 --- phpBB/includes/mcp/mcp_warn.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index d724b8703b..7d5e241eee 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -530,12 +530,30 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0) include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); - $user_row['user_lang'] = (file_exists($phpbb_root_path . 'language/' . $user_row['user_lang'] . "/mcp.$phpEx")) ? $user_row['user_lang'] : $config['default_lang']; - include($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp.$phpEx"); + // Okay we need to get the reason from the warned users language + // Only load up the language pack if the language is different to the current one + if ($user_row['user_lang'] != $user->lang_name) + { + // Load up the language pack + $lang = array(); + + $user_row['user_lang'] = (file_exists($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp." . $phpEx)) ? $user_row['user_lang'] : $config['default_lang']; + include($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp." . $phpEx); + + $warn_pm_subject = $lang['WARNING_PM_SUBJECT']; + $warn_pm_body = sprintf($lang['WARNING_PM_BODY'], $warning); + + unset($lang); // Free memory + } + else + { + $warn_pm_subject = $user->lang('WARNING_PM_SUBJECT'); + $warn_pm_body = $user->lang('WARNING_PM_BODY', $warning); + } $message_parser = new parse_message(); - $message_parser->message = $user->lang('WARNING_PM_BODY', $warning); + $message_parser->message = $warn_pm_body; $message_parser->parse(true, true, true, false, false, true, true); $pm_data = array( @@ -553,7 +571,7 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0) 'address_list' => array('u' => array($user_row['user_id'] => 'to')), ); - submit_pm('post', $user->lang('WARNING_PM_SUBJECT'), $pm_data, false); + submit_pm('post', $warn_pm_subject, $pm_data, false); } add_log('admin', 'LOG_USER_WARNING', $user_row['username']); From 276d48ed4f970b42f20a7013d27c6a169230ae74 Mon Sep 17 00:00:00 2001 From: lavigor Date: Sat, 27 Feb 2016 16:55:05 +0300 Subject: [PATCH 2/3] [ticket/14134] Fix code comments. PHPBB3-14134 --- phpBB/includes/mcp/mcp_warn.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 7d5e241eee..5dcfa8c474 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -531,10 +531,9 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0) include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); // Okay we need to get the reason from the warned users language - // Only load up the language pack if the language is different to the current one + // Attempt to translate warning to language of user being warned if user's language differs from issuer's language if ($user_row['user_lang'] != $user->lang_name) { - // Load up the language pack $lang = array(); $user_row['user_lang'] = (file_exists($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp." . $phpEx)) ? $user_row['user_lang'] : $config['default_lang']; @@ -543,7 +542,7 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0) $warn_pm_subject = $lang['WARNING_PM_SUBJECT']; $warn_pm_body = sprintf($lang['WARNING_PM_BODY'], $warning); - unset($lang); // Free memory + unset($lang); } else { From 18a4505b235c64ec33934876b8a1c98a0ef66f50 Mon Sep 17 00:00:00 2001 From: lavigor Date: Fri, 25 Mar 2016 23:11:43 +0300 Subject: [PATCH 3/3] [ticket/14134] Fix Okay in a comment. PHPBB3-14134 --- phpBB/includes/mcp/mcp_warn.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 5dcfa8c474..33c898ffc2 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -530,7 +530,6 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0) include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); - // Okay we need to get the reason from the warned users language // Attempt to translate warning to language of user being warned if user's language differs from issuer's language if ($user_row['user_lang'] != $user->lang_name) {