Skip to:
Content

BuddyPress.org

Changeset 3396


Ignore:
Timestamp:
11/11/2010 07:15:18 AM (10 years ago)
Author:
johnjamesjacoby
Message:

Fixes #1236 (trunk) props swinton

File:
1 edited

Legend:

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

    r3383 r3396  
    738738
    739739        if ( $profiledata = $wpdb->get_row( $sql ) ) {
    740             $this->id           = $profiledata->id;
    741             $this->user_id      = $profiledata->user_id;
    742             $this->field_id     = $profiledata->field_id;
    743             $this->value        = stripslashes( $profiledata->value );
    744             $this->last_updated = $profiledata->last_updated;
    745         }
    746     }
    747 
     740            $this->id           = $profiledata->id;
     741            $this->user_id      = $profiledata->user_id;
     742            $this->field_id     = $profiledata->field_id;
     743            $this->value        = stripslashes( $profiledata->value );
     744            $this->last_updated = $profiledata->last_updated;
     745        }
     746    }
     747
     748    /**
     749     * exists ()
     750     *
     751     * Check if there is data already for the user.
     752     *
     753     * @global object $wpdb
     754     * @global array $bp
     755     * @return bool
     756     */
    748757    function exists() {
    749758        global $wpdb, $bp;
    750759
    751         /* Check to see if there is data already for the user. */
    752         $sql = $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = %d", $this->user_id, $this->field_id );
    753 
    754         if ( !$wpdb->get_row( $sql ) )
    755             return false;
    756 
    757         return true;
    758     }
    759 
     760       
     761        $retval = $wpdb->get_row( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = %d", $this->user_id, $this->field_id ) );
     762
     763        return apply_filters( 'xprofile_data_exists', (bool)$retval, $this );
     764    }
     765
     766    /**
     767     * is_valid_field()
     768     *
     769     * Check if this data is for a valid field.
     770     *
     771     * @global object $wpdb
     772     * @global array $bp
     773     * @return bool
     774     */
    760775    function is_valid_field() {
    761776        global $wpdb, $bp;
    762777
    763         /* check to see if this data is actually for a valid field. */
    764         $sql = $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE id = %d", $this->field_id );
    765 
    766         if ( !$wpdb->get_row( $sql ) )
    767             return false;
    768 
    769         return true;
     778        $retval = $wpdb->get_row( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE id = %d", $this->field_id ) );
     779
     780        return apply_filters( 'xprofile_data_is_valid_field', (bool)$retval, $this );
    770781    }
    771782
     
    773784        global $wpdb, $bp;
    774785
    775         $this->user_id      = apply_filters( 'xprofile_data_user_id_before_save', $this->user_id, $this->id );
    776         $this->field_id     = apply_filters( 'xprofile_data_field_id_before_save', $this->field_id, $this->id );
    777         $this->value        = apply_filters( 'xprofile_data_value_before_save', $this->value, $this->id );
    778         $this->last_updated = apply_filters( 'xprofile_data_last_updated_before_save', date( 'Y-m-d H:i:s' ), $this->id );
     786        $this->user_id      = apply_filters( 'xprofile_data_user_id_before_save', $this->user_id, $this->id );
     787        $this->field_id     = apply_filters( 'xprofile_data_field_id_before_save', $this->field_id, $this->id );
     788        $this->value        = apply_filters( 'xprofile_data_value_before_save', $this->value, $this->id );
     789        $this->last_updated = apply_filters( 'xprofile_data_last_updated_before_save', date( 'Y-m-d H:i:s' ), $this->id );
    779790
    780791        do_action( 'xprofile_data_before_save', $this );
Note: See TracChangeset for help on using the changeset viewer.