diff --git src/bp-templates/bp-nouveau/buddypress/common/js-templates/invites/index.php src/bp-templates/bp-nouveau/buddypress/common/js-templates/invites/index.php
index b99183c59..ae21663b0 100644
|
|
|
6 | 6 | * dealing with invites. |
7 | 7 | * |
8 | 8 | * @since 3.0.0 |
9 | | * @version 6.0.0 |
| 9 | * @version 10.0.0 |
10 | 10 | */ |
11 | 11 | ?> |
12 | 12 | |
… |
… |
|
57 | 57 | {{data.name}} |
58 | 58 | </div> |
59 | 59 | |
60 | | <# if ( undefined !== data.is_sent ) { #> |
| 60 | <# if ( 'invited' === data.scope ) { #> |
61 | 61 | <div class="item-meta"> |
62 | 62 | |
63 | | <# if ( undefined !== data.invited_by ) { #> |
| 63 | <# if ( data.invited_by.length > 0 ) { #> |
64 | 64 | <ul class="group-inviters"> |
65 | 65 | <li><?php esc_html_e( 'Invited by:', 'buddypress' ); ?></li> |
66 | 66 | <# for ( i in data.invited_by ) { #> |
… |
… |
|
82 | 82 | </div> |
83 | 83 | |
84 | 84 | <div class="action"> |
85 | | <# if ( undefined === data.is_sent || ( false === data.is_sent && true === data.can_edit ) ) { #> |
| 85 | <# if ( true === data.can_invite ) { #> |
86 | 86 | <button type="button" class="button invite-button group-add-remove-invite-button bp-tooltip bp-icons<# if ( data.selected ) { #> selected<# } #>" data-bp-tooltip="<# if ( data.selected ) { #><?php esc_attr_e( 'Cancel invitation', 'buddypress' ); ?><# } else { #><?php echo esc_attr_x( 'Invite', 'button', 'buddypress' ); ?><# } #>"> |
87 | 87 | <span class="icons" aria-hidden="true"></span> |
88 | 88 | <span class="bp-screen-reader-text"> |
… |
… |
|
95 | 95 | </button> |
96 | 96 | <# } #> |
97 | 97 | |
98 | | <# if ( undefined !== data.can_edit && true === data.can_edit ) { #> |
| 98 | <# if ( true === data.can_edit ) { #> |
99 | 99 | <button type="button" class="button invite-button group-remove-invite-button bp-tooltip bp-icons" data-bp-tooltip="<?php echo esc_attr_x( 'Cancel invitation', 'button', 'buddypress' ); ?>"> |
100 | 100 | <span class=" icons" aria-hidden="true"></span> |
101 | 101 | <span class="bp-screen-reader-text"><?php echo esc_attr_x( 'Cancel invitation', 'button', 'buddypress' ); ?></span> |
diff --git src/bp-templates/bp-nouveau/includes/groups/ajax.php src/bp-templates/bp-nouveau/includes/groups/ajax.php
index a6cedb82c..6f98a618c 100644
|
|
function bp_nouveau_ajax_get_users_to_invite() { |
283 | 283 | wp_send_json_error( $response ); |
284 | 284 | } |
285 | 285 | |
| 286 | if ( ! bp_is_group_create() && ! bp_groups_user_can_send_invites( bp_get_current_group_id(), bp_loggedin_user_id() ) ) { |
| 287 | $invite_status = bp_group_get_invite_status( bp_get_current_group_id() ); |
| 288 | if ( 'admins' === $invite_status ) { |
| 289 | $message = __( 'Inviting members to join this group is restricted to Group Administrators.', 'buddypress' ); |
| 290 | } else { |
| 291 | $message = __( 'Inviting members to join this group is restricted to Group Moderators and Administrators.', 'buddypress' ); |
| 292 | } |
| 293 | |
| 294 | wp_send_json_error( |
| 295 | array( |
| 296 | 'feedback' => $message, |
| 297 | 'type' => 'error', |
| 298 | ) |
| 299 | ); |
| 300 | } |
| 301 | |
286 | 302 | $request = bp_parse_args( |
287 | 303 | $_POST, |
288 | 304 | array( |
diff --git src/bp-templates/bp-nouveau/includes/groups/functions.php src/bp-templates/bp-nouveau/includes/groups/functions.php
index f87d873af..9f765d247 100644
|
|
function bp_nouveau_groups_get_inviter_ids( $user_id, $group_id ) { |
199 | 199 | * @since 3.0.0 |
200 | 200 | */ |
201 | 201 | function bp_nouveau_prepare_group_potential_invites_for_js( $user ) { |
202 | | $bp = buddypress(); |
| 202 | $bp = buddypress(); |
| 203 | $scope = ''; |
| 204 | if ( isset( $bp->groups->invites_scope ) ) { |
| 205 | $scope = $bp->groups->invites_scope; |
| 206 | } |
203 | 207 | |
204 | 208 | $response = array( |
205 | | 'id' => intval( $user->ID ), |
206 | | 'name' => $user->display_name, |
207 | | 'avatar' => htmlspecialchars_decode( bp_core_fetch_avatar( array( |
208 | | 'item_id' => $user->ID, |
209 | | 'object' => 'user', |
210 | | 'type' => 'thumb', |
211 | | 'width' => 50, |
212 | | 'height' => 50, |
213 | | 'html' => false ) |
214 | | ) ), |
| 209 | 'id' => intval( $user->ID ), |
| 210 | 'name' => $user->display_name, |
| 211 | 'avatar' => htmlspecialchars_decode( |
| 212 | bp_core_fetch_avatar( |
| 213 | array( |
| 214 | 'item_id' => $user->ID, |
| 215 | 'object' => 'user', |
| 216 | 'type' => 'thumb', |
| 217 | 'width' => 50, |
| 218 | 'height' => 50, |
| 219 | 'html' => false |
| 220 | ) |
| 221 | ) |
| 222 | ), |
| 223 | 'scope' => $scope, |
| 224 | 'is_sent' => false, |
| 225 | 'invited_by' => array(), |
| 226 | 'can_invite' => 'invited' !== $scope, |
215 | 227 | ); |
216 | 228 | |
217 | 229 | // Do extra queries only if needed |
218 | | if ( ! empty( $bp->groups->invites_scope ) && 'invited' === $bp->groups->invites_scope ) { |
219 | | $response['is_sent'] = (bool) groups_check_user_has_invite( $user->ID, bp_get_current_group_id() ); |
220 | | |
221 | | $inviter_ids = bp_nouveau_groups_get_inviter_ids( $user->ID, bp_get_current_group_id() ); |
| 230 | if ( 'invited' === $scope ) { |
| 231 | $response['is_sent'] = (bool) groups_check_user_has_invite( $user->ID, bp_get_current_group_id() ); |
| 232 | $inviter_ids = bp_nouveau_groups_get_inviter_ids( $user->ID, bp_get_current_group_id() ); |
222 | 233 | |
223 | 234 | foreach ( $inviter_ids as $inviter_id ) { |
224 | 235 | $class = false; |
… |
… |
function bp_nouveau_prepare_group_potential_invites_for_js( $user ) { |
228 | 239 | } |
229 | 240 | |
230 | 241 | $response['invited_by'][] = array( |
231 | | 'avatar' => htmlspecialchars_decode( bp_core_fetch_avatar( array( |
232 | | 'item_id' => $inviter_id, |
233 | | 'object' => 'user', |
234 | | 'type' => 'thumb', |
235 | | 'width' => 50, |
236 | | 'height' => 50, |
237 | | 'html' => false, |
238 | | 'class' => $class, |
239 | | ) ) ), |
| 242 | 'avatar' => htmlspecialchars_decode( |
| 243 | bp_core_fetch_avatar( |
| 244 | array( |
| 245 | 'item_id' => $inviter_id, |
| 246 | 'object' => 'user', |
| 247 | 'type' => 'thumb', |
| 248 | 'width' => 50, |
| 249 | 'height' => 50, |
| 250 | 'html' => false, |
| 251 | 'class' => $class, |
| 252 | ) |
| 253 | ) |
| 254 | ), |
240 | 255 | 'user_link' => bp_core_get_userlink( $inviter_id, false, true ), |
241 | 256 | 'user_name' => bp_core_get_username( $inviter_id ), |
242 | 257 | ); |
243 | 258 | } |
244 | 259 | |
245 | | if ( bp_is_item_admin() ) { |
246 | | $response['can_edit'] = true; |
247 | | } else { |
248 | | $response['can_edit'] = in_array( bp_loggedin_user_id(), $inviter_ids, true ); |
249 | | } |
| 260 | $response['can_edit'] = bp_is_item_admin() || in_array( bp_loggedin_user_id(), $inviter_ids, true ); |
250 | 261 | } |
251 | 262 | |
252 | 263 | /** |