Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/21/2010 11:19:32 AM (14 years ago)
Author:
apeatling
Message:

Fixed issues with the listing of hidden groups when you are logged in. Switched all references of bp_is_home() to the more appropriate bp_is_my_profile().

File:
1 edited

Legend:

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

    r2352 r2389  
    345345            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    346346
    347         if ( !is_site_admin() )
     347        if ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) )
    348348            $hidden_sql = "AND g.status != 'hidden'";
    349349
     
    371371        }
    372372
    373         if ( !is_site_admin() )
     373        if ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) )
    374374            $hidden_sql = "AND g.status != 'hidden'";
    375375
     
    396396            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    397397
    398         if ( !is_site_admin() )
     398        if ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) )
    399399            $hidden_sql = " AND g.status != 'hidden'";
    400400
     
    425425        }
    426426
     427        if ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) )
     428            $hidden_sql = " AND g.status != 'hidden'";
     429
    427430        if ( $search_terms ) {
    428431            $search_terms = like_escape( $wpdb->escape( $search_terms ) );
     
    450453            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    451454        }
     455
     456        if ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) )
     457            $hidden_sql = " AND g.status != 'hidden'";
    452458
    453459        if ( $search_terms ) {
     
    566572        global $wpdb, $bp;
    567573
    568         return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name}" ) );
     574        if ( !is_site_admin() )
     575            $hidden_sql = "WHERE status != 'hidden'";
     576
     577        return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql}" ) );
    569578    }
    570579
     
    751760
    752761        // If the user is logged in and viewing their own groups, we can show hidden and private groupss
    753         if ( bp_is_home() ) {
     762        if ( $user_id != $bp->loggedin_user->id ) {
    754763            $group_sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0{$pag_sql}", $user_id );
    755764            $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) );
     
    775784        }
    776785
    777         if ( !bp_is_home() )
     786        if ( $user_id != $bp->loggedin_user->id )
    778787            $hidden_sql = " AND g.status != 'hidden'";
    779788
     
    795804        }
    796805
    797         if ( !bp_is_home() )
     806        if ( $user_id != $bp->loggedin_user->id )
    798807            $hidden_sql = " AND g.status != 'hidden'";
    799808
     
    815824        }
    816825
    817         if ( !bp_is_home() )
     826        if ( $user_id != $bp->loggedin_user->id )
    818827            $hidden_sql = " AND g.status != 'hidden'";
    819828
     
    830839            $user_id = $bp->displayed_user->id;
    831840
    832         if ( bp_is_home() ) {
    833             return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) );
    834         } else {
     841        if ( $user_id != $bp->loggedin_user->id && !is_site_admin() ) {
    835842            return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
     843        } else {
     844            return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
    836845        }
    837846    }
     
    924933
    925934        // If the user is logged in and viewing their random groups, we can show hidden and private groups
    926         if ( bp_is_home() ) {
     935        if ( bp_is_my_profile() ) {
    927936            return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
    928937        } else {
Note: See TracChangeset for help on using the changeset viewer.