From 77398f5a2904dcbae2a650eb5910167ff26268f0 Mon Sep 17 00:00:00 2001 From: "matty%chariot.net.au" <> Date: Sat, 17 Nov 2001 18:29:54 +0000 Subject: Bug 104677 : Votes field (text style) on showvotes.cgi defaults to size 5, not natural size and doesn't include a maxlength attribute. Patch by Christoper Aillon . --- globals.pl | 17 +++++++++++++++++ showvotes.cgi | 14 ++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/globals.pl b/globals.pl index 1654738e5..09c9934bf 100644 --- a/globals.pl +++ b/globals.pl @@ -21,6 +21,7 @@ # Dan Mosedale # Jake # Bradley Baetz +# Christopher Aillon # Contains some global variables and routines used throughout bugzilla. @@ -1502,6 +1503,22 @@ sub PerformSubsts { return $str; } +# Min and max routines. +sub min { + my $min = shift(@_); + foreach my $val (@_) { + $min = $val if $val < $min; + } + return $min; +} + +sub max { + my $max = shift(@_); + foreach my $val (@_) { + $max = $val if $val > $max; + } + return $max; +} # Trim whitespace from front and back. diff --git a/showvotes.cgi b/showvotes.cgi index bb87848f0..a6928bf84 100755 --- a/showvotes.cgi +++ b/showvotes.cgi @@ -20,6 +20,7 @@ # # Contributor(s): Terry Weissman # Stephan Niemz +# Christopher Aillon use diagnostics; use strict; @@ -138,13 +139,14 @@ if (defined $::FORM{'bug_id'}) { $summary = html_quote($summary); $sum += $count; if ($canedit) { - my $min = $maxvotesperbug{$product}; # minimum of these two - $min = $::prodmaxvotes{$product} if $::prodmaxvotes{$product} < $min; - if( $min < 2 ) { # checkbox - my $checked = $count ? ' checked' : ''; + my $min = min($::prodmaxvotes{$product}, $maxvotesperbug{$product}); + if ($min < 2) { # checkbox + my $checked = $count ? ' checked="checked"' : ''; $count = qq{}; - }else { # normal input - $count = qq{}; + } + else { # text input + my $maxlength = length $min; + $count = qq{}; } } print qq{ -- cgit v1.2.3-24-g4f1b