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 79aa13acd..589601520 100644
|
|
|
|
| 25 | 25 | |
| 26 | 26 | </div> |
| 27 | 27 | |
| | 28 | <script type="text/html" id="tmpl-bp-group-invites-feedback"> |
| | 29 | <div class="bp-feedback {{data.type}}"> |
| | 30 | <span class="bp-icon" aria-hidden="true"></span> |
| | 31 | <p>{{{data.message}}}</p> |
| | 32 | </div> |
| | 33 | </script> |
| | 34 | |
| 28 | 35 | <script type="text/html" id="tmpl-bp-invites-nav"> |
| 29 | 36 | <a href="{{data.href}}" class="bp-invites-nav-item" data-nav="{{data.id}}">{{data.name}}</a> |
| 30 | 37 | </script> |
diff --git src/bp-templates/bp-nouveau/includes/groups/ajax.php src/bp-templates/bp-nouveau/includes/groups/ajax.php
index d0c25f5b5..3e3f904fa 100644
|
|
|
function bp_nouveau_ajax_get_users_to_invite() { |
| 253 | 253 | $bp = buddypress(); |
| 254 | 254 | |
| 255 | 255 | $response = array( |
| 256 | | 'feedback' => bp_nouveau_message_markup_wrapper( esc_html__( 'There was a problem performing this action. Please try again.', 'buddypress' ), 'error' ), |
| | 256 | 'feedback' => __( 'There was a problem performing this action. Please try again.', 'buddypress' ), |
| 257 | 257 | 'type' => 'error', |
| 258 | 258 | ); |
| 259 | 259 | |
| … |
… |
function bp_nouveau_ajax_get_users_to_invite() { |
| 281 | 281 | ) ); |
| 282 | 282 | |
| 283 | 283 | $bp->groups->invites_scope = 'members'; |
| 284 | | $message = bp_nouveau_message_markup_wrapper( __( 'Select members to invite by clicking the + button. Once you\'ve made your selection, use the "Send Invites" nav item to continue.', 'buddypress' ), 'info' ); |
| | 284 | $message = __( 'Select members to invite by clicking the + button. Once you\'ve made your selection, use the "Send Invites" nav item to continue.', 'buddypress' ); |
| 285 | 285 | |
| 286 | 286 | if ( 'friends' === $request['scope'] ) { |
| 287 | 287 | $request['user_id'] = bp_loggedin_user_id(); |
| 288 | 288 | $bp->groups->invites_scope = 'friends'; |
| 289 | | $message = bp_nouveau_message_markup_wrapper( __( 'Select friends to invite by clicking the + button. Once you\'ve made your selection, use the "Send Invites" nav item to continue.', 'buddypress' ), 'info' ); |
| | 289 | $message = __( 'Select friends to invite by clicking the + button. Once you\'ve made your selection, use the "Send Invites" nav item to continue.', 'buddypress' ); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | if ( 'invited' === $request['scope'] ) { |
| 293 | 293 | |
| 294 | 294 | if ( ! bp_group_has_invites( array( 'user_id' => 'any' ) ) ) { |
| 295 | 295 | wp_send_json_error( array( |
| 296 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'No pending invites found.', 'buddypress' ), 'info' ), |
| | 296 | 'feedback' => __( 'No pending invites found.', 'buddypress' ), |
| 297 | 297 | 'type' => 'info', |
| 298 | 298 | ) ); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | $request['is_confirmed'] = false; |
| 302 | 302 | $bp->groups->invites_scope = 'invited'; |
| 303 | | $message = bp_nouveau_message_markup_wrapper( __( 'You can view all the group\'s pending invites from this screen.', 'buddypress' ), 'info' ); |
| | 303 | $message = __( 'You can view all the group\'s pending invites from this screen.', 'buddypress' ); |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $potential_invites = bp_nouveau_get_group_potential_invites( $request ); |
| 307 | 307 | |
| 308 | 308 | if ( empty( $potential_invites->users ) ) { |
| 309 | 309 | $error = array( |
| 310 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'No members were found. Try another filter.', 'buddypress' ), 'info' ), |
| | 310 | 'feedback' => __( 'No members were found. Try another filter.', 'buddypress' ), |
| 311 | 311 | 'type' => 'info', |
| 312 | 312 | ); |
| 313 | 313 | |
| 314 | 314 | if ( 'friends' === $bp->groups->invites_scope ) { |
| 315 | 315 | $error = array( |
| 316 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'All your friends are already members of this group, or have already received an invite to join this group, or have requested to join it.', 'buddypress' ), 'info' ), |
| | 316 | 'feedback' => __( 'All your friends are already members of this group, or have already received an invite to join this group, or have requested to join it.', 'buddypress' ), |
| 317 | 317 | 'type' => 'info', |
| 318 | 318 | ); |
| 319 | 319 | |
| 320 | 320 | if ( 0 === (int) bp_get_total_friend_count( bp_loggedin_user_id() ) ) { |
| 321 | 321 | $error = array( |
| 322 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'You have no friends!', 'buddypress' ), 'info' ), |
| | 322 | 'feedback' => __( 'You have no friends!', 'buddypress' ), |
| 323 | 323 | 'type' => 'info', |
| 324 | 324 | ); |
| 325 | 325 | } |
| … |
… |
function bp_nouveau_ajax_send_group_invites() { |
| 348 | 348 | $bp = buddypress(); |
| 349 | 349 | |
| 350 | 350 | $response = array( |
| 351 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invites could not be sent. Please try again.', 'buddypress' ), 'error' ), |
| | 351 | 'feedback' => __( 'Invites could not be sent. Please try again.', 'buddypress' ), |
| | 352 | 'type' => 'error', |
| 352 | 353 | ); |
| 353 | 354 | |
| 354 | 355 | // Verify nonce |
| 355 | 356 | if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'groups_send_invites' ) ) { |
| 356 | | wp_send_json_error( |
| 357 | | array( |
| 358 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invites could not be sent. Please try again.', 'buddypress' ), 'error' ), |
| 359 | | 'type' => 'error', |
| 360 | | ) |
| 361 | | ); |
| | 357 | wp_send_json_error( $response ); |
| 362 | 358 | } |
| 363 | 359 | |
| 364 | 360 | $group_id = bp_get_current_group_id(); |
| … |
… |
function bp_nouveau_ajax_send_group_invites() { |
| 368 | 364 | } |
| 369 | 365 | |
| 370 | 366 | if ( ! bp_groups_user_can_send_invites( $group_id ) ) { |
| 371 | | wp_send_json_error( |
| 372 | | array( |
| 373 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'You are not allowed to send invites for this group.', 'buddypress' ), 'error' ), |
| 374 | | 'type' => 'error', |
| 375 | | ) |
| 376 | | ); |
| | 367 | $response['feedback'] = __( 'You are not allowed to send invites for this group.', 'buddypress' ); |
| | 368 | wp_send_json_error( $response ); |
| 377 | 369 | } |
| 378 | 370 | |
| 379 | 371 | if ( empty( $_POST['users'] ) ) { |
| … |
… |
function bp_nouveau_ajax_send_group_invites() { |
| 415 | 407 | |
| 416 | 408 | wp_send_json_error( |
| 417 | 409 | array( |
| 418 | | 'feedback' => bp_nouveau_message_markup_wrapper( esc_html( $error_message ), 'error' ), |
| | 410 | 'feedback' => $error_message, |
| 419 | 411 | 'users' => $errors, |
| 420 | 412 | 'type' => 'error', |
| 421 | 413 | ) |
| … |
… |
function bp_nouveau_ajax_send_group_invites() { |
| 424 | 416 | |
| 425 | 417 | wp_send_json_success( |
| 426 | 418 | array( |
| 427 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invites sent.', 'buddypress' ), 'success' ), |
| | 419 | 'feedback' => __( 'Invites sent.', 'buddypress' ), |
| | 420 | 'type' => 'success', |
| 428 | 421 | ) |
| 429 | 422 | ); |
| 430 | 423 | } |
| … |
… |
function bp_nouveau_ajax_remove_group_invite() { |
| 440 | 433 | if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'groups_invite_uninvite_user' ) ) { |
| 441 | 434 | wp_send_json_error( |
| 442 | 435 | array( |
| 443 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invites could not be removed. Please try again.', 'buddypress' ), 'error' ), |
| | 436 | 'feedback' => __( 'Invites could not be removed. Please try again.', 'buddypress' ), |
| | 437 | 'type' => 'error', |
| 444 | 438 | ) |
| 445 | 439 | ); |
| 446 | 440 | } |
| … |
… |
function bp_nouveau_ajax_remove_group_invite() { |
| 448 | 442 | if ( BP_Groups_Member::check_for_membership_request( $user_id, $group_id ) ) { |
| 449 | 443 | wp_send_json_error( |
| 450 | 444 | array( |
| 451 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'Too late! The user is already a member of the group.', 'buddypress' ), 'warning' ), |
| | 445 | 'feedback' => __( 'Too late! The user is already a member of the group.', 'buddypress' ), |
| | 446 | 'type' => 'warning', |
| 452 | 447 | 'code' => 1, |
| 453 | 448 | ) |
| 454 | 449 | ); |
| … |
… |
function bp_nouveau_ajax_remove_group_invite() { |
| 458 | 453 | if ( ! groups_uninvite_user( $user_id, $group_id ) ) { |
| 459 | 454 | wp_send_json_error( |
| 460 | 455 | array( |
| 461 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invite could not be removed successfully.', 'buddypress' ), 'error' ), |
| | 456 | 'feedback' => __( 'Invite could not be removed successfully.', 'buddypress' ), |
| | 457 | 'type' => 'error', |
| 462 | 458 | 'code' => 0, |
| 463 | 459 | ) |
| 464 | 460 | ); |
| … |
… |
function bp_nouveau_ajax_remove_group_invite() { |
| 466 | 462 | |
| 467 | 463 | wp_send_json_success( |
| 468 | 464 | array( |
| 469 | | 'feedback' => bp_nouveau_message_markup_wrapper( __( 'No more pending invites for the group.', 'buddypress' ), 'info' ), |
| | 465 | 'feedback' => __( 'No more pending invites for the group.', 'buddypress' ), |
| | 466 | 'type' => 'info', |
| 470 | 467 | 'has_invites' => bp_group_has_invites( array( 'user_id' => 'any' ) ), |
| 471 | 468 | ) |
| 472 | 469 | ); |
diff --git src/bp-templates/bp-nouveau/includes/groups/functions.php src/bp-templates/bp-nouveau/includes/groups/functions.php
index 6fc4fa23a..3dcac6def 100644
|
|
|
function bp_nouveau_groups_localize_scripts( $params = array() ) { |
| 127 | 127 | |
| 128 | 128 | $params['group_invites'] = array( |
| 129 | 129 | 'nav' => bp_sort_by_key( $invites_nav, 'order', 'num' ), |
| 130 | | 'loading' => bp_nouveau_message_markup_wrapper( __( 'Loading members. Please wait.', 'buddypress' ), 'loading' ), |
| 131 | | 'invites_form' => bp_nouveau_message_markup_wrapper( __( 'Use the "Send" button to send your invite or the "Cancel" button to abort.', 'buddypress' ), 'info' ), |
| 132 | | 'invites_form_reset' => bp_nouveau_message_markup_wrapper( __( 'Invites cleared. Please use one of the available tabs to select members to invite.', 'buddypress' ), 'success' ), |
| 133 | | 'invites_sending' => bp_nouveau_message_markup_wrapper( __( 'Sending the invites. Please wait.', 'buddypress' ), 'loading' ), |
| | 130 | 'loading' => __( 'Loading members. Please wait.', 'buddypress' ), |
| | 131 | 'invites_form' => __( 'Use the "Send" button to send your invite or the "Cancel" button to abort.', 'buddypress' ), |
| | 132 | 'invites_form_reset' => __( 'Invites cleared. Please use one of the available tabs to select members to invite.', 'buddypress' ), |
| | 133 | 'invites_sending' => __( 'Sending the invites. Please wait.', 'buddypress' ), |
| 134 | 134 | 'group_id' => ! bp_get_current_group_id() ? bp_get_new_group_id() : bp_get_current_group_id(), |
| 135 | 135 | 'is_group_create' => bp_is_group_create(), |
| 136 | 136 | 'nonces' => array( |
diff --git src/bp-templates/bp-nouveau/js/buddypress-group-invites.js src/bp-templates/bp-nouveau/js/buddypress-group-invites.js
index f78050d45..b0d103b5f 100644
|
|
|
window.bp = window.bp || {}; |
| 338 | 338 | bp.Views.Feedback = bp.Nouveau.GroupInvites.View.extend( { |
| 339 | 339 | tagName : 'div', |
| 340 | 340 | className : 'bp-invites-feedback', |
| | 341 | template : bp.template( 'bp-group-invites-feedback' ), |
| 341 | 342 | |
| 342 | 343 | initialize: function() { |
| 343 | | this.value = this.options.value; |
| 344 | | |
| 345 | | if ( this.options.type ) { |
| 346 | | this.el.className += ' ' + this.options.type; |
| 347 | | } |
| 348 | | }, |
| 349 | | |
| 350 | | render: function() { |
| 351 | | this.$el.html( this.value ); |
| 352 | | return this; |
| | 344 | this.model = new Backbone.Model( { |
| | 345 | type: this.options.type || 'info', |
| | 346 | message: this.options.value, |
| | 347 | } ); |
| 353 | 348 | } |
| 354 | 349 | } ); |
| 355 | 350 | |
| … |
… |
window.bp = window.bp || {}; |
| 709 | 704 | |
| 710 | 705 | $( this.el ).addClass( 'bp-hide' ); |
| 711 | 706 | |
| | 707 | bp.Nouveau.GroupInvites.displayFeedback( BP_Nouveau.group_invites.invites_sending, 'info' ); |
| | 708 | |
| 712 | 709 | this.collection.sync( 'create', _.pluck( this.collection.models, 'id' ), { |
| 713 | 710 | success : _.bind( this.invitesSent, this ), |
| 714 | 711 | error : _.bind( this.invitesError, this ), |
| … |
… |
window.bp = window.bp || {}; |
| 762 | 759 | view.remove(); |
| 763 | 760 | } ); |
| 764 | 761 | |
| 765 | | bp.Nouveau.GroupInvites.displayFeedback( BP_Nouveau.group_invites.invites_form_reset, 'help' ); |
| | 762 | bp.Nouveau.GroupInvites.displayFeedback( BP_Nouveau.group_invites.invites_form_reset, 'success' ); |
| 766 | 763 | } |
| 767 | 764 | } ); |
| 768 | 765 | |