| @@ 74-119 (lines=46) @@ | ||
| 71 | $mail_author = false; |
|
| 72 | if ('xoopspoll' === $pollmodules) { |
|
| 73 | $pollObj = $xpPollHandler->get($poll_id); |
|
| 74 | if ($pollObj instanceof XoopspollPoll) { |
|
| 75 | if ($pollObj->getVar('multiple')) { |
|
| 76 | $optionId = XoopsRequest::getInt('option_id', 0, 'POST'); |
|
| 77 | $optionId = (array)$optionId; // type cast to make sure it's an array |
|
| 78 | $optionId = array_map('intval', $optionId); // make sure values are integers |
|
| 79 | } else { |
|
| 80 | $optionId = $_POST['option_id']; |
|
| 81 | } |
|
| 82 | if (!$pollObj->hasExpired()) { |
|
| 83 | $msg = _MD_XOOPSPOLL_MUSTLOGIN; |
|
| 84 | //@todo:: add $url to all redirects |
|
| 85 | // $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $poll_id)); |
|
| 86 | if ($pollObj->isAllowedToVote()) { |
|
| 87 | $thisVoter = (!empty($GLOBALS['xoopsUser']) && ($GLOBALS['xoopsUser'] instanceof XoopsUser)) ? $GLOBALS['xoopsUser']->getVar('uid') : null; |
|
| 88 | $votedThisPoll = $xpLogHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $thisVoter); |
|
| 89 | if (!$votedThisPoll) { |
|
| 90 | /* user that hasn't voted before in this poll or module preferences allow it */ |
|
| 91 | $voteTime = time(); |
|
| 92 | if ($pollObj->vote($optionId, xoops_getenv('REMOTE_ADDR'), $voteTime)) { |
|
| 93 | if (!$xpPollHandler->updateCount($pollObj)) { // update the count and save in db |
|
| 94 | echo $pollObj->getHtmlErrors(); |
|
| 95 | exit(); |
|
| 96 | } |
|
| 97 | $msg = _MD_XOOPSPOLL_THANKSFORVOTE; |
|
| 98 | } else { |
|
| 99 | /* there was a problem registering the vote */ |
|
| 100 | redirect_header($GLOBALS['xoops']->buildUrl('index.php', array('poll_id' => $poll_id)), XoopspollConstants::REDIRECT_DELAY_MEDIUM, _MD_XOOPSPOLL_VOTE_ERROR); |
|
| 101 | } |
|
| 102 | } else { |
|
| 103 | $msg = _MD_XOOPSPOLL_ALREADYVOTED; |
|
| 104 | } |
|
| 105 | /* set anon user vote (and the time they voted) */ |
|
| 106 | if (!$GLOBALS['xoopsUser'] instanceof XoopsUser) { |
|
| 107 | xoops_load('pollUtility', 'xoopspoll'); |
|
| 108 | XoopspollPollUtility::setVoteCookie($poll_id, $voteTime, 0); |
|
| 109 | } |
|
| 110 | } else { |
|
| 111 | $msg = _MD_XOOPSPOLL_CANNOTVOTE; |
|
| 112 | } |
|
| 113 | } else { |
|
| 114 | /* poll has expired so just show the results */ |
|
| 115 | $msg = _MD_XOOPSPOLL_SORRYEXPIRED; |
|
| 116 | } |
|
| 117 | } else { |
|
| 118 | $msg = _MD_XOOPSPOLL_ERROR_INVALID_POLLID; |
|
| 119 | } |
|
| 120 | if (null !== $url) { |
|
| 121 | redirect_header($url, XoopspollConstants::REDIRECT_DELAY_MEDIUM, $msg); |
|
| 122 | } else { |
|
| @@ 57-102 (lines=46) @@ | ||
| 54 | ||
| 55 | $mail_author = false; |
|
| 56 | $pollObj = $xpPollHandler->get($poll_id); |
|
| 57 | if ($pollObj instanceof XoopspollPoll) { |
|
| 58 | if ($pollObj->getVar('multiple')) { |
|
| 59 | $optionId = $_POST['option_id']; |
|
| 60 | $optionId = (array)$optionId; // type cast to make sure it's an array |
|
| 61 | $optionId = array_map('intval', $optionId); // make sure values are integers |
|
| 62 | } else { |
|
| 63 | $optionId = $_POST['option_id']; |
|
| 64 | } |
|
| 65 | if (!$pollObj->hasExpired()) { |
|
| 66 | $msg = _MD_XOOPSPOLL_MUSTLOGIN; |
|
| 67 | //@todo:: add $url to all redirects |
|
| 68 | // $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $poll_id)); |
|
| 69 | if ($pollObj->isAllowedToVote()) { |
|
| 70 | $thisVoter = (!empty($GLOBALS['xoopsUser']) && ($GLOBALS['xoopsUser'] instanceof XoopsUser)) ? $GLOBALS['xoopsUser']->getVar('uid') : null; |
|
| 71 | $votedThisPoll = $xpLogHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $thisVoter); |
|
| 72 | if (!$votedThisPoll) { |
|
| 73 | /* user that hasn't voted before in this poll or module preferences allow it */ |
|
| 74 | $voteTime = time(); |
|
| 75 | if ($pollObj->vote($optionId, xoops_getenv('REMOTE_ADDR'), $voteTime)) { |
|
| 76 | if (!$xpPollHandler->updateCount($pollObj)) { // update the count and save in db |
|
| 77 | echo $pollObj->getHtmlErrors(); |
|
| 78 | exit(); |
|
| 79 | } |
|
| 80 | $msg = _MD_XOOPSPOLL_THANKSFORVOTE; |
|
| 81 | } else { |
|
| 82 | /* there was a problem registering the vote */ |
|
| 83 | redirect_header($GLOBALS['xoops']->buildUrl('index.php', array('poll_id' => $poll_id)), XoopspollConstants::REDIRECT_DELAY_MEDIUM, _MD_XOOPSPOLL_VOTE_ERROR); |
|
| 84 | } |
|
| 85 | } else { |
|
| 86 | $msg = _MD_XOOPSPOLL_ALREADYVOTED; |
|
| 87 | } |
|
| 88 | /* set anon user vote (and the time they voted) */ |
|
| 89 | if (!$GLOBALS['xoopsUser'] instanceof XoopsUser) { |
|
| 90 | xoops_load('pollUtility', 'xoopspoll'); |
|
| 91 | XoopspollPollUtility::setVoteCookie($poll_id, $voteTime, 0); |
|
| 92 | } |
|
| 93 | } else { |
|
| 94 | $msg = _MD_XOOPSPOLL_CANNOTVOTE; |
|
| 95 | } |
|
| 96 | } else { |
|
| 97 | /* poll has expired so just show the results */ |
|
| 98 | $msg = _MD_XOOPSPOLL_SORRYEXPIRED; |
|
| 99 | } |
|
| 100 | } else { |
|
| 101 | $msg = _MD_XOOPSPOLL_ERROR_INVALID_POLLID; |
|
| 102 | } |
|
| 103 | if (null !== $url) { |
|
| 104 | redirect_header($url, XoopspollConstants::REDIRECT_DELAY_MEDIUM, $msg); |
|
| 105 | } else { |
|
| @@ 159-204 (lines=46) @@ | ||
| 156 | // $option_id = XoopsRequest::getInt('option_id', 0, 'POST'); |
|
| 157 | $mail_author = false; |
|
| 158 | $pollObj = $pollHandler->get($pollId); |
|
| 159 | if ($pollObj instanceof XoopspollPoll) { |
|
| 160 | if ($pollObj->getVar('multiple')) { |
|
| 161 | $optionId = XoopsRequest::getArray('option_id', array(), 'POST'); |
|
| 162 | $optionId = (array)$optionId; // type cast to make sure it's an array |
|
| 163 | $optionId = array_map('intval', $optionId); // make sure values are integers |
|
| 164 | } else { |
|
| 165 | $optionId = XoopsRequest::getInt('option_id', 0, 'POST'); |
|
| 166 | } |
|
| 167 | if (!$pollObj->hasExpired()) { |
|
| 168 | $msg = _MD_XOOPSPOLL_MUSTLOGIN; |
|
| 169 | //@todo:: add $url to all redirects |
|
| 170 | // $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $pollId)); |
|
| 171 | if ($pollObj->isAllowedToVote()) { |
|
| 172 | $thisVoter = (!empty($GLOBALS['xoopsUser']) && ($GLOBALS['xoopsUser'] instanceof XoopsUser)) ? $GLOBALS['xoopsUser']->getVar('uid') : null; |
|
| 173 | $votedThisPoll = $logHandler->hasVoted($pollId, xoops_getenv('REMOTE_ADDR'), $thisVoter); |
|
| 174 | if (!$votedThisPoll) { |
|
| 175 | /* user that hasn't voted before in this poll or module preferences allow it */ |
|
| 176 | $voteTime = time(); |
|
| 177 | if ($pollObj->vote($optionId, xoops_getenv('REMOTE_ADDR'), $voteTime)) { |
|
| 178 | if (!$pollHandler->updateCount($pollObj)) { // update the count and save in db |
|
| 179 | echo $pollObj->getHtmlErrors(); |
|
| 180 | exit(); |
|
| 181 | } |
|
| 182 | $msg = _MD_XOOPSPOLL_THANKSFORVOTE; |
|
| 183 | } else { |
|
| 184 | /* there was a problem registering the vote */ |
|
| 185 | redirect_header($GLOBALS['xoops']->buildUrl('index.php', array('poll_id' => $pollId)), XoopspollConstants::REDIRECT_DELAY_MEDIUM, _MD_XOOPSPOLL_VOTE_ERROR); |
|
| 186 | } |
|
| 187 | } else { |
|
| 188 | $msg = _MD_XOOPSPOLL_ALREADYVOTED; |
|
| 189 | } |
|
| 190 | /* set anon user vote (and the time they voted) */ |
|
| 191 | if (!$GLOBALS['xoopsUser'] instanceof XoopsUser) { |
|
| 192 | xoops_load('pollUtility', 'xoopspoll'); |
|
| 193 | XoopspollPollUtility::setVoteCookie($pollId, $voteTime, 0); |
|
| 194 | } |
|
| 195 | } else { |
|
| 196 | $msg = _MD_XOOPSPOLL_CANNOTVOTE; |
|
| 197 | } |
|
| 198 | } else { |
|
| 199 | /* poll has expired so just show the results */ |
|
| 200 | $msg = _MD_XOOPSPOLL_SORRYEXPIRED; |
|
| 201 | } |
|
| 202 | } else { |
|
| 203 | $msg = _MD_XOOPSPOLL_ERROR_INVALID_POLLID; |
|
| 204 | } |
|
| 205 | if ('' !== $url) { |
|
| 206 | redirect_header($url, XoopspollConstants::REDIRECT_DELAY_MEDIUM, $msg); |
|
| 207 | } else { |
|