\n";
$display = FALSE;
}
if ($display && isset ($_GET["election_id"]) && is_numeric ($_GET["election_id"]))
$election_id = $_GET["election_id"];
else {
$election_id = -1;
$error .= "Please choose an election/referendum on this list.
\n";
$display = FALSE;
}
if ($display && $election_id >= 0) {
$election = elec_get_election ($handle, $election_id);
if ($election === FALSE) {
$error .= "The specified election/referendum does not exist.
\n";
$display = FALSE;
} else if (!elec_election_has_ended ($election)) {
$error .= "The voting period for the specified ".elec_election_get_type ($election)." starts on ".$election["voting_start"]." (UTC) and ends on ".$election["voting_end"]." (UTC). It is not possible to see the results now.
\n";
$display = FALSE;
}
}
if (isset ($election) && $election !== FALSE) {
echo "Results for the ".$election["name"]."
\n";
}
if ($display) {
$anon_tokens = elec_get_anon_tokens_for_election ($handle, $election_id);
if ($anon_tokens === FALSE) {
$error .= "Can not get the anonymous tokens for this ".elec_election_get_type ($election).".\n";
$display = FALSE;
}
}
if ($display) {
$results = elec_get_results_election ($handle, $election_id);
if ($results === FALSE) {
$error .= "Can not get the results for this ".elec_election_get_type ($election).".\n";
$display = FALSE;
}
}
if ($display) {
$choices = elec_choices_get ($handle, $election_id);
if ($choices === FALSE) {
$error .= "The ".elec_election_get_type ($election)." is not properly set up.\n";
$display = FALSE;
}
}
if ($display) {
$nb_voters = count ($anon_tokens);
$automatic_results = array ();
echo "Please note that these results are automatically calculated and are thus not the official results.
\n";
echo "".$election["question"]."
";
echo "".$nb_voters." members voted for this ".elec_election_get_type ($election).". The repartition of the votes is:
\n";
echo "\n";
foreach ($results as $result) {
$found = FALSE;
foreach ($choices as $choice) {
if ($choice["id"] == $result["choice_id"]) {
echo "".$choice["choice"]." (".$result["total_choice"]." votes)
\n";
$automatic_results[] = $choice["choice"];
$found = TRUE;
break;
}
}
if (!$found) {
echo "Unknown value (".$result["choice_id"].") (".$result["total_choice"]." votes)
\n";
$automatic_results[] = "Unknown value (".$result["choice_id"].")";
$error .= "There was an unkown vote: ".$result["choice_id"]."
\n";
}
}
echo "
\n";
echo "The automatic result of this ".elec_election_get_type ($election)." is thus:
\n";
echo "\n";
for ($i = 0; $i < $election["choices_nb"]; $i++) {
echo "".$automatic_results[$i]."
\n";
}
echo "
\n";
echo "Please look at the list of all votes and verify that your vote is correct.
\n";
}
if (isset ($error) && $error != "") {
echo "".$error."
\n";;
echo "If you don't understand the error, you should probably contact the Membership and Elections Committee, which can be reached at elections@gnome.org.
\n";
}
if (isset ($handle))
elec_sql_close ($handle);
?>