Ticket #3897: bp-cancel-friendship-request.patch
File bp-cancel-friendship-request.patch, 6.5 KB (added by , 13 years ago) |
---|
-
bp-friends/bp-friends-classes.php
### Eclipse Workspace Patch 1.0 #P BuddyPress-trunk
207 207 return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = %s WHERE id = %d AND friend_user_id = %d", bp_core_current_time(), $friendship_id, bp_loggedin_user_id() ) ); 208 208 } 209 209 210 public static function withdraw($friendship_id) { 211 global $wpdb, $bp; 212 213 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND initiator_user_id = %d", $friendship_id, bp_loggedin_user_id() ) ); 214 } 215 210 216 public static function reject($friendship_id) { 211 217 global $wpdb, $bp; 212 218 -
bp-friends/bp-friends-functions.php
139 139 return false; 140 140 } 141 141 142 function friends_withdraw_friendship( $initiator_userid, $friend_userid ) { 143 global $bp; 144 145 $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid ); 146 $friendship = new BP_Friends_Friendship( $friendship_id, true, false ); 147 148 if ( !$friendship->is_confirmed && BP_Friends_Friendship::withdraw( $friendship_id ) ) { 149 // Remove the friend request notice 150 bp_core_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' ); 151 152 do_action_ref_array( 'friends_friendship_whithdrawn', array( $friendship_id, &$friendship ) ); 153 return true; 154 } 155 156 return false; 157 } 158 142 159 function friends_check_friendship( $user_id, $possible_friend_id ) { 143 160 144 161 if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) ) -
bp-themes/bp-default/_inc/ajax.php
477 477 if ( !friends_add_friend( bp_loggedin_user_id(), $_POST['fid'] ) ) { 478 478 echo __("Friendship could not be requested.", 'buddypress'); 479 479 } else { 480 echo '<a href="' . bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests" class="requested">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';480 echo '<a id="friend-' . $_POST['fid'] . '" class="remove" rel="remove" title="' . __( 'Cancel Friendship Request', 'buddypress' ) . '" href="' . wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/cancel/' . (int)$_POST['fid'] . '/', 'friends_withdraw_friendship' ) . '" class="requested">' . __( 'Cancel Friendship Request', 'buddypress' ) . '</a>'; 481 481 } 482 } else if( 'pending' == BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), (int)$_POST['fid'] ) ) { 483 484 check_ajax_referer('friends_withdraw_friendship'); 485 486 if ( friends_withdraw_friendship( bp_loggedin_user_id(), (int)$_POST['fid'] ) ) { 487 echo '<a id="friend-' . $_POST['fid'] . '" class="add" rel="add" title="' . __( 'Add Friend', 'buddypress' ) . '" href="' . wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/add-friend/' . $_POST['fid'], 'friends_add_friend' ) . '">' . __( 'Add Friend', 'buddypress' ) . '</a>'; 488 } else { 489 echo __("Friendship request could not be cancelled.", 'buddypress'); 490 } 482 491 } else { 483 492 echo __( 'Request Pending', 'buddypress' ); 484 493 } -
bp-themes/bp-default/_inc/global.js
917 917 function() { 918 918 parentdiv.removeClass('add_friend'); 919 919 parentdiv.removeClass('loading'); 920 parentdiv.addClass('pending ');920 parentdiv.addClass('pending_friend'); 921 921 parentdiv.fadeIn(200).html(response); 922 922 } 923 923 ); -
bp-friends/bp-friends-screens.php
47 47 bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' ); 48 48 49 49 bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) ); 50 51 } elseif ( bp_is_action_variable( 'cancel', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) { 52 // Check the nonce 53 check_admin_referer( 'friends_withdraw_friendship' ); 54 55 if ( friends_withdraw_friendship( bp_loggedin_user_id(), bp_action_variable( 1 ) ) ) 56 bp_core_add_message( __( 'Friendship request withdrawn', 'buddypress' ) ); 57 else 58 bp_core_add_message( __( 'Friendship request could not be withdrawn', 'buddypress' ), 'error' ); 59 60 bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) ); 50 61 } 51 62 52 63 do_action( 'friends_screen_requests' ); -
bp-friends/bp-friends-template.php
318 318 'component' => 'friends', 319 319 'must_be_logged_in' => true, 320 320 'block_self' => true, 321 'wrapper_class' => 'friendship-button pending ',321 'wrapper_class' => 'friendship-button pending_friend', 322 322 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 323 'link_href' => trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests' ), 324 'link_text' => __( 'Friendship Requested', 'buddypress' ), 325 'link_title' => __( 'Friendship Requested', 'buddypress' ), 326 'link_class' => 'friendship-button pending requested' 323 'link_href' => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/cancel/' . $potential_friend_id . '/', 'friends_withdraw_friendship' ), 324 'link_text' => __( 'Cancel Friendship Request', 'buddypress' ), 325 'link_title' => __( 'Cancel Friendship Requested', 'buddypress' ), 326 'link_id' => 'friend-' . $potential_friend_id, 327 'link_rel' => 'remove', 328 'link_class' => 'friendship-button pending_friend requested' 327 329 ); 328 330 break; 329 331