Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/15/2015 03:59:23 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Moderators: First pass at per-forum moderators.

This commit introduces a powerful feature commonly found in other popular forum software that has been on our wishlist for nearly 9 years. It includes the following changes:

  • Custom forum-mod taxonomy for assigning user nicenames to forum IDs
  • Associated functions for defining capabilities, labels, etc...
  • New capability filters for ensuring forum moderators have the ability to moderate forums even without the moderator role assignment
  • New option for toggling the entire feature on/off (on by default)

Props jmdodd, netweb. See #459.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/replies/capabilities.php

    r5829 r5834  
    4040 * @uses get_post() To get the post
    4141 * @uses get_post_type_object() To get the post type object
     42 * @uses bbp_get_public_status_id() To get the public status id
     43 * @uses bbp_is_user_forum_mod() To check if the user is a forum moderator
     44 * @uses bbp_get_reply_forum_id() To get the repliy forum id
    4245 * @uses apply_filters() Filter mapped results
     46 *
    4347 * @return array Actual capabilities for meta capability
    4448 */
     
    6367                if ( ! empty( $_post ) ) {
    6468
    65                     // Get caps for post type object
     69                    // Get post type object
    6670                    $post_type = get_post_type_object( $_post->post_type );
    6771
     
    118122            if ( ! empty( $_post ) ) {
    119123
    120                 // Get caps for post type object
     124                // Get post type object
    121125                $post_type = get_post_type_object( $_post->post_type );
    122126                $caps      = array();
     
    127131
    128132                // User is author so allow edit if not in admin
    129                 } elseif ( !is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) {
     133                } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) {
    130134                    $caps[] = $post_type->cap->edit_posts;
    131135
    132                 // Unknown, so map to edit_others_posts
     136                // User is a per-forum moderator, make sure they can spectate.
     137                } elseif ( bbp_allow_forum_mods() && bbp_is_user_forum_mod( $user_id, bbp_get_reply_forum_id( $_post->ID ) ) ) {
     138                    $caps = array( 'spectate' );
     139
     140                // Fallback to edit_others_posts.
    133141                } else {
    134142                    $caps[] = $post_type->cap->edit_others_posts;
     
    146154            if ( ! empty( $_post ) ) {
    147155
    148                 // Get caps for post type object
     156                // Get post type object
    149157                $post_type = get_post_type_object( $_post->post_type );
    150158                $caps      = array();
Note: See TracChangeset for help on using the changeset viewer.