Skip to:
Content

BuddyPress.org

Ticket #5574: 5574.patch

File 5574.patch, 2.0 KB (added by imath, 11 years ago)
  • bp-core/admin/bp-core-tools.php

    diff --git bp-core/admin/bp-core-tools.php bp-core/admin/bp-core-tools.php
    index 5f2f320..35345fa 100644
    function bp_admin_repair_list() { 
    132132                );
    133133        }
    134134
     135        // Signups:
     136        // provide a way to clean the signups table
     137        if ( ! is_multisite() && ( ! defined( 'BP_SIGNUPS_SKIP_USER_CREATION' ) || ! BP_SIGNUPS_SKIP_USER_CREATION ) ) {
     138                $repair_list[30] = array(
     139                        'bp-signups',
     140                        __( 'Signups table', 'buddypress' ),
     141                        'bp_admin_repair_signups_table',
     142                );
     143        }
     144
    135145        ksort( $repair_list );
    136146
    137147        return (array) apply_filters( 'bp_repair_list', $repair_list );
    function bp_admin_repair_last_activity() { 
    264274}
    265275
    266276/**
     277 * Repair signups table on non multisite configs
     278 *
     279 * If a signup is active = 0 and the user status is not 2, delete the signup
     280 *
     281 * @since  BuddyPress (2.0.1)
     282 */
     283function bp_admin_repair_signups_table() {
     284        global $wpdb;
     285
     286        if ( is_multisite() )
     287                return;
     288
     289        $statement = __( 'Reparing the signups table %s', 'buddypress' );
     290        $result    = __( 'Failed!', 'buddypress' );
     291
     292        $signups_table  = buddypress()->members->table_name_signups;
     293        $sql['select'] = "DELETE FROM {$signups_table}";
     294        $sql['where']   = array();
     295        $sql['where'][]  = "active = 0";
     296
     297        $pending_users = $wpdb->get_col( "SELECT user_login FROM {$wpdb->users} WHERE user_status = '2'" );
     298
     299        if ( ! empty( $pending_users ) ) {
     300                $not_in = '"' . implode( '","', array_map( 'esc_sql', $pending_users ) ) .'"';
     301                $sql['where'][]  = "user_login NOT IN ({$not_in})";
     302        }
     303
     304        // Implode WHERE clauses
     305        $sql['where'] = 'WHERE ' . implode( ' AND ', $sql['where'] );
     306
     307        $sql_delete = join( ' ', $sql );
     308
     309        if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) {
     310                return array( 1, sprintf( $statement, $result ) );
     311        } else {
     312                return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
     313        }
     314}
     315
     316/**
    267317 * Assemble admin notices relating success/failure of repair processes.
    268318 *
    269319 * @since BuddyPress (2.0.0)