I am using vote-up-down (alt) allowing only votes up. I noticed that when a visitor votes up a comment that the author of the comment doesn't get the vote, rather the person who placed the vote gets that vote.
Maybe I don't fully understand the purpose of this module. I am using it (with vote-up-down) to allow visitors (anonymous and members) to vote up comments left by other members of the site.
I checked the vote-up-down-module and don't see anyplace where it inserts votes into the votingapi_votes table.
In looking at the code voteapi.module that inserts the vote into the voteapi_votes table:
function votingapi_add_vote($content_type, $content_id, $value, $value_type = VOTINGAPI_VALUE_DEFAULT_TYPE, $tag = VOTINGAPI_VALUE_DEFAULT_TAG, $uid = NULL) {
if ($uid == NULL) {
global $user;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is where my question is. Isn't this giving the vote to the current user and not
the person who created the content?
$uid = $user->uid;
}
$vobj->vote_id = db_next_id('{votingapi_vote}');
$vobj->content_type = $content_type;
$vobj->content_id = $content_id;
$vobj->value = $value;
$vobj->value_type = $value_type;
$vobj->tag = $tag;
$vobj->uid = $uid;
$vobj->timestamp = time();
$vobj->hostname = $_SERVER['REMOTE_ADDR'];
// Append internal IP if it exists.
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$vobj->hostname .= '-'. $_SERVER['HTTP_X_FORWARDED_FOR'];
}
db_query("INSERT INTO {votingapi_vote} (vote_id, content_type, content_id, value, value_type, tag, uid, timestamp, hostname) VALUES (%d, '%s', %d, %f, '%s', '%s', %d, %d, '%s')",
$vobj->vote_id, $vobj->content_type, $vobj->content_id, $vobj->value, $vobj->value_type, $vobj->tag, $vobj->uid, $vobj->timestamp, $vobj->hostname);
// Give other modules a chance to act on the insert operation.
votingapi_invoke('insert', $vobj);
return $vobj;
}
Comments
Comment #1
tracy_pilcher commentedOK,
Never mind. After looking at this for a while I understood what the votingapi was doing. and found that I could easily create the report I wanted. I.e. points awarded to a given user by just doing a simple query.
The votingapi module is recording who has voted so that it can prevent the same person from voting over and over for a given piece of content.
Live and learn, I'm sorry I doubted the wisdom of votingapi.
Please close this issue. I don't seem to be able to.
Thank you!
Tracy
Comment #2
dwwNot sure why you couldn't change the status with a followup comment like this. Anyway, glad to see you resolved this issue on your own. Cheers.