Changeset 1801
- Timestamp:
- 09/06/2009 11:42:31 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r1764 r1801 382 382 add_action( 'wpmu_delete_user', 'bp_activity_remove_data' ); 383 383 add_action( 'delete_user', 'bp_activity_remove_data' ); 384 add_action( 'make_spam_user', 'bp_activity_remove_data' ); 384 385 385 386 /* Ordering function - don't call this directly */ -
trunk/bp-core.php
r1788 r1801 355 355 add_action( 'admin_menu', 'bp_core_setup_nav', 2 ); 356 356 357 358 /******************************************************************************** 359 * Screen Functions 360 * 361 * Screen functions are the controllers of BuddyPress. They will execute when their 362 * specific URL is caught. They will first save or manipulate data using business 363 * functions, then pass on the user to a template file. 364 */ 365 366 367 /******************************************************************************** 368 * Action Functions 369 * 370 * Action functions are exactly the same as screen functions, however they do not 371 * have a template screen associated with them. Usually they will send the user 372 * back to the default screen after execution. 373 */ 374 375 357 376 /** 358 377 * bp_core_action_directory_members() … … 377 396 } 378 397 add_action( 'wp', 'bp_core_action_directory_members', 2 ); 398 399 /** 400 * bp_core_action_set_spammer_status() 401 * 402 * When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu 403 * this action will fire and mark or unmark the user and their blogs as spam. 404 * Must be a site admin for this function to run. 405 * 406 * @package BuddyPress Core 407 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 408 */ 409 function bp_core_action_set_spammer_status() { 410 global $bp; 411 412 if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id ) 413 return false; 414 415 if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) { 416 /* Get the functions file */ 417 require( ABSPATH . 'wp-admin/includes/mu.php' ); 418 419 if ( 'mark-spammer' == $bp->current_action ) 420 $is_spam = 1; 421 else 422 $is_spam = 0; 423 424 /* Get the blogs for the user */ 425 $blogs = get_blogs_of_user( $bp->displayed_user->id, true ); 426 427 foreach ( (array) $blogs as $key => $details ) { 428 /* Do not mark the main or current root blog as spam */ 429 if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id ) 430 continue; 431 432 /* Update the blog status */ 433 update_blog_status( $details->userblog_id, 'spam', $is_spam ); 434 435 /* Fire the standard WPMU hook */ 436 do_action( 'make_spam_blog', $details->userblog_id ); 437 } 438 439 /* Finally, mark this user as a spammer */ 440 update_user_status( $bp->displayed_user->id, 'spam', $is_spam, 1 ); 441 442 if ( $is_spam ) 443 bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) ); 444 else 445 bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) ); 446 447 do_action( 'bp_core_action_set_spammer_status' ); 448 449 bp_core_redirect( wp_get_referer() ); 450 } 451 } 452 add_action( 'wp', 'bp_core_action_set_spammer_status', 3 ); 453 454 /** 455 * bp_core_action_delete_user() 456 * 457 * Allows a site admin to delete a user from the adminbar menu. 458 * 459 * @package BuddyPress Core 460 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 461 */ 462 function bp_core_action_delete_user() { 463 global $bp; 464 465 if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id ) 466 return false; 467 468 if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) { 469 $errors = false; 470 471 if ( bp_core_delete_account( $bp->displayed_user->id ) ) { 472 bp_core_add_message( sprintf( __( '%s has been deleted from the system.', 'buddypress' ), $bp->displayed_user->fullname ) ); 473 } else { 474 bp_core_add_message( sprintf( __( 'There was an error deleting %s from the system. Please try again.', 'buddypress' ), $bp->displayed_user->fullname ), 'error' ); 475 $errors = true; 476 } 477 478 do_action( 'bp_core_action_set_spammer_status', $errors ); 479 480 if ( $errors ) 481 bp_core_redirect( $bp->displayed_user->domain ); 482 else 483 bp_core_redirect( $bp->loggedin_user->domain ); 484 } 485 } 486 add_action( 'wp', 'bp_core_action_delete_user', 3 ); 487 488 489 /******************************************************************************** 490 * Business Functions 491 * 492 * Business functions are where all the magic happens in BuddyPress. They will 493 * handle the actual saving or manipulation of information. Usually they will 494 * hand off to a database class for data access, then return 495 * true or false on success or failure. 496 */ 379 497 380 498 /** … … 957 1075 } 958 1076 1077 /** 1078 * bp_core_is_user_spammer() 1079 * 1080 * Checks if the user has been marked as a spammer. 1081 * 1082 * @package BuddyPress Core 1083 * @param $user_id int The id for the user. 1084 * @return int 1 if spammer, 0 if not. 1085 */ 1086 function bp_core_is_user_spammer( $user_id ) { 1087 global $wpdb; 1088 1089 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 ) ) ); 1090 } 1091 1092 /** 1093 * bp_core_is_user_deleted() 1094 * 1095 * Checks if the user has been marked as deleted. 1096 * 1097 * @package BuddyPress Core 1098 * @param $user_id int The id for the user. 1099 * @return int 1 if deleted, 0 if not. 1100 */ 1101 function bp_core_is_user_deleted( $user_id ) { 1102 global $wpdb; 1103 1104 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 ) ) ); 1105 } 959 1106 960 1107 /** … … 1329 1476 * @uses wpmu_delete_user() Deletes a user from the system. 1330 1477 */ 1331 function bp_core_delete_account() { 1332 global $bp; 1478 function bp_core_delete_account( $user_id = false ) { 1479 global $bp; 1480 1481 if ( !$user_id ) 1482 $user_id = $bp->loggedin_user->id; 1333 1483 1334 1484 /* Make sure account deletion is not disabled */ 1335 if ( 1 == (int)get_site_option( 'bp-disable-account-deletion') )1336 return false; 1337 1338 /* Site admins should not be allowed to delete their accounts*/1339 if ( is_site_admin( ) )1485 if ( ( 1 == (int)get_site_option( 'bp-disable-account-deletion' ) && !is_site_admin() ) ) 1486 return false; 1487 1488 /* Site admins should not be allowed to be deleted */ 1489 if ( is_site_admin( bp_core_get_username( $user_id ) ) ) 1340 1490 return false; 1341 1491 … … 1343 1493 require_once( ABSPATH . '/wp-admin/includes/user.php' ); 1344 1494 1345 return wpmu_delete_user( $ bp->loggedin_user->id);1495 return wpmu_delete_user( $user_id ); 1346 1496 } 1347 1497 … … 1515 1665 add_action( 'wpmu_delete_user', 'bp_core_remove_data', 1 ); 1516 1666 add_action( 'delete_user', 'bp_core_remove_data', 1 ); 1517 1667 add_action( 'make_spam_user', 'bp_core_remove_data', 1 ); 1518 1668 1519 1669 /** -
trunk/bp-core/bp-core-catchuri.php
r1741 r1801 130 130 } 131 131 } 132 133 132 134 133 if ( !isset($is_root_component) ) 135 134 $is_root_component = in_array( $bp_uri[0], $bp->root_components ); … … 241 240 if ( $bp_no_status_set ) 242 241 return false; 243 242 243 /* If this user has been marked as a spammer and the logged in user is not a site admin, redirect. */ 244 if ( isset( $bp->displayed_user->id ) && bp_core_is_user_spammer( $bp->displayed_user->id ) ) { 245 if ( !is_site_admin() ) 246 bp_core_redirect( $bp->root_domain ); 247 else 248 bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'error' ); 249 } 250 244 251 // If this user does not exist, redirect to the root domain. 245 252 if ( !$bp->displayed_user->id && $bp_unfiltered_uri[0] == BP_MEMBERS_SLUG && isset($bp_unfiltered_uri[1]) ) -
trunk/bp-core/bp-core-classes.php
r1636 r1801 242 242 like_escape($search_terms); 243 243 244 $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 );245 $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 );244 $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 ); 245 $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 ); 246 246 247 247 $total_users = $wpdb->get_var( $total_users_sql ); -
trunk/bp-friends.php
r1793 r1801 704 704 add_action( 'wpmu_delete_user', 'friends_remove_data', 1 ); 705 705 add_action( 'delete_user', 'friends_remove_data', 1 ); 706 add_action( 'make_spam_user', 'friends_remove_data', 1 ); 706 707 707 708 function friends_clear_friend_object_cache( $friendship_id ) { -
trunk/bp-groups.php
r1790 r1801 2566 2566 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user', 1 ); 2567 2567 add_action( 'delete_user', 'groups_remove_data_for_user', 1 ); 2568 add_action( 'make_spam_user', 'groups_remove_data_for_user', 1 ); 2568 2569 2569 2570 function groups_clear_group_object_cache( $group_id ) { -
trunk/bp-xprofile.php
r1799 r1801 225 225 add_action( 'admin_menu', 'xprofile_setup_nav', 2 ); 226 226 227 228 /** 229 * xprofile_setup_adminbar_menu() 230 * 231 * Adds an admin bar menu to any profile page providing site admin options for that user. 232 * 233 * @package BuddyPress XProfile 234 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 235 */ 236 function xprofile_setup_adminbar_menu() { 237 global $bp; 238 239 if ( !$bp->displayed_user->id ) 240 return false; 241 242 /* Don't show this menu to non site admins or if you're viewing your own profile */ 243 if ( !is_site_admin() || bp_is_home() ) 244 return false; 245 ?> 246 <li id="bp-adminbar-adminoptions-menu"> 247 <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a> 248 249 <ul> 250 <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> 251 <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> 252 253 <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?> 254 <li><a href="<?php echo $bp->displayed_user->domain ?>admin/mark-spammer/" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li> 255 <?php else : ?> 256 <li><a href="<?php echo $bp->displayed_user->domain ?>admin/unmark-spammer/" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li> 257 <?php endif; ?> 258 259 <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> 260 261 <?php do_action( 'xprofile_adminbar_menu_items' ) ?> 262 </ul> 263 </li> 264 <?php 265 } 266 add_action( 'bp_adminbar_menus', 'xprofile_setup_adminbar_menu', 20 ); 227 267 228 268 /******************************************************************************** -
trunk/bp-xprofile/bp-xprofile-templatetags.php
r1781 r1801 565 565 566 566 if ( $groups[$i]->fields ) 567 echo '<li' . $selected . '><a href="' . $bp-> loggedin_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . $groups[$i]->name . '</a></li>';567 echo '<li' . $selected . '><a href="' . $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . $groups[$i]->name . '</a></li>'; 568 568 } 569 569 … … 655 655 global $bp; 656 656 657 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' ) );657 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' ) ); 658 658 } 659 659
Note: See TracChangeset
for help on using the changeset viewer.