Skip to:
Content

bbPress.org

Changeset 3488


Ignore:
Timestamp:
09/06/2011 03:37:55 AM (14 years ago)
Author:
johnjamesjacoby
Message:

When moving a sticky topic to a new forum, forum sticky meta was not refreshed. Fixes #1626.

File:
1 edited

Legend:

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

    r3468 r3488  
    829829 * @uses bbp_get_topic_id() To get the topic id
    830830 * @uses bbp_get_forum_id() To get the forum id
     831 * @uses bbp_get_stickies() To get the old forums sticky topics
     832 * @uses delete_post_meta() To delete the forum sticky meta
     833 * @uses update_post_meta() To update the old forum sticky meta
     834 * @uses bbp_stick_topic() To stick the topic in the new forum
    831835 * @uses bbp_get_reply_post_type() To get the reply post type
    832836 * @uses bbp_get_public_child_ids() To get the public child ids
     
    838842 */
    839843function bbp_move_topic_handler( $topic_id, $old_forum_id, $new_forum_id ) {
     844
     845    // Validate parameters
    840846    $topic_id     = bbp_get_topic_id( $topic_id     );
    841847    $old_forum_id = bbp_get_forum_id( $old_forum_id );
    842848    $new_forum_id = bbp_get_forum_id( $new_forum_id );
    843     $replies      = bbp_get_public_child_ids( $topic_id, bbp_get_reply_post_type() );
     849
     850    /** Stickies **************************************************************/
     851
     852    // Get forum stickies
     853    $old_stickies = bbp_get_stickies( $old_forum_id );
     854
     855    // Only proceed if stickies are found
     856    if ( !empty( $old_stickies ) ) {
     857
     858        // Define local variables
     859        $updated_stickies = array();
     860
     861        // Loop through stickies of forum
     862        foreach ( $old_stickies as $sticky_topic_id ) {
     863
     864            // Add non-matches to the updated array
     865            if ( $topic_id != $sticky_topic_id ) {
     866                $updated_stickies[$k] = $v;
     867            }
     868        }
     869
     870        // No more stickies so delete the beta
     871        if ( empty( $updated_stickies ) ) {
     872            delete_post_meta ( $old_forum_id, '_bbp_sticky_topics' );
     873
     874        // Still stickies so update the meta
     875        } else {
     876            update_post_meta( $old_forum_id, '_bbp_sticky_topics', $updated_stickies );
     877        }
     878
     879        // Topic was sticky, so restick in new forum
     880        bbp_stick_topic( $topic_id );
     881    }
     882   
     883    /** Topic Replies *********************************************************/
     884
     885    // Get the topics replies
     886    $replies = bbp_get_public_child_ids( $topic_id, bbp_get_reply_post_type() );
    844887
    845888    // Update the forum_id of all replies in the topic
Note: See TracChangeset for help on using the changeset viewer.