Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/11/2012 02:14:07 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Remove unneeded globals and clean up some code in XProfile component. See #3989.

File:
1 edited

Legend:

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

    r5329 r5699  
    11<?php
    2 /********************************************************************************
    3  * Business Functions
     2
     3/**
     4 * BuddyPress XProfile Filters
    45 *
    56 * Business functions are where all the magic happens in BuddyPress. They will
     
    78 * hand off to a database class for data access, then return
    89 * true or false on success or failure.
     10 *
     11 * @package BuddyPress
     12 * @subpackage XProfileFilters
    913 */
    1014
     
    2529    extract( $r, EXTR_SKIP );
    2630
    27     if ( !$name )
     31    if ( empty( $name ) )
    2832        return false;
    2933
     
    7983
    8084    // Check we have the minimum details
    81     if ( !$field_group_id )
     85    if ( empty( $field_group_id ) )
    8286        return false;
    8387
     
    8791
    8892    // Instantiate a new field object
    89     if ( $field_id )
     93    if ( !empty( $field_id ) )
    9094        $field = new BP_XProfile_Field( $field_id );
    9195    else
     
    148152 * @param mixed $field The ID of the field, or the $name of the field.
    149153 * @param int $user_id The ID of the user
    150  * @global object $bp Global BuddyPress settings object
    151154 * @uses BP_XProfile_ProfileData::get_value_byid() Fetches the value based on the params passed.
    152155 * @return mixed The profile field data.
    153156 */
    154157function xprofile_get_field_data( $field, $user_id = 0 ) {
    155     global $bp;
    156158
    157159    if ( empty( $user_id ) )
     
    216218    }
    217219
     220    $possible_values = array();
     221
    218222    // Check the value is an acceptable value
    219223    if ( 'checkbox' == $field->type || 'radio' == $field->type || 'selectbox' == $field->type || 'multiselectbox' == $field->type ) {
     
    225229        if ( is_array( $value ) ) {
    226230            foreach( $value as $i => $single ) {
    227                 if ( !in_array( $single, (array)$possible_values ) ) {
     231                if ( !in_array( $single, $possible_values ) ) {
    228232                    unset( $value[$i] );
    229233                }
     
    233237            $value = array_merge( array(), $value );
    234238        } else {
    235             if ( !in_array( $value, (array)$possible_values ) ) {
     239            if ( !in_array( $value, $possible_values ) ) {
    236240                return false;
    237241            }
     
    301305 */
    302306function xprofile_get_random_profile_data( $user_id, $exclude_fullname = true ) {
    303     $field_data           = BP_XProfile_ProfileData::get_random( $user_id, $exclude_fullname );
    304 
    305     if ( !$field_data )
     307    $field_data = BP_XProfile_ProfileData::get_random( $user_id, $exclude_fullname );
     308
     309    if ( empty( $field_data ) )
    306310        return false;
    307311
    308312    $field_data[0]->value = xprofile_format_profile_field( $field_data[0]->type, $field_data[0]->value );
    309313
    310     if ( !$field_data[0]->value || empty( $field_data[0]->value ) )
     314    if ( empty( $field_data[0]->value ) )
    311315        return false;
    312316
     
    352356 */
    353357function xprofile_avatar_upload_dir( $directory = false, $user_id = 0 ) {
    354     global $bp;
    355358
    356359    if ( empty( $user_id ) )
Note: See TracChangeset for help on using the changeset viewer.