Skip to:
Content

BuddyPress.org

Changeset 2680 for trunk/bp-activity.php


Ignore:
Timestamp:
02/11/2010 04:19:46 PM (15 years ago)
Author:
apeatling
Message:

Allow developers to override the comment delete function to handle the deletion of child comments differently.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2678 r2680  
    11<?php
    22
    3 define ( 'BP_ACTIVITY_DB_VERSION', '2040' );
     3define ( 'BP_ACTIVITY_DB_VERSION', '2050' );
    44
    55/* Define the slug for the component */
     
    5151                KEY item_id (item_id),
    5252                KEY component (component),
     53                KEY type (type),
    5354                KEY mptt_left (mptt_left),
    54                 KEY mptt_right (mptt_right)
     55                KEY mptt_right (mptt_right),
     56                KEY hide_sitewide (hide_sitewide)
    5557               ) {$charset_collate};";
    5658
     
    762764
    763765function bp_activity_delete_comment( $activity_id, $comment_id ) {
    764     /* Recursively delete all children of this comment. */
    765     if ( $children = BP_Activity_Activity::get_child_comments( $comment_id ) ) {
    766         foreach( (array)$children as $child )
    767             bp_activity_delete_comment( $activity_id, $child->id );
    768     }
    769     bp_activity_delete( array( 'secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id ) );
     766    /***
     767     * You may want to hook into this filter if you want to override this function and
     768     * handle the deletion of child comments differently. Make sure you return false.
     769     */
     770    if ( !apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) )
     771        return false;
     772
     773    /* Delete any children of this comment. */
     774    bp_activity_delete_children( $activity_id, $comment_id );
    770775
    771776    /* Delete the actual comment */
     
    776781    BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
    777782
     783    do_action( 'bp_activity_delete_comment', $activity_id, $comment_id );
     784
    778785    return true;
    779786}
     787    function bp_activity_delete_children( $activity_id, $comment_id) {
     788        /* Recursively delete all children of this comment. */
     789        if ( $children = BP_Activity_Activity::get_child_comments( $comment_id ) ) {
     790            foreach( (array)$children as $child )
     791                bp_activity_delete_children( $activity_id, $child->id );
     792        }
     793        bp_activity_delete( array( 'secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id ) );
     794    }
    780795
    781796function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
Note: See TracChangeset for help on using the changeset viewer.