function vote_up_down_link in Vote Up/Down 6
Same name and namespace in other branches
- 5 vote_up_down.module \vote_up_down_link()
Implementation of hook_link().
File
- ./
vote_up_down.module, line 276
Code
function vote_up_down_link($type, $node = NULL, $teaser = FALSE) {
$links = array();
switch ($type) {
case 'node':
$node_type = in_array($node->type, variable_get('vote_up_down_node_types', array()), TRUE);
$style = variable_get('vote_up_down_widget_style_node', 0) == 1 ? '_alt' : '';
if ($node_type && user_access('view up/down votes')) {
if (variable_get('vote_up_down_reset_vote', 0) && (user_access('use vote up') || user_access('use vote down'))) {
$tag = variable_get('vote_up_down_tag', 'vote');
$criteria = array(
'content_type' => $type,
'content_id' => $node->nid,
'tag' => $tag,
);
$criteria += votingapi_current_user_identifier();
$user_vote = votingapi_select_single_vote_value($criteria);
if (!is_null($user_vote)) {
$token = drupal_get_token("vote_up_down/{$type}/{$node->nid}/0");
$links['vote_up_down_reset'] = array(
'title' => t('Reset vote'),
'href' => "vote_up_down/{$type}/{$node->nid}/0",
'attributes' => array(
'title' => t('Reset your vote.'),
),
'query' => drupal_get_destination() . '&token=' . $token,
);
}
}
if ($teaser && variable_get('vote_up_down_link_node', 0) && variable_get('vote_up_down_link_node', 0) != 2 && $style != "_alt") {
$links['vote_up_down_points'] = array(
'title' => theme('vote_up_down_points', $node->nid, $type),
'html' => TRUE,
);
}
else {
if (!$teaser && variable_get('vote_up_down_link_node', 0) > 1 && $style != "_alt") {
$links['vote_up_down_points'] = array(
'title' => theme('vote_up_down_points', $node->nid, $type),
'html' => TRUE,
);
}
}
}
break;
case 'comment':
if (variable_get('vote_up_down_reset_vote', 0) && (user_access('use vote up') || user_access('use vote down')) && (variable_get('vote_up_down_widget_comment', 0) || variable_get('vote_up_down_link_comment', 0))) {
$tag = variable_get('vote_up_down_tag', 'vote');
$criteria = array(
'content_type' => $type,
'content_id' => $node->cid,
'tag' => $tag,
);
$criteria += votingapi_current_user_identifier();
$user_vote = votingapi_select_single_vote_value($criteria);
if (!is_null($user_vote)) {
$token = drupal_get_token("vote_up_down/{$type}/{$node->cid}/0");
$links['vote_up_down_reset_c'] = array(
'title' => t('Reset vote'),
'href' => "vote_up_down/{$type}/{$node->cid}/0",
'attributes' => array(
'title' => t('Reset your vote.'),
),
'query' => drupal_get_destination() . '&token=' . $token,
);
}
}
if (variable_get('vote_up_down_link_comment', 0) && user_access('view up/down votes')) {
$links['vote_up_down_points_c'] = array(
'title' => theme('vote_up_down_points', $node->cid, $type, NULL),
'html' => TRUE,
);
}
break;
}
return $links;
}