[ticket/11769] Correctly supply the post author's username in posting.php

Only supply the username, when it is a guest posting or we edit and it was
supplied, otherwise post_data might hold data of the post we quote, in which
case username is the original poster, not the current one.

PHPBB3-11769
This commit is contained in:
Joas Schilling 2013-08-23 22:52:33 +02:00
parent ba9d303d52
commit 2845b153d8
2 changed files with 10 additions and 2 deletions

View file

@ -2604,7 +2604,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
// Send Notifications // Send Notifications
if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval) if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval)
{ {
$username = ($username) ? $username : $user->data['username']; // If a username was supplied or the poster is a guest, we use the supplied username.
// This way we will use "...post by guest-username..." in notifications,
// when guest-username was supplied and ommit the username-part otherwise.
$username = ($username || !$user->data['is_registered']) ? $username : $user->data['username'];
user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id'], $username); user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id'], $username);
} }

View file

@ -1131,8 +1131,13 @@ if ($submit || $preview || $refresh)
$data['topic_replies'] = $post_data['topic_replies']; $data['topic_replies'] = $post_data['topic_replies'];
} }
// Only supply the username, when it is a guest posting or we edit and it was supplied,
// otherwise post_data might hold data of the post we quote, in which case
// username is the original poster, not the current one. See: PHPBB3-11769
$post_author_name = ((!$user->data['is_registered'] || $mode == 'edit') && $post_data['username']) ? $post_data['username'] : '';
// The last parameter tells submit_post if search indexer has to be run // The last parameter tells submit_post if search indexer has to be run
$redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false); $redirect_url = submit_post($mode, $post_data['post_subject'], $post_author_name, $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false);
if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))
{ {