Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/21/2010 03:47:02 PM (15 years ago)
Author:
apeatling
Message:

Fixes #1598 - broken sitewide notices

File:
1 edited

Legend:

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

    r2381 r2397  
    295295    }
    296296
     297    function get_id( $user_id, $component, $type, $item_id, $secondary_item_id ) {
     298        global $bp, $wpdb;
     299
     300        $where_args = false;
     301
     302        if ( !empty( $user_id ) )
     303            $where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
     304
     305        if ( !empty( $component ) )
     306            $where_args[] = $wpdb->prepare( "component = %s", $component );
     307
     308        if ( !empty( $type ) )
     309            $where_args[] = $wpdb->prepare( "type = %s", $type );
     310
     311        if ( !empty( $item_id ) )
     312            $where_args[] = $wpdb->prepare( "item_id = %s", $item_id );
     313
     314        if ( !empty( $secondary_item_id ) )
     315            $where_args[] = $wpdb->prepare( "secondary_item_id = %s", $secondary_item_id );
     316
     317        if ( !empty( $where_args ) )
     318            $where_sql = 'WHERE ' . join( ' AND ', $where_args );
     319        else
     320            return false;
     321
     322        return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
     323    }
     324
    297325    function append_comments( $activities ) {
    298326        global $bp, $wpdb;
Note: See TracChangeset for help on using the changeset viewer.