You are here

function _fe_profile_save_field in Features Extra 7

Saves a profile field to the database.

@codingStandardsIgnoreStart

Parameters

array $field_data: The field data to save.

1 call to _fe_profile_save_field()
fe_profile_features_revert in fe_profile/fe_profile.module
Implements hook_features_revert().

File

fe_profile/fe_profile.module, line 89
Main functions and hook implementations for FE Profile.

Code

function _fe_profile_save_field($field_data) {

  // @codingStandardsIgnoreEnd
  if (!isset($field_data['options'])) {
    $field_data['options'] = '';
  }
  if (!isset($field_data['page'])) {
    $field_data['page'] = '';
  }
  if (!isset($field_data['fid'])) {
    $field_data = (object) $field_data;
    drupal_write_record('profile_field', $field_data);
  }
  else {
    $field_data = (object) $field_data;
    if (!db_query("SELECT * FROM {profile_field} WHERE fid = :fid", array(
      ':fid' => $field_data->fid,
    ))
      ->fetchObject()) {
      drupal_write_record('profile_field', $field_data);
    }
    else {
      drupal_write_record('profile_field', $field_data, array(
        'fid',
      ));
    }
  }
}