Skip to:
Content

bbPress.org

Changeset 2783


Ignore:
Timestamp:
01/09/2011 09:41:41 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Map read_ caps for forums/topics/replies. Also revert r2779 since we remove the moderator role completely. Props GautamGupta via Google Code-in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-caps.php

    r2779 r2783  
    179179        $admin->remove_cap( 'throttle'              );
    180180        $admin->remove_cap( 'view_trash'            );
    181     }
    182 
    183     // Remove caps from moderator role
    184     if ( $mod =& get_role( 'bbp_moderator' ) ) {
    185 
    186         // Topic caps
    187         $mod->remove_cap( 'publish_topics'        );
    188         $mod->remove_cap( 'edit_topics'           );
    189         $mod->remove_cap( 'edit_others_topics'    );
    190         $mod->remove_cap( 'delete_topics'         );
    191         $mod->remove_cap( 'delete_others_topics'  );
    192         $mod->remove_cap( 'read_private_topics'   );
    193 
    194         // Reply caps
    195         $mod->remove_cap( 'publish_replies'       );
    196         $mod->remove_cap( 'edit_replies'          );
    197         $mod->remove_cap( 'edit_others_replies'   );
    198         $mod->remove_cap( 'delete_replies'        );
    199         $mod->remove_cap( 'delete_others_replies' );
    200         $mod->remove_cap( 'read_private_replies'  );
    201 
    202         // Topic tag caps
    203         $mod->remove_cap( 'manage_topic_tags'     );
    204         $mod->remove_cap( 'edit_topic_tags'       );
    205         $mod->remove_cap( 'delete_topic_tags'     );
    206         $mod->remove_cap( 'assign_topic_tags'     );
    207 
    208         // Users
    209         $mod->remove_cap( 'edit_users'            );
    210 
    211         // Misc
    212         $mod->remove_cap( 'moderate'              );
    213         $mod->remove_cap( 'throttle'              );
    214         $mod->remove_cap( 'view_trash'            );
    215181    }
    216182
     
    268234
    269235    switch ( $cap ) {
     236        case 'read_forum' :
     237        case 'read_topic' :
     238        case 'read_reply' :
     239
     240            if ( $post = get_post( $args[0] ) ) {
     241                $caps      = array();
     242                $post_type = get_post_type_object( $post->post_type );
     243
     244                if ( 'private' != $post->post_status )
     245                    $caps[] = 'read';
     246                elseif ( (int) $user_id == (int) $post->post_author )
     247                    $caps[] = 'read';
     248                else
     249                    $caps[] = $post_type->cap->read_private_posts;
     250            }
     251
     252            break;
     253
    270254        case 'edit_forum' :
    271255        case 'edit_topic' :
     
    276260                $post_type = get_post_type_object( $post->post_type );
    277261
    278                 if ( (int)$user_id == (int)$post->post_author )
     262                if ( (int) $user_id == (int) $post->post_author )
    279263                    $caps[] = $post_type->cap->edit_posts;
    280264                else
     
    290274                $post_type = get_post_type_object( $post->post_type );
    291275
    292                 if ( (int)$user_id == (int) $post->post_author )
     276                if ( (int) $user_id == (int) $post->post_author )
    293277                    $caps[] = $post_type->cap->delete_posts;
    294278                else
Note: See TracChangeset for help on using the changeset viewer.