Changeset 9374
- Timestamp:
- 01/19/2015 08:25:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-classes.php
r9373 r9374 971 971 * Get the first activity ID that matches a set of criteria. 972 972 * 973 * @param int $user_id The user ID to filter by. 974 * @param string $component The component to filter by. 975 * @param string $type The activity type to filter by. 976 * @param int $item_id The associated item to filter by. 977 * @param int $secondary_item_id The secondary associated item to filter by. 978 * @param string $action The action to filter by. 979 * @param string $content The content to filter by. 980 * @param string $date_recorded The date to filter by. 973 * @param int $user_id User ID to filter by 974 * @param string $component Component to filter by 975 * @param string $type Activity type to filter by 976 * @param int $item_id Associated item to filter by 977 * @param int $secondary_item_id Secondary associated item to filter by 978 * @param string $action Action to filter by 979 * @param string $content Content to filter by 980 * @param string $date_recorded Date to filter by 981 * 982 * @todo Should parameters be optional? 983 * 981 984 * @return int|bool Activity ID on success, false if none is found. 982 985 */ 983 986 public static function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) { 984 global $bp, $wpdb; 987 global $wpdb; 988 989 $bp = buddypress(); 985 990 986 991 $where_args = false; 987 992 988 if ( ! empty( $user_id ) )993 if ( ! empty( $user_id ) ) { 989 994 $where_args[] = $wpdb->prepare( "user_id = %d", $user_id ); 990 991 if ( !empty( $component ) ) 995 } 996 997 if ( ! empty( $component ) ) { 992 998 $where_args[] = $wpdb->prepare( "component = %s", $component ); 993 994 if ( !empty( $type ) ) 999 } 1000 1001 if ( ! empty( $type ) ) { 995 1002 $where_args[] = $wpdb->prepare( "type = %s", $type ); 996 997 if ( !empty( $item_id ) ) 1003 } 1004 1005 if ( ! empty( $item_id ) ) { 998 1006 $where_args[] = $wpdb->prepare( "item_id = %d", $item_id ); 999 1000 if ( !empty( $secondary_item_id ) ) 1007 } 1008 1009 if ( ! empty( $secondary_item_id ) ) { 1001 1010 $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id ); 1002 1003 if ( !empty( $action ) ) 1011 } 1012 1013 if ( ! empty( $action ) ) { 1004 1014 $where_args[] = $wpdb->prepare( "action = %s", $action ); 1005 1006 if ( !empty( $content ) ) 1015 } 1016 1017 if ( ! empty( $content ) ) { 1007 1018 $where_args[] = $wpdb->prepare( "content = %s", $content ); 1008 1009 if ( !empty( $date_recorded ) ) 1019 } 1020 1021 if ( ! empty( $date_recorded ) ) { 1010 1022 $where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded ); 1011 1012 if ( !empty( $where_args ) ) 1023 } 1024 1025 if ( ! empty( $where_args ) ) { 1013 1026 $where_sql = 'WHERE ' . join( ' AND ', $where_args ); 1014 else1015 return false;1016 1017 return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );1027 return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" ); 1028 } 1029 1030 return false; 1018 1031 } 1019 1032
Note: See TracChangeset
for help on using the changeset viewer.