Ticket #8139: 8139.09.02-capabilities.patch
File 8139.09.02-capabilities.patch, 10.1 KB (added by , 3 years ago) |
---|
-
src/bp-members/bp-members-adminbar.php
diff --git src/bp-members/bp-members-adminbar.php src/bp-members/bp-members-adminbar.php index 282be654c..c9ff861c0 100644
function bp_members_admin_bar_add_invitations_menu() { 193 193 return; 194 194 } 195 195 196 if ( is_user_logged_in() && bp_get_members_invitations_allowed() && ( bp_current_user_can( 'bp_members_send_invitation' ) || bp_members_invitations_user_has_sent_invites()) ) {196 if ( bp_current_user_can( 'bp_members_invitations_view_screens' ) ) { 197 197 $bp = buddypress(); 198 198 $invitations_link = trailingslashit( bp_loggedin_user_domain() . bp_get_members_invitations_slug() ); 199 199 … … function bp_members_admin_bar_add_invitations_menu() { 209 209 ) 210 210 ); 211 211 212 if ( bp_current_user_can( 'bp_members_ send_invitation' ) ) {212 if ( bp_current_user_can( 'bp_members_invitations_view_send_screen' ) ) { 213 213 $wp_admin_bar->add_node( 214 214 array( 215 215 'id' => $bp->my_account_menu_id . '-invitations-send', 216 216 'parent' => $bp->my_account_menu_id . '-invitations', 217 217 'title' => __( 'Send Invites', 'buddypress' ), 218 'href' => $invitations_link ,218 'href' => $invitations_link . 'send-invites/', 219 219 'meta' => array( 220 220 'class' => 'ab-sub-secondary' 221 221 ) -
src/bp-members/bp-members-filters.php
diff --git src/bp-members/bp-members-filters.php src/bp-members/bp-members-filters.php index d0d65e4fe..f7d89c672 100644
function bp_members_user_can_filter( $retval, $user_id, $capability, $site_id, $ 149 149 break; 150 150 151 151 case 'bp_members_send_invitation': 152 if ( bp_get_members_invitations_allowed() ) {152 if ( is_user_logged_in() && bp_get_members_invitations_allowed() ) { 153 153 $retval = true; 154 154 } 155 155 break; … … function bp_members_user_can_filter( $retval, $user_id, $capability, $site_id, $ 167 167 } 168 168 } 169 169 break; 170 171 case 'bp_members_invitations_view_screens': 172 $retval = bp_get_members_invitations_allowed() && ( bp_user_can( $user_id, 'bp_members_send_invitation' ) || bp_members_invitations_user_has_sent_invites( $user_id ) ); 173 break; 174 175 case 'bp_members_invitations_view_send_screen': 176 $retval = is_user_logged_in() && bp_get_members_invitations_allowed(); 177 break; 170 178 } 171 179 172 180 return $retval; -
src/bp-members/bp-members-invitations.php
diff --git src/bp-members/bp-members-invitations.php src/bp-members/bp-members-invitations.php index 2a04c3dbd..a89b9f54a 100644
function bp_members_invitations_setup_nav() { 15 15 return; 16 16 } 17 17 18 $user_has_access = bp_user_has_access(); 19 $user_can_send = bp_user_can( bp_displayed_user_id(), 'bp_members_send_invitation' ); 20 $user_has_invites = bp_members_invitations_user_has_sent_invites( bp_displayed_user_id() ); 18 $user_has_access = bp_user_has_access(); 19 $default_subnav_slug = ( bp_is_my_profile() && bp_user_can( bp_displayed_user_id(), 'bp_members_invitations_view_send_screen' ) ) ? 'send-invites' : 'list-invites'; 21 20 22 21 /* Add 'Invitations' to the main user profile navigation */ 23 22 bp_core_new_nav_item( … … function bp_members_invitations_setup_nav() { 26 25 'slug' => bp_get_members_invitations_slug(), 27 26 'position' => 80, 28 27 'screen_function' => 'members_screen_send_invites', 29 'default_subnav_slug' => ( $user_can_send && bp_is_my_profile() ) ? 'send-invites' : 'list-invites',30 'show_for_displayed_user' => $user_has_access && ( $user_can_send || $user_has_invites)28 'default_subnav_slug' => $default_subnav_slug, 29 'show_for_displayed_user' => $user_has_access && bp_user_can( bp_displayed_user_id(), 'bp_members_invitations_view_screens' ) 31 30 ) 32 31 ); 33 32 … … function bp_members_invitations_setup_nav() { 42 41 'parent_url' => $parent_link, 43 42 'screen_function' => 'members_screen_send_invites', 44 43 'position' => 10, 45 'user_has_access' => $user_has_access && $user_can_send && bp_is_my_profile()44 'user_has_access' => $user_has_access && bp_is_my_profile() && bp_user_can( bp_displayed_user_id(), 'bp_members_invitations_view_send_screen' ) 46 45 ) 47 46 ); 48 47 … … function bp_members_invitations_setup_nav() { 54 53 'parent_url' => $parent_link, 55 54 'screen_function' => 'members_screen_list_sent_invites', 56 55 'position' => 20, 57 'user_has_access' => $user_has_access && ( $user_can_send || $user_has_invites)56 'user_has_access' => $user_has_access && bp_user_can( bp_displayed_user_id(), 'bp_members_invitations_view_screens' ) 58 57 ) 59 58 ); 60 59 } -
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 6eeb3b62f..5cd0af16c 100644
14 14 ?> 15 15 </h2> 16 16 17 <?php if ( bp_user_can( bp_displayed_user_id(), 'bp_members_send_invitation' ) ) : ?> 18 17 19 <form class="standard-form members-invitation-form" id="members-invitation-form" method="post"> 18 20 <p class="description"><?php esc_html_e( 'Fill out the form below to invite a new user to join this site. Upon submission of the form, an email will be sent to the invitee containing a link to accept your invitation. You may also add a custom message to the email.', 'buddypress' ); ?></p> 19 21 … … 30 32 <input id="submit" type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Send Invitation', 'buddypress' ) ?>" /> 31 33 </p> 32 34 </form> 35 36 <?php else : ?> 37 38 <p class="bp-feedback error"> 39 <span class="bp-icon" aria-hidden="true"></span> 40 <span class="bp-help-text"> 41 <?php echo apply_filters( 'members_invitations_form_access_restricted', esc_html__( 'Sorry, you are not allowed to send invitations.', 'buddypress' ) ); ?> 42 </span> 43 </p> 44 45 <?php endif; ?> -
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 077c1fa24..5b5d21bd8 100644
13 13 ?> 14 14 </h2> 15 15 16 <p class="bp-feedback info"> 17 <span class="bp-icon" aria-hidden="true"></span> 18 <span class="bp-help-text"> 19 <?php esc_html_e( 'Fill out the form below to invite a new user to join this site. Upon submission of the form, an email will be sent to the invitee containing a link to accept your invitation. You may also add a custom message to the email.', 'buddypress' ); ?> 20 </span> 21 </p> 22 23 <form class="standard-form network-invitation-form" id="network-invitation-form" method="post"> 24 <label for="bp_members_invitation_invitee_email"> 25 <?php esc_html_e( 'Email', 'buddypress' ); ?> 26 <span class="bp-required-field-label"><?php esc_html_e( '(required)', 'buddypress' ); ?></span> 27 </label> 28 <input id="bp_members_invitation_invitee_email" type="email" name="invitee_email" required="required"> 29 30 <label for="bp_members_invitation_message"> 31 <?php esc_html_e( 'Add a personalized message to the invitation (optional)', 'buddypress' ); ?> 32 </label> 33 <textarea id="bp_members_invitation_message" name="invite_message"></textarea> 34 35 <input type="hidden" name="action" value="send-invite"> 36 37 <?php bp_nouveau_submit_button( 'member-send-invite' ); ?> 38 </form> 16 <?php if ( bp_user_can( bp_displayed_user_id(), 'bp_members_send_invitation' ) ) : ?> 17 18 <?php bp_nouveau_user_feedback( 'member-invitations-help' ); ?> 19 20 <form class="standard-form network-invitation-form" id="network-invitation-form" method="post"> 21 <label for="bp_members_invitation_invitee_email"> 22 <?php esc_html_e( 'Email', 'buddypress' ); ?> 23 <span class="bp-required-field-label"><?php esc_html_e( '(required)', 'buddypress' ); ?></span> 24 </label> 25 <input id="bp_members_invitation_invitee_email" type="email" name="invitee_email" required="required"> 26 27 <label for="bp_members_invitation_message"> 28 <?php esc_html_e( 'Add a personalized message to the invitation (optional)', 'buddypress' ); ?> 29 </label> 30 <textarea id="bp_members_invitation_message" name="invite_message"></textarea> 31 32 <input type="hidden" name="action" value="send-invite"> 33 34 <?php bp_nouveau_submit_button( 'member-send-invite' ); ?> 35 </form> 36 37 <?php else : ?> 38 39 <?php bp_nouveau_user_feedback( 'member-invitations-not-allowed' ); ?> 40 41 <?php endif; ?> -
src/bp-templates/bp-nouveau/includes/functions.php
diff --git src/bp-templates/bp-nouveau/includes/functions.php src/bp-templates/bp-nouveau/includes/functions.php index 1b17c6294..7fcb08943 100644
function bp_nouveau_get_user_feedback( $feedback_id = '' ) { 1090 1090 'type' => 'info', 1091 1091 'message' => __( 'Currently only your friends can invite you to groups. Uncheck the box to allow any member to send invites.', 'buddypress' ), 1092 1092 ), 1093 'member-invites-none' => array( 1093 'member-invitations-help' => array( 1094 'type' => 'info', 1095 'message' => __( 'Fill out the form below to invite a new user to join this site. Upon submission of the form, an email will be sent to the invitee containing a link to accept your invitation. You may also add a custom message to the email.', 'buddypress' ), 1096 ), 1097 'member-invitations-none' => array( 1094 1098 'type' => 'info', 1095 1099 'message' => __( 'There are no invitations to display.', 'buddypress' ), 1096 1100 ), 1101 'member-invitations-not-allowed' => array( 1102 'type' => 'error', 1103 /** 1104 * Use this filter to edit the restricted feedback message displayed into the Send invitation form. 1105 * 1106 * @since 8.0.0 1107 * 1108 * @param string $value The restricted feedback message displayed into the Send invitation form. 1109 */ 1110 'message' => apply_filters( 1111 'members_invitations_form_access_restricted', 1112 __( 'Sorry, you are not allowed to send invitations.', 'buddypress' ) 1113 ), 1114 ), 1097 1115 ) 1098 1116 ); 1099 1117