Choice lookup needs to happen here by the info we have,
which is anon_token_id. This adds the functions and code necessary to do that. This is probably a bit of a hack.
This commit is contained in:
parent
2deda98022
commit
f5872caf9d
2 changed files with 36 additions and 0 deletions
|
@ -195,6 +195,34 @@ function elec_choices_get ($handle, $election_id) {
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function elec_choices_get_by_anon_token_id ($handle, $anon_token_id) {
|
||||||
|
global $choices_table;
|
||||||
|
global $anon_tokens_table;
|
||||||
|
|
||||||
|
if ($handle === FALSE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
$query = "SELECT c.choice, c.id FROM ";
|
||||||
|
$query .= $choices_table . " c, " . $anon_tokens_table . " a";
|
||||||
|
$query .= " WHERE c.election_id = a.election_id";
|
||||||
|
$query .= " AND a.id = " . $anon_token_id;
|
||||||
|
$query .= " ORDER BY c.id";
|
||||||
|
|
||||||
|
|
||||||
|
$result = mysql_query ($query, $handle);
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
$retval = FALSE;
|
||||||
|
} else {
|
||||||
|
$result_array = array ();
|
||||||
|
while ($buffer = mysql_fetch_assoc ($result)) {
|
||||||
|
$result_array[] = $buffer;
|
||||||
|
}
|
||||||
|
$retval = $result_array;
|
||||||
|
}
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
function elec_verify_elections ($choices) {
|
function elec_verify_elections ($choices) {
|
||||||
if ($choices === FALSE || count ($choices) <= 1)
|
if ($choices === FALSE || count ($choices) <= 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -41,6 +41,14 @@ if (!$verify_token || $error) {
|
||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
} else {
|
} else {
|
||||||
$votes = elec_get_votes_for_anon_token ($handle, $anon_token_id);
|
$votes = elec_get_votes_for_anon_token ($handle, $anon_token_id);
|
||||||
|
$choices = elec_choices_get_by_anon_token_id($handle, $anon_token_id);
|
||||||
|
if ($choices === FALSE) {
|
||||||
|
$error .= "The ".htmlspecialchars(elec_election_get_type ($election))." is not properly set up.\n";
|
||||||
|
}
|
||||||
|
$choices_name = array ();
|
||||||
|
foreach ($choices as $choice) {
|
||||||
|
$choices_name[$choice["id"]] = $choice["choice"];
|
||||||
|
}
|
||||||
echo "<tr class=\"".$class."\">\n";
|
echo "<tr class=\"".$class."\">\n";
|
||||||
echo "<td><span class=\"token\">".htmlspecialchars($verify_token)."</span></td>\n";
|
echo "<td><span class=\"token\">".htmlspecialchars($verify_token)."</span></td>\n";
|
||||||
echo "<td>";
|
echo "<td>";
|
||||||
|
|
Loading…
Reference in a new issue