Changeset 5803 for trunk/bp-members/bp-members-actions.php
- Timestamp:
- 02/17/2012 05:30:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-members/bp-members-actions.php
r5751 r5803 25 25 */ 26 26 function bp_core_action_set_spammer_status( $user_id = 0 ) { 27 global $wpdb;28 29 // Only super admins can currently spam users30 if ( !bp_current_user_can( 'bp_moderate' ) || bp_is_my_profile() )31 return;32 27 33 28 // Use displayed user if it's not yourself 34 if ( empty( $user_id ) && bp_is_user())29 if ( empty( $user_id ) ) 35 30 $user_id = bp_displayed_user_id(); 36 37 // Bail if no user ID38 if ( empty( $user_id ) )39 return;40 41 // Bail if user ID is super admin42 if ( is_super_admin( $user_id ) )43 return;44 31 45 32 if ( bp_is_current_component( 'admin' ) && ( in_array( bp_current_action(), array( 'mark-spammer', 'unmark-spammer' ) ) ) ) { … … 48 35 check_admin_referer( 'mark-unmark-spammer' ); 49 36 50 // Get the functions file 51 if ( is_multisite() ) { 52 require( ABSPATH . 'wp-admin/includes/ms.php' ); 53 } 37 // To spam or not to spam 38 $status = bp_is_current_action( 'mark-spammer' ) ? 'spam' : 'ham'; 54 39 55 // T o spam or not to spam56 $is_spam = bp_is_current_action( 'mark-spammer' ) ? 1 : 0;40 // The heavy lifting 41 bp_core_process_spammer_status( $user_id, $status ); 57 42 58 // Get the blogs for the user 59 $blogs = get_blogs_of_user( $user_id, true ); 60 61 foreach ( (array) $blogs as $key => $details ) { 62 63 // Do not mark the main or current root blog as spam 64 if ( 1 == $details->userblog_id || bp_get_root_blog_id() == $details->userblog_id ) { 65 continue; 66 } 67 68 // Update the blog status 69 update_blog_status( $details->userblog_id, 'spam', $is_spam ); 70 } 71 72 // Finally, mark this user as a spammer 73 if ( is_multisite() ) { 74 update_user_status( $user_id, 'spam', $is_spam ); 75 } 76 77 // Always set single site status 78 $wpdb->update( $wpdb->users, array( 'user_status' => $is_spam ), array( 'ID' => $user_id ) ); 79 80 // Add feedback message 81 if ( $is_spam ) { 43 // Add feedback message. @todo - Error reporting 44 if ( 'spam' == $status ) { 82 45 bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) ); 83 46 } else { … … 85 48 } 86 49 87 // We need a special hook for is_spam so that components can delete data at spam time 88 $bp_action = $is_spam ? 'bp_make_spam_user' : 'bp_make_ham_user'; 89 do_action( $bp_action, bp_displayed_user_id() ); 90 91 // Call multisite actions in single site mode for good measure 92 if ( !is_multisite() ) { 93 $wp_action = $is_spam ? 'make_spam_user' : 'make_ham_user'; 94 do_action( $wp_action, bp_displayed_user_id() ); 95 } 96 97 // Allow plugins to do neat things 50 // Deprecated. Use bp_core_process_spammer_status. 51 $is_spam = 'spam' == $status; 98 52 do_action( 'bp_core_action_set_spammer_status', bp_displayed_user_id(), $is_spam ); 99 53
Note: See TracChangeset
for help on using the changeset viewer.