function advpoll_form_submit_check in Advanced Poll 7.3
Same name and namespace in other branches
- 7 advpoll.module \advpoll_form_submit_check()
- 7.2 advpoll.module \advpoll_form_submit_check()
Prevents voting on the same poll again.
Method is used to check again for user having already voted in order to prevent having multiple instances of the same poll open on different pages to cast more votes.
3 calls to advpoll_form_submit_check()
- advpoll_draggable_submit in advpoll_ranking/
advpoll_ranking.module - Submit handler for ranking polls.
- advpoll_form_submit in ./
advpoll.module - Submit handler for voting.
- advpoll_ranking_submit in advpoll_ranking/
advpoll_ranking.module - Submit handler for ranking polls.
File
- ./
advpoll.module, line 800
Code
function advpoll_form_submit_check($data, $nid) {
if ($data->mode === 'cookie' && isset($_COOKIE['advpoll' . $nid])) {
return t('You have already voted on this poll.');
}
if ($data->mode === 'normal') {
global $user;
$criteria = array();
$criteria['entity_id'] = $nid;
$criteria['entity_type'] = 'node';
$criteria['value_type'] = 'percent';
$criteria['uid'] = $user->uid;
if (!$user->uid) {
$criteria['vote_source'] = ip_address();
}
$results = votingapi_select_votes($criteria);
if ($results) {
return t('You have already voted on this poll.');
}
}
}