Index: /trunk/bp-activity.php
===================================================================
--- /trunk/bp-activity.php	(revision 1800)
+++ /trunk/bp-activity.php	(revision 1801)
@@ -382,4 +382,5 @@
 add_action( 'wpmu_delete_user', 'bp_activity_remove_data' );
 add_action( 'delete_user', 'bp_activity_remove_data' );
+add_action( 'make_spam_user', 'bp_activity_remove_data' );
 
 /* Ordering function - don't call this directly */
Index: /trunk/bp-core.php
===================================================================
--- /trunk/bp-core.php	(revision 1800)
+++ /trunk/bp-core.php	(revision 1801)
@@ -355,4 +355,23 @@
 add_action( 'admin_menu', 'bp_core_setup_nav', 2 );
 
+
+/********************************************************************************
+ * Screen Functions
+ *
+ * Screen functions are the controllers of BuddyPress. They will execute when their
+ * specific URL is caught. They will first save or manipulate data using business
+ * functions, then pass on the user to a template file.
+ */
+
+
+/********************************************************************************
+ * Action Functions
+ *
+ * Action functions are exactly the same as screen functions, however they do not
+ * have a template screen associated with them. Usually they will send the user
+ * back to the default screen after execution.
+ */
+
+
 /**
  * bp_core_action_directory_members()
@@ -377,4 +396,103 @@
 }
 add_action( 'wp', 'bp_core_action_directory_members', 2 );
+
+/**
+ * bp_core_action_set_spammer_status()
+ *
+ * When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
+ * this action will fire and mark or unmark the user and their blogs as spam.
+ * Must be a site admin for this function to run.
+ * 
+ * @package BuddyPress Core
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
+ */
+function bp_core_action_set_spammer_status() {
+	global $bp;
+	
+	if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id )
+		return false;
+
+	if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) {
+		/* Get the functions file */
+		require( ABSPATH . 'wp-admin/includes/mu.php' );
+		
+		if ( 'mark-spammer' == $bp->current_action )
+			$is_spam = 1;
+		else
+			$is_spam = 0;
+
+		/* Get the blogs for the user */
+		$blogs = get_blogs_of_user( $bp->displayed_user->id, true );
+	
+		foreach ( (array) $blogs as $key => $details ) {
+			/* Do not mark the main or current root blog as spam */
+			if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id ) 
+				continue; 
+		
+			/* Update the blog status */
+			update_blog_status( $details->userblog_id, 'spam', $is_spam );
+		
+			/* Fire the standard WPMU hook */
+			do_action( 'make_spam_blog', $details->userblog_id );
+		}
+	
+		/* Finally, mark this user as a spammer */
+		update_user_status( $bp->displayed_user->id, 'spam', $is_spam, 1 );
+		
+		if ( $is_spam )
+			bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) );
+		else
+			bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) );
+			
+		do_action( 'bp_core_action_set_spammer_status' );
+		
+		bp_core_redirect( wp_get_referer() );
+	}
+}
+add_action( 'wp', 'bp_core_action_set_spammer_status', 3 );
+
+/**
+ * bp_core_action_delete_user()
+ *
+ * Allows a site admin to delete a user from the adminbar menu.
+ * 
+ * @package BuddyPress Core
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
+ */
+function bp_core_action_delete_user() {
+	global $bp;
+	
+	if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id )
+		return false;
+	
+	if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) {
+		$errors = false;
+		
+		if ( bp_core_delete_account( $bp->displayed_user->id ) ) {
+			bp_core_add_message( sprintf( __( '%s has been deleted from the system.', 'buddypress' ), $bp->displayed_user->fullname ) );
+		} else {
+			bp_core_add_message( sprintf( __( 'There was an error deleting %s from the system. Please try again.', 'buddypress' ), $bp->displayed_user->fullname ), 'error' );
+			$errors = true;
+		}
+		
+		do_action( 'bp_core_action_set_spammer_status', $errors );
+		
+		if ( $errors )
+			bp_core_redirect( $bp->displayed_user->domain );
+		else
+			bp_core_redirect( $bp->loggedin_user->domain );
+	}
+}
+add_action( 'wp', 'bp_core_action_delete_user', 3 );
+
+
+/********************************************************************************
+ * Business Functions
+ *
+ * Business functions are where all the magic happens in BuddyPress. They will
+ * handle the actual saving or manipulation of information. Usually they will
+ * hand off to a database class for data access, then return
+ * true or false on success or failure.
+ */
 
 /**
@@ -957,4 +1075,33 @@
 }
 
+/**
+ * bp_core_is_user_spammer()
+ *
+ * Checks if the user has been marked as a spammer.
+ *
+ * @package BuddyPress Core
+ * @param $user_id int The id for the user.
+ * @return int 1 if spammer, 0 if not.
+ */
+function bp_core_is_user_spammer( $user_id ) {
+	global $wpdb;
+	
+	return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT spam FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) ); 
+}
+
+/**
+ * bp_core_is_user_deleted()
+ *
+ * Checks if the user has been marked as deleted.
+ *
+ * @package BuddyPress Core
+ * @param $user_id int The id for the user.
+ * @return int 1 if deleted, 0 if not.
+ */
+function bp_core_is_user_deleted( $user_id ) {
+	global $wpdb;
+	
+	return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT deleted FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) ); 	
+}
 
 /**
@@ -1329,13 +1476,16 @@
  * @uses wpmu_delete_user() Deletes a user from the system.
  */
-function bp_core_delete_account() {
-	global $bp;
+function bp_core_delete_account( $user_id = false ) {
+	global $bp;
+
+	if ( !$user_id )
+		$user_id = $bp->loggedin_user->id;
 
 	/* Make sure account deletion is not disabled */
-	if ( 1 == (int)get_site_option( 'bp-disable-account-deletion' ) )
-		return false;
-
-	/* Site admins should not be allowed to delete their accounts */
-	if ( is_site_admin() )
+	if ( ( 1 == (int)get_site_option( 'bp-disable-account-deletion' ) && !is_site_admin() ) )
+		return false;
+
+	/* Site admins should not be allowed to be deleted */
+	if ( is_site_admin( bp_core_get_username( $user_id ) ) )
 		return false;
 
@@ -1343,5 +1493,5 @@
 	require_once( ABSPATH . '/wp-admin/includes/user.php' );
 
-	return wpmu_delete_user( $bp->loggedin_user->id  );
+	return wpmu_delete_user( $user_id );
 }
 
@@ -1515,5 +1665,5 @@
 add_action( 'wpmu_delete_user', 'bp_core_remove_data', 1 );
 add_action( 'delete_user', 'bp_core_remove_data', 1 );
-
+add_action( 'make_spam_user', 'bp_core_remove_data', 1 );
 
 /**
Index: /trunk/bp-core/bp-core-catchuri.php
===================================================================
--- /trunk/bp-core/bp-core-catchuri.php	(revision 1800)
+++ /trunk/bp-core/bp-core-catchuri.php	(revision 1801)
@@ -130,6 +130,5 @@
 		}
 	}
-
-
+	
 	if ( !isset($is_root_component) )
 		$is_root_component = in_array( $bp_uri[0], $bp->root_components );
@@ -241,5 +240,13 @@
 	if ( $bp_no_status_set )
 		return false;
-		
+
+	/* If this user has been marked as a spammer and the logged in user is not a site admin, redirect. */
+	if ( isset( $bp->displayed_user->id ) && bp_core_is_user_spammer( $bp->displayed_user->id ) ) {
+		if ( !is_site_admin() )
+			bp_core_redirect( $bp->root_domain );
+		else
+			bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'error' );
+	}
+
 	// If this user does not exist, redirect to the root domain.
 	if ( !$bp->displayed_user->id && $bp_unfiltered_uri[0] == BP_MEMBERS_SLUG && isset($bp_unfiltered_uri[1]) )
Index: /trunk/bp-core/bp-core-classes.php
===================================================================
--- /trunk/bp-core/bp-core-classes.php	(revision 1800)
+++ /trunk/bp-core/bp-core-classes.php	(revision 1801)
@@ -242,6 +242,6 @@
 		like_escape($search_terms);	
 
-		$total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT DISTINCT count(u.ID) as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC", $search_terms );
-		$paged_users_sql = apply_filters( 'bp_core_search_users_sql', "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql );
+		$total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT DISTINCT count(u.ID) as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC", $search_terms );
+		$paged_users_sql = apply_filters( 'bp_core_search_users_sql', "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql );
 
 		$total_users = $wpdb->get_var( $total_users_sql );
Index: /trunk/bp-friends.php
===================================================================
--- /trunk/bp-friends.php	(revision 1800)
+++ /trunk/bp-friends.php	(revision 1801)
@@ -704,4 +704,5 @@
 add_action( 'wpmu_delete_user', 'friends_remove_data', 1 );
 add_action( 'delete_user', 'friends_remove_data', 1 );
+add_action( 'make_spam_user', 'friends_remove_data', 1 );
 
 function friends_clear_friend_object_cache( $friendship_id ) {
Index: /trunk/bp-groups.php
===================================================================
--- /trunk/bp-groups.php	(revision 1800)
+++ /trunk/bp-groups.php	(revision 1801)
@@ -2566,4 +2566,5 @@
 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user', 1 );
 add_action( 'delete_user', 'groups_remove_data_for_user', 1 );
+add_action( 'make_spam_user', 'groups_remove_data_for_user', 1 );
 
 function groups_clear_group_object_cache( $group_id ) {
Index: /trunk/bp-xprofile.php
===================================================================
--- /trunk/bp-xprofile.php	(revision 1800)
+++ /trunk/bp-xprofile.php	(revision 1801)
@@ -225,4 +225,44 @@
 add_action( 'admin_menu', 'xprofile_setup_nav', 2 );
 
+
+/**
+ * xprofile_setup_adminbar_menu()
+ *
+ * Adds an admin bar menu to any profile page providing site admin options for that user.
+ * 
+ * @package BuddyPress XProfile
+ * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
+ */
+function xprofile_setup_adminbar_menu() {
+	global $bp;
+	
+	if ( !$bp->displayed_user->id )
+		return false;
+	
+	/* Don't show this menu to non site admins or if you're viewing your own profile */
+	if ( !is_site_admin() || bp_is_home() )
+		return false;
+	?>
+	<li id="bp-adminbar-adminoptions-menu">
+		<a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
+		
+		<ul>
+			<li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit/"><?php printf( __( "Edit %s's Profile", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>
+			<li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/change-avatar/"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>
+			
+			<?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?>
+				<li><a href="<?php echo $bp->displayed_user->domain ?>admin/mark-spammer/" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li>
+			<?php else : ?>
+				<li><a href="<?php echo $bp->displayed_user->domain ?>admin/unmark-spammer/" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li>
+			<?php endif; ?>
+			
+			<li><a href="<?php echo $bp->displayed_user->domain ?>admin/delete-user/" class="confirm"><?php printf( __( "Delete %s", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>
+			
+			<?php do_action( 'xprofile_adminbar_menu_items' ) ?>
+		</ul>
+	</li>
+	<?php
+}
+add_action( 'bp_adminbar_menus', 'xprofile_setup_adminbar_menu', 20 );
 
 /********************************************************************************
Index: /trunk/bp-xprofile/bp-xprofile-templatetags.php
===================================================================
--- /trunk/bp-xprofile/bp-xprofile-templatetags.php	(revision 1800)
+++ /trunk/bp-xprofile/bp-xprofile-templatetags.php	(revision 1801)
@@ -565,5 +565,5 @@
 		
 		if ( $groups[$i]->fields )
-			echo '<li' . $selected . '><a href="' . $bp->loggedin_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . $groups[$i]->name . '</a></li>';
+			echo '<li' . $selected . '><a href="' . $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . $groups[$i]->name . '</a></li>';
 	}
 	
@@ -655,5 +655,5 @@
 		global $bp;
 		
-		return apply_filters( 'bp_get_avatar_delete_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->profile->slug . '/change-avatar/delete-avatar/', 'bp_delete_avatar_link' ) );
+		return apply_filters( 'bp_get_avatar_delete_link', wp_nonce_url( $bp->displayed_user->domain . $bp->profile->slug . '/change-avatar/delete-avatar/', 'bp_delete_avatar_link' ) );
 	}
 
