Skip to:
Content

bbPress.org

Changeset 3017


Ignore:
Timestamp:
04/22/2011 10:56:44 AM (14 years ago)
Author:
johnjamesjacoby
Message:

When merging two topics together, the destination topic post_date cannot be after the source topic or any merged replies. Fixes #1502. Props GautamGupta for original patch.

Location:
branches/plugin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-topic-functions.php

    r2993 r3017  
    677677            do_action( 'bbp_merge_topic', $destination_topic->ID, $source_topic->ID );
    678678
     679            // Check if the destination topic is older than the source topic
     680            if ( strtotime( $source_topic->post_date ) < strtotime( $destination_topic->post_date ) ) {
     681
     682                // Set destination topic post_date to 1 second before source topic
     683                $destination_post_date = date( 'Y-m-d H:i:s', strtotime( $source_topic->post_date ) - 1 );
     684
     685                $postarr = array(
     686                    'ID'            => $destination_topic_id,
     687                    'post_date'     => $destination_post_date,
     688                    'post_date_gmt' => get_gmt_from_date( $destination_post_date )
     689                );
     690
     691                // Update destination topic
     692                wp_update_post( $postarr );
     693            }
     694
    679695            // Remove the topic from everybody's subscriptions
    680696            $subscribers = bbp_get_topic_subscribers( $source_topic->ID );
  • branches/plugin/bbp-themes/bbp-twentyten/bbpress/form-merge.php

    r2943 r3017  
    2828
    2929                    <div class="bbp-template-notice">
    30                         <p><?php _e( '<strong>NOTE:</strong> All replies within both topics will be merged chronologically. The order of the merged replies is based on the time and date they were posted.', 'bbpress' ); ?></p>
    31                     </div>
    32 
    33                     <div class="bbp-template-notice error">
    34                         <p><?php _e( '<strong>WARNING:</strong> This process cannot be undone.', 'bbpress' ); ?></p>
     30                        <p><?php _e( 'All replies within both topics will be merged chronologically. The order of the merged replies is based on the time and date they were posted. If the destination topic was created after this one, it\'s post date will be updated to second earlier than this one.', 'bbpress' ); ?></p>
    3531                    </div>
    3632
     
    8379                    </fieldset>
    8480
     81                    <div class="bbp-template-notice error">
     82                        <p><?php _e( '<strong>WARNING:</strong> This process cannot be undone.', 'bbpress' ); ?></p>
     83                    </div>
     84
    8585                    <div class="bbp-submit-wrapper">
    8686                        <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_merge_topic_submit" name="bbp_merge_topic_submit"><?php _e( 'Submit', 'bbpress' ); ?></button>
  • branches/plugin/bbp-themes/bbp-twentyten/bbpress/form-split.php

    r2993 r3017  
    2727
    2828                    <div class="bbp-template-notice">
    29                         <p><?php _e( '<strong>NOTE:</strong> If you use the existing topic option, replies within both topics will be merged chronologically. The order of the merged replies is based on the time and date they were posted.', 'bbpress' ); ?></p>
    30                     </div>
    31 
    32                     <div class="bbp-template-notice error">
    33                         <p><?php _e( '<strong>WARNING:</strong> This process cannot be undone.', 'bbpress' ); ?></p>
     29                        <p><?php _e( 'If you use the existing topic option, replies within both topics will be merged chronologically. The order of the merged replies is based on the time and date they were posted.', 'bbpress' ); ?></p>
    3430                    </div>
    3531
     
    8783                    </fieldset>
    8884
     85                    <div class="bbp-template-notice error">
     86                        <p><?php _e( '<strong>WARNING:</strong> This process cannot be undone.', 'bbpress' ); ?></p>
     87                    </div>
     88
    8989                    <div class="bbp-submit-wrapper">
    9090                        <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_merge_topic_submit" name="bbp_merge_topic_submit"><?php _e( 'Submit', 'bbpress' ); ?></button>
Note: See TracChangeset for help on using the changeset viewer.