Check correct voting in ballot.
It's possible that ballots get mixed up when
a voter is participating in more than one
voting and sending the ballots manually (by
copying and pasting them into his mail client).
UseVote could - and should! - check that the
ballot belongs to the current voting by comparing
the ballot introduction ("WAHLSCHEIN fuer ...")
with the votename and throw an error if they
don't match.
* Add ballotintro (default: WAHLSCHEIN fuer) and
tpl_wrong_voting (default: wrong-voting) to
usevote.cfg
* Add messages to messages.cfg
* Modify ballot and ballot-personal templates
accordingly
* Add check to uvvote.pl
* Add error handling to UVmenu.pm
* Change UVmenu::menu call in uvcfv.pl due
to new parameter ($voting)
Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
parent
fb9d3eb071
commit
b9f5201405
8 changed files with 56 additions and 7 deletions
17
uvvote.pl
17
uvvote.pl
|
|
@ -224,6 +224,7 @@ sub process_vote {
|
|||
my $onevote = 0; # 0=no votes, 1=everything OK, 2=vote cancelled
|
||||
my $voteerror = ""; # error message in case of invalid vote
|
||||
my $ballot_id = ""; # ballot id (German: Wahlscheinkennung)
|
||||
my $voting = ""; # voting (should be votename)
|
||||
|
||||
# found address?
|
||||
if ($voter_addr) {
|
||||
|
|
@ -239,6 +240,14 @@ sub process_vote {
|
|||
push (@errors, 'InvalidAddress');
|
||||
}
|
||||
|
||||
# correct voting?
|
||||
if ($$body =~ /\Q$config{ballotintro}\E\s+(.+?)\s*$/m) {
|
||||
$voting = $1;
|
||||
push (@errors, 'WrongVoting') if ($config{votename} !~ /^\s*\Q$voting\E\s*$/);
|
||||
} else {
|
||||
push (@errors, 'NoVoting');
|
||||
}
|
||||
|
||||
# personalized ballots?
|
||||
if ($config{personal}) {
|
||||
if ($$body =~ /$config{ballotidtext}\s+([a-z0-9]+)/) {
|
||||
|
|
@ -343,7 +352,7 @@ sub process_vote {
|
|||
# Errors encountered?
|
||||
if (@errors) {
|
||||
my $res = UVmenu::menu(\@votes, \@header, $body, \$voter_addr, \$voter_name,
|
||||
\$ballot_id, \@set, \@errors);
|
||||
\$ballot_id, \$voting, \@set, \@errors);
|
||||
return 0 if ($res eq 'i'); # "Ignore": Ignore vote, don't save
|
||||
|
||||
my $tpl;
|
||||
|
|
@ -402,6 +411,12 @@ sub process_vote {
|
|||
my $msg = $template->processTemplate($config{tpl_bdsg_error});
|
||||
UVsendmail::mail($voter_addr, "Fehler", $msg, $msgid) if ($config{voteack});
|
||||
return 0;
|
||||
} elsif ($error{NoVoting} or $error{WrongVoting}) {
|
||||
$voteerror = UVmessage::get("VOTE_WRONG_VOTING");
|
||||
my $template = UVtemplate->new();
|
||||
$template->setKey('body' => $$body);
|
||||
my $msg = $template->processTemplate($config{tpl_wrong_voting});
|
||||
UVsendmail::mail($voter_addr, "Fehler", $msg, $msgid) if ($config{voteack});
|
||||
} elsif ($error{NoVote}) {
|
||||
$voteerror = UVmessage::get("VOTE_NO_VOTES");
|
||||
my $template = UVtemplate->new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue