Skip to:
Content

BuddyPress.org

Changeset 2556


Ignore:
Timestamp:
02/03/2010 10:44:26 AM (14 years ago)
Author:
apeatling
Message:

Fixes #1777

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r2548 r2556  
    22572257    do_action( 'groups_ban_member', $user_id, $group_id );
    22582258
    2259     return $member->ban();
     2259    if ( !$member->ban() )
     2260        return false;
     2261
     2262    update_usermeta( $user_id, 'total_group_count', (int)$total_count - 1 );
    22602263}
    22612264
  • trunk/bp-groups/bp-groups-classes.php

    r2550 r2556  
    121121        global $wpdb, $bp;
    122122
    123         // Delete groupmeta for the group
     123        /* Delete groupmeta for the group */
    124124        groups_delete_groupmeta( $this->id );
    125125
    126         // Modify group count usermeta for members
    127         for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
    128             $user = $this->user_dataset[$i];
    129 
    130             $total_count = get_usermeta( $user->user_id, 'total_group_count' );
    131 
    132             if ( $total_count != '' ) {
    133                 update_usermeta( $user->user_id, 'total_group_count', (int)$total_count - 1 );
    134             }
    135 
    136             // Now delete the group member record
    137             BP_Groups_Member::delete( $user->user_id, $this->id, false );
    138         }
     126        /* Fetch the user IDs of all the members of the group */
     127        $user_ids = BP_Groups_Member::get_group_member_ids( $this->id );
     128        $user_ids = implode( ',', (array)$user_ids );
     129
     130        /* Modify group count usermeta for members */
     131        $wpdb->query( $wpdb->prepare( "UPDATE {$bp->groups->table_name_groupmeta} SET meta_value = meta_value - 1 WHERE meta_key = 'total_group_count' AND user_id IN ( {$user_ids} )" ) );
     132
     133        /* Now delete all group member entries */
     134        BP_Groups_Member::delete_all( $this->id );
    139135
    140136        do_action( 'bp_groups_delete_group', $this );
     
    724720        groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) );
    725721
     722        $group_count = get_usermeta( $this->user_id, 'total_group_count' );
     723        if ( !empty( $group_count ) )
     724            update_usermeta( $this->user_id, 'total_group_count', (int)$group_count - 1 );
     725
    726726        return $this->save();
    727727    }
     
    734734
    735735        groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) );
     736        update_usermeta( $this->user_id, 'total_group_count', (int)get_usermeta( $this->user_id, 'total_group_count' ) + 1 );
    736737
    737738        return $this->save();
     
    936937            return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
    937938        }
     939    }
     940
     941    function get_group_member_ids( $group_id ) {
     942        global $bp, $wpdb;
     943
     944        return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) );
    938945    }
    939946
     
    9961003
    9971004        return array( 'members' => $members, 'count' => $total_member_count );
     1005    }
     1006
     1007    function delete_all( $group_id ) {
     1008        global $wpdb, $bp;
     1009
     1010        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
    9981011    }
    9991012
  • trunk/bp-groups/bp-groups-notifications.php

    r2537 r2556  
    77    $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' );
    88
    9     foreach ( $group->user_dataset as $user ) {
    10         if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_group_updated' ) ) continue;
    11 
    12         $ud = bp_core_get_core_userdata( $user->user_id );
     9    $user_ids = BP_Groups_Member::get_group_member_ids( $this->id );
     10    foreach ( $user_ids as $user_id ) {
     11        if ( 'no' == get_usermeta( $user_id, 'notification_groups_group_updated' ) ) continue;
     12
     13        $ud = bp_core_get_core_userdata( $user_id );
    1314
    1415        // Set up and send the message
     
    1617
    1718        $group_link = site_url( $bp->groups->slug . '/' . $group->slug );
    18         $settings_link = bp_core_get_user_domain( $user->user_id ) . 'settings/notifications/';
     19        $settings_link = bp_core_get_user_domain( $user_id ) . 'settings/notifications/';
    1920
    2021        $message = sprintf( __(
Note: See TracChangeset for help on using the changeset viewer.