Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/23/2012 06:18:39 AM (12 years ago)
Author:
johnjamesjacoby
Message:

First pass at adding user capabilities screen and action to settings component:

  • Add capabilities template
  • Unhook core spammer and deleted user actions and move to settings
  • Route admin bar links appropriately to new locations
  • Allow delete-account to be accessed by super admins in place of broken alerts
  • Improve general settings feedback
  • @todo - backpat post mortem
  • See #4038
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-members/bp-members-functions.php

    r5803 r5829  
    489489 * Processes a spammed or unspammed user
    490490 *
    491  * This function is called in two ways:
    492  *  - in bp_core_action_set_spammer_status() (when spamming from the front-end)
    493  *  - by bp_core_mark_user_spam_admin() or bp_core_mark_user_ham_admin() (when spamming from the
    494  *    Dashboard)
    495  *
    496  * @since 1.6
     491 * This function is called in three ways:
     492 *  - in bp_settings_action_capabilities() (from the front-end)
     493 *  - by bp_core_mark_user_spam_admin()    (from wp-admin)
     494 *  - bp_core_mark_user_ham_admin()        (from wp-admin)
     495 *
     496 * @since BuddyPress (1.6)
    497497 *
    498498 * @param int $user_id The user being spammed/hammed
     
    519519    }
    520520
    521     $is_spam = 'spam' == $status;
     521    $is_spam = ( 'spam' == $status );
    522522
    523523    // Only you can prevent infinite loops
    524524    remove_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' );
    525     remove_action( 'make_ham_user', 'bp_core_mark_user_ham_admin' );
     525    remove_action( 'make_ham_user',  'bp_core_mark_user_ham_admin' );
    526526
    527527    // When marking as spam in the Dashboard, these actions are handled by WordPress
    528528    if ( !is_admin() ) {
     529
    529530        // Get the blogs for the user
    530531        $blogs = get_blogs_of_user( $user_id, true );
     
    551552        // Call multisite actions in single site mode for good measure
    552553        if ( !is_multisite() ) {
    553             $wp_action = $is_spam ? 'make_spam_user' : 'make_ham_user';
     554            $wp_action = ( true === $is_spam ) ? 'make_spam_user' : 'make_ham_user';
    554555            do_action( $wp_action, bp_displayed_user_id() );
    555556        }
     
    557558
    558559    // Hide this user's activity
    559     if ( $is_spam && bp_is_active( 'activity' ) ) {
     560    if ( ( true === $is_spam ) && bp_is_active( 'activity' ) ) {
    560561        bp_activity_hide_user_activity( $user_id );
    561562    }
    562563
    563564    // We need a special hook for is_spam so that components can delete data at spam time
    564     $bp_action = $is_spam ? 'bp_make_spam_user' : 'bp_make_ham_user';
     565    $bp_action = ( true === $is_spam ) ? 'bp_make_spam_user' : 'bp_make_ham_user';
    565566    do_action( $bp_action, $user_id );
    566567
     
    574575 * Hook to WP's make_spam_user and run our custom BP spam functions
    575576 *
    576  * @since 1.6
     577 * @since BuddyPress (1.6)
    577578 *
    578579 * @param int $user_id The user id passed from the make_spam_user hook
     
    586587 * Hook to WP's make_ham_user and run our custom BP spam functions
    587588 *
    588  * @since 1.6
     589 * @since BuddyPress (1.6)
    589590 *
    590591 * @param int $user_id The user id passed from the make_ham_user hook
     
    751752 *
    752753 * @package BuddyPress Core
    753  * @global object $bp Global BuddyPress settings object
    754  * @uses bp_current_user_can() Checks to see if the user is a site administrator.
    755754 * @uses wpmu_delete_user() Deletes a user from the system on multisite installs.
    756755 * @uses wp_delete_user() Deletes a user from the system on singlesite installs.
    757756 */
    758757function bp_core_delete_account( $user_id = 0 ) {
    759     global $bp, $wp_version;
    760 
    761     if ( !$user_id )
     758
     759    if ( empty( $user_id ) )
    762760        $user_id = bp_loggedin_user_id();
    763761
    764762    // Make sure account deletion is not disabled
    765     if ( !empty( $bp->site_options['bp-disable-account-deletion'] ) && !bp_current_user_can( 'bp_moderate' ) )
     763    if ( bp_disable_account_deletion() )
    766764        return false;
    767765
     
    772770    // Specifically handle multi-site environment
    773771    if ( is_multisite() ) {
    774         if ( $wp_version >= '3.0' )
    775             require( ABSPATH . '/wp-admin/includes/ms.php' );
    776         else
    777             require( ABSPATH . '/wp-admin/includes/mu.php' );
    778 
     772        require( ABSPATH . '/wp-admin/includes/ms.php'   );
    779773        require( ABSPATH . '/wp-admin/includes/user.php' );
    780774
Note: See TracChangeset for help on using the changeset viewer.