Changeset 7374 for trunk/bp-friends/bp-friends-classes.php
- Timestamp:
- 09/07/2013 01:02:33 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-friends/bp-friends-classes.php
r7308 r7374 183 183 } 184 184 185 public static function check_is_friend( $loggedin_userid, $possible_friend_userid ) { 186 global $wpdb, $bp; 187 188 if ( empty( $loggedin_userid ) || empty( $possible_friend_userid ) ) 189 return false; 190 191 $result = $wpdb->get_results( $wpdb->prepare( "SELECT id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id = %d) OR (initiator_user_id = %d AND friend_user_id = %d)", $loggedin_userid, $possible_friend_userid, $possible_friend_userid, $loggedin_userid ) ); 192 193 if ( !empty( $result ) ) { 185 /** 186 * Check friendship status between two users 187 * 188 * Note that 'pending' means that $initiator_userid has sent a friend 189 * request to $possible_friend_userid that has not yet been approved, 190 * while 'awaiting_response' is the other way around ($possible_friend_userid 191 * sent the initial request) 192 * 193 * @param int $initiator_userid The id of the user who is the initiator 194 * of the potential friendship/request. 195 * @param int $possible_friend_userid The id of the user who is the 196 * recipient of the potential friendship/request. 197 * @return string The friendship status, from among 'not_friends', 198 * 'is_friend', 'pending', and 'awaiting_response' 199 */ 200 public static function check_is_friend( $initiator_userid, $possible_friend_userid ) { 201 global $wpdb, $bp; 202 203 if ( empty( $initiator_userid ) || empty( $possible_friend_userid ) ) { 204 return false; 205 } 206 207 $result = $wpdb->get_results( $wpdb->prepare( "SELECT id, initiator_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id = %d) OR (initiator_user_id = %d AND friend_user_id = %d)", $initiator_userid, $possible_friend_userid, $possible_friend_userid, $initiator_userid ) ); 208 209 if ( ! empty( $result ) ) { 194 210 if ( 0 == (int) $result[0]->is_confirmed ) { 195 return 'pending';211 $status = $initiator_userid == $result[0]->initiator_user_id ? 'pending' : 'awaiting_response'; 196 212 } else { 197 return'is_friend';213 $status = 'is_friend'; 198 214 } 199 215 } else { 200 return 'not_friends'; 201 } 216 $status = 'not_friends'; 217 } 218 219 return $status; 202 220 } 203 221
Note: See TracChangeset
for help on using the changeset viewer.