Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Bug: roles without permissions [ admin/structure/rate/1/edit ] can see widget title. wrong!
Added permission checkl and return null where necessary
Patched with 1-hide-widget-title-to-role-without-permission
/**
* Implements hook_node_view().
*/
function rate_node_view($node, $view_mode, $langcode = '') {
if ($view_mode != 'rss') {
// Adding the form to the node view
$widgets = rate_get_active_widgets('node', $node->type, $view_mode);
foreach ($widgets as $widget_id => $widget) {
$widget_name = 'rate_' . $widget->name;
_rate_check_widget($widget);
$display_mode = $view_mode == 'teaser' ? $widget->teaser_display_mode : $widget->node_display_mode;
$widget_code = array(
'#weight' => $widget->node_display == RATE_DISPLAY_ABOVE_CONTENT ? -50 : 50,
'#markup' => rate_generate_widget($widget_id, 'node', $node->nid, $display_mode),
'#title' => check_plain($widget->title),
'#type' => 'item',
);
$permission_status = _rate_check_permissions($widget, $node);
if ($permission_status == RATE_PERMISSION_DISALLOWED_ROLE ) {
return null;
}
elseif ($widget->node_display == RATE_DISPLAY_DISABLE) {
$node->$widget_name = $widget_code;
}
else {
$node->content[$widget_name] = $widget_code;
}
}
}
}