Commit dc08d842 by Scott

Merge branch 'pr/101' into dev

parents 1086d15c ad7de9cc
...@@ -477,13 +477,19 @@ ...@@ -477,13 +477,19 @@
of user. Updates points and reports events as appropriate. of user. Updates points and reports events as appropriate.
*/ */
{ {
qa_db_post_set_userid($oldquestion['postid'], $userid); require_once QA_INCLUDE_DIR . 'qa-db-votes.php';
$postid = $oldquestion['postid'];
qa_db_post_set_userid($postid, $userid);
qa_db_uservote_remove_own($postid);
qa_db_post_recount_votes($postid);
qa_db_points_update_ifuser($oldquestion['userid'], array('qposts', 'aselects', 'qvoteds', 'upvoteds', 'downvoteds')); qa_db_points_update_ifuser($oldquestion['userid'], array('qposts', 'aselects', 'qvoteds', 'upvoteds', 'downvoteds'));
qa_db_points_update_ifuser($userid, array('qposts', 'aselects', 'qvoteds', 'upvoteds', 'downvoteds')); qa_db_points_update_ifuser($userid, array('qposts', 'aselects', 'qvoteds', 'qupvotes', 'qdownvotes', 'upvoteds', 'downvoteds'));
qa_report_event('q_claim', $userid, $handle, $cookieid, array( qa_report_event('q_claim', $userid, $handle, $cookieid, array(
'postid' => $oldquestion['postid'], 'postid' => $postid,
'oldquestion' => $oldquestion, 'oldquestion' => $oldquestion,
)); ));
} }
...@@ -734,13 +740,19 @@ ...@@ -734,13 +740,19 @@
of user. Updates points and reports events as appropriate. of user. Updates points and reports events as appropriate.
*/ */
{ {
qa_db_post_set_userid($oldanswer['postid'], $userid); require_once QA_INCLUDE_DIR . 'qa-db-votes.php';
$postid = $oldanswer['postid'];
qa_db_post_set_userid($postid, $userid);
qa_db_uservote_remove_own($postid);
qa_db_post_recount_votes($postid);
qa_db_points_update_ifuser($oldanswer['userid'], array('aposts', 'aselecteds', 'avoteds', 'upvoteds', 'downvoteds')); qa_db_points_update_ifuser($oldanswer['userid'], array('aposts', 'aselecteds', 'avoteds', 'upvoteds', 'downvoteds'));
qa_db_points_update_ifuser($userid, array('aposts', 'aselecteds', 'avoteds', 'upvoteds', 'downvoteds')); qa_db_points_update_ifuser($userid, array('aposts', 'aselecteds', 'avoteds', 'aupvotes', 'adownvotes', 'upvoteds', 'downvoteds'));
qa_report_event('a_claim', $userid, $handle, $cookieid, array( qa_report_event('a_claim', $userid, $handle, $cookieid, array(
'postid' => $oldanswer['postid'], 'postid' => $postid,
'parentid' => $oldanswer['parentid'], 'parentid' => $oldanswer['parentid'],
'oldanswer' => $oldanswer, 'oldanswer' => $oldanswer,
)); ));
...@@ -1049,19 +1061,24 @@ ...@@ -1049,19 +1061,24 @@
of user. Updates points and reports events as appropriate. of user. Updates points and reports events as appropriate.
*/ */
{ {
qa_db_post_set_userid($oldcomment['postid'], $userid); require_once QA_INCLUDE_DIR . 'qa-db-votes.php';
$postid = $oldcomment['postid'];
qa_db_post_set_userid($postid, $userid);
qa_db_uservote_remove_own($postid);
qa_db_post_recount_votes($postid);
qa_db_points_update_ifuser($oldcomment['userid'], array('cposts')); qa_db_points_update_ifuser($oldcomment['userid'], array('cposts'));
qa_db_points_update_ifuser($userid, array('cposts')); qa_db_points_update_ifuser($userid, array('cposts'));
qa_report_event('c_claim', $userid, $handle, $cookieid, array( qa_report_event('c_claim', $userid, $handle, $cookieid, array(
'postid' => $oldcomment['postid'], 'postid' => $postid,
'parentid' => $oldcomment['parentid'], 'parentid' => $oldcomment['parentid'],
'oldcomment' => $oldcomment, 'oldcomment' => $oldcomment,
)); ));
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
*/ */
\ No newline at end of file
...@@ -150,6 +150,18 @@ ...@@ -150,6 +150,18 @@
)); ));
} }
/**
* Remove all votes assigned to a post that had been cast by the owner of the post.
*
* @param int $postid The post ID from which the owner's votes will be removed.
*/
function qa_db_uservote_remove_own($postid)
{
qa_db_query_sub(
'DELETE uv FROM ^uservotes uv JOIN ^posts p ON uv.postid=p.postid AND uv.userid=p.userid WHERE uv.postid=#', $postid
);
}
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
......
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