Ticket #2002: 2002.003.diff
File 2002.003.diff, 10.5 KB (added by , 14 years ago) |
---|
-
bp-themes/bp-default/_inc/ajax.php
53 53 if ( !empty( $_POST['page'] ) && '-1' != $_POST['page'] ) 54 54 $qs[] = 'page=' . $_POST['page']; 55 55 56 $object_search_text = bp_get_search_default_text( $object ); 57 if ( !empty( $_POST['search_terms'] ) && $object_search_text != $_POST['search_terms'] && 'false' != $_POST['search_terms'] && 'undefined' != $_POST['search_terms'] ) 56 $object_search_text = bp_get_search_default_text( $object ); 57 if ( !empty( $_POST['search_terms'] ) && $object_search_text != $_POST['search_terms'] && 'false' != $_POST['search_terms'] && 'undefined' != $_POST['search_terms'] ) 58 58 $qs[] = 'search_terms=' . $_POST['search_terms']; 59 59 60 60 /* Now pass the querystring to override default values. */ … … 231 231 } 232 232 add_action( 'wp_ajax_new_activity_comment', 'bp_dtheme_new_activity_comment' ); 233 233 234 /* AJAX delete an activity */ 234 /** 235 * bp_dtheme_delete_activity() 236 * 237 * Delete specific activity item via AJAX. 238 * 239 * @since 1.2 240 * 241 * @uses do_action() Calls 'bp_activity_before_action_delete_activity' hook to allow action 242 * to be taken before the activity is deleted. 243 * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow action 244 * to be taken after the activity is deleted. 245 * @uses check_admin_referer() 246 * @uses is_user_logged_in() 247 * @uses is_super_admin() 248 * @uses bp_loggedin_user_id() 249 * @uses bp_activity_delete() 250 * 251 * @global object $bp BuddyPress global settings 252 * @return bool False on failure. True if activity deleted. 253 */ 235 254 function bp_dtheme_delete_activity() { 236 255 global $bp; 237 256 … … 249 268 $activity = new BP_Activity_Activity( $_POST['id'] ); 250 269 251 270 // Check access 252 if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id)271 if ( !is_super_admin() && ( (int) $activity->user_id !== (int) bp_loggedin_user_id() ) ) 253 272 return false; 254 273 255 274 // Call the action before the delete so plugins can still fetch information about it … … 326 345 * @since 1.3 327 346 */ 328 347 function bp_dtheme_get_single_activity_content() { 329 $activity_array = bp_activity_get_specific( array( 330 'activity_ids' => $_POST['activity_id'], 331 'display_comments' => 'stream' 348 $activity_array = bp_activity_get_specific( array( 349 'activity_ids' => $_POST['activity_id'], 350 'display_comments' => 'stream' 332 351 ) ); 333 352 334 353 $activity = !empty( $activity_array['activities'][0] ) ? $activity_array['activities'][0] : false; 335 354 336 355 if ( !$activity ) 337 356 exit(); // todo: error? 338 357 339 358 // Activity content retrieved through AJAX should run through normal filters, but not be 340 359 // truncated 341 360 remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 ); 342 361 $content = apply_filters( 'bp_get_activity_content_body', $activity->content ); 343 362 344 363 echo $content; 345 364 346 365 exit(); 347 366 } 348 367 add_action( 'wp_ajax_get_single_activity_content', 'bp_dtheme_get_single_activity_content' ); … … 647 666 if ( !$ud ) 648 667 continue; 649 668 650 if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) ) 669 if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) ) 651 670 $username = $ud->user_login; 652 671 else 653 672 $username = $ud->user_nicename; -
bp-activity/bp-activity-actions.php
63 63 } 64 64 add_action( 'bp_actions', 'bp_activity_action_permalink_router' ); 65 65 66 /** 67 * bp_activity_action_delete_activity() 68 * 69 * Delete specific activity item and redirect to previous page ( if applicable ). 70 * 71 * @package BuddyPress Activity 72 * @since 1.1 73 * 74 * @uses do_action() Calls 'bp_activity_before_action_delete_activity' hook to allow actions 75 * to be taken before the activity is deleted. 76 * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions 77 * to be taken after the activity is deleted. 78 * @uses bp_is_activity_component() 79 * @uses bp_is_current_action() 80 * @uses check_admin_referer() 81 * @uses wp_get_referer() 82 * @uses bp_get_root_domain() 83 * @uses bp_activity_delete() 84 * @uses bp_core_add_message() 85 * @uses bp_core_redirect() 86 * 87 * @global object $bp 88 */ 66 89 function bp_activity_action_delete_activity() { 67 90 global $bp; 68 91 69 92 // Not viewing activity or action is not delete 70 if ( ( $bp->activity->slug != bp_current_component()) || !bp_is_current_action( 'delete' ) )93 if ( bp_is_activity_component() || !bp_is_current_action( 'delete' ) ) 71 94 return false; 72 95 73 96 // Not viewing a specific activity item … … 82 105 $activity = new BP_Activity_Activity( $activity_id ); 83 106 84 107 // Check access 85 if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id)108 if ( !is_super_admin() && $activity->user_id != bp_loggedin_user_id() ) 86 109 return false; 87 110 88 111 // Call the action before the delete so plugins can still fetch information about it 89 112 do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id ); 90 113 114 // Check for the redirect query arg, otherwise let WP handle things 115 $bp_redirect_to = ( isset( $_GET['bp_redirect_to'] ) ) ? $_GET['bp_redirect_to'] : wp_get_referer(); 116 117 // Always redirect somewhere 118 if ( empty( $bp_redirect_to ) ) 119 $bp_redirect_to = bp_get_root_domain(); 120 91 121 // Delete the activity item and provide user feedback 92 122 if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) ) 93 123 bp_core_add_message( __( 'Activity deleted', 'buddypress' ) ); … … 97 127 do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id ); 98 128 99 129 // Redirect 100 bp_core_redirect( wp_get_referer());130 bp_core_redirect( $bp_redirect_to ); 101 131 } 102 132 add_action( 'bp_actions', 'bp_activity_action_delete_activity' ); 103 133 … … 218 248 219 249 function bp_activity_action_sitewide_feed() { 220 250 global $bp, $wp_query; 221 251 222 252 if ( !bp_is_current_component( 'activity' ) || !bp_is_current_action( 'feed' ) || bp_is_user() || !empty( $bp->groups->current_group ) ) 223 253 return false; 224 254 -
bp-activity/bp-activity-template.php
394 394 */ 395 395 function bp_activity_has_more_items() { 396 396 global $activities_template; 397 398 $remaining_pages = floor( ( $activities_template->total_activity_count - 1 ) / ( $activities_template->pag_num * $activities_template->pag_page ) ); 397 398 $remaining_pages = floor( ( $activities_template->total_activity_count - 1 ) / ( $activities_template->pag_num * $activities_template->pag_page ) ); 399 399 $has_more_items = (int)$remaining_pages ? true : false; 400 400 401 401 return apply_filters( 'bp_activity_has_more_items', $has_more_items ); 402 402 } 403 403 … … 504 504 } 505 505 function bp_get_activity_user_link() { 506 506 global $activities_template; 507 507 508 508 if ( empty( $activities_template->activity->user_id ) ) 509 509 $link = $activities_template->activity->primary_link; 510 510 else … … 722 722 723 723 if ( $bp->loggedin_user->is_super_admin ) 724 724 $can_delete = true; 725 725 726 726 if ( $activities_template->activity->user_id == $bp->loggedin_user->id ) 727 727 $can_delete = true; 728 728 729 729 if ( $bp->is_item_admin && $bp->is_single_item ) 730 730 $can_delete = true; 731 731 732 732 return apply_filters( 'bp_activity_user_can_delete', $can_delete ); 733 733 } 734 734 … … 801 801 foreach ( (array)$comment->children as $comment_child ) { 802 802 // Put the comment into the global so it's available to filters 803 803 $activities_template->activity->current_comment = $comment_child; 804 804 805 805 if ( empty( $comment_child->user_fullname ) ) 806 806 $comment_child->user_fullname = $comment_child->display_name; 807 807 … … 853 853 854 854 $content .= bp_activity_recurse_comments( $comment_child ); 855 855 $content .= '</li>'; 856 856 857 857 // Unset in the global in case of the last iteration 858 858 unset( $activities_template->activity->current_comment ); 859 859 } … … 978 978 return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component . ' ' . $activities_template->activity->type . $class ); 979 979 } 980 980 981 /** 982 * bp_activity_delete_link() 983 * 984 * Display the activity delete link. 985 * 986 * @package BuddyPress Activity 987 * @since 1.1 988 * 989 * @uses bp_get_activity_delete_link() 990 */ 981 991 function bp_activity_delete_link() { 982 992 echo bp_get_activity_delete_link(); 983 993 } 994 995 /** 996 * bp_get_activity_delete_link() 997 * 998 * Return the activity delete link. 999 * 1000 * @package BuddyPress Activity 1001 * @since 1.1 1002 * 1003 * @uses apply_filters() Calls 'bp_get_activity_delete_link' hook to allow altering 1004 * of the activity delete link. 1005 * @uses bp_is_activity_component() 1006 * @uses bp_current_action() 1007 * @uses wp_nonce_url() 1008 * @uses add_query_arg() 1009 * @uses wp_get_referer() 1010 * @uses bp_get_root_domain() 1011 * @uses bp_get_activity_root_slug() 1012 * 1013 * @global object $bp BuddyPress global settings 1014 * @global object $activities_template BuddyPress Activities Template 1015 * @return string $link Activity delete link. Contains $bp_redirect_to arg if on single activity page. 1016 */ 984 1017 function bp_get_activity_delete_link() { 985 1018 global $activities_template, $bp; 986 1019 987 return apply_filters( 'bp_get_activity_delete_link', '<a href="' . wp_nonce_url( bp_get_root_domain() . '/' . $bp->activity->slug . '/delete/' . $activities_template->activity->id, 'bp_activity_delete_link' ) . '" class="item-button delete-activity confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>' ); 1020 // Determine if we're on a single activity page, and customize accordingly 1021 if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) 1022 $link = '<a href="' . wp_nonce_url( add_query_arg( array( 'bp_redirect_to' => wp_get_referer() ), bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id ), 'bp_activity_delete_link' ) . '" class="item-button delete-single-activity confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>' ); 1023 else 1024 $link = '<a href="' . wp_nonce_url( ( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id ), 'bp_activity_delete_link' ) . '" class="item-button delete-activity confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>' ); 1025 1026 return apply_filters( 'bp_get_activity_delete_link', $link ); 988 1027 } 989 1028 990 1029 function bp_activity_latest_update( $user_id = 0 ) {