diff --git src/bp-groups/classes/class-bp-groups-group.php src/bp-groups/classes/class-bp-groups-group.php
index 9b89695..4ef990c 100644
|
|
class BP_Groups_Group { |
1320 | 1320 | |
1321 | 1321 | if ( !empty( $user_id ) ) { |
1322 | 1322 | $user_id = absint( esc_sql( $user_id ) ); |
1323 | | $paged_groups = $wpdb->get_results( "SELECT DISTINCT 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_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} ORDER BY f.topics DESC {$pag_sql}" ); |
1324 | | $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql}" ); |
| 1323 | $paged_group_ids = $wpdb->get_results( "SELECT DISTINCT g.id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm.group_id AND (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} ORDER BY f.topics DESC {$pag_sql}" ); |
| 1324 | $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm.group_id AND (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql}" ); |
1325 | 1325 | } else { |
1326 | | $paged_groups = $wpdb->get_results( "SELECT DISTINCT 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_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} {$exclude_sql} ORDER BY f.topics DESC {$pag_sql}" ); |
1327 | | $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} {$exclude_sql}" ); |
| 1326 | $paged_group_ids = $wpdb->get_results( "SELECT DISTINCT g.id FROM {$bp->groups->table_name_groupmeta} gm, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm.group_id AND (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} {$exclude_sql} ORDER BY f.topics DESC {$pag_sql}" ); |
| 1327 | $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm.group_id AND (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} {$exclude_sql}" ); |
1328 | 1328 | } |
1329 | 1329 | |
1330 | | if ( !empty( $populate_extras ) ) { |
1331 | | foreach ( (array) $paged_groups as $group ) { |
1332 | | $group_ids[] = $group->id; |
| 1330 | $uncached_group_ids = bp_get_non_cached_ids( $paged_group_ids, 'bp_groups' ); |
| 1331 | if ( $uncached_group_ids ) { |
| 1332 | $group_ids_sql = implode( ',', array_map( 'intval', $uncached_group_ids ) ); |
| 1333 | $group_data_objects = $wpdb->get_results( "SELECT g.* FROM {$bp->groups->table_name} g WHERE g.id IN ({$group_ids_sql})" ); |
| 1334 | foreach ( $group_data_objects as $group_data_object ) { |
| 1335 | wp_cache_set( $group_data_object->id, $group_data_object, 'bp_groups' ); |
1333 | 1336 | } |
1334 | | $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' ); |
1335 | 1337 | } |
1336 | 1338 | |
1337 | | return array( 'groups' => $paged_groups, 'total' => $total_groups ); |
| 1339 | $paged_groups = array(); |
| 1340 | foreach ( $paged_group_ids as $paged_group_id ) { |
| 1341 | $paged_groups[] = new BP_Groups_Group( $paged_group_id ); |
| 1342 | } |
| 1343 | |
| 1344 | return array( 'groups' => $paged_groups, 'total' => (int) $total_groups ); |
1338 | 1345 | } |
1339 | 1346 | |
1340 | 1347 | /** |
… |
… |
class BP_Groups_Group { |
1426 | 1433 | |
1427 | 1434 | if ( !empty( $user_id ) ) { |
1428 | 1435 | $user_id = esc_sql( $user_id ); |
1429 | | $paged_groups = $wpdb->get_results( "SELECT DISTINCT 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_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} ORDER BY f.posts ASC {$pag_sql}" ); |
1430 | | $total_groups = $wpdb->get_results( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} " ); |
| 1436 | $paged_group_ids = $wpdb->get_results( "SELECT DISTINCT g.id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm.group_id AND (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} ORDER BY f.posts ASC {$pag_sql}" ); |
| 1437 | $total_groups = $wpdb->get_results( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm.group_id AND (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} " ); |
1431 | 1438 | } else { |
1432 | | $paged_groups = $wpdb->get_results( "SELECT DISTINCT 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_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} {$exclude_sql} ORDER BY f.posts ASC {$pag_sql}" ); |
1433 | | $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql} {$exclude_sql}" ); |
| 1439 | $paged_group_ids = $wpdb->get_results( "SELECT DISTINCT g.id FROM {$bp->groups->table_name_groupmeta} gm, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm.group_id AND (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} {$exclude_sql} ORDER BY f.posts ASC {$pag_sql}" ); |
| 1440 | $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm.group_id AND (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) {$hidden_sql} {$search_sql} {$exclude_sql}" ); |
1434 | 1441 | } |
1435 | 1442 | |
1436 | | if ( !empty( $populate_extras ) ) { |
1437 | | foreach ( (array) $paged_groups as $group ) { |
1438 | | $group_ids[] = $group->id; |
| 1443 | $uncached_group_ids = bp_get_non_cached_ids( $paged_group_ids, 'bp_groups' ); |
| 1444 | if ( $uncached_group_ids ) { |
| 1445 | $group_ids_sql = implode( ',', array_map( 'intval', $uncached_group_ids ) ); |
| 1446 | $group_data_objects = $wpdb->get_results( "SELECT g.* FROM {$bp->groups->table_name} g WHERE g.id IN ({$group_ids_sql})" ); |
| 1447 | foreach ( $group_data_objects as $group_data_object ) { |
| 1448 | wp_cache_set( $group_data_object->id, $group_data_object, 'bp_groups' ); |
1439 | 1449 | } |
1440 | | $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, 'newest' ); |
1441 | 1450 | } |
1442 | 1451 | |
1443 | | return array( 'groups' => $paged_groups, 'total' => $total_groups ); |
| 1452 | $paged_groups = array(); |
| 1453 | foreach ( $paged_group_ids as $paged_group_id ) { |
| 1454 | $paged_groups[] = new BP_Groups_Group( $paged_group_id ); |
| 1455 | } |
| 1456 | |
| 1457 | return array( 'groups' => $paged_groups, 'total' => (int) $total_groups ); |
1444 | 1458 | } |
1445 | 1459 | |
1446 | 1460 | /** |