Commit f54156e6 by Scott

Handle points/events for comment voting

parent a31b8060
...@@ -112,7 +112,7 @@ function qa_vote_error_html($post, $vote, $userid, $topage) ...@@ -112,7 +112,7 @@ function qa_vote_error_html($post, $vote, $userid, $topage)
* @param $handle * @param $handle
* @param $cookieid * @param $cookieid
* @param $vote * @param $vote
* @return mixed * @return void
*/ */
function qa_vote_set($post, $userid, $handle, $cookieid, $vote) function qa_vote_set($post, $userid, $handle, $cookieid, $vote)
{ {
...@@ -130,9 +130,13 @@ function qa_vote_set($post, $userid, $handle, $cookieid, $vote) ...@@ -130,9 +130,13 @@ function qa_vote_set($post, $userid, $handle, $cookieid, $vote)
qa_db_uservote_set($post['postid'], $userid, $vote); qa_db_uservote_set($post['postid'], $userid, $vote);
qa_db_post_recount_votes($post['postid']); qa_db_post_recount_votes($post['postid']);
$postisanswer = ($post['basetype'] == 'A'); if (!in_array($post['basetype'], array('Q', 'A', 'C'))) {
return;
}
$prefix = strtolower($post['basetype']);
if ($postisanswer) { if ($prefix === 'a') {
qa_db_post_acount_update($post['parentid']); qa_db_post_acount_update($post['parentid']);
qa_db_unupaqcount_update(); qa_db_unupaqcount_update();
} }
...@@ -140,24 +144,24 @@ function qa_vote_set($post, $userid, $handle, $cookieid, $vote) ...@@ -140,24 +144,24 @@ function qa_vote_set($post, $userid, $handle, $cookieid, $vote)
$columns = array(); $columns = array();
if ($vote > 0 || $oldvote > 0) if ($vote > 0 || $oldvote > 0)
$columns[] = $postisanswer ? 'aupvotes' : 'qupvotes'; $columns[] = $prefix . 'upvotes';
if ($vote < 0 || $oldvote < 0) if ($vote < 0 || $oldvote < 0)
$columns[] = $postisanswer ? 'adownvotes' : 'qdownvotes'; $columns[] = $prefix . 'downvotes';
qa_db_points_update_ifuser($userid, $columns); qa_db_points_update_ifuser($userid, $columns);
qa_db_points_update_ifuser($post['userid'], array($postisanswer ? 'avoteds' : 'qvoteds', 'upvoteds', 'downvoteds')); qa_db_points_update_ifuser($post['userid'], array($prefix . 'voteds', 'upvoteds', 'downvoteds'));
if ($post['basetype'] == 'Q') if ($prefix === 'q')
qa_db_hotness_update($post['postid']); qa_db_hotness_update($post['postid']);
if ($vote < 0) if ($vote < 0)
$event = $postisanswer ? 'a_vote_down' : 'q_vote_down'; $event = $prefix . '_vote_down';
elseif ($vote > 0) elseif ($vote > 0)
$event = $postisanswer ? 'a_vote_up' : 'q_vote_up'; $event = $prefix . '_vote_up';
else else
$event = $postisanswer ? 'a_vote_nil' : 'q_vote_nil'; $event = $prefix . '_vote_nil';
qa_report_event($event, $userid, $handle, $cookieid, array( qa_report_event($event, $userid, $handle, $cookieid, array(
'postid' => $post['postid'], 'postid' => $post['postid'],
......
...@@ -58,6 +58,9 @@ class qa_event_limits ...@@ -58,6 +58,9 @@ class qa_event_limits
case 'a_vote_up': case 'a_vote_up':
case 'a_vote_down': case 'a_vote_down':
case 'a_vote_nil': case 'a_vote_nil':
case 'c_vote_up':
case 'c_vote_down':
case 'c_vote_nil':
qa_limits_increment($userid, QA_LIMIT_VOTES); qa_limits_increment($userid, QA_LIMIT_VOTES);
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment