function radioactivity_get_field_maximum in Radioactivity 7
1 call to radioactivity_get_field_maximum()
- radioactivity_field_formatter_view in ./
radioactivity.field.inc - Implements hook_field_formatter_view().
File
- ./
radioactivity.field.inc, line 262
Code
function radioactivity_get_field_maximum($field_id, $entity_type) {
static $cache;
if (isset($cache[$field_id . $entity_type])) {
return $cache[$field_id . $entity_type];
}
$field_info = field_info_field_by_id($field_id);
// Update field database
$half_life = $field_info['settings']['half_life'];
$cut_off = $field_info['settings']['cut_off'];
$field_name = $field_info['field_name'];
$table_name = 'field_data_' . $field_name;
$energy = $field_name . '_' . RADIOACTIVITY_FIELD_ENERGY;
$timestamp = $field_name . '_' . RADIOACTIVITY_FIELD_TIMESTAMP;
// grab update value from deferred values table
// and update it to the fields table if it is used
$query = db_select($table_name, "tb")
->condition("tb.entity_type", $entity_type)
->condition("tb.deleted", "0");
$query
->addExpression("MAX(tb." . $energy . ")", "energy");
$result = $query
->execute()
->fetchField();
if (!$result) {
$result = $cut_off;
}
$cache[$field_id . $entity_type] = $result;
return $cache[$field_id . $entity_type];
}