summaryrefslogtreecommitdiffstats
path: root/doeditvotes.cgi
diff options
context:
space:
mode:
authorterry%mozilla.org <>1999-10-08 08:54:47 +0200
committerterry%mozilla.org <>1999-10-08 08:54:47 +0200
commitc6f80310afc00cf7d5114e638cbaaefde3914da0 (patch)
tree6bdaf2497180648d821f3a91e320b6c80b29de23 /doeditvotes.cgi
parent12d85f8fa42b7130608531ea61b287e9fa822125 (diff)
downloadbugzilla-c6f80310afc00cf7d5114e638cbaaefde3914da0.tar.gz
bugzilla-c6f80310afc00cf7d5114e638cbaaefde3914da0.tar.xz
Added the ability for users to "vote" on which bugs they think should
be fixed.
Diffstat (limited to 'doeditvotes.cgi')
-rwxr-xr-xdoeditvotes.cgi102
1 files changed, 102 insertions, 0 deletions
diff --git a/doeditvotes.cgi b/doeditvotes.cgi
new file mode 100755
index 000000000..03c4c1d88
--- /dev/null
+++ b/doeditvotes.cgi
@@ -0,0 +1,102 @@
+#!/usr/bonsaitools/bin/perl -w
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# The contents of this file are subject to the Mozilla Public License
+# Version 1.0 (the "License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# License for the specific language governing rights and limitations
+# under the License.
+#
+# The Original Code is the Bugzilla Bug Tracking System.
+#
+# The Initial Developer of the Original Code is Netscape Communications
+# Corporation. Portions created by Netscape are Copyright (C) 1998
+# Netscape Communications Corporation. All Rights Reserved.
+#
+# Contributor(s): Terry Weissman <terry@mozilla.org>
+
+use diagnostics;
+use strict;
+
+require "CGI.pl";
+
+confirm_login();
+
+print "Content-type: text/html\n\n";
+
+ConnectToDatabase();
+GetVersionTable();
+
+my $who = DBNameToIdAndCheck($::COOKIE{'Bugzilla_login'});
+
+if ($who ne $::FORM{'who'}) {
+ PutHeader("Wrong login.");
+ print "The login info got confused. If you want to adjust the votes\n";
+ print "for <tt>$::COOKIE{'Bugzilla_login'}</tt>, then please\n";
+ print "<a href=showvotes.cgi?user=$who>click here</a>.<hr>\n";
+ navigation_header();
+ exit();
+}
+
+my @buglist = grep {/^\d+$/} keys(%::FORM);
+
+if (0 == @buglist) {
+ PutHeader("Oops?");
+ print "Something got confused. Please click <b>Back</b> and try again.";
+ navigation_header();
+ exit();
+}
+
+foreach my $id (@buglist) {
+ $::FORM{$id} = trim($::FORM{$id});
+ if ($::FORM{$id} !~ /\d+/ || $::FORM{$id} < 0) {
+ PutHeader("Numbers only, please");
+ print "Only use numeric values for your bug votes.\n";
+ print "Please click <b>Back</b> and try again.<hr>\n";
+ navigation_header();
+ exit();
+ }
+}
+
+SendSQL("select bug_id, product from bugs where bug_id = " .
+ join(" or bug_id = ", @buglist));
+
+my %prodcount;
+
+while (MoreSQLData()) {
+ my ($id, $prod) = (FetchSQLData());
+ if (!defined $prodcount{$prod}) {
+ $prodcount{$prod} = 0;
+ }
+ $prodcount{$prod} += $::FORM{$id};
+}
+
+foreach my $prod (keys(%prodcount)) {
+ if ($prodcount{$prod} > $::prodmaxvotes{$prod}) {
+ PutHeader("Don't overstuff!", "Illegal vote");
+ print "You may only use $::prodmaxvotes{$prod} votes for bugs in the\n";
+ print "<tt>$prod</tt> product, but you are using $prodcount{$prod}.\n";
+ print "Please click <b>Back</b> and try again.<hr>\n";
+ navigation_header();
+ exit();
+ }
+}
+
+SendSQL("delete from votes where who = $who");
+foreach my $id (@buglist) {
+ if ($::FORM{$id} > 0) {
+ SendSQL("insert into votes (who, bug_id, count) values ($who, $id, $::FORM{$id})");
+ }
+}
+
+PutHeader("Voting tabulated", "Voting tabulated", $::COOKIE{'Bugzilla_login'});
+print "Your votes have been recorded.\n";
+print qq{<p><a href="showvotes.cgi?user=$who">Review your votes</a><hr>\n};
+navigation_header();
+exit();
+
+