Initial checkin of upstream version 4.09.
[usenet/usevote.git] / uvballot.pl
CommitLineData
ac7e2c54
TH
1#!/usr/bin/perl -w
2
3###############################################################################
4# UseVoteGer 4.09 Wahlscheingenerierung
5# (c) 2001-2005 Marc Langer <uv@marclanger.de>
6#
7# This script package is free software; you can redistribute it and/or
8# modify it under the terms of the GNU Public License as published by the
9# Free Software Foundation.
10#
11# Use this script to create the ballot which can be inserted into the CfV.
12# Not for personal ballots (personal=1 in usevote.cfg), use uvcfv.pl instead.
13#
14# Many thanks to:
15# - Ron Dippold (Usevote 3.0, 1993/94)
16# - Frederik Ramm (German translation, 1994)
17# - Wolfgang Behrens (UseVoteGer 3.1, based on Frederik's translation, 1998/99)
18# - Cornell Binder for some good advice and code fragments
19#
20# This is a complete rewrite of UseVoteGer 3.1 in Perl (former versions were
21# written in C). Not all functions of Usevote/UseVoteGer 3.x are implemented!
22###############################################################################
23
24use strict;
25use Getopt::Long;
26use Text::Wrap qw(wrap $columns);
27use FindBin qw($Bin);
28use lib $Bin;
29use UVconfig;
30use UVtemplate;
31
32my %opt_ctl = ();
33
34print STDERR "\n$usevote_version Wahlscheingenerierung - (c) 2001-2005 Marc Langer\n\n";
35
36# unknown parameters remain in @ARGV (for "help")
37Getopt::Long::Configure(qw(pass_through bundling));
38
39# Put known parameters in %opt_ctl
40GetOptions(\%opt_ctl, qw(t|template c|config-file=s));
41
42# Additional parameters or invalid options? Show help and exit.
43help() if (@ARGV);
44
45# Get name auf config file (default: usevote.cfg) and read it
46my $cfgfile = $opt_ctl{c} || "usevote.cfg";
47UVconfig::read_config($cfgfile);
48
49# Set columns for Text::Wrap
50$columns = $config{rightmargin};
51
52if ($config{personal}) {
53 print_ballot_personal();
54} else {
55 print_ballot();
56}
57
58exit 0;
59
60
61##############################################################################
62# Print out a proper ballot #
63##############################################################################
64
65sub print_ballot {
66
67 my $template = UVtemplate->new();
68
69 $template->setKey('votename' => $config{votename});
70 $template->setKey('nametext' => $config{nametext});
71 $template->setKey('bdsg' => $config{bdsg});
72 $template->setKey('bdsgtext' => $config{bdsgtext});
73 $template->setKey('bdsginfo' => $config{bdsginfo});
74
75 for (my $n=0; $n<@groups; $n++) {
76 $template->addListItem('groups', pos=>$n+1, group=>$groups[$n]);
77 }
78
79 print $template->processTemplate($config{'tpl_ballot'});
80
81}
82
83
84##############################################################################
85# Generate a ballot request (if personalized ballots are activated) #
86##############################################################################
87
88sub print_ballot_personal {
89 my $template = UVtemplate->new();
90 $template->setKey('mailaddress' => $config{mailfrom});
91 print $template->processTemplate($config{'tpl_ballot_request'});
92}
93
94
95##############################################################################
96# Print help text (options and syntax) on -h or --help #
97##############################################################################
98
99sub help {
100 print STDERR <<EOF;
101Usage: uvballot.pl [-c config_file]
102 uvballot.pl -h
103
104Generiert den Wahlschein fuer den CfV. Bei personalisierten Wahlscheinen
105(personal = 1 in usevote.cfg) wird nur ein Dummy-Abschnitt mit Hinweisen
106zur Wahlscheinanforderung ausgegeben.
107
108 -c config_file liest die Konfiguration aus config_file
109 (usevote.cfg falls nicht angegeben)
110
111 -h, --help zeigt diesen Hilfetext an
112
113EOF
114
115 exit 0;
116}
This page took 0.014766 seconds and 4 git commands to generate.