Send localised disapproval reasons in the recipients local language. #31645

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8837 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Chris Smith 2008-09-08 00:29:48 +00:00
parent aa6c728e6f
commit 3dfa386f2c
2 changed files with 43 additions and 2 deletions

View file

@ -119,6 +119,7 @@
<li>[Fix] Stop search bots incrementing topic views. (Bug #32675 - Patch by eviL&lt;3)</li> <li>[Fix] Stop search bots incrementing topic views. (Bug #32675 - Patch by eviL&lt;3)</li>
<li>[Fix] Use correct link for post author search. (Bug #32595)</li> <li>[Fix] Use correct link for post author search. (Bug #32595)</li>
<li>[Fix] Do not decrease topics counter when deleting shadow topics. (Bug #26495)</li> <li>[Fix] Do not decrease topics counter when deleting shadow topics. (Bug #26495)</li>
<li>[Fix] Send localised disapproval reasons in the recipients local language. (Bug #31645)</li>
</ul> </ul>

View file

@ -816,6 +816,13 @@ function disapprove_post($post_id_list, $id, $mode)
// If the reason is defined within the language file, we will use the localized version, else just use the database entry... // If the reason is defined within the language file, we will use the localized version, else just use the database entry...
$disapprove_reason = (strtolower($row['reason_title']) != 'other') ? ((isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description']) : ''; $disapprove_reason = (strtolower($row['reason_title']) != 'other') ? ((isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description']) : '';
$disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; $disapprove_reason .= ($reason) ? "\n\n" . $reason : '';
if (isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
{
$disapprove_reason_lang = strtoupper($row['reason_title']);
}
$email_disapprove_reason = $disapprove_reason;
} }
} }
@ -935,6 +942,8 @@ function disapprove_post($post_id_list, $id, $mode)
// Notify Poster? // Notify Poster?
if ($notify_poster) if ($notify_poster)
{ {
$lang_reasons = array();
foreach ($post_info as $post_id => $post_data) foreach ($post_info as $post_id => $post_data)
{ {
if ($post_data['poster_id'] == ANONYMOUS) if ($post_data['poster_id'] == ANONYMOUS)
@ -942,6 +951,35 @@ function disapprove_post($post_id_list, $id, $mode)
continue; continue;
} }
if (isset($disapprove_reason_lang))
{
// Okay we need to get the reason from the posters language
if (!isset($lang_reasons[$post_data['user_lang']]))
{
// Assign the current users translation as the default, this is not ideal but getting the board default adds another layer of complexity.
$lang_reasons[$post_data['user_lang']] = $user->lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang];
// Only load up the language pack if the language is different to the current one
if ($post_data['user_lang'] != $user->lang_name && file_exists($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx))
{
// Load up the language pack
$lang = array();
@include($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx);
// If we find the reason in this language pack use it
if (isset($lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]))
{
$lang_reasons[$post_data['user_lang']] = $lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang];
}
unset($lang); // Free memory
}
}
$email_disapprove_reason = $lang_reasons[$post_data['user_lang']];
$email_disapprove_reason .= ($reason) ? "\n\n" . $reason : '';
}
$email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_disapproved' : 'post_disapproved'; $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_disapproved' : 'post_disapproved';
$messenger->template($email_template, $post_data['user_lang']); $messenger->template($email_template, $post_data['user_lang']);
@ -951,15 +989,17 @@ function disapprove_post($post_id_list, $id, $mode)
$messenger->assign_vars(array( $messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($post_data['username']), 'USERNAME' => htmlspecialchars_decode($post_data['username']),
'REASON' => htmlspecialchars_decode($disapprove_reason), 'REASON' => htmlspecialchars_decode($email_disapprove_reason),
'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])),
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title']))) 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])))
); );
$messenger->send($post_data['user_notify_type']); $messenger->send($post_data['user_notify_type']);
} }
unset($lang_reasons);
} }
unset($post_info, $disapprove_reason); unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang);
$messenger->save_queue(); $messenger->save_queue();