diff --git bp-core/bp-core-caps.php bp-core/bp-core-caps.php
index 2ed693d..900c8e4 100644
|
|
|
function bp_current_user_can( $capability, $blog_id = 0 ) { |
| 196 | 196 | return (bool) apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id ); |
| 197 | 197 | } |
| 198 | 198 | |
| | 199 | /** |
| | 200 | * Check whether a user has a given capability. |
| | 201 | * |
| | 202 | * @since BuddyPress (?.?.0) |
| | 203 | * |
| | 204 | * @global $blog_id |
| | 205 | * @param int $user_id the id of the user to check |
| | 206 | * @param string $capability Capability or role name. |
| | 207 | * @uses bp_get_root_blog_id() to get the blog id where BuddyPress is activated |
| | 208 | * @uses switch_to_blog() to eventually switch to BuddyPress root blog id |
| | 209 | * @uses restore_current_blog() to switch back to current blog |
| | 210 | * @return bool True if the user has the cap for the given blog. |
| | 211 | */ |
| | 212 | function bp_user_can( $user_id = 0, $capability = '' ) { |
| | 213 | global $blog_id; |
| | 214 | |
| | 215 | if ( empty( $user_id ) || empty( $capability ) ) { |
| | 216 | return false; |
| | 217 | } |
| | 218 | |
| | 219 | if ( $blog_id != bp_get_root_blog_id() ) { |
| | 220 | switch_to_blog( bp_get_root_blog_id() ); |
| | 221 | $retval = user_can( $user_id, $capability ); |
| | 222 | restore_current_blog(); |
| | 223 | } else { |
| | 224 | $retval = user_can( $user_id, $capability ); |
| | 225 | } |
| | 226 | |
| | 227 | return (bool) apply_filters( 'bp_user_can', $retval, $user_id, $capability ); |
| | 228 | } |
| | 229 | |
| | 230 | |
| 199 | 231 | /** |
| 200 | 232 | * Temporary implementation of 'bp_moderate' cap. |
| 201 | 233 | * |
diff --git bp-core/bp-core-template.php bp-core/bp-core-template.php
index 51c1b38..128a9f7 100644
|
|
|
function bp_get_options_nav() { |
| 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"'; |
diff --git bp-groups/bp-groups-loader.php bp-groups/bp-groups-loader.php
index 0dc2f8a..5a28f1b 100644
|
|
|
class BP_Groups_Component extends BP_Component { |
| 427 | 427 | // member and does not have an outstanding invitation, |
| 428 | 428 | // show a "Request Membership" nav item. |
| 429 | 429 | if ( is_user_logged_in() && |
| 430 | | ! bp_current_user_can( 'bp_moderate' ) && |
| 431 | 430 | ! $this->current_group->is_user_member && |
| 432 | 431 | ! groups_check_for_membership_request( bp_loggedin_user_id(), $this->current_group->id ) && |
| 433 | 432 | $this->current_group->status == 'private' && |
diff --git bp-groups/bp-groups-screens.php bp-groups/bp-groups-screens.php
index aef0c90..38e9897 100644
|
|
|
function groups_screen_group_request_membership() { |
| 480 | 480 | bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) ); |
| 481 | 481 | } |
| 482 | 482 | bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); |
| | 483 | |
| | 484 | } else if( bp_current_user_can( 'bp_moderate') ) { |
| | 485 | |
| | 486 | /** |
| | 487 | * the template loaded in this case will default to 'groups/single/plugins' |
| | 488 | * So to avoid modifying the home template and maximize compatibility with |
| | 489 | * themes, we'll use the bp_template_action of this hook to load the |
| | 490 | * 'groups/single/request-membership' template part |
| | 491 | */ |
| | 492 | add_action( 'bp_template_content', create_function( '', 'return bp_get_template_part("groups/single/request-membership");' ) ); |
| 483 | 493 | } |
| 484 | 494 | |
| 485 | 495 | do_action( 'groups_screen_group_request_membership', $bp->groups->current_group->id ); |
| … |
… |
function groups_screen_group_admin_manage_members() { |
| 728 | 738 | if ( !check_admin_referer( 'groups_ban_member' ) ) |
| 729 | 739 | return false; |
| 730 | 740 | |
| | 741 | $redirect = bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/'; |
| | 742 | |
| | 743 | if ( bp_user_can( $user_id, 'bp_moderate' ) ) { |
| | 744 | bp_core_add_message( __( 'The site Administrator cannot be banned from a group.', 'buddypress' ), 'error' ); |
| | 745 | bp_core_redirect( $redirect ); |
| | 746 | } |
| | 747 | |
| 731 | 748 | // Ban a user. |
| 732 | 749 | if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) ) |
| 733 | 750 | bp_core_add_message( __( 'There was an error when banning that user, please try again', 'buddypress' ), 'error' ); |
| … |
… |
function groups_screen_group_admin_manage_members() { |
| 736 | 753 | |
| 737 | 754 | do_action( 'groups_banned_member', $user_id, $bp->groups->current_group->id ); |
| 738 | 755 | |
| 739 | | bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/' ); |
| | 756 | bp_core_redirect( $redirect ); |
| 740 | 757 | } |
| 741 | 758 | |
| 742 | 759 | if ( bp_is_action_variable( 'unban', 1 ) && is_numeric( bp_action_variable( 2 ) ) ) { |
diff --git bp-templates/bp-legacy/buddypress/groups/single/admin.php bp-templates/bp-legacy/buddypress/groups/single/admin.php
index 449a7bf..ef26a93 100644
|
|
|
|
| 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> |
| | 273 | |
| | 274 | <?php endif; ?> |
| 269 | 275 | |
| 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> |
| 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 | |