Ticket #5357: 5357.option1.diff
File 5357.option1.diff, 6.6 KB (added by , 11 years ago) |
---|
-
bp-core/bp-core-caps.php
199 199 } 200 200 201 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 /** 202 233 * Temporary implementation of 'bp_moderate' cap. 203 234 * 204 235 * In BuddyPress 1.6, the 'bp_moderate' cap was introduced. In order to -
bp-groups/bp-groups-actions.php
365 365 ) ); 366 366 } 367 367 add_action( 'bp_actions', 'groups_action_group_feed' ); 368 369 /** 370 * Handles Administrator group membership requests 371 * 372 * As the screen function for the request-membership template is 373 * not set for a site Administrator in Groups loader class, this 374 * is a way to leave it as is and allow the group membership request 375 * to process. 376 */ 377 function bp_group_membership_request_from_admin() { 378 379 if ( bp_is_group_membership_request() && 1 == $_REQUEST['bp_moderate'] && bp_current_user_can( 'bp_moderate' ) ) { 380 381 // Check the nonce 382 if ( ! check_admin_referer( 'groups_request_membership' ) ) 383 return false; 384 385 if ( $group = groups_get_current_group() ){ 386 387 $redirect = bp_get_group_permalink( $group ); 388 389 // If the Admin is already a member let's redirect him to group members Admin. 390 if ( groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) { 391 bp_core_add_message( __( 'You are already a member of this group.', 'buddypress' ) ); 392 bp_core_redirect( $redirect ); 393 // Processing group membership request 394 } else { 395 396 if ( ! groups_send_membership_request( bp_loggedin_user_id(), $group->id ) ) { 397 $message = __( 'There was an error sending your group membership request, please try again.', 'buddypress' ); 398 399 // This should never happen... A group admin should not be able to ban a super admin ! 400 if( groups_is_user_banned( bp_loggedin_user_id(), $group->id ) ) { 401 $message = __( 'You were banned from this group.', 'buddypress' ); 402 } 403 404 bp_core_add_message( $message, 'error' ); 405 } else { 406 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' ) ); 407 } 408 409 bp_core_redirect( $redirect ); 410 } 411 } 412 } 413 } 414 add_action( 'bp_actions', 'bp_group_membership_request_from_admin' ); -
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-groups/bp-groups-template.php
1825 1825 'link_title' => __( 'Request Membership', 'buddypress' ), 1826 1826 'link_class' => 'group-button request-membership', 1827 1827 ); 1828 1829 if( bp_current_user_can( 'bp_moderate' ) ) { 1830 $button['link_href'] = add_query_arg( 'bp_moderate', 1, $button['link_href'] ); 1831 } 1828 1832 } 1829 1833 1830 1834 break; -
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 269 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> 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; ?> 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