Skip to:
Content

BuddyPress.org

Changeset 9374


Ignore:
Timestamp:
01/19/2015 08:25:17 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Add brackets and remove $bp global touch in BP_Activity_Activity::get_id(). See #5138, #5891.

File:
1 edited

Legend:

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

    r9373 r9374  
    971971         * Get the first activity ID that matches a set of criteria.
    972972         *
    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         *
    981984         * @return int|bool Activity ID on success, false if none is found.
    982985         */
    983986        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();
    985990
    986991                $where_args = false;
    987992
    988                 if ( !empty( $user_id ) )
     993                if ( ! empty( $user_id ) ) {
    989994                        $where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
    990 
    991                 if ( !empty( $component ) )
     995                }
     996
     997                if ( ! empty( $component ) ) {
    992998                        $where_args[] = $wpdb->prepare( "component = %s", $component );
    993 
    994                 if ( !empty( $type ) )
     999                }
     1000
     1001                if ( ! empty( $type ) ) {
    9951002                        $where_args[] = $wpdb->prepare( "type = %s", $type );
    996 
    997                 if ( !empty( $item_id ) )
     1003                }
     1004
     1005                if ( ! empty( $item_id ) ) {
    9981006                        $where_args[] = $wpdb->prepare( "item_id = %d", $item_id );
    999 
    1000                 if ( !empty( $secondary_item_id ) )
     1007                }
     1008
     1009                if ( ! empty( $secondary_item_id ) ) {
    10011010                        $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id );
    1002 
    1003                 if ( !empty( $action ) )
     1011                }
     1012
     1013                if ( ! empty( $action ) ) {
    10041014                        $where_args[] = $wpdb->prepare( "action = %s", $action );
    1005 
    1006                 if ( !empty( $content ) )
     1015                }
     1016
     1017                if ( ! empty( $content ) ) {
    10071018                        $where_args[] = $wpdb->prepare( "content = %s", $content );
    1008 
    1009                 if ( !empty( $date_recorded ) )
     1019                }
     1020
     1021                if ( ! empty( $date_recorded ) ) {
    10101022                        $where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded );
    1011 
    1012                 if ( !empty( $where_args ) )
     1023                }
     1024
     1025                if ( ! empty( $where_args ) ) {
    10131026                        $where_sql = 'WHERE ' . join( ' AND ', $where_args );
    1014                 else
    1015                         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;
    10181031        }
    10191032
Note: See TracChangeset for help on using the changeset viewer.