Skip to:
Content

BuddyPress.org

Changeset 2119


Ignore:
Timestamp:
11/25/2009 10:26:14 AM (15 years ago)
Author:
apeatling
Message:

Fixes #1284 props MrMaz.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1/bp-groups/bp-groups-classes.php

    r2103 r2119  
    422422        global $wpdb, $bp;
    423423
     424        // Default sql WHERE conditions are blank. TODO: generic handler function.
     425        $where_sql = null;
     426        $where_conditions = array();
     427
     428        // Limit results to public status
    424429        if ( $only_public )
    425             $public_sql = $wpdb->prepare( " AND g.status = 'public'" );
     430            $where_conditions[] = $wpdb->prepare( "g.status = 'public'" );
    426431
    427432        if ( !is_site_admin() )
    428             $hidden_sql = $wpdb->prepare( " AND g.status != 'hidden'");
     433            $where_conditions[] = $wpdb->prepare( "g.status != 'hidden'");
     434
     435        // Build where sql statement if necessary
     436        if ( !empty( $where_conditions ) )
     437            $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
    429438
    430439        if ( $limit && $page )
     
    438447            switch ( $sort_by ) {
    439448                default:
    440                     $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g WHERE 1=1 {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" );
     449                    $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" );
    441450                    break;
    442451                case 'members':
     
    448457            }
    449458        } else {
    450             $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" );
     459            $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" );
    451460        }
    452461
Note: See TracChangeset for help on using the changeset viewer.