Skip to:
Content

BuddyPress.org

Changeset 9675


Ignore:
Timestamp:
04/01/2015 10:29:02 PM (9 years ago)
Author:
johnjamesjacoby
Message:

XProfile: Code formatting cleanup to BP_XProfile_ProfileData.

Also updates an unused & long since deprecated function to maybe actually return correct results.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php

    r9674 r9675  
    144144            }
    145145
    146             if ( false === $result )
     146            if ( false === $result ) {
    147147                return false;
     148            }
    148149
    149150            /**
     
    182183        do_action_ref_array( 'xprofile_data_before_delete', array( $this ) );
    183184
    184         if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $this->field_id, $this->user_id ) ) )
     185        $deleted = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $this->field_id, $this->user_id ) );
     186        if ( empty( $deleted ) ) {
    185187            return false;
     188        }
    186189
    187190        /**
     
    423426        global $wpdb;
    424427
    425         if ( empty( $fields ) )
     428        if ( empty( $fields ) ) {
    426429            return false;
    427 
    428         $bp = buddypress();
    429 
    430         if ( empty( $user_id ) )
     430        }
     431
     432        $bp = buddypress();
     433
     434        if ( empty( $user_id ) ) {
    431435            $user_id = bp_displayed_user_id();
     436        }
    432437
    433438        $field_sql = '';
     
    447452        }
    448453
    449         $sql = $wpdb->prepare( "SELECT d.value, f.name FROM {$bp->profile->table_name_data} d, {$bp->profile->table_name_fields} f WHERE d.field_id = f.id AND d.user_id = %d AND f.parent_id = 0 $field_sql", $user_id );
    450 
    451         if ( !$values = $wpdb->get_results( $sql ) )
     454        $sql    = $wpdb->prepare( "SELECT d.value, f.name FROM {$bp->profile->table_name_data} d, {$bp->profile->table_name_fields} f WHERE d.field_id = f.id AND d.user_id = %d AND f.parent_id = 0 $field_sql", $user_id );
     455        $values = $wpdb->get_results( $sql );
     456
     457        if ( empty( $values ) || is_wp_error( $values ) ) {
    452458            return false;
     459        }
    453460
    454461        $new_values = array();
     
    474481        global $wpdb;
    475482
    476         $bp = buddypress();
    477 
    478         if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE field_id = %d", $field_id ) ) )
     483        $bp      = buddypress();
     484        $deleted = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE field_id = %d", $field_id ) );
     485        if ( empty( $deleted ) || is_wp_error( $deleted ) ) {
    479486            return false;
     487        }
    480488
    481489        return true;
     
    512520    public static function get_fullname( $user_id = 0 ) {
    513521
    514         if ( empty( $user_id ) )
     522        if ( empty( $user_id ) ) {
    515523            $user_id = bp_displayed_user_id();
    516 
    517         $data = xprofile_get_field_data( bp_xprofile_fullname_field_id(), $user_id );
    518 
    519         return $data[$field_name];
     524        }
     525
     526        return xprofile_get_field_data( bp_xprofile_fullname_field_id(), $user_id );
    520527    }
    521528}
Note: See TracChangeset for help on using the changeset viewer.