Skip to:
Content

bbPress.org

Changeset 4301


Ignore:
Timestamp:
11/02/2012 07:25:11 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Capabilities:

  • Update BBP_User_Admin to use roles UI instead of capabilities.
  • Leave capabilities in for now, but hidden behind a switch function.
  • See #1939.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/users.php

    r4279 r4301  
    4747            return;
    4848
    49         // Admin styles
    50         add_action( 'admin_head',        array( $this, 'admin_head'          ) );
    51 
    5249        // User profile edit/display actions
    53         add_action( 'edit_user_profile', array( $this, 'user_profile_forums' ) );
    54 
    55         // Noop WordPress additional caps output area
    56         add_filter( 'additional_capabilities_display', '__return_false' );
     50        add_action( 'edit_user_profile', array( $this, 'secondary_role_display' ) );
     51
     52        // Show advanced capabilities
     53        if ( bbp_use_advanced_capability_editor() ) {
     54
     55            // Admin styles
     56            add_action( 'admin_head',        array( $this, 'admin_head' ) );
     57
     58            // User profile edit/display actions
     59            add_action( 'edit_user_profile', array( $this, 'advanced_capability_display' ) );
     60
     61            // Noop WordPress additional caps output area
     62            add_filter( 'additional_capabilities_display', '__return_false' );
     63        }
    5764    }
    5865
     
    93100
    94101    /**
    95      * Responsible for saving additional profile options and settings
     102     * Default interface for setting a forum role
     103     *
     104     * @since bbPress (r4285)
     105     *
     106     * @param WP_User $profileuser User data
     107     * @return bool Always false
     108     */
     109    public function secondary_role_display( $profileuser ) {
     110
     111        // Bail if current user cannot edit users
     112        if ( ! current_user_can( 'edit_user', $profileuser->ID ) )
     113            return; ?>
     114
     115        <h3><?php _e( 'Forums', 'bbpress' ); ?></h3>
     116
     117        <table class="form-table">
     118            <tbody>
     119                <tr>
     120                    <th><?php _e( 'Forum Role', 'bbpress' ); ?></th>
     121                    <td>
     122
     123                        <?php $user_role = bbp_get_user_role( $profileuser->ID ); ?>
     124
     125                        <select name="bbp-forums-role" id="bbp-forums-role">
     126
     127                            <?php if ( ! empty( $user_role ) ) : ?>
     128
     129                                <option value=""><?php _e( '&mdash; No role for this forum &mdash;', 'bbpress' ); ?></option>
     130
     131                            <?php else : ?>
     132
     133                                <option value="" selected="selected"><?php _e( '&mdash; No role for this forum &mdash;', 'bbpress' ); ?></option>
     134
     135                            <?php endif; ?>
     136
     137                            <?php foreach ( bbp_get_editable_roles() as $role => $details ) : ?>
     138
     139                                <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>
     140
     141                            <?php endforeach; ?>
     142
     143                        </select>
     144                    </td>
     145                </tr>
     146
     147            </tbody>
     148        </table>
     149
     150        <?php
     151    }
     152
     153    /**
     154     * Responsible for displaying bbPress's advanced capability interface.
     155     *
     156     * Hidden by default. Must be explicitly enabled.
    96157     *
    97158     * @since bbPress (r2464)
     
    101162     * @return bool Always false
    102163     */
    103     public function user_profile_forums( $profileuser ) {
     164    public function advanced_capability_display( $profileuser ) {
    104165
    105166        // Bail if current user cannot edit users
    106167        if ( ! current_user_can( 'edit_user', $profileuser->ID ) )
    107168            return; ?>
    108 
    109         <h3><?php _e( 'Forum Capabilities', 'bbpress' ); ?></h3>
    110169
    111170        <table class="form-table">
Note: See TracChangeset for help on using the changeset viewer.