Commit 653e1919 authored by terry%mozilla.org's avatar terry%mozilla.org

Patch by freitag@suse.de (Klaas Freitag) -- add options to let Bugzilla require…

Patch by freitag@suse.de (Klaas Freitag) -- add options to let Bugzilla require comments on certain operations.
parent 64dbc1f6
...@@ -631,8 +631,16 @@ sub DumpBugActivity { ...@@ -631,8 +631,16 @@ sub DumpBugActivity {
} }
#
# Prints a warnbanner incl. image with given message
#
sub warnBanner( $ )
{
my ($msg) = (@_);
print Param("warnbannerhtml");
print $msg;
print Param("warnfooterhtml");
}
############# Live code below here (that is, not subroutine defs) ############# ############# Live code below here (that is, not subroutine defs) #############
......
...@@ -176,6 +176,17 @@ information about what Bugzilla is and what it can do, see ...@@ -176,6 +176,17 @@ information about what Bugzilla is and what it can do, see
DefParam("warnbannerhtml",
"HTML to prepend to warning messages.",
"l",
"<font size=+1>");
DefParam("warnfooterhtml",
"HTML to append to warning messages.",
"l",
"</font>");
DefParam("changedmail", DefParam("changedmail",
q{The email that gets sent to people when a bug changes. Within this q{The email that gets sent to people when a bug changes. Within this
text, %to% gets replaced by the assigned-to and reported-by people, text, %to% gets replaced by the assigned-to and reported-by people,
...@@ -378,5 +389,36 @@ DefParam("browserbugmessage", ...@@ -378,5 +389,36 @@ DefParam("browserbugmessage",
"If strictvaluechecks is on, and the bugzilla gets unexpected data from the browser, in addition to displaying the cause of the problem, it will output this HTML as well.", "If strictvaluechecks is on, and the bugzilla gets unexpected data from the browser, in addition to displaying the cause of the problem, it will output this HTML as well.",
"l", "l",
"this may indicate a bug in your browser.\n"); "this may indicate a bug in your browser.\n");
#
# Parameters to force users to comment their changes for different actions.
DefParam("commentonaccept",
"If this option is on, the user needs to enter a short comment if he accepts the bug",
"b", 0 );
DefParam("commentonclearresolution",
"If this option is on, the user needs to enter a short comment if the bugs resolution is cleared",
"b", 0 );
DefParam("commentonresolve",
"If this option is on, the user needs to enter a short comment if the bug is resolved",
"b", 0 );
DefParam("commentonreassign",
"If this option is on, the user needs to enter a short comment if the bug is reassigned",
"b", 0 );
DefParam("commentonreassignbycomponent",
"If this option is on, the user needs to enter a short comment if the bug is reassigned by component",
"b", 0 );
DefParam("commentonreopen",
"If this option is on, the user needs to enter a short comment if the bug is reopened",
"b", 0 );
DefParam("commentonverify",
"If this option is on, the user needs to enter a short comment if the bug is verified",
"b", 0 );
DefParam("commentonclose",
"If this option is on, the user needs to enter a short comment if the bug is closed",
"b", 0 );
DefParam("commentonduplicate",
"If this option is on, the user needs to enter a short comment if the bug is marked as duplicate",
"b", 0 );
1; 1;
...@@ -169,6 +169,35 @@ sub ChangeResolution { ...@@ -169,6 +169,35 @@ sub ChangeResolution {
} }
} }
#
# This function checks if there is a comment required for a specific
# function and tests, if the comment was given.
# If comments are required for functions is defined by params.
#
sub CheckonComment( $ ) {
my ($function) = (@_);
# Param is 1 if comment should be added !
my $ret = Param( "commenton" . $function );
# Allow without comment in case of undefined Params.
$ret = 0 unless ( defined( $ret ));
if( $ret ) {
if (!defined $::FORM{'comment'} || $::FORM{'comment'} =~ /^\s*$/) {
# No commet - sorry, action not allowed !
warnBanner("You have to specify a <b>comment</b> on this change." .
"<p>" .
"Please press <b>Back</b> and give some words " .
"on the reason of the your change.\n" );
exit( 0 );
} else {
$ret = 0;
}
}
return( ! $ret ); # Return val has to be inverted
}
my $foundbit = 0; my $foundbit = 0;
foreach my $b (grep(/^bit-\d*$/, keys %::FORM)) { foreach my $b (grep(/^bit-\d*$/, keys %::FORM)) {
...@@ -220,20 +249,20 @@ SWITCH: for ($::FORM{'knob'}) { ...@@ -220,20 +249,20 @@ SWITCH: for ($::FORM{'knob'}) {
/^none$/ && do { /^none$/ && do {
last SWITCH; last SWITCH;
}; };
/^accept$/ && do { /^accept$/ && CheckonComment( "accept" ) && do {
ChangeStatus('ASSIGNED'); ChangeStatus('ASSIGNED');
last SWITCH; last SWITCH;
}; };
/^clearresolution$/ && do { /^clearresolution$/ && CheckonComment( "clearresolution" ) &&do {
ChangeResolution(''); ChangeResolution('');
last SWITCH; last SWITCH;
}; };
/^resolve$/ && do { /^resolve$/ && CheckonComment( "resolve" ) && do {
ChangeStatus('RESOLVED'); ChangeStatus('RESOLVED');
ChangeResolution($::FORM{'resolution'}); ChangeResolution($::FORM{'resolution'});
last SWITCH; last SWITCH;
}; };
/^reassign$/ && do { /^reassign$/ && CheckonComment( "reassign" ) && do {
ChangeStatus('NEW'); ChangeStatus('NEW');
DoComma(); DoComma();
if ( Param("strictvaluechecks") ) { if ( Param("strictvaluechecks") ) {
...@@ -248,7 +277,7 @@ SWITCH: for ($::FORM{'knob'}) { ...@@ -248,7 +277,7 @@ SWITCH: for ($::FORM{'knob'}) {
$::query .= "assigned_to = $newid"; $::query .= "assigned_to = $newid";
last SWITCH; last SWITCH;
}; };
/^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"; print "You must specify a product to help determine the new\n";
print "owner of these bugs.\n"; print "owner of these bugs.\n";
...@@ -269,19 +298,19 @@ SWITCH: for ($::FORM{'knob'}) { ...@@ -269,19 +298,19 @@ SWITCH: for ($::FORM{'knob'}) {
$::query .= "assigned_to = $newid"; $::query .= "assigned_to = $newid";
last SWITCH; last SWITCH;
}; };
/^reopen$/ && do { /^reopen$/ && CheckonComment( "reopen" ) && do {
ChangeStatus('REOPENED'); ChangeStatus('REOPENED');
last SWITCH; last SWITCH;
}; };
/^verify$/ && do { /^verify$/ && CheckonComment( "verify" ) && do {
ChangeStatus('VERIFIED'); ChangeStatus('VERIFIED');
last SWITCH; last SWITCH;
}; };
/^close$/ && do { /^close$/ && CheckonComment( "close" ) && do {
ChangeStatus('CLOSED'); ChangeStatus('CLOSED');
last SWITCH; last SWITCH;
}; };
/^duplicate$/ && do { /^duplicate$/ && CheckonComment( "duplicate" ) && do {
ChangeStatus('RESOLVED'); ChangeStatus('RESOLVED');
ChangeResolution('DUPLICATE'); ChangeResolution('DUPLICATE');
if ( Param('strictvaluechecks') ) { if ( Param('strictvaluechecks') ) {
......
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