Changeset 2976
- Timestamp:
- 04/29/2010 09:11:02 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.2/bp-friends/bp-friends-classes.php
r2362 r2976 127 127 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d OR friend_user_id = %d) AND is_confirmed = 1", $user_id, $user_id ) ); 128 128 129 if ( !$count ) 129 // Do not update meta if user has never had friends 130 if ( !$count && !get_usermeta( $user_id, 'total_friend_count' ) ) 130 131 return 0; 131 132 132 update_usermeta( $user_id, 'total_friend_count', $count );133 return $count;133 update_usermeta( $user_id, 'total_friend_count', (int)$count ); 134 return (int)$count; 134 135 } 135 136 … … 315 316 global $wpdb, $bp; 316 317 318 // Delete all friendships related to $user_id 317 319 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) ); 318 320 319 321 // Delete friend request notifications for members who have a notification from this user. 320 322 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id ) ); 323 324 // Get friends of $user_id and update their respective friend counts 325 $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id ); 326 foreach ( (array)$friend_ids as $friend_id ) 327 BP_Friends_Friendship::total_friend_count( $friend_id ); 328 321 329 } 322 330 }
Note: See TracChangeset
for help on using the changeset viewer.