Changeset 6100
- Timestamp:
- 06/14/2012 08:12:59 PM (12 years ago)
- Location:
- trunk/bp-groups
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-cache.php
r6093 r6100 50 50 add_action( 'groups_create_group_step_complete', 'groups_clear_group_object_cache' ); 51 51 52 /** 53 * Clears caches for the group creator when a group is created 54 * 55 * @param int $group_id 56 * @param BP_Groups_Group $group_obj 57 * @since BuddyPress (1.6) 58 */ 59 function bp_groups_clear_group_creator_cache( $group_id, $group_obj ) { 60 // Clears the 'total groups' for this user 61 groups_clear_group_user_object_cache( $group_obj->id, $group_obj->creator_id ); 62 } 63 add_action( 'groups_created_group', 'bp_groups_clear_group_creator_cache', 10, 2 ); 64 65 /** 66 * Clears caches for all members in a group when a group is deleted 67 * 68 * @param BP_Groups_Group $group_obj 69 * @param array User IDs who were in this group 70 * @since BuddyPress (1.6) 71 */ 72 function bp_groups_clear_group_members_caches( $group_obj, $user_ids ) { 73 // Clears the 'total groups' cache for each member in a group 74 foreach ( (array) $user_ids as $user_id ) 75 groups_clear_group_user_object_cache( $group_obj->id, $user_id ); 76 } 77 add_action( 'bp_groups_delete_group', 'bp_groups_clear_group_members_caches', 10, 2 ); 78 52 79 function groups_clear_group_user_object_cache( $group_id, $user_id ) { 53 wp_cache_delete( 'bp_total_groups_for_user_' . $user_id );80 wp_cache_delete( 'bp_total_groups_for_user_' . $user_id, 'bp' ); 54 81 } 55 82 add_action( 'groups_join_group', 'groups_clear_group_user_object_cache', 10, 2 ); -
trunk/bp-groups/bp-groups-classes.php
r5999 r6100 173 173 174 174 // Fetch the user IDs of all the members of the group 175 $user_ids = BP_Groups_Member::get_group_member_ids( $this->id );176 $user_id s= implode( ',', (array) $user_ids );175 $user_ids = BP_Groups_Member::get_group_member_ids( $this->id ); 176 $user_id_str = implode( ',', (array) $user_ids ); 177 177 178 178 // Modify group count usermeta for members 179 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->usermeta} SET meta_value = meta_value - 1 WHERE meta_key = 'total_group_count' AND user_id IN ( {$user_id s} )" ) );179 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->usermeta} SET meta_value = meta_value - 1 WHERE meta_key = 'total_group_count' AND user_id IN ( {$user_id_str} )" ) ); 180 180 181 181 // Now delete all group member entries 182 182 BP_Groups_Member::delete_all( $this->id ); 183 183 184 do_action_ref_array( 'bp_groups_delete_group', array( &$this ) );184 do_action_ref_array( 'bp_groups_delete_group', array( &$this, $user_ids ) ); 185 185 186 186 wp_cache_delete( 'bp_groups_group_' . $this->id, 'bp' ); -
trunk/bp-groups/bp-groups-functions.php
r6093 r6100 130 130 } 131 131 132 do_action( 'groups_created_group', $group->id );132 do_action( 'groups_created_group', $group->id, $group ); 133 133 134 134 return $group->id;
Note: See TracChangeset
for help on using the changeset viewer.