Skip to:
Content

BuddyPress.org

Changeset 2644 for trunk/bp-activity.php


Ignore:
Timestamp:
02/10/2010 03:15:48 PM (15 years ago)
Author:
apeatling
Message:

Fixes #1862 - remove all child comments when deleting a comment.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2636 r2644  
    687687 * The action passes one parameter that is a single activity ID or an
    688688 * array of activity IDs depending on the number deleted.
     689 *
     690 * If you are deleting an activity comment please use bp_activity_delete_comment();
    689691*/
    690692
     
    755757    /* End deprecation */
    756758
     759function bp_activity_delete_comment( $activity_id, $comment_id ) {
     760    /* Recursively delete all children of this comment. */
     761    if ( $children = BP_Activity_Activity::get_child_comments( $comment_id ) ) {
     762        foreach( (array)$children as $child )
     763            bp_activity_delete_comment( $activity_id, $child->id );
     764    }
     765    bp_activity_delete( array( 'secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id ) );
     766
     767    /* Delete the actual comment */
     768    if ( !bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) )
     769        return false;
     770
     771    /* Recalculate the comment tree */
     772    BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
     773
     774    return true;
     775}
     776
    757777function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
    758778    global $bp;
Note: See TracChangeset for help on using the changeset viewer.