Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/05/2016 06:27:54 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Moderators: Refactor per-forum moderators to use meta-data instead of mocked taxonomy terms.

If the future of Forums is a taxonomy (vs. a custom post-type) then a per-forum Moderator taxonomy for a Forum taxonomy won't work very well, for a few reasons:

  • Scalability
  • Taxonomies for taxonomies is a bit more inception than should be required for this simple feature
  • Forum moderators do not require much of what taxonomy objects provide (permalinks, visibility, metadata, etc...)
  • User taxonomy terms matching nicenames works okay for something like Automattic's P2 theme, but bbPress requires a user ID based solution to avoid data synchronization issues between nicenames & term slugs

So... the future of per-forum per-user capability mappings is in meta-data using map_meta_cap.

This commit:

  • Removes the forum_mod taxonomy and surrounding code additions introduced in the first pass in r5834
  • Renames forum_mod functions to forum_moderator to be more explicit
  • Adds CRUD wrapper functions for per-forum moderator meta data
  • Adds administrative interfaces for assigning moderators to forums for wp-admin and forum edit pages
  • Adds helper functions for getting user nicenames & IDs

Note that this feature has now been refactored to no longer be forum specific (I.E. object agnostic) -- it's possible for any user access to be mapped based on the object type using any meta-data key. While this is currently useful for per-forum moderators, it may be user for per-topic blocking, per-topic-tag moderation, etc...

See #459.

File:
1 edited

Legend:

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

    r5951 r6056  
    5959 * @uses get_post_type_object() To get the post type object
    6060 * @uses bbp_get_public_status_id() To get the  public status id
    61  * @uses bbp_is_user_forum_mod() To check if the user is a forum moderator
     61 * @uses bbp_is_user_forum_moderator() To check if the user is a forum moderator
    6262 * @uses bbp_get_topic_forum_id() To get the opic forum id
    6363 * @uses apply_filters() Filter capability map results
     
    156156
    157157                    // If user is a per-forum moderator, make sure they can spectate.
    158                     if ( bbp_is_user_forum_mod( $user_id, bbp_get_topic_forum_id( $_post->ID ) ) ) {
     158                    if ( bbp_is_user_forum_moderator( $user_id, bbp_get_topic_forum_id( $_post->ID ) ) ) {
    159159                        $caps = array( 'spectate' );
    160160
Note: See TracChangeset for help on using the changeset viewer.