Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
d5e23e1b
Commit
d5e23e1b
authored
Sep 28, 2014
by
pupi1985
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug which allowed users to have own votes on posts they own
parent
bfeb6aea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
10 deletions
+41
-10
qa-app-post-update.php
qa-include/qa-app-post-update.php
+26
-10
qa-db-votes.php
qa-include/qa-db-votes.php
+15
-0
No files found.
qa-include/qa-app-post-update.php
View file @
d5e23e1b
...
...
@@ -473,13 +473,19 @@
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_remove_owner_votes_from_post
(
$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
(
$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
(
'postid'
=>
$
oldquestion
[
'postid'
]
,
'postid'
=>
$
postid
,
'oldquestion'
=>
$oldquestion
,
));
}
...
...
@@ -726,13 +732,19 @@
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_remove_owner_votes_from_post
(
$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
(
$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
(
'postid'
=>
$
oldanswer
[
'postid'
]
,
'postid'
=>
$
postid
,
'parentid'
=>
$oldanswer
[
'parentid'
],
'oldanswer'
=>
$oldanswer
,
));
...
...
@@ -1030,19 +1042,24 @@
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_remove_owner_votes_from_post
(
$postid
);
qa_db_post_recount_votes
(
$postid
);
qa_db_points_update_ifuser
(
$oldcomment
[
'userid'
],
array
(
'cposts'
));
qa_db_points_update_ifuser
(
$userid
,
array
(
'cposts'
));
qa_report_event
(
'c_claim'
,
$userid
,
$handle
,
$cookieid
,
array
(
'postid'
=>
$
oldcomment
[
'postid'
]
,
'postid'
=>
$
postid
,
'parentid'
=>
$oldcomment
[
'parentid'
],
'oldcomment'
=>
$oldcomment
,
));
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa-include/qa-db-votes.php
View file @
d5e23e1b
...
...
@@ -150,6 +150,21 @@
));
}
/**
* Remove all votes assigned to a post that had been cast by the owner of the post.
*
* @param int $postid The post id which will be removed all votes from its owner.
*/
function
qa_db_remove_owner_votes_from_post
(
$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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment