function fivestar_field in Fivestar 5
Same name and namespace in other branches
- 6.2 includes/fivestar.field.inc \fivestar_field()
- 6 fivestar_field.inc \fivestar_field()
Implementation of hook_field().
File
- ./
fivestar_field.inc, line 106 - Provides CCK integration for fivestar module
Code
function fivestar_field($op, &$node, $field, &$items, $teaser, $page) {
$fieldname = $field['field_name'];
switch ($op) {
case 'insert':
case 'update':
case 'delete':
foreach ($items as $delta => $item) {
if ($node->status == 0 || $op == 'delete') {
$rating = 0;
}
else {
$rating = $items[$delta]['rating'];
}
$items[$delta]['target'] = fivestar_field_target($node, $field, $item);
if (is_numeric($items[$delta]['target'])) {
_fivestar_cast_vote('node', $items[$delta]['target'], $rating, $field['axis'], $node->uid, FALSE, TRUE);
votingapi_recalculate_results('node', $items[$delta]['target']);
}
}
break;
case 'view':
foreach ($items as $delta => $item) {
$items[$delta]['view'] = content_format($field, $item);
}
return theme('field', $node, $field, $items, $teaser, $page);
}
}