Changeset 7052
- Timestamp:
- 05/11/2013 11:42:36 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-classes.php
r7021 r7052 346 346 347 347 $r = wp_parse_args( $args, $defaults ); 348 extract( $r );349 348 350 349 $sql = array(); … … 354 353 $sql['from'] = " FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2,"; 355 354 356 if ( !empty( $ user_id) )355 if ( !empty( $r['user_id'] ) ) 357 356 $sql['members_from'] = " {$bp->groups->table_name_members} m,"; 358 357 359 358 $sql['group_from'] = " {$bp->groups->table_name} g WHERE"; 360 359 361 if ( !empty( $ user_id) )360 if ( !empty( $r['user_id'] ) ) 362 361 $sql['user_where'] = " g.id = m.group_id AND"; 363 362 364 363 $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'"; 365 364 366 if ( empty( $ show_hidden) )365 if ( empty( $r['show_hidden'] ) ) 367 366 $sql['hidden'] = " AND g.status != 'hidden'"; 368 367 369 if ( !empty( $ search_terms) ) {370 $search_terms = esc_sql( like_escape( $ search_terms) );368 if ( !empty( $r['search_terms'] ) ) { 369 $search_terms = esc_sql( like_escape( $r['search_terms'] ) ); 371 370 $sql['search'] = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 372 371 } 373 372 374 $meta_query_sql = self::get_meta_query_sql( $ meta_query);373 $meta_query_sql = self::get_meta_query_sql( $r['meta_query'] ); 375 374 376 375 if ( ! empty( $meta_query_sql['join'] ) ) { … … 383 382 } 384 383 385 if ( !empty( $ user_id) )386 $sql['user'] = $wpdb->prepare( " AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $ user_id);387 388 if ( !empty( $ include) ) {384 if ( !empty( $r['user_id'] ) ) 385 $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 388 $include = wp_parse_id_list( $r['include'] ); 390 389 $include = $wpdb->escape( implode( ',', $include ) ); … … 392 391 } 393 392 394 if ( !empty( $ exclude) ) {393 if ( !empty( $r['exclude'] ) ) { 395 394 $exclude = wp_parse_id_list( $r['exclude'] ); 396 395 $exclude = $wpdb->escape( implode( ',', $exclude ) ); … … 398 397 } 399 398 400 switch ( $ type) {399 switch ( $r['type'] ) { 401 400 case 'newest': default: 402 401 $sql['order'] = " ORDER BY g.date_created DESC"; … … 416 415 } 417 416 418 if ( !empty( $ per_page ) && !empty( $page) )419 $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $ page - 1 ) * $per_page), intval( $per_page) );417 if ( !empty( $r['per_page'] ) && !empty( $r['page'] ) ) 418 $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $r['page'] - 1 ) * $r['per_page']), intval( $r['per_page'] ) ); 420 419 421 420 // Get paginated results … … 425 424 $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"; 426 425 427 if ( !empty( $ user_id) )426 if ( !empty( $r['user_id'] ) ) 428 427 $total_sql['select'] .= ", {$bp->groups->table_name_members} m"; 429 428 … … 434 433 $total_sql['where'][] = "( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 435 434 436 if ( !empty( $ user_id) )435 if ( !empty( $r['user_id'] ) ) 437 436 $total_sql['where'][] = "m.group_id = g.id AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0"; 438 437 … … 464 463 465 464 // Populate some extra information instead of querying each time in the loop 466 if ( !empty( $ populate_extras) ) {465 if ( !empty( $r['populate_extras'] ) ) { 467 466 $group_ids = $wpdb->escape( join( ',', (array) $group_ids ) ); 468 $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, $ type);467 $paged_groups = BP_Groups_Group::get_group_extras( $paged_groups, $group_ids, $r['type'] ); 469 468 } 470 469
Note: See TracChangeset
for help on using the changeset viewer.