function vud_node_link in Vote Up/Down 7
Same name and namespace in other branches
- 6.3 vud_node/vud_node.module \vud_node_link()
- 6.2 vud_node/vud_node.module \vud_node_link()
Implementation of hook_link().
File
- vud_node/
vud_node.module, line 279 - Adds a voting widget to nodes.
Code
function vud_node_link($type, $object, $teaser = FALSE) {
$links = array();
switch ($type) {
case 'node':
$node =& $object;
$votes_display_mode = variable_get('vud_node_votes', VUD_NODE_DISPLAY_BOTH);
$node_type = in_array($node->type, variable_get('vud_node_types', array()), TRUE);
$widget_theme = variable_get('vud_node_widget', 'plain');
$tag = variable_get('vud_tag', 'vote');
$view_vud_node_votes_count = user_access('view vote up/down count on nodes') || user_access('use vote up/down on nodes');
switch ($votes_display_mode) {
case VUD_NODE_DISPLAY_NO:
break;
case VUD_NODE_DISPLAY_TEASER_ONLY:
if ($teaser == 1 && $node_type && $view_vud_node_votes_count) {
$links['vud_node_votes_count'] = array(
'title' => theme('vud_votes', array(
'entity_id' => $node->nid,
'type' => $type,
'tag' => $tag,
'widget_theme' => $widget,
)),
'html' => TRUE,
);
}
break;
case VUD_NODE_DISPLAY_FULL_ONLY:
if ($teaser == 0 && $node_type && $view_vud_node_votes_count) {
$links['vud_node_votes_count'] = array(
'title' => theme('vud_votes', array(
'entity_id' => $node->nid,
'type' => $type,
'tag' => $tag,
'widget_theme' => $widget,
)),
'html' => TRUE,
);
}
break;
case VUD_NODE_DISPLAY_BOTH:
if ($node_type && $view_vud_node_votes_count) {
$links['vud_node_votes_count'] = array(
'title' => theme('vud_votes', array(
'entity_id' => $node->nid,
'type' => $type,
'tag' => $tag,
'widget_theme' => $widget,
)),
'html' => TRUE,
);
}
break;
}
if ($node_type && variable_get('vud_node_reset', 0) && user_access('reset vote up/down votes')) {
$tag = variable_get('vud_tag', 'vote');
$criteria = array(
'entity_type' => $type,
'entity_id' => $node->nid,
'tag' => $tag,
);
$criteria += votingapi_current_user_identifier();
$user_vote = votingapi_select_single_vote_value($criteria);
if (!is_null($user_vote)) {
$reset_token = drupal_get_token("votereset/node/{$node->nid}/{$tag}/{$widget_theme}");
$links['vud_node_votes_reset_link'] = array(
'title' => t('Reset your vote'),
'href' => "votereset/node/{$node->nid}/{$tag}/{$widget_theme}/{$reset_token}",
'attributes' => array(
'rel' => 'nofollow',
),
'html' => TRUE,
);
}
}
break;
}
return $links;
}