You are here

function fivestar_fivestar_access in Fivestar 8

Same name and namespace in other branches
  1. 5 fivestar.module \fivestar_fivestar_access()
  2. 6.2 fivestar.module \fivestar_fivestar_access()
  3. 6 fivestar.module \fivestar_fivestar_access()
  4. 7.2 fivestar.module \fivestar_fivestar_access()

Implements hook_fivestar_access().

File

./fivestar.module, line 130
A simple n-star voting widget, usable in other forms.

Code

function fivestar_fivestar_access($entity_type, $id, $vote_type, $uid) {

  // Check to see if there is a field instance on this entity.
  $fields = field_read_fields([
    'module' => 'fivestar',
  ]);
  foreach ($fields as $field) {
    if ($field['settings']['axis'] == $vote_type) {
      $params = [
        'entity_type' => $entity_type,
        'field_name' => $field['field_name'],
      ];
      $instance = field_read_instances($params);
      if (!empty($instance)) {
        return TRUE;
      }
    }
  }
}