Ticket #5357: 5357.option2.diff
File 5357.option2.diff, 5.9 KB (added by , 11 years ago) |
---|
-
bp-core/bp-core-caps.php
198 198 return (bool) apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id ); 199 199 } 200 200 201 /** 202 * Check whether a user has a given capability. 203 * 204 * @since BuddyPress (?.?.0) 205 * 206 * @global $blog_id 207 * @param int $user_id the id of the user to check 208 * @param string $capability Capability or role name. 209 * @uses bp_get_root_blog_id() to get the blog id where BuddyPress is activated 210 * @uses switch_to_blog() to eventually switch to BuddyPress root blog id 211 * @uses restore_current_blog() to switch back to current blog 212 * @return bool True if the user has the cap for the given blog. 213 */ 214 function bp_user_can( $user_id = 0, $capability = '' ) { 215 global $blog_id; 216 217 if ( empty( $user_id ) || empty( $capability ) ) { 218 return false; 219 } 220 221 if ( $blog_id != bp_get_root_blog_id() ) { 222 switch_to_blog( bp_get_root_blog_id() ); 223 $retval = user_can( $user_id, $capability ); 224 restore_current_blog(); 225 } else { 226 $retval = user_can( $user_id, $capability ); 227 } 228 229 return (bool) apply_filters( 'bp_user_can', $retval, $user_id, $capability ); 230 } 231 232 201 233 /** 202 234 * Temporary implementation of 'bp_moderate' cap. 203 235 * -
bp-core/bp-core-template.php
53 53 if ( !$subnav_item['user_has_access'] ) 54 54 continue; 55 55 56 if ( 'request-membership' == $subnav_item['slug'] && bp_current_user_can( 'bp_moderate' ) ) 57 continue; 58 56 59 // If the current action or an action variable matches the nav item id, then add a highlight CSS class. 57 60 if ( $subnav_item['slug'] == bp_current_action() ) { 58 61 $selected = ' class="current selected"'; -
bp-groups/bp-groups-loader.php
421 421 // member and does not have an outstanding invitation, 422 422 // show a "Request Membership" nav item. 423 423 if ( is_user_logged_in() && 424 ! bp_current_user_can( 'bp_moderate' ) &&425 424 ! $this->current_group->is_user_member && 426 425 ! groups_check_for_membership_request( bp_loggedin_user_id(), $this->current_group->id ) && 427 426 $this->current_group->status == 'private' && -
bp-groups/bp-groups-screens.php
728 728 if ( !check_admin_referer( 'groups_ban_member' ) ) 729 729 return false; 730 730 731 $redirect = bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/'; 732 733 if ( bp_user_can( $user_id, 'bp_moderate' ) ) { 734 bp_core_add_message( __( 'The site Administrator cannot be banned from a group.', 'buddypress' ), 'error' ); 735 bp_core_redirect( $redirect ); 736 } 737 731 738 // Ban a user. 732 739 if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) ) 733 740 bp_core_add_message( __( 'There was an error when banning that user, please try again', 'buddypress' ), 'error' ); … … 736 743 737 744 do_action( 'groups_banned_member', $user_id, $bp->groups->current_group->id ); 738 745 739 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/');746 bp_core_redirect( $redirect ); 740 747 } 741 748 742 749 if ( bp_is_action_variable( 'unban', 1 ) && is_numeric( bp_action_variable( 2 ) ) ) { -
bp-templates/bp-legacy/buddypress/groups/single/admin.php
265 265 266 266 <a href="<?php bp_group_member_unban_link(); ?>" class="button confirm member-unban" title="<?php _e( 'Unban this member', 'buddypress' ); ?>"><?php _e( 'Remove Ban', 'buddypress' ); ?></a> 267 267 268 <?php else : ?> 268 <?php else: ?> 269 270 <?php if ( ! bp_user_can( bp_get_group_member_id(), 'bp_moderate' ) ) : ?> 271 272 <a href="<?php bp_group_member_ban_link(); ?>" class="button confirm member-ban" title="<?php _e( 'Kick and ban this member', 'buddypress' ); ?>"><?php _e( 'Kick & Ban', 'buddypress' ); ?></a> 269 273 270 <a href="<?php bp_group_member_ban_link(); ?>" class="button confirm member-ban" title="<?php _e( 'Kick and ban this member', 'buddypress' ); ?>"><?php _e( 'Kick & Ban', 'buddypress' ); ?></a> 274 <?php endif; ?> 275 271 276 <a href="<?php bp_group_member_promote_mod_link(); ?>" class="button confirm member-promote-to-mod" title="<?php _e( 'Promote to Mod', 'buddypress' ); ?>"><?php _e( 'Promote to Mod', 'buddypress' ); ?></a> 272 277 <a href="<?php bp_group_member_promote_admin_link(); ?>" class="button confirm member-promote-to-admin" title="<?php _e( 'Promote to Admin', 'buddypress' ); ?>"><?php _e( 'Promote to Admin', 'buddypress' ); ?></a> 273 278 -
bp-templates/bp-legacy/buddypress/groups/single/home.php
69 69 // Old group forums 70 70 elseif ( bp_is_group_forum() ) : bp_get_template_part( 'groups/single/forum' ); 71 71 72 // group membership requests for site admins 73 elseif ( bp_is_group_membership_request() && bp_current_user_can( 'bp_moderate' ) ) : 74 bp_get_template_part( 'groups/single/request-membership' ); 75 72 76 // Anything else (plugins mostly) 73 77 else : bp_get_template_part( 'groups/single/plugins' ); 74 78