function votingapiactivity_token_values in Activity 6
Same name and namespace in other branches
- 5.4 contrib/votingapiactivity/votingapiactivity.module \votingapiactivity_token_values()
- 5.3 contrib/votingapiactivity/votingapiactivity.module \votingapiactivity_token_values()
Token module integration. Defines available default token values.
File
- contrib/
votingapiactivity/ votingapiactivity.module, line 66
Code
function votingapiactivity_token_values($type, $data = NULL, $options = array()) {
if ($type == 'votingapiactivity' && !empty($data)) {
$author_vote = db_fetch_object(db_query('SELECT value FROM {votingapi_vote} WHERE uid = %d AND content_id = %d', $data['uid'], $data['content-id']));
$data['author-vote'] = $author_vote->value;
$content_votes = db_query('SELECT value, function FROM {votingapi_cache} WHERE content_id = %d', $data['content-id']);
while ($row = db_fetch_object($content_votes)) {
$content_vote[$row->function] = $row->value;
}
$data['content-vote-avg'] = $content_vote['average'];
$data['content-vote-count'] = $content_vote['count'];
$data['content-type'] = $data['content-type'] == t('comment') ? $data['content-type'] : theme('activity_node_type', $data['content-type']);
$link_attributes = array();
if ($data['content-type'] == t('comment')) {
$link_attributes['fragment'] = 'comment-' . $data['content_id'];
}
$data['content-link'] = l($data['content-title'], 'node/' . $data['content-nid'], $link_attributes);
return $data;
}
}