Changeset 2556 for trunk/bp-groups/bp-groups-classes.php
- Timestamp:
- 02/03/2010 10:44:26 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-classes.php
r2550 r2556 121 121 global $wpdb, $bp; 122 122 123 / / Delete groupmeta for the group123 /* Delete groupmeta for the group */ 124 124 groups_delete_groupmeta( $this->id ); 125 125 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 ); 139 135 140 136 do_action( 'bp_groups_delete_group', $this ); … … 724 720 groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) ); 725 721 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 726 726 return $this->save(); 727 727 } … … 734 734 735 735 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 ); 736 737 737 738 return $this->save(); … … 936 937 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 ) ); 937 938 } 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 ) ); 938 945 } 939 946 … … 996 1003 997 1004 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 ) ); 998 1011 } 999 1012
Note: See TracChangeset
for help on using the changeset viewer.