Skip to:
Content

bbPress.org

Ticket #1502: topic_merge.diff

File topic_merge.diff, 1.8 KB (added by GautamGupta, 14 years ago)
  • bbp-includes/bbp-topic-functions.php

     
    676676                        // Update counts, etc...
    677677                        do_action( 'bbp_merge_topic', $destination_topic->ID, $source_topic->ID );
    678678
     679                        // Check if the post date of the source topic is earlier than that of destination topic
     680                        if ( strtotime( $source_topic->post_date ) < strtotime( $destination_topic->post_date ) ) {
     681
     682                                // If that's the case then revert back the date of the destination topic
     683                                // So that the topic is displayed before anything
     684                                $destination_post_date = date( 'Y-m-d H:i:s', strtotime( $source_topic->post_date ) - 1 );
     685
     686                                $postarr = array(
     687                                        'ID'            => $destination_topic_id,
     688                                        'post_date'     => $destination_post_date,
     689                                        'post_date_gmt' => get_gmt_from_date( $destination_post_date )
     690                                );
     691
     692                                wp_update_post( $postarr );
     693                        }
     694
    679695                        // Remove the topic from everybody's subscriptions
    680696                        $subscribers = bbp_get_topic_subscribers( $source_topic->ID );
    681697                        foreach ( (array) $subscribers as $subscriber ) {
  • bbp-themes/bbp-twentyten/bbpress/form-merge.php

     
    2828
    2929                                        <div class="bbp-template-notice">
    3030                                                <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                                                <p><?php _e( 'Also note that if this topic was created before the destination topic, then the destination topic\'s post date would be changed to a second before this topic\'s date. ', 'bbpress' ); ?></p>
    3132                                        </div>
    3233
    3334                                        <div class="bbp-template-notice error">