You are here

function _fivestar_field_target in Fivestar 7.2

Helper function to find the id that should be rated when a field is changed.

1 call to _fivestar_field_target()
_fivestar_field_helper in includes/fivestar.field.inc

File

includes/fivestar.field.inc, line 187
Provides CCK integration for fivestar module.

Code

function _fivestar_field_target($entity, $field, $instance, $item, $langcode) {
  if ($instance['widget']['type'] == 'exposed') {
    return NULL;
  }
  if (isset($instance['settings']['target'])) {
    $target = fivestar_get_targets($field, $instance, $instance['settings']['target'], $entity, $langcode);
  }
  else {

    // If all else fails, default to voting on the instance the field is attached to.
    list($id, $vid, $bundle) = entity_extract_ids($instance['entity_type'], $entity);
    $target = array(
      'entity_id' => $id,
      'entity_type' => $instance['entity_type'],
    );
  }
  return $target;
}