# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: \\UBU\www\sandbox\public_html\wp-content\plugins\buddypress\bp-groups
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
|
|
|
421 | 421 | function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) { |
422 | 422 | global $wpdb, $bp; |
423 | 423 | |
| 424 | // TODO this optional where statement code should be refactored into its own generic function for re-use by many other functions |
| 425 | // default sql WHERE conditions are blank |
| 426 | $where_sql = null; |
| 427 | $where_conditions = array(); |
| 428 | |
| 429 | // limit results to public status |
424 | 430 | if ( $only_public ) |
425 | | $public_sql = $wpdb->prepare( " WHERE g.status = 'public'" ); |
| 431 | $where_conditions[] = $wpdb->prepare( "g.status = 'public'" ); |
426 | 432 | |
| 433 | // limit results to non-hidden status |
427 | 434 | if ( !is_site_admin() ) |
428 | | $hidden_sql = $wpdb->prepare( " AND g.status != 'hidden'"); |
| 435 | $where_conditions[] = $wpdb->prepare( "g.status != 'hidden'"); |
429 | 436 | |
| 437 | // build where sql statement if necessary |
| 438 | if ( !empty( $where_conditions ) ) { |
| 439 | $where_sql = 'WHERE ' . join( ' AND ', $where_conditions ); |
| 440 | } |
| 441 | |
430 | 442 | if ( $limit && $page ) |
431 | 443 | $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); |
432 | 444 | |
… |
… |
|
437 | 449 | |
438 | 450 | switch ( $sort_by ) { |
439 | 451 | default: |
440 | | $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" ); |
| 452 | $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" ); |
441 | 453 | break; |
442 | 454 | case 'members': |
443 | | $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'total_member_count' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" ); |
| 455 | $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'total_member_count' {$where_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" ); |
444 | 456 | break; |
445 | 457 | case 'last_active': |
446 | | $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'last_activity' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" ); |
| 458 | $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'last_activity' {$where_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" ); |
447 | 459 | break; |
448 | 460 | } |
449 | 461 | } else { |
450 | | $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" ); |
451 | | No newline at end of file |
| 462 | $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" ); |
| 463 | No newline at end of file |
452 | 464 | } |
453 | 465 | |