Changeset 2119
- Timestamp:
- 11/25/2009 10:26:14 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1/bp-groups/bp-groups-classes.php
r2103 r2119 422 422 global $wpdb, $bp; 423 423 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 424 429 if ( $only_public ) 425 $ public_sql = $wpdb->prepare( " ANDg.status = 'public'" );430 $where_conditions[] = $wpdb->prepare( "g.status = 'public'" ); 426 431 427 432 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 ); 429 438 430 439 if ( $limit && $page ) … … 438 447 switch ( $sort_by ) { 439 448 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}" ); 441 450 break; 442 451 case 'members': … … 448 457 } 449 458 } 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}" ); 451 460 } 452 461
Note: See TracChangeset
for help on using the changeset viewer.