diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index ac8775b0a0..0b1fc95746 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -186,7 +186,7 @@
  • [Feature] Ability to define minimum number of characters for posts/pms
  • [Feature] Store signature configuration options in database (Bug #45115 - Patch by rxu)
  • [Feature] Add bare-bones quick-reply editor to viewtopic.
  • - +
  • [Feature] Detect when a post has been altered by someone else while editing. (Patch by bantu)
  • 1.ii. Changes since 3.0.4

    diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 18bb432769..22fbfe3495 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -944,6 +944,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id WHERE p.topic_id = $topic_id " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . ' ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' + ' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . ' ORDER BY p.post_time '; $sql .= ($mode == 'post_review') ? 'ASC' : 'DESC'; $result = $db->sql_query_limit($sql, $config['posts_per_page']); @@ -962,6 +963,12 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id return false; } + // Handle 'post_review_edit' like 'post_review' from now on + if ($mode == 'post_review_edit') + { + $mode = 'post_review'; + } + $sql = $db->sql_build_query('SELECT', array( 'SELECT' => 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe', diff --git a/phpBB/language/en/posting.php b/phpBB/language/en/posting.php index e665f540eb..fae9f6124c 100644 --- a/phpBB/language/en/posting.php +++ b/phpBB/language/en/posting.php @@ -167,6 +167,7 @@ $lang = array_merge($lang, array( 'POST_ICON' => 'Post icon', 'POST_NORMAL' => 'Normal', 'POST_REVIEW' => 'Post review', + 'POST_REVIEW_EDIT_EXPLAIN' => 'This post has been altered by another user while you were editing it. You may wish to review the current version of this post and adjust your edits.', 'POST_REVIEW_EXPLAIN' => 'At least one new post has been made to this topic. You may wish to review your post in light of this.', 'POST_STORED' => 'This message has been posted successfully.', 'POST_STORED_MOD' => 'This message has been submitted successfully, but it will need to be approved by a moderator before it is publicly viewable.', diff --git a/phpBB/posting.php b/phpBB/posting.php index 598f500bc4..de5cdb9c6a 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -370,6 +370,7 @@ else } $post_data['post_edit_locked'] = (isset($post_data['post_edit_locked'])) ? (int) $post_data['post_edit_locked'] : 0; +$post_data['post_subject_md5'] = (isset($post_data['post_subject']) && $mode == 'edit') ? md5($post_data['post_subject']) : ''; $post_data['post_subject'] = (in_array($mode, array('quote', 'edit'))) ? $post_data['post_subject'] : ((isset($post_data['topic_title'])) ? $post_data['topic_title'] : ''); $post_data['topic_time_limit'] = (isset($post_data['topic_time_limit'])) ? (($post_data['topic_time_limit']) ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit']) : 0; $post_data['poll_length'] = (!empty($post_data['poll_length'])) ? (int) $post_data['poll_length'] / 86400 : 0; @@ -704,6 +705,37 @@ if ($submit || $preview || $refresh) // Grab md5 'checksum' of new message $message_md5 = md5($message_parser->message); + // If editing and checksum has changed we know the post was edited while we're editing + // Notify and show user the changed post + if ($mode == 'edit' && $post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) + { + $edit_post_message_checksum = request_var('edit_post_message_checksum', ''); + $edit_post_subject_checksum = request_var('edit_post_subject_checksum', ''); + + // $post_data['post_checksum'] is the checksum of the post submitted in the meantime + // $message_md5 is the checksum of the post we're about to submit + // $edit_post_message_checksum is the checksum of the post we're editing + // ... + + // We make sure nobody else made exactly the same change + // we're about to submit by also checking $message_md5 != $post_data['post_checksum'] + if (($edit_post_message_checksum !== '' && $edit_post_message_checksum != $post_data['post_checksum'] && $message_md5 != $post_data['post_checksum']) + || ($edit_post_subject_checksum !== '' && $edit_post_subject_checksum != $post_data['post_subject_md5'] && md5($post_data['post_subject']) != $post_data['post_subject_md5'])) + { + if (topic_review($topic_id, $forum_id, 'post_review_edit', $post_id)) + { + $template->assign_vars(array( + 'S_POST_REVIEW' => true, + + 'L_POST_REVIEW_EXPLAIN' => $user->lang['POST_REVIEW_EDIT_EXPLAIN'], + )); + } + + $submit = false; + $refresh = true; + } + } + // Check checksum ... don't re-parse message if the same $update_message = ($mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN) ? true : false; @@ -1261,6 +1293,14 @@ $s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? ''; $s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '' : ''; +if ($mode == 'edit') +{ + $s_hidden_fields .= build_hidden_fields(array( + 'edit_post_message_checksum' => $post_data['post_checksum'], + 'edit_post_subject_checksum' => $post_data['post_subject_md5'], + )); +} + // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview if (isset($captcha) && $captcha->is_solved() !== false) {