diff --git src/bp-templates/bp-legacy/buddypress-functions.php src/bp-templates/bp-legacy/buddypress-functions.php
index 98f7901..bb53fdd 100644
|
|
function bp_legacy_theme_ajax_invite_user() { |
1026 | 1026 | if ( BP_Groups_Member::check_for_membership_request( $friend_id, $group_id ) ) { |
1027 | 1027 | $user_status = 'is_pending'; |
1028 | 1028 | |
| 1029 | // Check if the user was invited by someone else |
| 1030 | } else if ( BP_Groups_Member::check_has_invite( $friend_id, $group_id, false ) ) { |
| 1031 | $user_status = 'has_invite'; |
| 1032 | |
1029 | 1033 | // Create the user invitation |
1030 | 1034 | } else if ( groups_invite_user( array( 'user_id' => $friend_id, 'group_id' => $group_id ) ) ) { |
1031 | 1035 | $user_status = 'is_invited'; |
… |
… |
function bp_legacy_theme_ajax_invite_user() { |
1039 | 1043 | |
1040 | 1044 | $uninvite_url = bp_is_current_action( 'create' ) ? bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/group-invites/?user_id=' . $friend_id : bp_get_group_permalink( $group ) . 'send-invites/remove/' . $friend_id; |
1041 | 1045 | |
1042 | | echo '<li id="uid-' . $user->id . '">'; |
1043 | | echo $user->avatar_thumb; |
1044 | | echo '<h4>' . $user->user_link . '</h4>'; |
1045 | | echo '<span class="activity">' . esc_attr( $user->last_active ) . '</span>'; |
1046 | | echo '<div class="action"> |
1047 | | <a class="button remove" href="' . wp_nonce_url( $uninvite_url, 'groups_invite_uninvite_user' ) . '" id="uid-' . esc_attr( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a> |
1048 | | </div>'; |
| 1046 | if ( empty( $_POST['is_new_template'] ) ) { |
| 1047 | echo '<li id="uid-' . $user->id . '">'; |
| 1048 | echo $user->avatar_thumb; |
| 1049 | echo '<h4>' . $user->user_link . '</h4>'; |
| 1050 | echo '<span class="activity">' . esc_attr( $user->last_active ) . '</span>'; |
| 1051 | echo '<div class="action"> |
| 1052 | <a class="button remove" href="' . wp_nonce_url( $uninvite_url, 'groups_invite_uninvite_user' ) . '" id="uid-' . esc_attr( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a> |
| 1053 | </div>'; |
| 1054 | |
| 1055 | if ( 'is_pending' == $user_status ) { |
| 1056 | echo '<p class="description">' . sprintf( __( '%s has previously requested to join this group. Sending an invitation will automatically add the member to the group.', 'buddypress' ), $user->user_link ) . '</p>'; |
| 1057 | } |
1049 | 1058 | |
1050 | | if ( 'is_pending' == $user_status ) { |
1051 | | echo '<p class="description">' . sprintf( __( '%s has previously requested to join this group. Sending an invitation will automatically add the member to the group.', 'buddypress' ), $user->user_link ) . '</p>'; |
| 1059 | echo '</li>'; |
| 1060 | } else { |
| 1061 | if ( 'is_pending' == $user_status ) { |
| 1062 | echo '-1<p>' . sprintf( __( '%s has previously requested to join this group. Request is awaiting approval by a group admin.', 'buddypress' ), $user->fullname ) .'</p>'; |
| 1063 | } else if ( 'has_invite' == $user_status ) { |
| 1064 | echo '-1<p>' . sprintf( __( '%s has already been invited to join this group by another member.', 'buddypress' ), $user->fullname ) .'</p>'; |
| 1065 | } else { |
| 1066 | echo 1; |
| 1067 | } |
1052 | 1068 | } |
1053 | 1069 | |
1054 | | echo '</li>'; |
1055 | 1070 | exit; |
1056 | 1071 | |
1057 | 1072 | } elseif ( 'uninvite' == $_POST['friend_action'] ) { |
diff --git src/bp-templates/bp-legacy/js/buddypress.js src/bp-templates/bp-legacy/js/buddypress.js
index 5f19a6d..a29fcfc 100644
|
|
jq(document).ready( function() { |
1018 | 1018 | // We use the existence of this div to check for old- vs new- |
1019 | 1019 | // style templates. |
1020 | 1020 | var invites_new_template = jq( '#send-invite-form > .invite' ).length, |
1021 | | friend_id, friend_action; |
| 1021 | friend_id, friend_action, ajaxdata = {}, input = jq( this ); |
1022 | 1022 | |
1023 | 1023 | jq('.ajax-loader').toggle(); |
1024 | 1024 | |
1025 | 1025 | // Dim the form until the response arrives |
1026 | 1026 | if ( invites_new_template ) { |
1027 | | jq( this ).parents( 'ul' ).find( 'input' ).prop( 'disabled', true ); |
| 1027 | input.parents( 'ul' ).find( 'input' ).prop( 'disabled', true ); |
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | friend_id = jq(this).val(); |
… |
… |
jq(document).ready( function() { |
1035 | 1035 | friend_action = 'uninvite'; |
1036 | 1036 | } |
1037 | 1037 | |
| 1038 | ajaxdata = { |
| 1039 | action: 'groups_invite_user', |
| 1040 | 'friend_action' : friend_action, |
| 1041 | 'cookie' : bp_get_cookies(), |
| 1042 | '_wpnonce' : jq('#_wpnonce_invite_uninvite_user').val(), |
| 1043 | 'friend_id' : friend_id, |
| 1044 | 'group_id' : jq('#group_id').val(), |
| 1045 | 'is_new_template' : 1, |
| 1046 | }; |
| 1047 | |
1038 | 1048 | if ( ! invites_new_template ) { |
1039 | 1049 | jq( '.item-list-tabs li.selected' ).addClass( 'loading' ); |
| 1050 | ajaxdata.is_new_template = 0; |
1040 | 1051 | } |
1041 | 1052 | |
1042 | | jq.post( ajaxurl, { |
1043 | | action: 'groups_invite_user', |
1044 | | 'friend_action': friend_action, |
1045 | | 'cookie': bp_get_cookies(), |
1046 | | '_wpnonce': jq('#_wpnonce_invite_uninvite_user').val(), |
1047 | | 'friend_id': friend_id, |
1048 | | 'group_id': jq('#group_id').val() |
1049 | | }, |
| 1053 | jq.post( ajaxurl, ajaxdata, |
1050 | 1054 | function(response) |
1051 | 1055 | { |
1052 | 1056 | if ( jq('#message') ) { |
… |
… |
jq(document).ready( function() { |
1054 | 1058 | } |
1055 | 1059 | |
1056 | 1060 | if ( invites_new_template ) { |
| 1061 | // Check for specific cases |
| 1062 | if ( response[0] + response[1] === '-1' ) { |
| 1063 | |
| 1064 | if ( ! jq('.invite .main-column #message').length ) { |
| 1065 | jq('.invite .main-column').prepend( '<div id="message">' + response.substr( 2, response.length ) + '</div>' ); |
| 1066 | } else { |
| 1067 | jq('.invite .main-column #message').html( response.substr( 2, response.length ) ); |
| 1068 | jq('#message').show(); |
| 1069 | } |
| 1070 | |
| 1071 | // Enable the checkboxes |
| 1072 | input.parents( 'ul' ).find( 'input' ).prop( 'disabled', false ); |
| 1073 | |
| 1074 | // Uncheck to avoid another user's invite to be removed |
| 1075 | input.prop( 'checked', false ); |
| 1076 | |
| 1077 | // Stop the process |
| 1078 | return; |
| 1079 | } |
1057 | 1080 | // With new-style templates, we refresh the |
1058 | 1081 | // entire list |
1059 | 1082 | bp_filter_request( 'invite', 'bp-invite-filter', 'bp-invite-scope', 'div.invite', false, 1, '', '', '' ); |