function fivestar_node_type in Fivestar 5
Same name and namespace in other branches
- 6.2 fivestar.module \fivestar_node_type()
- 6 fivestar.module \fivestar_node_type()
Implementation of hook_node_types().
File
- ./
fivestar.module, line 359 - A simple n-star voting widget, usable in other forms.
Code
function fivestar_node_type($op, $info) {
$type = $info->type;
$variables = array(
'fivestar',
'fivestar_unvote',
'fivestar_style',
'fivestar_stars',
'fivestar_comment',
'fivestar_position',
'fivestar_position_teaser',
);
// Be responsible and cleanup unneeded variables.
if ($op == 'delete') {
foreach ($variables as $variable) {
variable_del($variable . '_' . $type);
}
}
elseif ($op == 'update' && !empty($info->old_type) && $info->old_type != $info->type) {
foreach ($variables as $variable) {
$value = variable_get($variable . '_' . $type, -1);
if ($value != -1) {
variable_del($variable . '_' . $type);
variable_set($variable . '_' . $type, $value);
}
}
}
}