Commit 63ececeb authored by dave%intrec.com's avatar dave%intrec.com

Fix for bug 31295: use checkbox for votes if only one vote allowed. Also…

Fix for bug 31295: use checkbox for votes if only one vote allowed. Also eliminate displaying products with no votes. Patch by Stephan Niemz <st.n@gmx.net>
parent cfb492c4
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# Rights Reserved. # Rights Reserved.
# #
# Contributor(s): Terry Weissman <terry@mozilla.org> # Contributor(s): Terry Weissman <terry@mozilla.org>
# Stephan Niemz <st.n@gmx.net>
use diagnostics; use diagnostics;
use strict; use strict;
...@@ -59,7 +60,7 @@ if (defined $::FORM{'bug_id'}) { ...@@ -59,7 +60,7 @@ if (defined $::FORM{'bug_id'}) {
PutHeader("Show votes", "Show votes", $name); PutHeader("Show votes", "Show votes", $name);
print qq{<form action="doeditvotes.cgi">\n}; print qq{<form action="doeditvotes.cgi">\n};
print "<table><tr><td></td><th>Bug \#</th><th>Summary</th><th>Votes</th></tr>\n"; print "<table><tr><td></td><th>Bug \#</th><th>Summary</th><th>Votes</th></tr>\n";
SendSQL("lock tables bugs read, votes write"); SendSQL("lock tables bugs read, products read, votes write");
if (defined($::FORM{'voteon'})) { if (defined($::FORM{'voteon'})) {
# Oh, boy, what a hack. Make sure there is an entry for this bug # Oh, boy, what a hack. Make sure there is an entry for this bug
# in the vote table, just so that things display right. # in the vote table, just so that things display right.
...@@ -71,12 +72,21 @@ if (defined $::FORM{'bug_id'}) { ...@@ -71,12 +72,21 @@ if (defined $::FORM{'bug_id'}) {
} }
my $canedit = (defined $::COOKIE{'Bugzilla_login'} && my $canedit = (defined $::COOKIE{'Bugzilla_login'} &&
$::COOKIE{'Bugzilla_login'} eq $name); $::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))) { foreach my $product (sort(keys(%::prodmaxvotes))) {
if ($::prodmaxvotes{$product} <= 0) { if ($::prodmaxvotes{$product} <= 0) {
next; next;
} }
my $qprod = value_quote($product); 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"); 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; my $sum = 0;
print "<tr><th>$product</th></tr>"; print "<tr><th>$product</th></tr>";
while (MoreSQLData()) { while (MoreSQLData()) {
...@@ -90,14 +100,21 @@ if (defined $::FORM{'bug_id'}) { ...@@ -90,14 +100,21 @@ if (defined $::FORM{'bug_id'}) {
$summary = html_quote($summary); $summary = html_quote($summary);
$sum += $count; $sum += $count;
if ($canedit) { if ($canedit) {
$count = "<input name=$id value=$count size=5>"; 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{<input type="checkbox" name="$id" value="1"$checked>};
}else { # normal input
$count = qq{<input name="$id" value="$count" size="5">};
}
} }
print qq{ print qq{
<tr> <tr>
<td></td> <td></td>
<td>$strike<a href="showvotes.cgi?bug_id=$id">$id</a>$endstrike</td> <td>$strike<a href="showvotes.cgi?bug_id=$id">$id</a>$endstrike</td>
<td><a href="show_bug.cgi?id=$id">$summary</a></td> <td><a href="show_bug.cgi?id=$id">$summary</a></td>
<td align=right>$count</td> <td align="right">$count</td>
</tr> </tr>
}; };
} }
...@@ -109,7 +126,7 @@ if (defined $::FORM{'bug_id'}) { ...@@ -109,7 +126,7 @@ if (defined $::FORM{'bug_id'}) {
if ($canedit) { if ($canedit) {
print qq{<input type=submit value="Submit">\n}; print qq{<input type=submit value="Submit">\n};
print "<br>To change your votes, type in new numbers (using zero to\n"; print "<br>To change your votes, type in new numbers (using zero to\n";
print "mean no votes), and then click <b>Submit</b>.\n"; print "mean no votes) or change the checkbox, and then click <b>Submit</b>.\n";
} }
print "<input type=hidden name=who value=$who>"; print "<input type=hidden name=who value=$who>";
print "</form>\n"; print "</form>\n";
...@@ -120,4 +137,3 @@ if (defined $::FORM{'bug_id'}) { ...@@ -120,4 +137,3 @@ if (defined $::FORM{'bug_id'}) {
print qq{<a href="votehelp.html">Help! I don't understand this voting stuff</a>}; print qq{<a href="votehelp.html">Help! I don't understand this voting stuff</a>};
PutFooter(); PutFooter();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment