function fivestar_fivestar_access in Fivestar 7.2
Same name and namespace in other branches
- 8 fivestar.module \fivestar_fivestar_access()
- 5 fivestar.module \fivestar_fivestar_access()
- 6.2 fivestar.module \fivestar_fivestar_access()
- 6 fivestar.module \fivestar_fivestar_access()
Implements hook_fivestar_access().
This hook is called before every vote is cast through Fivestar. It allows modules to allow voting on any type of entity, such as nodes, users, or comments.
Parameters
$entity_type: Type entity.
$id: Identifier within the type.
$tag: The VotingAPI tag string.
$uid: The user ID trying to cast the vote.
Return value
bool|NULL Returns TRUE if voting is supported on this object. Returns NULL if voting is not supported on this object by this module. If needing to absolutely deny all voting on this object, regardless of permissions defined in other modules, return FALSE. Note if all modules return NULL, stating no preference, then access will be denied.
File
- ./
fivestar.module, line 364
Code
function fivestar_fivestar_access($entity_type, $id, $tag, $uid) {
// Check to see if there is a field instance on this entity.
$fields = field_read_fields(array(
'module' => 'fivestar',
));
foreach ($fields as $field) {
if ($field['settings']['axis'] == $tag) {
$params = array(
'entity_type' => $entity_type,
'field_name' => $field['field_name'],
);
$instance = field_read_instances($params);
if (!empty($instance)) {
return TRUE;
}
}
}
}