From 63ececeb0b04265e63e777874f0dae99549ab75f Mon Sep 17 00:00:00 2001 From: "dave%intrec.com" <> Date: Wed, 24 Jan 2001 10:41:41 +0000 Subject: Fix for bug 31295: use checkbox for votes if only one vote allowed. Also eliminate displaying products with no votes. Patch by Stephan Niemz --- showvotes.cgi | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/showvotes.cgi b/showvotes.cgi index 3bdfcf2e5..8e7dc0d4d 100755 --- a/showvotes.cgi +++ b/showvotes.cgi @@ -19,6 +19,7 @@ # Rights Reserved. # # Contributor(s): Terry Weissman +# Stephan Niemz use diagnostics; use strict; @@ -59,7 +60,7 @@ if (defined $::FORM{'bug_id'}) { PutHeader("Show votes", "Show votes", $name); print qq{
\n}; print "\n"; - SendSQL("lock tables bugs read, votes write"); + SendSQL("lock tables bugs read, products read, votes write"); if (defined($::FORM{'voteon'})) { # Oh, boy, what a hack. Make sure there is an entry for this bug # in the vote table, just so that things display right. @@ -71,12 +72,21 @@ if (defined $::FORM{'bug_id'}) { } my $canedit = (defined $::COOKIE{'Bugzilla_login'} && $::COOKIE{'Bugzilla_login'} eq $name); + my %maxvotesperbug; + if( $canedit ) { + SendSQL("SELECT products.product, products.maxvotesperbug FROM products"); + while (MoreSQLData()) { + my ($prod, $max) = (FetchSQLData()); + $maxvotesperbug{$prod}= $max; + } + } foreach my $product (sort(keys(%::prodmaxvotes))) { if ($::prodmaxvotes{$product} <= 0) { next; } my $qprod = value_quote($product); SendSQL("select votes.bug_id, votes.count, bugs.short_desc, bugs.bug_status from votes, bugs where votes.who = $who and votes.bug_id = bugs.bug_id and bugs.product = " . SqlQuote($product) . "order by votes.bug_id"); + next if !MoreSQLData(); # don't show products without any votes my $sum = 0; print ""; while (MoreSQLData()) { @@ -90,14 +100,21 @@ if (defined $::FORM{'bug_id'}) { $summary = html_quote($summary); $sum += $count; if ($canedit) { - $count = ""; + my $min = $maxvotesperbug{$product}; # minimum of these two + $min = $::prodmaxvotes{$product} if $::prodmaxvotes{$product} < $min; + if( $min < 2 ) { # checkbox + my $checked = $count ? ' checked' : ''; + $count = qq{}; + }else { # normal input + $count = qq{}; + } } print qq{ - + }; } @@ -109,15 +126,14 @@ if (defined $::FORM{'bug_id'}) { if ($canedit) { print qq{\n}; print "
To change your votes, type in new numbers (using zero to\n"; - print "mean no votes), and then click Submit.\n"; + print "mean no votes) or change the checkbox, and then click Submit.\n"; } print ""; print "\n"; SendSQL("delete from votes where count <= 0"); SendSQL("unlock tables"); } - + print qq{Help! I don't understand this voting stuff}; PutFooter(); - -- cgit v1.2.3-24-g4f1b
Bug \#SummaryVotes
$product
$strike$id$endstrike $summary$count$count