Skip to:
Content

BuddyPress.org

Ticket #7794: 7794.groupInvites.feedback.patch

File 7794.groupInvites.feedback.patch, 11.1 KB (added by imath, 7 years ago)
  • src/bp-templates/bp-nouveau/buddypress/common/js-templates/invites/index.php

    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
     
    2525
    2626</div>
    2727
     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
    2835<script type="text/html" id="tmpl-bp-invites-nav">
    2936        <a href="{{data.href}}" class="bp-invites-nav-item" data-nav="{{data.id}}">{{data.name}}</a>
    3037</script>
  • src/bp-templates/bp-nouveau/includes/groups/ajax.php

    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() { 
    253253        $bp = buddypress();
    254254
    255255        $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' ),
    257257                'type'     => 'error',
    258258        );
    259259
    function bp_nouveau_ajax_get_users_to_invite() { 
    281281        ) );
    282282
    283283        $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' );
    285285
    286286        if ( 'friends' === $request['scope'] ) {
    287287                $request['user_id'] = bp_loggedin_user_id();
    288288                $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' );
    290290        }
    291291
    292292        if ( 'invited' === $request['scope'] ) {
    293293
    294294                if ( ! bp_group_has_invites( array( 'user_id' => 'any' ) ) ) {
    295295                        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' ),
    297297                                'type'     => 'info',
    298298                        ) );
    299299                }
    300300
    301301                $request['is_confirmed'] = false;
    302302                $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' );
    304304        }
    305305
    306306        $potential_invites = bp_nouveau_get_group_potential_invites( $request );
    307307
    308308        if ( empty( $potential_invites->users ) ) {
    309309                $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' ),
    311311                        'type'     => 'info',
    312312                );
    313313
    314314                if ( 'friends' === $bp->groups->invites_scope ) {
    315315                        $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' ),
    317317                                'type'     => 'info',
    318318                        );
    319319
    320320                        if ( 0 === (int) bp_get_total_friend_count( bp_loggedin_user_id() ) ) {
    321321                                $error = array(
    322                                         'feedback' => bp_nouveau_message_markup_wrapper( __( 'You have no friends!', 'buddypress' ), 'info' ),
     322                                        'feedback' => __( 'You have no friends!', 'buddypress' ),
    323323                                        'type'     => 'info',
    324324                                );
    325325                        }
    function bp_nouveau_ajax_send_group_invites() { 
    348348        $bp = buddypress();
    349349
    350350        $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',
    352353        );
    353354
    354355        // Verify nonce
    355356        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 );
    362358        }
    363359
    364360        $group_id = bp_get_current_group_id();
    function bp_nouveau_ajax_send_group_invites() { 
    368364        }
    369365
    370366        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 );
    377369        }
    378370
    379371        if ( empty( $_POST['users'] ) ) {
    function bp_nouveau_ajax_send_group_invites() { 
    415407
    416408                wp_send_json_error(
    417409                        array(
    418                                 'feedback' => bp_nouveau_message_markup_wrapper( esc_html( $error_message ), 'error' ),
     410                                'feedback' => $error_message,
    419411                                'users'    => $errors,
    420412                                'type'     => 'error',
    421413                        )
    function bp_nouveau_ajax_send_group_invites() { 
    424416
    425417        wp_send_json_success(
    426418                array(
    427                         'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invites sent.', 'buddypress' ), 'success' ),
     419                        'feedback' => __( 'Invites sent.', 'buddypress' ),
     420                        'type'     => 'success',
    428421                )
    429422        );
    430423}
    function bp_nouveau_ajax_remove_group_invite() { 
    440433        if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'groups_invite_uninvite_user' ) ) {
    441434                wp_send_json_error(
    442435                        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',
    444438                        )
    445439                );
    446440        }
    function bp_nouveau_ajax_remove_group_invite() { 
    448442        if ( BP_Groups_Member::check_for_membership_request( $user_id, $group_id ) ) {
    449443                wp_send_json_error(
    450444                        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',
    452447                                'code'     => 1,
    453448                        )
    454449                );
    function bp_nouveau_ajax_remove_group_invite() { 
    458453        if ( ! groups_uninvite_user( $user_id, $group_id ) ) {
    459454                wp_send_json_error(
    460455                        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',
    462458                                'code'     => 0,
    463459                        )
    464460                );
    function bp_nouveau_ajax_remove_group_invite() { 
    466462
    467463        wp_send_json_success(
    468464                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',
    470467                        'has_invites' => bp_group_has_invites( array( 'user_id' => 'any' ) ),
    471468                )
    472469        );
  • src/bp-templates/bp-nouveau/includes/groups/functions.php

    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() ) { 
    127127
    128128        $params['group_invites'] = array(
    129129                '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' ),
    134134                'group_id'           => ! bp_get_current_group_id() ? bp_get_new_group_id() : bp_get_current_group_id(),
    135135                'is_group_create'    => bp_is_group_create(),
    136136                'nonces'             => array(
  • src/bp-templates/bp-nouveau/js/buddypress-group-invites.js

    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 || {}; 
    338338        bp.Views.Feedback = bp.Nouveau.GroupInvites.View.extend( {
    339339                tagName   : 'div',
    340340                className : 'bp-invites-feedback',
     341                template  : bp.template( 'bp-group-invites-feedback' ),
    341342
    342343                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                        } );
    353348                }
    354349        } );
    355350
    window.bp = window.bp || {}; 
    709704
    710705                        $( this.el ).addClass( 'bp-hide' );
    711706
     707                        bp.Nouveau.GroupInvites.displayFeedback( BP_Nouveau.group_invites.invites_sending, 'info' );
     708
    712709                        this.collection.sync( 'create', _.pluck( this.collection.models, 'id' ), {
    713710                                success : _.bind( this.invitesSent, this ),
    714711                                error   : _.bind( this.invitesError, this ),
    window.bp = window.bp || {}; 
    762759                                view.remove();
    763760                        } );
    764761
    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' );
    766763                }
    767764        } );
    768765