From c6f80310afc00cf7d5114e638cbaaefde3914da0 Mon Sep 17 00:00:00 2001 From: "terry%mozilla.org" <> Date: Fri, 8 Oct 1999 06:54:47 +0000 Subject: Added the ability for users to "vote" on which bugs they think should be fixed. --- doeditvotes.cgi | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 doeditvotes.cgi (limited to 'doeditvotes.cgi') 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 + +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 $::COOKIE{'Bugzilla_login'}, then please\n"; + print "click here.
\n"; + navigation_header(); + exit(); +} + +my @buglist = grep {/^\d+$/} keys(%::FORM); + +if (0 == @buglist) { + PutHeader("Oops?"); + print "Something got confused. Please click Back 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 Back and try again.
\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 "$prod product, but you are using $prodcount{$prod}.\n"; + print "Please click Back and try again.
\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{

Review your votes


\n}; +navigation_header(); +exit(); + + -- cgit v1.2.3-24-g4f1b