Skip to:
Content

BuddyPress.org

Ticket #8139: 8139-load-one-inviations-screen.patch

File 8139-load-one-inviations-screen.patch, 16.2 KB (added by imath, 3 years ago)
  • src/bp-members/actions/invitations-bulk-manage.php

    diff --git src/bp-members/actions/invitations-bulk-manage.php src/bp-members/actions/invitations-bulk-manage.php
    index e2cd26c33..5f33c627a 100644
    function bp_members_invitations_action_bulk_manage() { 
    2424        // Get the parameters.
    2525        $action      = ! empty( $_POST['invitation_bulk_action'] ) ? $_POST['invitation_bulk_action'] : '';
    2626        $nonce       = ! empty( $_POST['invitations_bulk_nonce'] ) ? $_POST['invitations_bulk_nonce'] : '';
    27         $invitations = ! empty( $_POST['network_invitations']    ) ? $_POST['network_invitations']    : '';
     27        $invitations = ! empty( $_POST['member_invitations']     ) ? $_POST['member_invitations']    : '';
    2828
    2929        // Bail if no action or no IDs.
    3030        if ( ( ! in_array( $action, array( 'cancel', 'resend' ), true ) ) || empty( $invitations ) || empty( $nonce ) ) {
    function bp_members_invitations_action_bulk_manage() { 
    7979        // Redirect.
    8080        bp_core_redirect( bp_displayed_user_domain() . bp_get_members_invitations_slug() . '/' . bp_current_action() . '/' );
    8181}
    82 add_action( 'bp_actions', 'bp_members_invitations_action_bulk_manage' );
    83  No newline at end of file
     82add_action( 'bp_actions', 'bp_members_invitations_action_bulk_manage' );
  • src/bp-members/bp-members-template.php

    diff --git src/bp-members/bp-members-template.php src/bp-members/bp-members-template.php
    index b52adb7ce..09d3d022a 100644
    function bp_the_members_invitations_resend_url( $user_id = 0 ) { 
    32913291                $url = add_query_arg( $args, $link );
    32923292
    32933293                // Add the nonce.
    3294                 $url = wp_nonce_url( $url, 'bp_network_invitation_resend_' . $id );
     3294                $url = wp_nonce_url( $url, 'bp_member_invitation_resend_' . $id );
    32953295
    32963296                /**
    32973297                 * Filters the URL used for resending a single invitation.
    function bp_members_invitations_bulk_management_dropdown() { 
    34993499
    35003500        <input type="submit" id="invitation-bulk-manage" class="button action" value="<?php echo esc_attr_x( 'Apply', 'button', 'buddypress' ); ?>">
    35013501        <?php
    3502 }
    3503  No newline at end of file
     3502}
  • src/bp-members/classes/class-bp-members-component.php

    diff --git src/bp-members/classes/class-bp-members-component.php src/bp-members/classes/class-bp-members-component.php
    index 8effd0cf0..f81224679 100644
    class BP_Members_Component extends BP_Component { 
    144144                // Invitations.
    145145                if ( is_user_logged_in() && bp_is_user_members_invitations() ) {
    146146                        // Actions.
    147                         if ( bp_is_post_request() ) {
     147                        if ( isset( $_POST['member_invitations'] ) ) {
    148148                                require $this->path . 'bp-members/actions/invitations-bulk-manage.php';
    149149                        }
    150150
    151151                        // Screens.
    152                         if ( bp_is_user_members_invitations_list() ) {
    153                                 require $this->path . 'bp-members/screens/list-invites.php';
    154                         } else {
    155                                 require $this->path . 'bp-members/screens/send-invites.php';
    156                         }
     152                        require $this->path . 'bp-members/screens/invitations.php';
    157153                }
    158154        }
    159155
  • new file src/bp-members/screens/invitations.php

    diff --git src/bp-members/screens/invitations.php src/bp-members/screens/invitations.php
    new file mode 100644
    index 000000000..128046d36
    - +  
     1<?php
     2/**
     3 * BuddyPress Members: Invitations screens
     4 *
     5 * @package BuddyPress
     6 * @subpackage MembersScreens
     7 * @since 8.0.0
     8 */
     9
     10// Exit if accessed directly.
     11defined( 'ABSPATH' ) || exit;
     12
     13/**
     14 * Catch and process the Send Invites page.
     15 *
     16 * @since 8.0.0
     17 */
     18function members_screen_send_invites() {
     19
     20        // Chack if there's an invitation to send.
     21        if ( isset( $_REQUEST['action'] ) && 'send-invite' === wp_unslash( $_REQUEST['action'] ) ) {
     22                $user_id      = bp_displayed_user_id();
     23                $default_args = array(
     24                        'invitee_email' => '',
     25                        'inviter_id'    => $user_id,
     26                        'content'       => '',
     27                        'send_invite'   => 1,
     28                );
     29
     30                $invite_args = wp_parse_args( array_map( 'wp_unslash', $_REQUEST ), $default_args );
     31                $invite_args = array_intersect_key( $invite_args, $default_args );
     32
     33                // Check the nonce and delete the invitation.
     34                if ( bp_verify_nonce_request( 'bp_members_invitation_send_' . $user_id ) && bp_members_invitations_invite_user( $invite_args ) ) {
     35                        bp_core_add_message( __( 'Invitation successfully sent!', 'buddypress' )          );
     36                } else {
     37                        bp_core_add_message( __( 'There was a problem sending that invitation. The user could already be a member of the site or have chosen not to receive invitations from this site.', 'buddypress' ), 'error' );
     38                }
     39
     40                // Redirect.
     41                bp_core_redirect( bp_get_members_invitations_send_invites_permalink( $user_id ) );
     42        }
     43
     44        /**
     45         * Fires before the loading of template for the send membership invitations page.
     46         *
     47         * @since 8.0.0
     48         */
     49        do_action( 'members_screen_send_invites' );
     50
     51        /**
     52         * Filters the template used to display the send membership invitations page.
     53         *
     54         * @since 8.0.0
     55         *
     56         * @param string $template Path to the send membership invitations template to load.
     57         */
     58        bp_core_load_template( apply_filters( 'members_template_send_invites', 'members/single/invitations' ) );
     59}
     60
     61/**
     62 * Catch and process the Pending Invites page.
     63 *
     64 * @since 8.0.0
     65 */
     66function members_screen_list_sent_invites() {
     67
     68        // Chack if there's an invitation to cancel or resend.
     69        if ( isset( $_GET['action'], $_GET['invitation_id'] ) && $_GET['action'] && $_GET['invitation_id'] ) {
     70                $action        = wp_unslash( $_GET['action'] );
     71                $invitation_id = (int) wp_unslash( $_GET['invitation_id'] );
     72                $user_id       = bp_displayed_user_id();
     73
     74                if ( 'cancel' === $action ) {
     75                        // Check the nonce and delete the invitation.
     76                        if ( bp_verify_nonce_request( 'bp_members_invitations_cancel_' . $invitation_id ) && bp_members_invitations_delete_by_id( $invitation_id ) ) {
     77                                bp_core_add_message( __( 'Invitation successfully canceled.', 'buddypress' ) );
     78                        } else {
     79                                bp_core_add_message( __( 'There was a problem canceling that invitation.', 'buddypress' ), 'error' );
     80                        }
     81                } elseif ( 'resend' === $action ) {
     82                        // Check the nonce and resend the invitation.
     83                        if ( bp_verify_nonce_request( 'bp_member_invitation_resend_' . $invitation_id ) && bp_members_invitation_resend_by_id( $invitation_id ) ) {
     84                                bp_core_add_message( __( 'Invitation successfully resent.', 'buddypress' ) );
     85                        } else {
     86                                bp_core_add_message( __( 'There was a problem resending that invitation.', 'buddypress' ), 'error' );
     87                        }
     88                } else {
     89                        /**
     90                         * Hook here to handle custom actions.
     91                         *
     92                         * @since 8.0.0
     93                         *
     94                         * @param string $action        The action name.
     95                         * @param int    $invitation_id The invitation ID.
     96                         * @param int    $user_id       The displayed user ID.
     97                         */
     98                        do_action( 'bp_members_invitations_list_invites_action', $action, $invitation_id, $user_id );
     99                }
     100
     101                // Redirect.
     102                bp_core_redirect( bp_get_members_invitations_list_invites_permalink( $user_id ) );
     103        }
     104
     105        /**
     106         * Fires before the loading of template for the send membership invitations page.
     107         *
     108         * @since 8.0.0
     109         */
     110        do_action( 'members_screen_list_sent_invites' );
     111
     112        /**
     113         * Filters the template used to display the send membership invitations page.
     114         *
     115         * @since 8.0.0
     116         *
     117         * @param string $template Path to the send membership invitations template to load.
     118         */
     119        bp_core_load_template( apply_filters( 'members_template_list_sent_invites', 'members/single/invitations' ) );
     120}
  • deleted file src/bp-members/screens/list-invites.php

    diff --git src/bp-members/screens/list-invites.php src/bp-members/screens/list-invites.php
    deleted file mode 100644
    index 600cee733..000000000
    + -  
    1 <?php
    2 /**
    3  * Members: Sent Invitations Status
    4  *
    5  * @package BuddyPress
    6  * @subpackage MembersScreens
    7  * @since 8.0.0
    8  */
    9 
    10 /**
    11  * Catch and process the Send Invites page.
    12  *
    13  * @since 8.0.0
    14  */
    15 function members_screen_list_sent_invites() {
    16 
    17         /**
    18          * Fires before the loading of template for the send membership invitations page.
    19          *
    20          * @since 8.0.0
    21          */
    22         do_action( 'members_screen_list_sent_invites' );
    23 
    24         /**
    25          * Filters the template used to display the send membership invitations page.
    26          *
    27          * @since 8.0.0
    28          *
    29          * @param string $template Path to the send membership invitations template to load.
    30          */
    31         bp_core_load_template( apply_filters( 'members_template_list_sent_invites', 'members/single/invitations' ) );
    32 }
    33 
    34 /**
    35  * Handle canceling or resending single invitations.
    36  *
    37  * @since 8.0.0
    38  *
    39  * @return bool
    40  */
    41 function bp_members_invitations_action_handling() {
    42 
    43         // Bail if not the read screen.
    44         if ( ! bp_is_user_members_invitations_list() ) {
    45                 return false;
    46         }
    47 
    48         // Get the action.
    49         $action = ! empty( $_GET['action']        ) ? $_GET['action']        : '';
    50         $nonce  = ! empty( $_GET['_wpnonce']      ) ? $_GET['_wpnonce']      : '';
    51         $id     = ! empty( $_GET['invitation_id'] ) ? $_GET['invitation_id'] : '';
    52 
    53         // Bail if no action or no ID.
    54         if ( empty( $action ) || empty( $id ) ) {
    55                 return false;
    56         }
    57 
    58         if ( 'cancel' === $action ) {
    59                 // Check the nonce and delete the invitation.
    60                 if ( bp_verify_nonce_request( 'bp_members_invitations_cancel_' . $id ) && bp_members_invitations_delete_by_id( $id ) ) {
    61                         bp_core_add_message( __( 'Invitation successfully canceled.', 'buddypress' ) );
    62                 } else {
    63                         bp_core_add_message( __( 'There was a problem canceling that invitation.', 'buddypress' ), 'error' );
    64                 }
    65         } else if ( 'resend' === $action ) {
    66                 // Check the nonce and resend the invitation.
    67                 if ( bp_verify_nonce_request( 'bp_network_invitation_resend_' . $id ) && bp_members_invitation_resend_by_id( $id ) ) {
    68                         bp_core_add_message( __( 'Invitation successfully resent.', 'buddypress' ) );
    69                 } else {
    70                         bp_core_add_message( __( 'There was a problem resending that invitation.', 'buddypress' ), 'error' );
    71                 }
    72         } else {
    73                 return false;
    74         }
    75 
    76         // Redirect.
    77         $user_id = bp_displayed_user_id();
    78         bp_core_redirect( bp_get_members_invitations_list_invites_permalink( $user_id ) );
    79 }
    80 add_action( 'bp_actions', 'bp_members_invitations_action_handling' );
  • deleted file src/bp-members/screens/send-invites.php

    diff --git src/bp-members/screens/send-invites.php src/bp-members/screens/send-invites.php
    deleted file mode 100644
    index f2af326e2..000000000
    + -  
    1 <?php
    2 /**
    3  * Members: Send Invitations
    4  *
    5  * @package BuddyPress
    6  * @subpackage MembersScreens
    7  * @since 8.0.0
    8  */
    9 
    10 /**
    11  * Catch and process the Send Invites page.
    12  *
    13  * @since 8.0.0
    14  */
    15 function members_screen_send_invites() {
    16 
    17         /**
    18          * Fires before the loading of template for the send membership invitations page.
    19          *
    20          * @since 8.0.0
    21          */
    22         do_action( 'members_screen_send_invites' );
    23 
    24         /**
    25          * Filters the template used to display the send membership invitations page.
    26          *
    27          * @since 8.0.0
    28          *
    29          * @param string $template Path to the send membership invitations template to load.
    30          */
    31         bp_core_load_template( apply_filters( 'members_template_send_invites', 'members/single/invitations' ) );
    32 }
    33 
    34 /**
    35  * Handle sending invitations.
    36  *
    37  * @since 8.0.0
    38  *
    39  * @return bool
    40  */
    41 function bp_network_invitations_catch_send_action() {
    42 
    43         // Bail if not the read screen.
    44         if ( ! bp_is_user_members_invitations_send_screen() ) {
    45                 return false;
    46         }
    47 
    48         // Get the action.
    49         $action  = ! empty( $_REQUEST['action']          ) ? $_REQUEST['action']          : '';
    50         $nonce   = ! empty( $_REQUEST['_wpnonce']        ) ? $_REQUEST['_wpnonce']        : '';
    51         $email   = ! empty( $_REQUEST['invitee_email']   ) ? $_REQUEST['invitee_email']   : '';
    52         $message = ! empty( $_REQUEST['invite_message']  ) ? $_REQUEST['invite_message']  : '';
    53 
    54         // Bail if missing required info.
    55         if ( ( 'send-invite' !== $action ) ) {
    56                 return false;
    57         }
    58 
    59         $invite_args = array(
    60                 'invitee_email' => $email,
    61                 'inviter_id'    => bp_displayed_user_id(),
    62                 'content'       => $message,
    63                 'send_invite'   => 1
    64         );
    65 
    66         // Check the nonce and delete the invitation.
    67         if ( bp_verify_nonce_request( 'bp_members_invitation_send_' . bp_displayed_user_id() ) && bp_members_invitations_invite_user( $invite_args ) ) {
    68                 bp_core_add_message( __( 'Invitation successfully sent!', 'buddypress' )          );
    69         } else {
    70                 bp_core_add_message( __( 'There was a problem sending that invitation. The user could already be a member of the site or have chosen not to receive invitations from this site.', 'buddypress' ), 'error' );
    71         }
    72 
    73         // Redirect.
    74         $user_id = bp_displayed_user_id();
    75         bp_core_redirect( bp_get_members_invitations_send_invites_permalink( $user_id ) );
    76 }
    77 add_action( 'bp_actions', 'bp_network_invitations_catch_send_action' );
  • src/bp-templates/bp-legacy/buddypress/members/single/invitations/invitations-loop.php

    diff --git src/bp-templates/bp-legacy/buddypress/members/single/invitations/invitations-loop.php src/bp-templates/bp-legacy/buddypress/members/single/invitations/invitations-loop.php
    index 6ec6a861a..5ce52e231 100644
     
    3636                                <tr>
    3737                                        <td class="bulk-select-check">
    3838                                                <label for="<?php bp_the_members_invitation_property( 'id', 'attribute' ); ?>">
    39                                                         <input id="<?php bp_the_members_invitation_property( 'id', 'attribute' ); ?>" type="checkbox" name="network_invitations[]" value="<?php bp_the_members_invitation_property( 'id', 'attribute' ); ?>" class="invitation-check">
     39                                                        <input id="<?php bp_the_members_invitation_property( 'id', 'attribute' ); ?>" type="checkbox" name="member_invitations[]" value="<?php bp_the_members_invitation_property( 'id', 'attribute' ); ?>" class="invitation-check">
    4040                                                        <span class="bp-screen-reader-text">
    4141                                                                <?php
    4242                                                                        /* translators: accessibility text */
  • src/bp-templates/bp-legacy/buddypress/members/single/invitations/send-invites.php

    diff --git src/bp-templates/bp-legacy/buddypress/members/single/invitations/send-invites.php src/bp-templates/bp-legacy/buddypress/members/single/invitations/send-invites.php
    index 5cd0af16c..15ab7a9b4 100644
     
    2323        <input id="bp_members_invitation_invitee_email" type="email" name="invitee_email" required="required">
    2424
    2525        <label for="bp_members_invitation_message"><?php esc_html_e( 'Add a personalized message to the invitation (optional)', 'buddypress' ); ?></label>
    26         <textarea id="bp_members_invitation_message" name="invite_message"></textarea>
     26        <textarea id="bp_members_invitation_message" name="content"></textarea>
    2727
    2828        <input type="hidden" name="action" value="send-invite">
    2929
  • src/bp-templates/bp-nouveau/buddypress/members/single/invitations/invitations-loop.php

    diff --git src/bp-templates/bp-nouveau/buddypress/members/single/invitations/invitations-loop.php src/bp-templates/bp-nouveau/buddypress/members/single/invitations/invitations-loop.php
    index f4aa643ee..7e884db26 100644
     
    3434                                <tr>
    3535                                        <td class="bulk-select-check">
    3636                                                <label for="<?php bp_the_members_invitation_property( 'id', 'attribute' ); ?>">
    37                                                         <input id="<?php bp_the_members_invitation_property( 'id', 'attribute' ); ?>" type="checkbox" name="network_invitations[]" value="<?php bp_the_members_invitation_property( 'id', 'attribute' ); ?>" class="invitation-check">
     37                                                        <input id="<?php bp_the_members_invitation_property( 'id', 'attribute' ); ?>" type="checkbox" name="member_invitations[]" value="<?php bp_the_members_invitation_property( 'id', 'attribute' ); ?>" class="invitation-check">
    3838                                                        <span class="bp-screen-reader-text">
    3939                                                                <?php
    4040                                                                        /* translators: accessibility text */
  • src/bp-templates/bp-nouveau/buddypress/members/single/invitations/send-invites.php

    diff --git src/bp-templates/bp-nouveau/buddypress/members/single/invitations/send-invites.php src/bp-templates/bp-nouveau/buddypress/members/single/invitations/send-invites.php
    index 5b5d21bd8..6e3f21da4 100644
     
    2727                <label for="bp_members_invitation_message">
    2828                        <?php esc_html_e( 'Add a personalized message to the invitation (optional)', 'buddypress' ); ?>
    2929                </label>
    30                 <textarea id="bp_members_invitation_message" name="invite_message"></textarea>
     30                <textarea id="bp_members_invitation_message" name="content"></textarea>
    3131
    3232                <input type="hidden" name="action" value="send-invite">
    3333