Redirect ended polls to the results page

This commit is contained in:
Alex Cabal 2022-08-20 13:18:42 -05:00
parent 7201081aed
commit 35565d90f6

View file

@ -9,6 +9,12 @@ $canVote = true; // Allow non-logged-in users to see the 'vote' button
try{
$poll = Poll::GetByUrlName(HttpInput::Str(GET, 'pollurlname', false));
if(!$poll->IsActive() && $poll->End !== null && $poll->End < new DateTime()){
// If the poll ended, redirect to the results
header('Location: ' . $poll->Url . '/votes');
exit();
}
if(isset($GLOBALS['User'])){
$canVote = false; // User is logged in, hide the vote button unless they haven't voted yet
try{