Skip to:
Content

BuddyPress.org

Changeset 8093


Ignore:
Timestamp:
03/09/2014 07:18:31 PM (10 years ago)
Author:
boonebgorges
Message:

Remove Invite noscript support for group invitations screens

Fixes #5281

Props imath

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-actions.php

    r7788 r8093  
    123123        }
    124124
    125         if ( 'group-invites' == bp_get_groups_current_create_step() )
     125        if ( 'group-invites' === bp_get_groups_current_create_step() ) {
     126            if ( ! empty( $_POST['friends'] ) ) {
     127                foreach ( (array) $_POST['friends'] as $friend ) {
     128                    groups_invite_user( array(
     129                        'user_id'  => $friend,
     130                        'group_id' => $bp->groups->new_group_id,
     131                    ) );
     132                }
     133            }
     134
    126135            groups_send_invites( bp_loggedin_user_id(), $bp->groups->new_group_id );
     136        }
    127137
    128138        do_action( 'groups_create_group_step_save_' . bp_get_groups_current_create_step() );
     
    180190    }
    181191
     192    // Remove invitations
     193    if ( 'group-invites' === bp_get_groups_current_create_step() && ! empty( $_REQUEST['user_id'] ) && is_numeric( $_REQUEST['user_id'] ) ) {
     194        if ( ! check_admin_referer( 'groups_invite_uninvite_user' ) ) {
     195            return false;
     196        }
     197
     198        $message = __( 'Invite successfully removed', 'buddypress' );
     199        $error   = false;
     200
     201        if( ! groups_uninvite_user( (int) $_REQUEST['user_id'], $bp->groups->new_group_id ) ) {
     202            $message = __( 'There was an error removing the invite', 'buddypress' );
     203            $error   = 'error';
     204        }
     205
     206        bp_core_add_message( $message, $error );
     207        bp_core_redirect( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/group-invites/' );
     208    }
     209
    182210    // Group avatar is handled separately
    183211    if ( 'group-avatar' == bp_get_groups_current_create_step() && isset( $_POST['upload'] ) ) {
  • trunk/bp-groups/bp-groups-screens.php

    r8090 r8093  
    447447    }
    448448}
     449
     450/**
     451 * Process group invitation removal requests.
     452 *
     453 * Note that this function is only used when JS is disabled. Normally, clicking
     454 * Remove Invite removes the invitation via AJAX.
     455 *
     456 * @since BuddyPress (2.0.0)
     457 */
     458function groups_remove_group_invite() {
     459    if ( ! bp_is_group_invites() ) {
     460        return;
     461    }
     462
     463    if ( ! bp_is_action_variable( 'remove', 0 ) || ! is_numeric( bp_action_variable( 1 ) ) ) {
     464        return;
     465    }
     466
     467    if ( ! check_admin_referer( 'groups_invite_uninvite_user' ) ) {
     468        return false;
     469    }
     470
     471    $friend_id = intval( bp_action_variable( 1 ) );
     472    $group_id  = bp_get_current_group_id();
     473    $message   = __( 'Invite successfully removed', 'buddypress' );
     474    $redirect  = wp_get_referer();
     475    $error     = false;
     476
     477    if ( ! bp_groups_user_can_send_invites( $group_id ) ) {
     478        $message = __( 'You are not allowed to send or remove invites', 'buddypress' );
     479        $error = 'error';
     480    } else if ( BP_Groups_Member::check_for_membership_request( $friend_id, $group_id ) ) {
     481        $message = __( 'The member requested to join the group', 'buddypress' );
     482        $error = 'error';
     483    } else if ( ! groups_uninvite_user( $friend_id, $group_id ) ) {
     484        $message = __( 'There was an error removing the invite', 'buddypress' );
     485        $error = 'error';
     486    }
     487
     488    bp_core_add_message( $message, $error );
     489    bp_core_redirect( $redirect );
     490}
     491add_action( 'bp_screens', 'groups_remove_group_invite' );
    449492
    450493function groups_screen_group_request_membership() {
  • trunk/bp-groups/bp-groups-template.php

    r8069 r8093  
    33843384        global $invites_template;
    33853385
    3386         return wp_nonce_url( site_url( bp_get_groups_slug() . '/' . $invites_template->invite->group_id . '/invites/remove/' . $invites_template->invite->user->id ), 'groups_invite_uninvite_user' );
     3386        $user_id = intval( $invites_template->invite->user->id );
     3387
     3388        if ( bp_is_current_action( 'create' ) ) {
     3389            $uninvite_url = bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/group-invites/?user_id=' . $user_id;
     3390        } else {
     3391            $uninvite_url = bp_get_group_permalink( groups_get_current_group() ) . 'send-invites/remove/' . $user_id;
     3392        }
     3393
     3394        return wp_nonce_url( $uninvite_url, 'groups_invite_uninvite_user' );
    33873395    }
    33883396
  • trunk/bp-templates/bp-legacy/buddypress-functions.php

    r8090 r8093  
    10001000        $user = new BP_Core_User( $friend_id );
    10011001
     1002        $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;
     1003
    10021004        echo '<li id="uid-' . $user->id . '">';
    10031005        echo $user->avatar_thumb;
     
    10051007        echo '<span class="activity">' . esc_attr( $user->last_active ) . '</span>';
    10061008        echo '<div class="action">
    1007                 <a class="button remove" href="' . wp_nonce_url( bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . esc_attr( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
     1009                <a class="button remove" href="' . wp_nonce_url( $uninvite_url, 'groups_invite_uninvite_user' ) . '" id="uid-' . esc_attr( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
    10081010              </div>';
    10091011
Note: See TracChangeset for help on using the changeset viewer.