Commit 0effcbcf authored by terry%mozilla.org's avatar terry%mozilla.org

Make a universal routine to report errors in forms, so that we can

have a universal (and more noticable) way of displaying them.
parent 78dfe401
...@@ -799,6 +799,15 @@ sub PutFooter { ...@@ -799,6 +799,15 @@ sub PutFooter {
} }
sub PuntTryAgain ($) {
my ($str) = (@_);
print PerformSubsts(Param("errorhtml"),
{errormsg => $str});
PutFooter();
exit;
}
sub CheckIfVotedConfirmed { sub CheckIfVotedConfirmed {
my ($id, $who) = (@_); my ($id, $who) = (@_);
SendSQL("SELECT bugs.votes, bugs.bug_status, products.votestoconfirm, " . SendSQL("SELECT bugs.votes, bugs.bug_status, products.votestoconfirm, " .
...@@ -878,18 +887,6 @@ sub DumpBugActivity { ...@@ -878,18 +887,6 @@ sub DumpBugActivity {
} }
#
# Prints a warnbanner incl. image with given message
#
sub warnBanner( $ )
{
my ($msg) = (@_);
print Param("warnbannerhtml");
print $msg;
print Param("warnfooterhtml");
}
sub GetCommandMenu { sub GetCommandMenu {
my $loggedin = quietly_check_login(); my $loggedin = quietly_check_login();
my $html = qq{<FORM METHOD=GET ACTION="show_bug.cgi">}; my $html = qq{<FORM METHOD=GET ACTION="show_bug.cgi">};
......
...@@ -82,10 +82,7 @@ sub SqlifyDate { ...@@ -82,10 +82,7 @@ sub SqlifyDate {
} }
my $date = str2time($str); my $date = str2time($str);
if (!defined $date) { if (!defined $date) {
print "\n\n<P>The string '<tt>$str</tt>' is not a legal date.\n"; PuntTryAgain("The string '<tt>$str</tt>' is not a legal date.");
print "<P>Please click the <B>Back</B> button and try again.\n";
PutFooter();
exit;
} }
return time2str("%Y/%m/%d %H:%M:%S", $date); return time2str("%Y/%m/%d %H:%M:%S", $date);
} }
...@@ -117,10 +114,7 @@ sub Error { ...@@ -117,10 +114,7 @@ sub Error {
if (!$serverpush) { if (!$serverpush) {
print "Content-type: text/html\n\n"; print "Content-type: text/html\n\n";
} }
print $str; PuntTryAgain($str);
print "\n<P>Please press <B>Back</B> and try again.\n";
PutFooter();
exit();
} }
......
...@@ -207,6 +207,13 @@ DefParam("footerhtml", ...@@ -207,6 +207,13 @@ DefParam("footerhtml",
%commandmenu% %commandmenu%
</TD></TR></TABLE></TD></TR></TABLE>'); </TD></TR></TABLE></TD></TR></TABLE>');
DefParam("errorhtml",
"This is what is printed out when a form is improperly filled out. %errormsg% is replaced by the actual error itself; %<i>anythingelse</i>% gets replaced by the definition of that parameter (as defined on this page).",
"l",
qq{<TABLE CELLPADDING=20><TR><TD BGCOLOR="#ff0000">
<FONT SIZE="+2">%errormsg%</FONT></TD></TR></TABLE>
<P>Please press <B>Back</B> and try again.<P>});
DefParam("bannerhtml", DefParam("bannerhtml",
...@@ -243,17 +250,6 @@ DefParam("shutdownhtml", ...@@ -243,17 +250,6 @@ DefParam("shutdownhtml",
""); "");
DefParam("warnbannerhtml",
"HTML to prepend to warning messages.",
"l",
"<font size=+1>");
DefParam("warnfooterhtml",
"HTML to append to warning messages.",
"l",
"</font>");
DefParam("passwordmail", DefParam("passwordmail",
q{The email that gets sent to people to tell them their password. Within q{The email that gets sent to people to tell them their password. Within
this text, %mailaddress% gets replaced by the person's email address, this text, %mailaddress% gets replaced by the person's email address,
......
...@@ -33,7 +33,16 @@ sub sillyness { ...@@ -33,7 +33,16 @@ sub sillyness {
my $zz; my $zz;
$zz = $::buffer; $zz = $::buffer;
$zz = %::COOKIE; $zz = %::COOKIE;
$zz = %::components;
$zz = %::versions;
$zz = @::legal_bug_status;
$zz = @::legal_opsys;
$zz = @::legal_platform;
$zz = @::legal_priority;
$zz = @::legal_product;
$zz = @::legal_severity;
} }
confirm_login(); confirm_login();
print "Set-Cookie: PLATFORM=$::FORM{'product'} ; path=/ ; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; print "Set-Cookie: PLATFORM=$::FORM{'product'} ; path=/ ; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
...@@ -59,18 +68,12 @@ umask 0; ...@@ -59,18 +68,12 @@ umask 0;
ConnectToDatabase(); ConnectToDatabase();
if (!defined $::FORM{'component'} || $::FORM{'component'} eq "") { if (!defined $::FORM{'component'} || $::FORM{'component'} eq "") {
print "You must choose a component that corresponds to this bug. If\n"; PuntTryAgain("You must choose a component that corresponds to this bug. " .
print "necessary, just guess. But please hit the <B>Back</B> button\n"; "If necessary, just guess.");
print "and choose a component.\n";
PutFooter();
exit 0
} }
if (!defined $::FORM{'short_desc'} || trim($::FORM{'short_desc'}) eq "") { if (!defined $::FORM{'short_desc'} || trim($::FORM{'short_desc'}) eq "") {
print "You must enter a summary for this bug. Please hit the\n"; PuntTryAgain("You must enter a summary for this bug.");
print "<B>Back</B> button and try again.\n";
PutFooter();
exit;
} }
my $forceAssignedOK = 0; my $forceAssignedOK = 0;
......
...@@ -179,17 +179,14 @@ sub CheckCanChangeField { ...@@ -179,17 +179,14 @@ sub CheckCanChangeField {
SendSQL("UNLOCK TABLES"); SendSQL("UNLOCK TABLES");
$oldvalue = value_quote($oldvalue); $oldvalue = value_quote($oldvalue);
$newvalue = value_quote($newvalue); $newvalue = value_quote($newvalue);
print qq{ print PuntTryAgain(qq{
<H1>Sorry, not allowed.</H1>
Only the owner or submitter of the bug, or a sufficiently Only the owner or submitter of the bug, or a sufficiently
empowered user, may make that change to the $f field. empowered user, may make that change to the $f field.
<TABLE> <TABLE>
<TR><TH ALIGN="right">Old value:</TH><TD>$oldvalue</TD></TR> <TR><TH ALIGN="right">Old value:</TH><TD>$oldvalue</TD></TR>
<TR><TH ALIGN="right">New value:</TH><TD>$newvalue</TD></TR> <TR><TH ALIGN="right">New value:</TH><TD>$newvalue</TD></TR>
</TABLE> </TABLE>
});
<P>Click <B>Back</B> and try again.
};
PutFooter(); PutFooter();
exit(); exit();
} }
...@@ -310,12 +307,9 @@ sub CheckonComment( $ ) { ...@@ -310,12 +307,9 @@ sub CheckonComment( $ ) {
if( $ret ) { if( $ret ) {
if (!defined $::FORM{'comment'} || $::FORM{'comment'} =~ /^\s*$/) { if (!defined $::FORM{'comment'} || $::FORM{'comment'} =~ /^\s*$/) {
# No comment - sorry, action not allowed ! # No comment - sorry, action not allowed !
warnBanner("You have to specify a <b>comment</b> on this change." . PuntTryAgain("You have to specify a <b>comment</b> on this " .
"<p>" . "change. Please give some words " .
"Please press <b>Back</b> and give some words " . "on the reason for your change.");
"on the reason of the your change.\n" );
PutFooter();
exit( 0 );
} else { } else {
$ret = 0; $ret = 0;
} }
...@@ -420,10 +414,10 @@ SWITCH: for ($::FORM{'knob'}) { ...@@ -420,10 +414,10 @@ SWITCH: for ($::FORM{'knob'}) {
if ( Param("strictvaluechecks") ) { if ( Param("strictvaluechecks") ) {
if ( !defined$::FORM{'assigned_to'} || if ( !defined$::FORM{'assigned_to'} ||
trim($::FORM{'assigned_to'}) eq "") { trim($::FORM{'assigned_to'}) eq "") {
print "You cannot reassign to a bug to noone. Unless you intentionally cleared out the \"Reassign bug to\" field, "; PuntTryAgain("You cannot reassign to a bug to nobody. Unless " .
print Param("browserbugmessage"); "you intentionally cleared out the " .
PutFooter(); "\"Reassign bug to\" field, " .
exit 0; Param("browserbugmessage"));
} }
} }
my $newid = DBNameToIdAndCheck($::FORM{'assigned_to'}); my $newid = DBNameToIdAndCheck($::FORM{'assigned_to'});
...@@ -432,16 +426,12 @@ SWITCH: for ($::FORM{'knob'}) { ...@@ -432,16 +426,12 @@ SWITCH: for ($::FORM{'knob'}) {
}; };
/^reassignbycomponent$/ && CheckonComment( "reassignbycomponent" ) && do { /^reassignbycomponent$/ && CheckonComment( "reassignbycomponent" ) && do {
if ($::FORM{'product'} eq $::dontchange) { if ($::FORM{'product'} eq $::dontchange) {
print "You must specify a product to help determine the new\n"; PuntTryAgain("You must specify a product to help determine the " .
print "owner of these bugs.\n"; "new owner of these bugs.");
PutFooter();
exit 0
} }
if ($::FORM{'component'} eq $::dontchange) { if ($::FORM{'component'} eq $::dontchange) {
print "You must specify a component whose owner should get\n"; PuntTryAgain("You must specify a component whose owner should " .
print "assigned these bugs.\n"; "get assigned these bugs.");
PutFooter();
exit 0
} }
ChangeStatus('NEW'); ChangeStatus('NEW');
SendSQL("select initialowner from components where program=" . SendSQL("select initialowner from components where program=" .
...@@ -487,16 +477,13 @@ SWITCH: for ($::FORM{'knob'}) { ...@@ -487,16 +477,13 @@ SWITCH: for ($::FORM{'knob'}) {
SendSQL("SELECT bug_id FROM bugs WHERE bug_id = " . SqlQuote($num)); SendSQL("SELECT bug_id FROM bugs WHERE bug_id = " . SqlQuote($num));
$num = FetchOneColumn(); $num = FetchOneColumn();
if (!$num) { if (!$num) {
print "You must specify a bug number of which this bug is a\n"; PuntTryAgain("You must specify a bug number of which this bug " .
print "duplicate. The bug has not been changed.\n"; "is a duplicate. The bug has not been changed.")
PutFooter();
exit;
} }
if (!defined($::FORM{'id'}) || $num == $::FORM{'id'}) { if (!defined($::FORM{'id'}) || $num == $::FORM{'id'}) {
print "Nice try, $::FORM{'who'}. But it doesn't really make sense to mark a\n"; PuntTryAgain("Nice try, $::FORM{'who'}. But it doesn't really ".
print "bug as a duplicate of itself, does it?\n"; "make sense to mark a bug as a duplicate of " .
PutFooter(); "itself, does it?");
exit;
} }
AppendComment($num, $::FORM{'who'}, "*** Bug $::FORM{'id'} has been marked as a duplicate of this bug. ***"); AppendComment($num, $::FORM{'who'}, "*** Bug $::FORM{'id'} has been marked as a duplicate of this bug. ***");
if ( Param('strictvaluechecks') ) { if ( Param('strictvaluechecks') ) {
...@@ -518,10 +505,7 @@ SWITCH: for ($::FORM{'knob'}) { ...@@ -518,10 +505,7 @@ SWITCH: for ($::FORM{'knob'}) {
if ($#idlist < 0) { if ($#idlist < 0) {
print "You apparently didn't choose any bugs to modify.\n"; PuntTryAgain("You apparently didn't choose any bugs to modify.");
print "<p>Click <b>Back</b> and try again.\n";
PutFooter();
exit;
} }
...@@ -535,12 +519,10 @@ if ($::FORM{'keywords'}) { ...@@ -535,12 +519,10 @@ if ($::FORM{'keywords'}) {
} }
my $i = $::keywordsbyname{$keyword}; my $i = $::keywordsbyname{$keyword};
if (!$i) { if (!$i) {
print "Unknown keyword named <code>$keyword</code>.\n"; PuntTryAgain("Unknown keyword named <code>$keyword</code>. " .
print "<P>The legal keyword names are <A HREF=describekeywords.cgi>"; "<P>The legal keyword names are " .
print "listed here</A>.\n"; "<A HREF=describekeywords.cgi>" .
print "<P>Please click the <B>Back</B> button and try again.\n"; "listed here</A>.");
PutFooter();
exit;
} }
if (!$keywordseen{$i}) { if (!$keywordseen{$i}) {
push(@keywordlist, $i); push(@keywordlist, $i);
...@@ -553,10 +535,8 @@ my $keywordaction = $::FORM{'keywordaction'} || "makeexact"; ...@@ -553,10 +535,8 @@ my $keywordaction = $::FORM{'keywordaction'} || "makeexact";
if ($::comma eq "" && 0 == @keywordlist && $keywordaction ne "makeexact") { if ($::comma eq "" && 0 == @keywordlist && $keywordaction ne "makeexact") {
if (!defined $::FORM{'comment'} || $::FORM{'comment'} =~ /^\s*$/) { if (!defined $::FORM{'comment'} || $::FORM{'comment'} =~ /^\s*$/) {
print "Um, you apparently did not change anything on the selected\n"; PuntTryAgain("Um, you apparently did not change anything on the " .
print "bugs. <p>Click <b>Back</b> and try again.\n"; "selected bugs.");
PutFooter();
exit;
} }
} }
...@@ -679,10 +659,7 @@ The changes made were: ...@@ -679,10 +659,7 @@ The changes made were:
SqlQuote($i)); SqlQuote($i));
my $comp = FetchOneColumn(); my $comp = FetchOneColumn();
if ($comp ne $i) { if ($comp ne $i) {
print "<H1>$i is not a legal bug number</H1>\n"; PuntTryAgain("$i is not a legal bug number");
print "<p>Click <b>Back</b> and try again.\n";
PutFooter();
exit;
} }
if (!exists $seen{$i}) { if (!exists $seen{$i}) {
push(@{$deps{$target}}, $i); push(@{$deps{$target}}, $i);
...@@ -696,12 +673,10 @@ The changes made were: ...@@ -696,12 +673,10 @@ The changes made were:
while (MoreSQLData()) { while (MoreSQLData()) {
my $t = FetchOneColumn(); my $t = FetchOneColumn();
if ($t == $id) { if ($t == $id) {
print "<H1>Dependency loop detected!</H1>\n"; PuntTryAgain("Dependency loop detected!<P>" .
print "The change you are making to dependencies\n"; "The change you are making to " .
print "has caused a circular dependency chain.\n"; "dependencies has caused a circular " .
print "<p>Click <b>Back</b> and try again.\n"; "dependency chain.");
PutFooter();
exit;
} }
if (!exists $seen{$t}) { if (!exists $seen{$t}) {
push @stack, $t; push @stack, $t;
......
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