Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/07/2012 08:04:06 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Capabilities:

  • Remove most capability mappings to 'participate' cap.
  • Update bbp_set_current_user_default_role() to dynamically map a logged in user if global access is turned off.
  • Provides alternative to users being granted a database role without taking any action.
  • This makes bbPress work similarly to comments, though a decision needs to be made regarding profile pages for these "anonymous" users.
File:
1 edited

Legend:

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

    r4330 r4349  
    33/**
    44 * bbPress Topic Capabilites
    5  * 
     5 *
    66 * Used to map topic capabilities to WordPress's existing capabilities.
    77 *
     
    7171
    7272            // User cannot participate
    73             if ( ! user_can( $user_id, 'participate' ) ) {
     73            if ( ! user_can( $user_id, 'spectate' ) ) {
    7474                $caps = array( 'do_not_allow' );
    7575
    7676            // Do some post ID based logic
    7777            } else {
    78            
     78
    7979                // Get the post
    8080                $_post = get_post( $args[0] );
     
    8686                    // Post is public
    8787                    if ( bbp_get_public_status_id() == $_post->post_status ) {
    88                         $caps = array( 'particpate' );
     88                        $caps = array( 'spectate' );
    8989
    9090                    // User is author so allow read
    9191                    } elseif ( (int) $user_id == (int) $_post->post_author ) {
    92                         $caps = array( 'participate' );
     92                        $caps = array( 'spectate' );
    9393
    9494                    // Unknown so map to private posts
     
    105105        case 'publish_topics'  :
    106106
    107             // Non participants cannot participate
    108             if ( ! user_can( $user_id, 'participate' ) ) {
    109                 $caps = array( 'do_not_allow' );
    110 
    111107            // Moderators can always publish
    112             } elseif ( user_can( $user_id, 'moderate' ) ) {
    113                 $caps = array( $cap );
     108            if ( user_can( $user_id, 'moderate' ) ) {
     109                $caps = array( 'moderate' );
    114110            }
    115111
     
    122118        case 'edit_others_topics' :
    123119
    124             // Non participants cannot manage content
    125             if ( ! user_can( $user_id, 'participate' ) ) {
    126                 $caps = array( 'do_not_allow' );
    127 
    128120            // Moderators can always edit
    129             } elseif ( user_can( $user_id, 'moderate' ) ) {
     121            if ( user_can( $user_id, 'moderate' ) ) {
    130122                $caps = array( $cap );
    131123            }
     
    178170                // Moderators can always edit forum content
    179171                } elseif ( user_can( $user_id, 'moderate' ) ) {
    180                     $caps[] = 'participate';
     172                    $caps[] = 'moderate';
    181173
    182174                // Unknown so map to delete_others_posts
     
    187179
    188180            break;
    189            
     181
    190182        // Moderation override
    191183        case 'delete_topics'         :
    192184        case 'delete_others_topics'  :
    193185
    194             // Non participants cannot manage content
    195             if ( ! user_can( $user_id, 'participate' ) ) {
    196                 $caps = array( 'do_not_allow' );
    197 
    198186            // Moderators can always delete
    199             } elseif ( user_can( $user_id, 'moderate' ) ) {
     187            if ( user_can( $user_id, 'moderate' ) ) {
    200188                $caps = array( $cap );
    201189            }
    202190
    203191            break;
    204            
     192
    205193        /** Admin *************************************************************/
    206194
     
    229217    // What capability is being checked?
    230218    switch ( $cap ) {
    231         case 'manage_topic_tags' :
    232         case 'edit_topic_tags'   :
    233         case 'delete_topic_tags' :
    234         case 'assign_topic_tags' :
    235 
    236             // Non participants cannot manage content
    237             if ( ! user_can( $user_id, 'participate' ) ) {
    238                 $caps = array( 'do_not_allow' );
     219        case 'manage_topic_tags'    :
     220        case 'edit_topic_tags'      :
     221        case 'delete_topic_tags'    :
     222        case 'assign_topic_tags'    :
     223        case 'bbp_topic_tags_admin' :
    239224
    240225            // Moderators can always edit
    241             } elseif ( user_can( $user_id, 'moderate' ) ) {
    242                 $caps = array( $cap );
    243             }
    244 
    245             break;
    246 
    247         case 'bbp_topic_tags_admin' :
    248             $caps = array( 'moderate' );
     226            if ( user_can( $user_id, 'moderate' ) ) {
     227                $caps = array( 'moderate' );
     228            }
    249229    }
    250230
Note: See TracChangeset for help on using the changeset viewer.