Skip to:
Content

BuddyPress.org

Changeset 7053


Ignore:
Timestamp:
05/11/2013 11:42:40 AM (11 years ago)
Author:
boonebgorges
Message:

Whitespace and bracket normalization in BP_Groups_Group::get()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-classes.php

    r7052 r7053  
    353353        $sql['from']   = " FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2,";
    354354
    355         if ( !empty( $r['user_id'] ) )
     355        if ( ! empty( $r['user_id'] ) ) {
    356356            $sql['members_from'] = " {$bp->groups->table_name_members} m,";
     357        }
    357358
    358359        $sql['group_from'] = " {$bp->groups->table_name} g WHERE";
    359360
    360         if ( !empty( $r['user_id'] ) )
     361        if ( ! empty( $r['user_id'] ) ) {
    361362            $sql['user_where'] = " g.id = m.group_id AND";
     363        }
    362364
    363365        $sql['where'] = " g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'";
    364366
    365         if ( empty( $r['show_hidden'] ) )
     367        if ( empty( $r['show_hidden'] ) ) {
    366368            $sql['hidden'] = " AND g.status != 'hidden'";
    367 
    368         if ( !empty( $r['search_terms'] ) ) {
     369        }
     370
     371        if ( ! empty( $r['search_terms'] ) ) {
    369372            $search_terms = esc_sql( like_escape( $r['search_terms'] ) );
    370373            $sql['search'] = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
     
    382385        }
    383386
    384         if ( !empty( $r['user_id'] ) )
     387        if ( ! empty( $r['user_id'] ) ) {
    385388            $sql['user'] = $wpdb->prepare( " AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $r['user_id'] );
    386 
    387         if ( !empty( $r['include'] ) ) {
     389        }
     390
     391        if ( ! empty( $r['include'] ) ) {
    388392            $include        = wp_parse_id_list( $r['include'] );
    389393            $include        = $wpdb->escape( implode( ',', $include ) );
     
    391395        }
    392396
    393         if ( !empty( $r['exclude'] ) ) {
     397        if ( ! empty( $r['exclude'] ) ) {
    394398            $exclude        = wp_parse_id_list( $r['exclude'] );
    395399            $exclude        = $wpdb->escape( implode( ',', $exclude ) );
     
    398402
    399403        switch ( $r['type'] ) {
    400             case 'newest': default:
     404            case 'newest':
     405            default:
    401406                $sql['order'] = " ORDER BY g.date_created DESC";
    402407                break;
     
    415420        }
    416421
    417         if ( !empty( $r['per_page'] ) && !empty( $r['page'] ) )
     422        if ( ! empty( $r['per_page'] ) && ! empty( $r['page'] ) ) {
    418423            $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $r['page'] - 1 ) * $r['per_page']), intval( $r['per_page'] ) );
     424        }
    419425
    420426        // Get paginated results
     
    424430        $total_sql['select'] = "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name} g, {$bp->groups->table_name_members} gm1, {$bp->groups->table_name_groupmeta} gm2";
    425431
    426         if ( !empty( $r['user_id'] ) )
     432        if ( ! empty( $r['user_id'] ) ) {
    427433            $total_sql['select'] .= ", {$bp->groups->table_name_members} m";
    428 
    429         if ( !empty( $sql['hidden'] ) )
     434        }
     435
     436        if ( ! empty( $sql['hidden'] ) ) {
    430437            $total_sql['where'][] = "g.status != 'hidden'";
    431 
    432         if ( !empty( $sql['search'] ) )
     438        }
     439
     440        if ( ! empty( $sql['search'] ) ) {
    433441            $total_sql['where'][] = "( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
    434 
    435         if ( !empty( $r['user_id'] ) )
     442        }
     443
     444        if ( ! empty( $r['user_id'] ) ) {
    436445            $total_sql['where'][] = "m.group_id = g.id AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0";
     446        }
    437447
    438448        // Already escaped in the paginated results block
    439         if ( ! empty( $include ) )
     449        if ( ! empty( $include ) ) {
    440450            $total_sql['where'][] = "g.id IN ({$include})";
     451        }
    441452
    442453        // Already escaped in the paginated results block
    443         if ( ! empty( $exclude ) )
     454        if ( ! empty( $exclude ) ) {
    444455            $total_sql['where'][] = "g.id NOT IN ({$exclude})";
     456        }
    445457
    446458        $total_sql['where'][] = "g.id = gm1.group_id";
     
    450462        $t_sql = $total_sql['select'];
    451463
    452         if ( !empty( $total_sql['where'] ) )
     464        if ( ! empty( $total_sql['where'] ) ) {
    453465            $t_sql .= " WHERE " . join( ' AND ', (array) $total_sql['where'] );
     466        }
    454467
    455468        // Get total group results
Note: See TracChangeset for help on using the changeset viewer.