Changeset 2644
- Timestamp:
- 02/10/2010 03:15:48 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r2636 r2644 687 687 * The action passes one parameter that is a single activity ID or an 688 688 * array of activity IDs depending on the number deleted. 689 * 690 * If you are deleting an activity comment please use bp_activity_delete_comment(); 689 691 */ 690 692 … … 755 757 /* End deprecation */ 756 758 759 function 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 757 777 function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { 758 778 global $bp; -
trunk/bp-activity/bp-activity-classes.php
r2619 r2644 39 39 $this->date_recorded = $row->date_recorded; 40 40 $this->hide_sitewide = $row->hide_sitewide; 41 $this->mptt_left = $row->mptt_left; 42 $this->mptt_right = $row->mptt_right; 41 43 } 42 44 } … … 374 376 375 377 /* Get all descendants of this node */ 376 $descendants = $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ));378 $descendants = BP_Activity_Activity::get_child_comments( $parent_id ); 377 379 378 380 /* Loop the descendants and recalculate the left and right values */ … … 390 392 } 391 393 394 function get_child_comments( $parent_id ) { 395 global $bp, $wpdb; 396 397 return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) ); 398 } 399 392 400 function get_recorded_components() { 393 401 global $wpdb, $bp; -
trunk/bp-themes/bp-default/_inc/ajax.php
r2606 r2644 226 226 return true; 227 227 } 228 add_action( 'wp_ajax_delete_activity_comment', 'bp_dtheme_delete_activity' );229 228 add_action( 'wp_ajax_delete_activity', 'bp_dtheme_delete_activity' ); 229 230 function bp_dtheme_delete_activity_comment() { 231 global $bp; 232 233 /* Check the nonce */ 234 check_admin_referer( 'bp_activity_delete_link' ); 235 236 if ( !is_user_logged_in() ) { 237 echo '-1'; 238 return false; 239 } 240 241 $comment = new BP_Activity_Activity( $_POST['id'] ); 242 243 /* Check access */ 244 if ( !is_site_admin() && $comment->user_id != $bp->loggedin_user->id ) 245 return false; 246 247 if ( empty( $_POST['id'] ) || !is_numeric( $_POST['id'] ) || !bp_activity_delete_comment( $comment->item_id, $comment->id ) ) { 248 echo '-1<div id="message" class="error"><p>' . __( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '</p></div>'; 249 return false; 250 } 251 252 return true; 253 } 254 add_action( 'wp_ajax_delete_activity_comment', 'bp_dtheme_delete_activity_comment' ); 230 255 231 256 function bp_dtheme_mark_activity_favorite() { -
trunk/bp-themes/bp-default/_inc/global.js
r2641 r2644 373 373 var link_href = target.attr('href'); 374 374 var comment_li = target.parent().parent(); 375 var form = comment_li.parents('div.activity-comments').children('form'); 375 376 376 377 var nonce = link_href.split('_wpnonce='); … … 386 387 j('div.activity-comments ul div.error').remove(); 387 388 389 /* Reset the form position */ 390 comment_li.parents('div.activity-comments').append(form); 391 388 392 j.post( ajaxurl, { 389 action: 'delete_activity ',393 action: 'delete_activity_comment', 390 394 'cookie': encodeURIComponent(document.cookie), 391 395 '_wpnonce': nonce, … … 398 402 comment_li.prepend( response.substr( 2, response.length ) ).hide().fadeIn( 200 ); 399 403 } else { 400 comment_li.fadeOut( 200, function() { 401 var children = j( 'li#' + comment_li.attr('id') + ' ul:first' ); 402 403 /* Fade in sub comments if any were found. */ 404 if ( children.length ) 405 comment_li.parent().append( children.html() ).hide().fadeIn( 200 ); 406 }); 404 var children = j( 'li#' + comment_li.attr('id') + ' ul' ).children('li'); 405 comment_li.fadeOut(200); 407 406 408 407 /* Decrease the "Reply (X)" button count */ 409 408 var parent_li = comment_li.parents('ul#activity-stream > li'); 410 j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html( j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html() - 1);409 j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html( j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html() - ( 1 + children.length ) ); 411 410 } 412 411 });
Note: See TracChangeset
for help on using the changeset viewer.