Permalink
Browse files

fixed unvoting points

  • Loading branch information...
1 parent c88868e commit f4741c1dbafa00ee1fb3c4c5712870282816e8c6 @NoahY committed Aug 14, 2012
Showing with 14 additions and 52 deletions.
  1. +0 −42 qa-history-check.php
  2. +14 −10 qa-history-layer.php
View
@@ -34,48 +34,6 @@ function process_event($event, $userid, $handle, $cookieid, $params) {
'c_post'
);
- //$undo = array('a_unselect', 'q_vote_nil', 'a_vote_nil','q_unflag', 'a_unflag', 'c_unflag');
-
- /*
-
- if(in_array($event, $undo)) {
- $uid = qa_db_read_one_value(
- qa_db_query_sub(
- 'SELECT userid FROM ^posts WHERE postid=#',
- $params['postid']
- ),
- true
- );
-
- $events = array(
- 'a_unselect' => "'in_a_select'",
- 'q_vote_nil' => "'in_q_vote_up','in_q_vote_down'",
- 'a_vote_nil' => "'in_a_vote_up','in_a_vote_down'",
- 'q_unflag' => "'in_q_flag'",
- 'a_unflag' => "'in_a_flag'",
- 'c_unflag' => "'in_c_flag'"
- );
-
- foreach($events as $out => $in) {
- if($out == $event) {
- $eventa = qa_db_read_one_assoc(
- qa_db_query_sub(
- 'SELECT * FROM ^eventlog WHERE datetime=(SELECT MAX(datetime) FROM ^eventlog AS e2 WHERE event IN ('.$in.') AND params LIKE $ AND userid=#)',
- '%postid='.$params['postid'].'%',$uid
- ),
- true
- );
- qa_db_query_sub(
- 'DELETE FROM ^eventlog WHERE event=$ AND params=$ AND datetime=$ AND userid=$',
- $eventa['event'],$eventa['params'],$eventa['datetime'],$eventa['userid']
- );
- }
- }
-
- }
-
- */
-
if(in_array($event, $twoway)) {
if(strpos($event,'u_') === 0) {
View
@@ -181,17 +181,19 @@ function user_activity_form() {
// compat fudge
$upvote = '';
$downvote = '';
- if($options['points_per_q_voted_up']) {
+ if(@$options['points_per_q_voted_up']) {
$upvote = '_up';
$downvote = '_down';
}
$option_events['in_q_vote_up'] = (int)$options['points_per_q_voted'.$upvote]*$multi;
$option_events['in_q_vote_down'] = (int)$options['points_per_q_voted'.$downvote]*$multi*(-1);
- //$option_events['in_q_vote_nil'] = (int)$options['points_per_q_voted']*$multi;
- $option_events['in_a_vote_up'] = (int)$options['points_per_a_voted'.$upvote]*$multi;
+ $option_events['in_q_unvote_up'] = (int)$options['points_per_q_voted'.$upvote]*$multi*(-1);
+ $option_events['in_q_unvote_down'] = (int)$options['points_per_q_voted'.$downvote]*$multi;
+ $option_events['in_a_vote_up'] = (int)$options['points_per_a_voted'.$upvote]*$multi*(-1);
$option_events['in_a_vote_down'] = (int)$options['points_per_a_voted'.$downvote]*$multi*(-1);
- //$option_events['in_a_vote_nil'] = (int)$options['points_per_a_voted']*$multi;
+ $option_events['in_a_unvote_up'] = (int)$options['points_per_a_voted'.$upvote]*$multi*(-1);
+ $option_events['in_a_unvote_down'] = (int)$options['points_per_a_voted'.$downvote]*$multi;
$option_events['in_a_select'] = (int)$options['points_a_selected']*$multi;
$option_events['in_a_unselect'] = (int)$options['points_a_selected']*$multi*(-1);
$option_events['q_post'] = (int)$options['points_post_q']*$multi;
@@ -357,13 +359,15 @@ function user_activity_form() {
$when = preg_replace('/([0-9]+)/','<span class="qa-history-item-date-no">$1</span>',$when);
- $points = @$option_events[$type];
-
- // special points
-
- if(in_array($type,array('in_q_vote_nil','in_a_vote_nil'))) {
- $points = $points*((int)$params['oldvote'] > (int)$params['vote']?-1:1);
+ if(strpos($type,'_vote_nil') == 4) {
+ if($params['oldvote'] == '1') // unvoting an upvote
+ $points = @$option_events[str_replace('_vote_nil','_unvote_up',$type)];
+ else // unvoting a downvote
+ $points = @$option_events[str_replace('_vote_nil','_unvote_down',$type)];
}
+ else
+ $points = @$option_events[$type];
+
$string = qa_opt('user_act_list_'.$type);

0 comments on commit f4741c1

Please sign in to comment.