votingapiactivity.module in Activity 5.2
File
contrib/votingapiactivity.module
View source
<?php
function votingapiactivity_activity_info() {
$tags = array();
$query = db_query("SELECT DISTINCT tag FROM {votingapi_cache}");
while ($result = db_fetch_array($query)) {
$tags[] = $result['tag'];
}
return array(
'name' => 'votingapi',
'module' => 'votingapi',
'ops' => array(
'mark',
'unmark',
),
'types' => array_values($tags),
'tokens' => array(
'user' => 'user who done the action',
'node-id' => 'id of what was voted upon',
'node-title' => 'title of what was voted upon',
'rating' => 'rating data',
),
);
}
function votingapiactivity_votingapi_insert() {
global $user;
$args = func_get_args();
$node = node_load($args[0]->content_id);
$action = 'mark';
$type = 1;
$token = array(
'user-id' => $user->uid,
'user-name' => $user->name,
'node-id' => $args[0]->content_id,
'node-title' => $node->title,
'rating-value' => $args[0]->value,
'rating_type' => $args[0]->value_type,
);
activity_insert('votingapi', $type, $action, $token);
}