Changeset 5834 for trunk/src/includes/users/capabilities.php
- Timestamp:
- 07/15/2015 03:59:23 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/capabilities.php
r5827 r5834 15 15 * @since bbPress (r4242) 16 16 * 17 * @param array $caps Capabilities for meta capability 18 * @param string $cap Capability name 19 * @param int $user_id User id 20 * @param array $args Arguments 17 * @param array $caps Capabilities for meta capability. 18 * @param string $cap Capability name. 19 * @param int $user_id User id. 20 * @param array $args Arguments. 21 * @uses bbp_is_user_inactive() To check if user is spammer or deleted 22 * @uses get_post() To get the post 23 * @uses bbp_get_forum_post_type() To get the forum post type 24 * @uses bbp_get_topic_post_type() To get the topic post type 25 * @uses bbp_get_topic_forum_id() To get the topic forum id 26 * @uses bbp_get_reply_post_type() To get the reply post type 27 * @uses bbp_get_reply_forum_id() To get the reply forum id 28 * @uses bbp_is_user_forum_mod() To check if the user is a forum moderator 21 29 * @uses apply_filters() Filter mapped results 30 * 22 31 * @return array Actual capabilities for meta capability 23 32 */ … … 26 35 // What capability is being checked? 27 36 switch ( $cap ) { 28 case 'spectate' : 29 case 'participate' : 30 case 'moderate' : 31 32 // Do not allow inactive users 37 case 'spectate' : 38 39 // Do not allow inactive users. 33 40 if ( bbp_is_user_inactive( $user_id ) ) { 34 41 $caps = array( 'do_not_allow' ); 35 42 36 // Moderators are always participants43 // Default to the current cap. 37 44 } else { 38 45 $caps = array( $cap ); 46 } 47 break; 48 49 case 'participate' : 50 51 // Do not allow inactive users. 52 if ( bbp_is_user_inactive( $user_id ) ) { 53 $caps = array( 'do_not_allow' ); 54 55 // Default to the current cap. 56 } else { 57 $caps = array( $cap ); 58 } 59 break; 60 61 case 'moderate' : 62 63 // Do not allow inactive users. 64 if ( bbp_is_user_inactive( $user_id ) ) { 65 $caps = array( 'do_not_allow' ); 66 67 // Default to the current cap. 68 } else { 69 $caps = array( $cap ); 70 71 // Bail if no post to check. 72 if ( empty( $args[0] ) ) { 73 break; 74 } 75 76 // Get the post. 77 $_post = get_post( $args[0] ); 78 if ( empty( $_post ) ) { 79 break; 80 } 81 82 // Get forum ID for specific type of post. 83 switch ( $_post->post_type ) { 84 85 // Forum. 86 case bbp_get_forum_post_type() : 87 $forum_id = $_post->ID; 88 break; 89 90 // Topic. 91 case bbp_get_topic_post_type() : 92 $forum_id = bbp_get_topic_forum_id( $_post->ID ); 93 break; 94 95 // Reply. 96 case bbp_get_reply_post_type() : 97 $forum_id = bbp_get_reply_forum_id( $_post->ID ); 98 break; 99 100 // Any other post type defaults to 0. 101 default : 102 $forum_id = 0; 103 break; 104 } 105 106 // Bail if no forum ID. 107 if ( empty( $forum_id ) ) { 108 break; 109 } 110 111 // If user is a per-forum moderator, make sure they can spectate. 112 if ( bbp_is_user_forum_mod( $user_id, $forum_id ) ) { 113 $caps = array( 'spectate' ); 114 } 39 115 } 40 116 … … 212 288 return; 213 289 } 214 290 215 291 // Bail if current user cannot promote the passing user 216 292 if ( ! current_user_can( 'promote_user', $user_id ) ) { … … 308 384 309 385 // Don't add the user, but still give them the correct caps dynamically 310 } else { 386 } else { 311 387 $bbp->current_user->caps[$new_role] = true; 312 388 $bbp->current_user->get_role_caps(); … … 671 747 * @since bbPress (r4783) 672 748 * 673 * @param int $user_id 749 * @param int $user_id 674 750 * @return bool True if keymaster, false if not 675 751 */
Note: See TracChangeset
for help on using the changeset viewer.