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/functions.php

    r6037 r6056  
    393393                do_action( 'bbp_new_topic', $topic_id, $forum_id, $anonymous_data, $topic_author );
    394394
    395                 /** Stickies **********************************************************/
    396 
    397                 // Sticky check after 'bbp_new_topic' action so forum ID meta is set
    398                 if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array( 'stick', 'super', 'unstick' ) ) ) {
    399 
    400                         // What's the caps?
    401                         if ( current_user_can( 'moderate', $topic_id ) ) {
    402 
    403                                 // What's the haps?
    404                                 switch ( $_POST['bbp_stick_topic'] ) {
    405 
    406                                         // Sticky in this forum
    407                                         case 'stick'   :
    408                                                 bbp_stick_topic( $topic_id );
    409                                                 break;
    410 
    411                                         // Super sticky in all forums
    412                                         case 'super'   :
    413                                                 bbp_stick_topic( $topic_id, true );
    414                                                 break;
    415 
    416                                         // We can avoid this as it is a new topic
    417                                         case 'unstick' :
    418                                         default        :
    419                                                 break;
    420                                 }
    421                         }
    422                 }
    423 
    424395                /** Additional Actions (After Save) ***********************************/
    425396
    … …  
    761732                }
    762733
    763                 /** Stickies **********************************************************/
    764 
    765                 // Get the topic types
    766                 $topic_types = bbp_get_topic_types( $topic_id );
    767 
    768                 // Maybe sticky
    769                 if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array_keys( $topic_types ) ) ) {
    770 
    771                         // What's the caps?
    772                         if ( current_user_can( 'moderate', $topic_id ) ) {
    773 
    774                                 // What's the haps?
    775                                 switch ( $_POST['bbp_stick_topic'] ) {
    776 
    777                                         // Sticky in forum
    778                                         case 'stick'   :
    779                                                 bbp_stick_topic( $topic_id );
    780                                                 break;
    781 
    782                                         // Sticky in all forums
    783                                         case 'super'   :
    784                                                 bbp_stick_topic( $topic_id, true );
    785                                                 break;
    786 
    787                                         // Normal
    788                                         case 'unstick' :
    789                                         default        :
    790                                                 bbp_unstick_topic( $topic_id );
    791                                                 break;
    792                                 }
    793                         }
    794                 }
    795 
    796734                /** Additional Actions (After Save) ***********************************/
    797735
    … …  
    879817        if ( empty( $forum_id ) ) {
    880818                $forum_id = bbp_get_topic_forum_id( $topic_id );
     819        }
     820
     821        // Get the topic types
     822        $topic_types = bbp_get_topic_types( $topic_id );
     823
     824        // Sticky check after 'bbp_new_topic' action so forum ID meta is set
     825        if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array_keys( $topic_types ) ) ) {
     826
     827                // What's the caps?
     828                if ( current_user_can( 'moderate', $topic_id ) ) {
     829
     830                        // What's the haps?
     831                        switch ( $_POST['bbp_stick_topic'] ) {
     832
     833                                // Sticky in this forum
     834                                case 'stick'   :
     835                                        bbp_stick_topic( $topic_id );
     836                                        break;
     837
     838                                // Super sticky in all forums
     839                                case 'super'   :
     840                                        bbp_stick_topic( $topic_id, true );
     841                                        break;
     842
     843                                // We can avoid this as it is a new topic
     844                                case 'unstick' :
     845                                default        :
     846                                        break;
     847                        }
     848                }
    881849        }
    882850
Note: See TracChangeset for help on using the changeset viewer.