Skip to:
Content

BuddyPress.org

Ticket #2641: 2641.patch

File 2641.patch, 5.3 KB (added by boonebgorges, 14 years ago)
  • bp-groups/bp-groups-classes.php

     
    918918                return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );
    919919        }
    920920
    921         function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true ) {
     921        function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false ) {
    922922                global $bp, $wpdb;
    923923
    924924                if ( $limit && $page )
    925925                        $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    926926
    927927                if ( $exclude_admins_mods )
    928                         $exclude_sql = $wpdb->prepare( "AND is_admin = 0 AND is_mod = 0" );
     928                        $exclude_admins_sql = $wpdb->prepare( "AND is_admin = 0 AND is_mod = 0" );
    929929
    930930                if ( $exclude_banned )
    931931                        $banned_sql = $wpdb->prepare( " AND is_banned = 0" );
    932932
     933                if ( $exclude )
     934                        $exclude_sql = $wpdb->prepare( " AND m.user_id NOT IN ({$exclude})" );
     935
    933936                if ( bp_is_active( 'xprofile' ) )
    934                         $members = $wpdb->get_results( $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, pd.value as display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u, {$bp->profile->table_name_data} pd WHERE u.ID = m.user_id AND u.ID = pd.user_id AND pd.field_id = 1 AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) );
     937                        $members = $wpdb->get_results( $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, pd.value as display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u, {$bp->profile->table_name_data} pd WHERE u.ID = m.user_id AND u.ID = pd.user_id AND pd.field_id = 1 AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) );
    935938                else
    936                         $members = $wpdb->get_results( $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u WHERE u.ID = m.user_id AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) );
     939                        $members = $wpdb->get_results( $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u WHERE u.ID = m.user_id AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) );
    937940
    938941                if ( !$members )
    939942                        return false;
     
    941944                if ( !isset($pag_sql) )
    942945                        $total_member_count = count($members);
    943946                else
    944                         $total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql}", $group_id ) );
     947                        $total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql}", $group_id ) );
    945948
    946949                /* Fetch whether or not the user is a friend */
    947950                foreach ( (array)$members as $user ) $user_ids[] = $user->user_id;
  • bp-groups/bp-groups-templatetags.php

     
    12331233        var $pag_links;
    12341234        var $total_group_count;
    12351235
    1236         function bp_groups_group_members_template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned ) {
     1236        function bp_groups_group_members_template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude ) {
    12371237                global $bp;
    12381238
    12391239                $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1;
    12401240                $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    12411241
    1242                 $this->members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned );
     1242                $this->members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned, $exclude );
    12431243
    12441244                if ( !$max || $max >= (int)$this->members['count'] )
    12451245                        $this->total_member_count = (int)$this->members['count'];
     
    13201320                'group_id' => $bp->groups->current_group->id,
    13211321                'per_page' => 20,
    13221322                'max' => false,
     1323                'exclude' => false,
    13231324                'exclude_admins_mods' => 1,
    13241325                'exclude_banned' => 1
    13251326        );
     
    13271328        $r = wp_parse_args( $args, $defaults );
    13281329        extract( $r, EXTR_SKIP );
    13291330
    1330         $members_template = new BP_Groups_Group_Members_Template( $group_id, $per_page, $max, (int)$exclude_admins_mods, (int)$exclude_banned );
     1331        $members_template = new BP_Groups_Group_Members_Template( $group_id, $per_page, $max, (int)$exclude_admins_mods, (int)$exclude_banned, $exclude );
    13311332        return apply_filters( 'bp_group_has_members', $members_template->has_members(), &$members_template );
    13321333}
    13331334