2005-10-24 17:59:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function step3_do () {
|
|
|
|
global $election;
|
2005-10-24 18:25:43 +00:00
|
|
|
global $choices_nb;
|
|
|
|
global $choices;
|
2005-10-24 17:59:15 +00:00
|
|
|
global $vote;
|
|
|
|
global $votes_array;
|
|
|
|
|
|
|
|
$result = "<h2>Step 3/4 - Confirm your vote</h2>\n";
|
|
|
|
|
|
|
|
$result .= "<p><strong>".$election["question"]."</strong></p>\n";
|
2005-10-24 18:25:43 +00:00
|
|
|
if (($choices_nb == 1 && $vote < 0) ||
|
|
|
|
($choices_nb > 1 && count ($votes_array) >= 1)) {
|
2005-10-24 17:59:15 +00:00
|
|
|
$result .= "<p>You choose to vote for:</p>\n";
|
|
|
|
|
|
|
|
$result .= "<div class=\"votedata\">\n";
|
2005-10-24 18:25:43 +00:00
|
|
|
if ($choices_nb == 1) {
|
2005-10-24 17:59:15 +00:00
|
|
|
|
2005-10-24 18:25:43 +00:00
|
|
|
$choice = null;
|
|
|
|
foreach ($choices as $opt) {
|
2005-10-24 17:59:15 +00:00
|
|
|
if ($opt["id"] == $vote) {
|
2005-10-24 18:25:43 +00:00
|
|
|
$choice = $opt;
|
2005-10-24 17:59:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-10-24 18:25:43 +00:00
|
|
|
if ($choice != null)
|
|
|
|
$result .= "<p>".$choice["choice"]."</p>\n";
|
2005-10-24 17:59:15 +00:00
|
|
|
else {
|
|
|
|
$result .= "<p>Unknown vote: ".$vote."</p>\n";
|
|
|
|
$error .= "There was an unkown vote: ".$vote."<br />\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$result .= "<ul>\n";
|
|
|
|
foreach ($votes_array as $vote) {
|
|
|
|
$found = FALSE;
|
2005-10-24 18:25:43 +00:00
|
|
|
foreach ($choices as $choice) {
|
|
|
|
if ($choice["id"] == $vote) {
|
|
|
|
$result .= "<li>".$choice["choice"]."</li>\n";
|
2005-10-24 17:59:15 +00:00
|
|
|
$found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$found) {
|
|
|
|
$result .= "<li>Unknown vote: ".$vote."</li>\n";
|
|
|
|
$error .= "There was an unkown vote: ".$vote."<br />\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$result .= "</ul>\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
$result .= "</div>\n";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$result .= "<div class=\"votedata\">\n";
|
|
|
|
$result .= "<p>You choose to vote for none of the possible answers.</p>\n";
|
|
|
|
$result .= "</div>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$result .= "<p>To confirm this vote, please continue to the next step.</p>\n";
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|