Update documentation.
[usenet/usevote.git] / UVmenu.pm
index d90da9c..07e32c8 100644 (file)
--- a/UVmenu.pm
+++ b/UVmenu.pm
@@ -17,7 +17,8 @@ $VERSION = "0.4";
 ##############################################################################
 # Menu for interaction with the votetaker                                    #
 # Parameters: votes list and header (references to arrays)                   #
-#             Body, Mailadress, Name, Ballot ID (references to strings)      #
+#             Body, Mailadress, Name, Ballot ID,                             #
+#             Voting (references to strings)                                 #
 #             List of newly set fields (reference to array)                  #
 #             List of errors to correct (Array-Ref)                          #
 # Return Values: 'w': proceed                                                #
@@ -25,7 +26,7 @@ $VERSION = "0.4";
 ##############################################################################
 
 sub menu {
-  my ($votes, $header, $body, $addr, $name, $ballot_id, $set, $errors) = @_;
+  my ($votes, $header, $body, $addr, $name, $ballot_id, $voting, $set, $errors) = @_;
   my $input = "";
   my $voter_addr = $$addr || '';
   my $voter_name = $$name || '';
@@ -59,6 +60,7 @@ sub menu {
   while (1) {
 
     system($config{clearcmd});
+    print "-> $config{votename} <-\n";
     print UVmessage::get("MENU_PROBLEMS") . "\n";
 
     foreach my $error (keys %errors) {
@@ -68,6 +70,12 @@ sub menu {
     my $menucaption = UVmessage::get("MENU_CAPTION");
     print "\n\n$menucaption\n";
     print "=" x length($menucaption), "\n\n";
+
+    # don't print this option if called from uvcfv.pl
+    unless ($mailonly) {
+      print "(0) ", UVmessage::get("MENU_DIFF_BALLOT"), "\n";
+    }
+
     print "(1) ", UVmessage::get("MENU_SHOW_MAIL"), "\n\n",
           UVmessage::get("MENU_CHANGE_PROPERTIES"), "\n",
           "(2) ", UVmessage::get("MENU_ADDRESS"), " [$voter_addr]\n";
@@ -79,6 +87,7 @@ sub menu {
       print "(5) ", UVmessage::get("MENU_BALLOT_ID"), " [$$ballot_id]\n"
         if ($config{personal});
       print "(6) ", UVmessage::get("MENU_BDSG"), "\n" if ($config{bdsg});
+      print "(7) ", UVmessage::get("MENU_VOTING"), " [", $$voting, "]\n";
     }
 
     print "\n",
@@ -93,7 +102,14 @@ sub menu {
     # only accept 1, 2, i and w if called from uvcfv.pl
     next if ($mailonly && $input !~ /^[12iw]$/i);
 
-    if ($input eq '1') {
+    if ($input eq '0') {
+      # ignore SIGPIPE (Bug in more and less)
+      $SIG{PIPE} = 'IGNORE';
+      open (DIFF, "|$config{diff} - $config{sampleballotfile} | $config{pager}");
+      print DIFF $$body, "\n";
+      close (DIFF);
+
+    } elsif ($input eq '1') {
       system($config{clearcmd});
       # ignore SIGPIPE (Bug in more and less)
       $SIG{PIPE} = 'IGNORE';
@@ -269,6 +285,22 @@ sub menu {
         $errors{InvalidBDSG} = UVmessage::get("MENU_INVALIDBDSG");
       }
 
+    } elsif ($input eq '7') {
+      my $sel;
+      do {
+        print "[a] ", UVmessage::get("MENU_VOTING_CORRECT"), "\n",
+              "[b] ", UVmessage::get("MENU_VOTING_WRONG"), "\n\n",
+              UVmessage::get("MENU_PROMPT");
+        $sel = <STDIN>;
+      } until ($sel =~ /^[ab]$/i);
+
+      if ($sel =~ /^a$/i) {
+        delete $errors{NoVoting};
+        delete $errors{WrongVoting};
+      } else {
+        $errors{WrongVoting} = UVmessage::get("MENU_WRONGVOTING");
+      }
+
     } elsif ($input =~ /^i$/i) {
       my $ignore = UVmessage::get("MENU_IGNORE_STRING");
       # Set columns for Text::Wrap
This page took 0.011739 seconds and 4 git commands to generate.