Skip to:
Content

BuddyPress.org

Changeset 4561


Ignore:
Timestamp:
06/24/2011 08:14:09 PM (13 years ago)
Author:
boonebgorges
Message:

Ensures that the activity items corresponding to all child posts are deleted when the entire topic thread is deleted. Fixes #3300 for trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-forums.php

    r4348 r4561  
    188188}
    189189
     190/**
     191 * Handles the forum topic deletion routine
     192 *
     193 * @package BuddyPress
     194 *
     195 * @uses bp_activity_delete() to delete corresponding activity items
     196 * @uses bp_forums_get_topic_posts() to get the child posts
     197 * @uses bp_forums_delete_topic() to do the deletion itself
     198 * @param int $topic_id The id of the topic to be deleted
     199 * @return bool True if the delete routine went through properly
     200 */
    190201function groups_delete_group_forum_topic( $topic_id ) {
    191202    global $bp;
     203
     204    // Before deleting the thread, get the post ids so that their activity items can be deleted
     205    $posts = bp_forums_get_topic_posts( array( 'topic_id' => $topic_id, 'per_page' => -1 ) );
    192206
    193207    if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) {
    194208        do_action( 'groups_before_delete_group_forum_topic', $topic_id );
    195209
    196         // Delete the activity stream item
    197         if ( bp_is_active( 'activity' ) )
     210        // Delete the activity stream items
     211        if ( bp_is_active( 'activity' ) ) {
     212            // The activity item for the initial topic
    198213            bp_activity_delete( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic' ) );
     214           
     215            // The activity item for each post
     216            foreach ( (array)$posts as $post ) {
     217                bp_activity_delete( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post->post_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post' ) );
     218            }
     219        }
    199220
    200221        do_action( 'groups_delete_group_forum_topic', $topic_id );
Note: See TracChangeset for help on using the changeset viewer.