Skip to:
Content

BuddyPress.org

Ticket #6437: class-bp-groups-member.php.patch

File class-bp-groups-member.php.patch, 4.3 KB (added by lenasterg, 9 years ago)
  • src/bp-groups/classes/class-bp-groups-member.php

     
    478478
    479479                $bp = buddypress();
    480480
    481                 // If the user is logged in and viewing their own groups, we can show hidden and private groups
    482                 if ( $user_id != bp_loggedin_user_id() ) {
     481                // If the user is logged in and viewing their own groups OR the user has bp_moderate cap, we can show hidden and private groups
     482                if ( $user_id != bp_loggedin_user_id() && !bp_current_user_can( 'bp_moderate' ) ) {
    483483                        $group_sql = $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0{$pag_sql}", $user_id );
    484484                        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id ) );
    485485                } else {
     
    522522                        $filter_sql = $wpdb->prepare( " AND ( g.name LIKE %s OR g.description LIKE %s )", $search_terms_like, $search_terms_like );
    523523                }
    524524
    525                 if ( $user_id != bp_loggedin_user_id() )
     525                // If the user is logged in and viewing their own groups OR the user has bp_moderate cap,  we can show hidden and private groups
     526                if ( $user_id != bp_loggedin_user_id() && !bp_current_user_can( 'bp_moderate' ) ) {
    526527                        $hidden_sql = " AND g.status != 'hidden'";
    527 
     528}
    528529                $bp = buddypress();
    529530
    530531                $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY m.date_modified DESC {$pag_sql}" );
     
    563564                        $filter_sql = $wpdb->prepare( " AND ( g.name LIKE %s OR g.description LIKE %s )", $search_terms_like, $search_terms_like );
    564565                }
    565566
    566                 if ( $user_id != bp_loggedin_user_id() )
     567                // If the user is logged in and viewing their own groups OR the user has bp_moderate cap,  we can show hidden and private groups
     568                if ( $user_id != bp_loggedin_user_id() && !bp_current_user_can( 'bp_moderate' ) ) {
    567569                        $hidden_sql = " AND g.status != 'hidden'";
    568 
     570                }
    569571                $bp = buddypress();
    570572
    571573                $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY m.date_modified ASC {$pag_sql}" );
     
    604606                        $filter_sql = $wpdb->prepare( " AND ( g.name LIKE %s OR g.description LIKE %s )", $search_terms_like, $search_terms_like );
    605607                }
    606608
    607                 if ( $user_id != bp_loggedin_user_id() )
     609                // If the user is logged in and viewing their own groups OR the user has bp_moderate cap,  we can show hidden and private groups
     610                if ( $user_id != bp_loggedin_user_id() && !bp_current_user_can( 'bp_moderate' ) ) {
    608611                        $hidden_sql = " AND g.status != 'hidden'";
    609 
     612}
    610613                $bp = buddypress();
    611614
    612615                $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY m.date_modified ASC {$pag_sql}" );