Changeset 7422 for trunk/bp-activity/bp-activity-classes.php
- Timestamp:
- 10/13/2013 02:36:04 AM (13 years ago)
- File:
-
- 1 edited
-
trunk/bp-activity/bp-activity-classes.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r7403 r7422 551 551 * Otherwise use the filters. 552 552 * 553 * @since BuddyPress (1.2) 554 * 553 555 * @param array $args { 554 556 * @int $id Optional. The ID of a specific item to delete. … … 628 630 $activity_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" ); 629 631 630 if ( ! $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) )632 if ( ! $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) ) { 631 633 return false; 632 634 } 635 636 // Handle accompanying activity comments and meta deletion 633 637 if ( $activity_ids ) { 634 BP_Activity_Activity::delete_activity_item_comments( $activity_ids ); 638 $activity_ids_comma = implode( ',', wp_parse_id_list( $activity_ids ) ); 639 $activity_comments_where_sql = "WHERE type = 'activity_comment' AND item_id IN ({$activity_ids_comma})"; 640 641 // Fetch the activity comment IDs for our deleted activity items 642 $activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$activity_comments_where_sql}" ); 643 644 // We have activity comments! 645 if ( ! empty( $activity_comment_ids ) ) { 646 // Delete activity comments 647 $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$activity_comments_where_sql}" ); 648 649 // Merge activity IDs with activity comment IDs 650 $activity_ids = array_merge( $activity_ids, $activity_comment_ids ); 651 } 652 653 // Delete all activity meta entries for activity items and activity comments 635 654 BP_Activity_Activity::delete_activity_meta_entries( $activity_ids ); 636 637 return $activity_ids;638 655 } 639 656 … … 644 661 * Delete the comments associated with a set of activity items. 645 662 * 663 * @since BuddyPress (1.2) 664 * 665 * @todo Mark as deprecated? Method is no longer used internally. 666 * 646 667 * @param array $activity_ids Activity IDs whose comments should be deleted. 668 * @param bool $delete_meta Should we delete the activity meta items for these comments? 647 669 * @return bool True on success. 648 670 */ 649 public static function delete_activity_item_comments( $activity_ids = array() ) {671 public static function delete_activity_item_comments( $activity_ids = array(), $delete_meta = true ) { 650 672 global $bp, $wpdb; 651 673 674 $delete_meta = (bool) $delete_meta; 675 652 676 $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) ); 653 677 678 if ( $delete_meta ) { 679 // Fetch the activity comment IDs for our deleted activity items 680 $activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" ); 681 682 if ( ! empty( $activity_comment_ids ) ) { 683 self::delete_activity_meta_entries( $activity_comment_ids ); 684 } 685 } 686 654 687 return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" ); 655 688 } … … 657 690 /** 658 691 * Delete the meta entries associated with a set of activity items. 692 * 693 * @since BuddyPress (1.2) 659 694 * 660 695 * @param array $activity_ids Activity IDs whose meta should be deleted.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)