You are here

function better_statistics_get_fields_data in Better Statistics 7

Returns data for all valid, declared fields in preparation for DB insertion.

2 calls to better_statistics_get_fields_data()
better_statistics_better_statistics_ajax in ./better_statistics.statistics.inc
Implements hook_better_statistics_ajax().
better_statistics_exit in ./better_statistics.module
Implements hook_exit().

File

./better_statistics.module, line 330
Drupal hook implementations for the Better Statistics module.

Code

function better_statistics_get_fields_data() {
  $fields = variable_get('better_statistics_fields', better_statistics_get_default_fields());
  $field_data = array();

  // Loop through all custom fields.
  foreach ($fields as $field => $data) {

    // Only insert data into this field if there's a callback to get data.
    if (is_callable($data['callback'])) {
      $field_data[$field] = $data['callback']($field);
    }
  }

  // The AID field should be removed in order to auto-increment.
  unset($field_data['aid']);
  return $field_data;
}