Skip to:
Content

BuddyPress.org

Changeset 7146


Ignore:
Timestamp:
06/04/2013 03:04:33 AM (12 years ago)
Author:
boonebgorges
Message:

Updates the Groups Admin member interface to use BP_Group_Member_Query

This provides increased flexibility for fixes to be introduced for #4977

Location:
trunk/bp-groups
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/admin/js/admin.js

    r6606 r7146  
    1212    }
    1313
    14     var id = 'undefined' !== typeof group_members ? '&group_members=' + group_members : '';
     14    var id = 'undefined' !== typeof group_id ? '&group_id=' + group_id : '';
    1515    $(document).ready( function() {
    1616        /* Initialize autocomplete */
  • trunk/bp-groups/bp-groups-admin.php

    r7088 r7146  
    719719        'mod'    => array(),
    720720        'member' => array(),
    721         'banned' => array()
     721        'banned' => array(),
    722722    );
    723723
    724     if ( bp_group_has_members( array(
    725         'group_id' => $item->id,
    726         'exclude_admins_mods' => false,
    727         'exclude_banned' => false
    728     ) ) ) {
    729         // Get a list of admins and mods, to reduce lookups
    730         // We'll rekey them by user_id for convenience
    731         $admins = $mods = array();
    732 
    733         foreach ( (array) groups_get_group_admins( $item->id ) as $admin_obj ) {
    734             $admins[ $admin_obj->user_id ] = $admin_obj;
    735         }
    736 
    737         foreach ( (array) groups_get_group_mods( $item->id ) as $admin_obj ) {
    738             $mods[ $admin_obj->user_id ] = $admin_obj;
    739         }
    740 
    741         while ( bp_group_members() ) {
    742             bp_group_the_member();
    743             if ( bp_get_group_member_is_banned() ) {
    744                 $members['banned'][] = $members_template->member;
    745             } else if ( isset( $admins[ bp_get_group_member_id() ] ) ) {
    746                 $members['admin'][]  = $members_template->member;
    747             } else if ( isset( $mods[ bp_get_group_member_id() ] ) ) {
    748                 $members['mod'][]    = $members_template->member;
    749             } else {
    750                 $members['member'][] = $members_template->member;
    751             }
    752 
    753             $member_ids[] = bp_get_group_member_id();
    754         }
     724    foreach ( $members as $type => &$member_type_users ) {
     725        $member_type_query = new BP_Group_Member_Query( array(
     726            'group_id'   => $item->id,
     727            'group_role' => array( $type ),
     728            'type'       => 'alphabetical',
     729            'per_page'   => 10,
     730        ) );
     731
     732        $member_type_users = $member_type_query->results;
    755733    }
    756734
    757735    // Echo out the javascript variable
    758     $member_ids = ! empty( $member_ids ) ? implode( ',', $member_ids ) : '';
    759     echo '<script type="text/javascript">var group_members = "' . $member_ids . '";</script>';
     736    echo '<script type="text/javascript">var group_id = "' . $item->id . '";</script>';
    760737
    761738    // Loop through each member type
     
    787764
    788765                <?php foreach ( $type_users as $type_user ) : ?>
    789 
    790766                    <tr>
    791                         <th scope="row" class="uid-column"><?php echo esc_html( $type_user->user_id ); ?></th>
     767                        <th scope="row" class="uid-column"><?php echo esc_html( $type_user->ID ); ?></th>
    792768
    793769                        <td class="uname-column">
    794                             <a style="float: left;" href="<?php echo bp_core_get_user_domain( $type_user->user_id ); ?>"><?php echo bp_core_fetch_avatar( array(
    795                                 'item_id' => $type_user->user_id,
     770                            <a style="float: left;" href="<?php echo bp_core_get_user_domain( $type_user->ID ); ?>"><?php echo bp_core_fetch_avatar( array(
     771                                'item_id' => $type_user->ID,
    796772                                'width'   => '32',
    797773                                'height'  => '32'
    798774                            ) ); ?></a>
    799775
    800                             <span style="margin: 8px; float: left;"><?php echo bp_core_get_userlink( $type_user->user_id ) ?></span>
     776                            <span style="margin: 8px; float: left;"><?php echo bp_core_get_userlink( $type_user->ID ) ?></span>
    801777                        </td>
    802778
    803779                        <td class="urole-column">
    804                             <select class="bp-groups-role" id="bp-groups-role-<?php echo esc_attr( $type_user->user_id ); ?>" name="bp-groups-role[<?php echo esc_attr( $type_user->user_id ); ?>]">
     780                            <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 ); ?>]">
    805781                                <option value="admin" <?php selected( 'admin', $member_type ) ?>><?php _e( 'Administrator', 'buddypress' ) ?></option>
    806782                                <option value="mod" <?php selected( 'mod', $member_type ) ?>><?php _e( 'Moderator', 'buddypress' ) ?></option>
     
    817793                             * @todo remove this, and do database detection on save
    818794                             */ ?>
    819                             <input type="hidden" name="bp-groups-existing-role[<?php echo esc_attr( $type_user->user_id ); ?>]" value="<?php echo esc_attr( $member_type ); ?>" />
     795                            <input type="hidden" name="bp-groups-existing-role[<?php echo esc_attr( $type_user->ID ); ?>]" value="<?php echo esc_attr( $member_type ); ?>" />
    820796                        </td>
    821797                    </tr>
     
    824800                        <tr>
    825801                            <td colspan="3">
    826                                 <?php do_action( 'bp_groups_admin_manage_member_row', $type_user->user_id, $item ); ?>
     802                                <?php do_action( 'bp_groups_admin_manage_member_row', $type_user->ID, $item ); ?>
    827803                            </td>
    828804                        </tr>
     
    905881
    906882    // Exclude current group members
    907     $group_members = isset( $_REQUEST['group_members'] ) ? wp_parse_id_list( $_REQUEST['group_members'] ) : array();
    908     $terms         = isset( $_REQUEST['term']          ) ? $_REQUEST['term'] : '';
    909     $users         = get_users( array(
     883    $group_id = isset( $_GET['group_id'] ) ? wp_parse_id_list( $_GET['group_id'] ) : array();
     884    $group_member_query = new BP_Group_Member_Query( array(
     885        'group_id'        => $group_id,
     886        'per_page'        => 0, // show all
     887        'group_type'      => array( 'member', 'mod', 'admin', ),
     888        'populate_extras' => false,
     889        'count_total'     => false,
     890    ) );
     891
     892    $group_members = ! empty( $group_member_query->results ) ? wp_list_pluck( $group_member_query->results, 'ID' ) : array();
     893
     894    $terms = isset( $_GET['term'] ) ? $_GET['term'] : '';
     895    $users = get_users( array(
    910896        'blog_id'        => false,
    911897        'search'         => '*' . $terms . '*',
Note: See TracChangeset for help on using the changeset viewer.