Changeset 2372
- Timestamp:
- 01/19/2010 09:26:59 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-friends/bp-friends-templatetags.php
r2332 r2372 161 161 } 162 162 163 function bp_friend_accept_request_link() { 164 echo bp_get_friend_accept_request_link(); 165 } 166 // You only have the user ID but you need the friendship ID !! 167 168 function bp_get_friend_accept_request_link() { 163 function bp_friend_friendship_id() { 164 echo bp_get_friend_friendship_id(); 165 } 166 function bp_get_friend_friendship_id() { 169 167 global $members_template, $bp; 170 168 … … 174 172 } 175 173 176 return apply_filters( 'bp_get_friend_ accept_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ));177 } 178 179 function bp_friend_ reject_request_link() {180 echo bp_get_friend_ reject_request_link();181 } 182 function bp_get_friend_ reject_request_link() {174 return apply_filters( 'bp_get_friend_friendship_id', $friendship_id ); 175 } 176 177 function bp_friend_accept_request_link() { 178 echo bp_get_friend_accept_request_link(); 179 } 180 function bp_get_friend_accept_request_link() { 183 181 global $members_template, $bp; 184 182 … … 188 186 } 189 187 188 return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ) ); 189 } 190 191 function bp_friend_reject_request_link() { 192 echo bp_get_friend_reject_request_link(); 193 } 194 function bp_get_friend_reject_request_link() { 195 global $members_template, $bp; 196 197 if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . $bp->loggedin_user->id ) ) { 198 $friendship_id = friends_get_friendship_id( $members_template->member->id, $bp->loggedin_user->id ); 199 wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . $bp->loggedin_user->id, $friendship_id, 'bp' ); 200 } 201 190 202 return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friendship_id, 'friends_reject_friendship' ) ); 191 203 } -
trunk/bp-themes/bp-default/_inc/ajax.php
r2371 r2372 353 353 add_action( 'wp_ajax_addremove_friend', 'bp_dtheme_ajax_addremove_friend' ); 354 354 355 function bp_dtheme_ajax_accept_friendship() { 356 check_admin_referer( 'friends_accept_friendship' ); 357 358 if ( !friends_accept_friendship( $_POST['id'] ) ) 359 echo "-1<div id='message' class='error'><p>" . __( 'There was a problem accepting that request. Please try again.', 'buddypress' ) . '</p></div>'; 360 361 return true; 362 } 363 add_action( 'wp_ajax_accept_friendship', 'bp_dtheme_ajax_accept_friendship' ); 364 365 function bp_dtheme_ajax_reject_friendship() { 366 check_admin_referer( 'friends_reject_friendship' ); 367 368 if ( !friends_reject_friendship( $_POST['id'] ) ) 369 echo "-1<div id='message' class='error'><p>" . __( 'There was a problem rejecting that request. Please try again.', 'buddypress' ) . '</p></div>'; 370 371 return true; 372 } 373 add_action( 'wp_ajax_reject_friendship', 'bp_dtheme_ajax_reject_friendship' ); 374 355 375 function bp_dtheme_ajax_joinleave_group() { 356 376 global $bp; -
trunk/bp-themes/bp-default/_inc/global.js
r2370 r2372 768 768 }); 769 769 770 /** Friendship Request Buttons **************************************/ 770 /** Friendship Requests **************************************/ 771 772 j("ul#friend-list a.accept, ul#friend-list a.reject").click( function() { 773 var button = j(this); 774 var li = j(this).parents('ul#friend-list li'); 775 var action_div = j(this).parents('li div.action'); 776 777 var id = li.attr('id').substr( 11, li.attr('id').length ); 778 var link_href = button.attr('href'); 779 780 var nonce = link_href.split('_wpnonce='); 781 nonce = nonce[1]; 782 783 if ( j(this).hasClass('accept') ) { 784 var action = 'accept_friendship'; 785 action_div.children('a.reject').css( 'visibility', 'hidden' ); 786 } else { 787 var action = 'reject_friendship'; 788 action_div.children('a.accept').css( 'visibility', 'hidden' ); 789 } 790 791 button.addClass('loading'); 792 793 j.post( ajaxurl, { 794 action: action, 795 'cookie': encodeURIComponent(document.cookie), 796 'id': id, 797 '_wpnonce': nonce 798 }, 799 function(response) { 800 button.removeClass('loading'); 801 802 if ( response[0] + response[1] == '-1' ) { 803 li.prepend( response.substr( 2, response.length ) ); 804 li.children('div#message').hide().fadeIn(200); 805 } else { 806 button.fadeOut( 100, function() { 807 if ( j(this).hasClass('accept') ) 808 j(this).html( 'Accepted' ).fadeIn(50); 809 else 810 j(this).html( 'Rejected' ).fadeIn(50); 811 }); 812 } 813 }); 814 815 return false; 816 }); 771 817 772 818 j("div.friendship-button a").live('click', function() { -
trunk/bp-themes/bp-default/members/single/friends/requests.php
r2284 r2372 6 6 <?php while ( bp_members() ) : bp_the_member(); ?> 7 7 8 <li >8 <li id="friendship-<?php bp_friend_friendship_id() ?>"> 9 9 <div class="item-avatar"> 10 10 <a href="<?php bp_member_link() ?>"><?php bp_member_avatar() ?></a> … … 20 20 <div class="action"> 21 21 <a class="button accept" href="<?php bp_friend_accept_request_link() ?>"><?php _e( 'Accept', 'buddypress' ); ?></a> 22 <a class="button reject confirm" href="<?php bp_friend_reject_request_link() ?>"><?php _e( 'Reject', 'buddypress' ); ?></a>22 <a class="button reject" href="<?php bp_friend_reject_request_link() ?>"><?php _e( 'Reject', 'buddypress' ); ?></a> 23 23 24 24 <?php do_action( 'bp_friend_requests_item_action' ) ?>
Note: See TracChangeset
for help on using the changeset viewer.