Changeset 1517
- Timestamp:
- 06/05/2009 07:19:37 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/bp-friends.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-friends.php
r1507 r1517 180 180 } 181 181 add_action( 'bp_notification_settings', 'friends_screen_notification_settings' ); 182 183 184 /***** Actions **********/ 185 186 function friends_action_add_friend() { 187 global $bp; 188 189 if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'add-friend' ) 190 return false; 191 192 $potential_friend_id = $bp->action_variables[0]; 193 194 if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) ) 195 return false; 196 197 if ( $potential_friend_id == $bp->loggedin_user->id ) 198 return false; 199 200 $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id ); 201 202 if ( 'not_friends' == $friendship_status ) { 203 204 if ( !check_admin_referer( 'friends_add_friend' ) ) 205 return false; 206 207 if ( !friends_add_friend( $bp->loggedin_user->id, $potential_friend_id ) ) { 208 bp_core_add_message( __( 'Friendship could not be requested.', 'buddypress' ), 'error' ); 209 } else { 210 bp_core_add_message( __( 'Friendship requested', 'buddypress' ) ); 211 } 212 } else if ( 'is_friend' == $friendship_status ) { 213 bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' ); 214 } else { 215 bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' ); 216 } 217 218 bp_core_redirect( $_SERVER['HTTP_REFERER'] ); 219 220 return false; 221 } 222 add_action( 'init', 'friends_action_add_friend' ); 223 224 function friends_action_remove_friend() { 225 global $bp; 226 227 if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'remove-friend' ) 228 return false; 229 230 $potential_friend_id = $bp->action_variables[0]; 231 232 if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) ) 233 return false; 234 235 if ( $potential_friend_id == $bp->loggedin_user->id ) 236 return false; 237 238 $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id ); 239 240 if ( 'is_friend' == $friendship_status ) { 241 242 if ( !check_admin_referer( 'friends_remove_friend' ) ) 243 return false; 244 245 if ( !friends_remove_friend( $bp->loggedin_user->id, $potential_friend_id ) ) { 246 bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' ); 247 } else { 248 bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) ); 249 } 250 } else if ( 'is_friends' == $friendship_status ) { 251 bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' ); 252 } else { 253 bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' ); 254 } 255 256 bp_core_redirect( $_SERVER['HTTP_REFERER'] ); 257 258 return false; 259 } 260 add_action( 'init', 'friends_action_remove_friend' ); 182 261 183 262
Note: See TracChangeset
for help on using the changeset viewer.