Skip to:
Content

BuddyPress.org

Changeset 8421


Ignore:
Timestamp:
05/16/2014 09:32:19 AM (11 years ago)
Author:
johnjamesjacoby
Message:

Group Admin: Updates to bp_groups_admin_edit_metabox_members():

  • Separate member roles and actions into option groups.
  • Add a bit more intelligence to Ban action VS Banned role.
  • Escape for JS and Gettext output where appropriate.
  • General whitespace clean-up.

See #5645.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-admin.php

    r8417 r8421  
    732732 */
    733733function bp_groups_admin_edit_metabox_members( $item ) {
    734     global $members_template;
    735734
    736735    // Pull up a list of group members, so we can separate out the types
     
    752751
    753752    foreach ( $members as $type => &$member_type_users ) {
    754         $page_qs_key = $type . '_page';
     753        $page_qs_key       = $type . '_page';
    755754        $current_type_page = isset( $_GET[ $page_qs_key ] ) ? absint( $_GET[ $page_qs_key ] ) : 1;
    756755        $member_type_query = new BP_Group_Member_Query( array(
     
    762761        ) );
    763762
    764         $member_type_users = $member_type_query->results;
    765 
     763        $member_type_users   = $member_type_query->results;
    766764        $pagination[ $type ] = bp_groups_admin_create_pagination_links( $member_type_query, $type );
    767765    }
    768766
    769767    // Echo out the javascript variable
    770     echo '<script type="text/javascript">var group_id = "' . $item->id . '";</script>';
     768    echo '<script type="text/javascript">var group_id = "' . esc_js( $item->id ) . '";</script>';
    771769
    772770    // Loop through each member type
     
    775773        <div class="bp-groups-member-type" id="bp-groups-member-type-<?php echo esc_attr( $member_type ) ?>">
    776774
    777             <h4>
    778                 <?php switch ( $member_type ) :
    779                     case 'admin'  : _e( 'Administrators', 'buddypress' ); break;
    780                     case 'mod'    : _e( 'Moderators',     'buddypress' ); break;
    781                     case 'member' : _e( 'Members',        'buddypress' ); break;
    782                     case 'banned' : _e( 'Banned Users',   'buddypress' ); break;
    783                 endswitch; ?>
    784             </h4>
     775            <h4><?php switch ( $member_type ) :
     776                    case 'admin'  : esc_html_e( 'Administrators', 'buddypress' ); break;
     777                    case 'mod'    : esc_html_e( 'Moderators',     'buddypress' ); break;
     778                    case 'member' : esc_html_e( 'Members',        'buddypress' ); break;
     779                    case 'banned' : esc_html_e( 'Banned Members', 'buddypress' ); break;
     780            endswitch; ?></h4>
    785781
    786782            <div class="bp-group-admin-pagination table-top">
     
    792788            <table class="widefat bp-group-members">
    793789                <thead>
    794                 <tr>
    795                     <th scope="col" class="uid-column"><?php _ex( 'ID', 'Group member user_id in group admin', 'buddypress' ) ?></th>
    796                     <th scope="col" class="uname-column"><?php _ex( 'Name', 'Group member name in group admin', 'buddypress' ) ?></th>
    797                     <th scope="col" class="urole-column"><?php _ex( 'Group Role', 'Group member role in group admin', 'buddypress' ) ?></th>
    798                 </tr>
     790                    <tr>
     791                        <th scope="col" class="uid-column"><?php _ex( 'ID', 'Group member user_id in group admin', 'buddypress' ); ?></th>
     792                        <th scope="col" class="uname-column"><?php _ex( 'Name', 'Group member name in group admin', 'buddypress' ); ?></th>
     793                        <th scope="col" class="urole-column"><?php _ex( 'Group Role', 'Group member role in group admin', 'buddypress' ); ?></th>
     794                    </tr>
    799795                </thead>
    800796
     
    812808                            ) ); ?></a>
    813809
    814                             <span style="margin: 8px; float: left;"><?php echo bp_core_get_userlink( $type_user->ID ) ?></span>
     810                            <span style="margin: 8px; float: left;"><?php echo bp_core_get_userlink( $type_user->ID ); ?></span>
    815811                        </td>
    816812
    817813                        <td class="urole-column">
    818814                            <select class="bp-groups-role" id="bp-groups-role-<?php echo esc_attr( $type_user->ID ); ?>" name="bp-groups-role[<?php echo esc_attr( $type_user->ID ); ?>]">
    819                                 <option value="admin" <?php selected( 'admin', $member_type ) ?>><?php _e( 'Administrator', 'buddypress' ) ?></option>
    820                                 <option value="mod" <?php selected( 'mod', $member_type ) ?>><?php _e( 'Moderator', 'buddypress' ) ?></option>
    821                                 <option value="member" <?php selected( 'member', $member_type ) ?>><?php _e( 'Member', 'buddypress' ) ?></option>
    822                                 <option class="banned" value="banned" <?php selected( 'banned', $member_type ) ?>><?php _e( 'Banned', 'buddypress' ) ?></option>
    823                                 <option class="remove" value="remove"><?php _e( 'Remove From Group', 'buddypress' ) ?></option>
     815                                <optgroup label="<?php esc_attr_e( 'Roles', 'buddypress' ); ?>">
     816                                    <option class="admin"  value="admin"  <?php selected( 'admin',  $member_type ); ?>><?php esc_html_e( 'Administrator', 'buddypress' ); ?></option>
     817                                    <option class="mod"    value="mod"    <?php selected( 'mod',    $member_type ); ?>><?php esc_html_e( 'Moderator',     'buddypress' ); ?></option>
     818                                    <option class="member" value="member" <?php selected( 'member', $member_type ); ?>><?php esc_html_e( 'Member',        'buddypress' ); ?></option>
     819                                    <?php if ( 'banned' === $member_type ) : ?>
     820                                    <option class="banned" value="banned" <?php selected( 'banned', $member_type ); ?>><?php esc_html_e( 'Banned',        'buddypress' ); ?></option>
     821                                    <?php endif; ?>
     822                                </optgroup>
     823                                <optgroup label="<?php esc_attr_e( 'Actions', 'buddypress' ); ?>">
     824                                    <option class="remove" value="remove"><?php esc_html_e( 'Remove', 'buddypress' ); ?></option>
     825                                    <?php if ( 'banned' !== $member_type ) : ?>
     826                                        <option class="banned" value="banned"><?php esc_html_e( 'Ban', 'buddypress' ); ?></option>
     827                                    <?php endif; ?>
     828                                </optgroup>
    824829                            </select>
    825830
     
    830835                             *
    831836                             * @todo remove this, and do database detection on save
    832                              */ ?>
     837                             */
     838                            ?>
    833839                            <input type="hidden" name="bp-groups-existing-role[<?php echo esc_attr( $type_user->ID ); ?>]" value="<?php echo esc_attr( $member_type ); ?>" />
    834840                        </td>
     
    849855
    850856            <div class="bp-group-admin-pagination table-bottom">
    851                 <?php echo $pagination[ $member_type ] ?>
     857                <?php echo $pagination[ $member_type ]; ?>
    852858            </div>
    853859
    854860        <?php else : ?>
    855861
    856             <p class="bp-groups-no-members description"><?php _e( 'No members of this type', 'buddypress' ) ?></p>
     862            <p class="bp-groups-no-members description"><?php esc_html_e( 'No members of this type', 'buddypress' ); ?></p>
    857863
    858864        <?php endif; ?>
     
    861867
    862868    <?php endforeach;
    863 
    864869}
    865870
Note: See TracChangeset for help on using the changeset viewer.