]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 424380: Bugzilla 3.0 lets you clear the resolution of resolved bugs - Patch by...
authorlpsolit%gmail.com <>
Mon, 24 Mar 2008 01:21:46 +0000 (01:21 +0000)
committerlpsolit%gmail.com <>
Mon, 24 Mar 2008 01:21:46 +0000 (01:21 +0000)
process_bug.cgi
template/en/default/global/user-error.html.tmpl

index b2655919bbe9a624df0a93778ccfe5438ebd6e7f..207607bd3bb248dc345fd3d718498a722f211655 100755 (executable)
@@ -1098,19 +1098,22 @@ if (defined $cgi->param('qa_contact')
     }
 }
 
+# By default, makes sure that all bugs are in a closed state.
+# If $all_open is true, makes sure that all bugs are open.
 sub check_bugs_resolution {
-    my $idlist = shift;
+    my ($idlist, $all_open) = @_;
     my $dbh = Bugzilla->dbh;
 
     my $open_states = join(',', map {$dbh->quote($_)} BUG_STATE_OPEN);
     # The list has already been validated.
     $idlist = join(',', @$idlist);
-    my $is_open =
+    my $sql_cond = $all_open ? 'NOT' : '';
+    my $has_unwanted_bugs =
       $dbh->selectrow_array("SELECT 1 FROM bugs WHERE bug_id IN ($idlist)
-                             AND bug_status IN ($open_states)");
+                             AND bug_status $sql_cond IN ($open_states)");
 
-    # If there is at least one open bug, then the test failed.
-    return !$is_open;
+    # If there are unwanted bugs, then the test fails.
+    return !$has_unwanted_bugs;
 }
 
 SWITCH: for ($cgi->param('knob')) {
@@ -1133,6 +1136,9 @@ SWITCH: for ($cgi->param('knob')) {
         last SWITCH;
     };
     /^clearresolution$/ && CheckonComment( "clearresolution" ) && do {
+        # All bugs must already be open.
+        check_bugs_resolution(\@idlist, 'all_open')
+          || ThrowUserError('resolution_deletion_not_allowed');
         ChangeResolution($bug, '');
         last SWITCH;
     };
index 64fe816633c18baee8c7c87eeaf453b5cdb19f7b..8009b95459f4f1abf62991d65d81a2ed2bd24503 100644 (file)
     [% title = "Summary Needed" %]
     You must enter a summary for this [% terms.bug %].
 
+  [% ELSIF error == "resolution_deletion_not_allowed" %]
+    [% title = "Resolution Change Not Allowed" %]
+    You cannot clear the resolution of open [% terms.bugs %].
+
   [% ELSIF error == "resolution_not_allowed" %]
     [% title = "Resolution Not Allowed" %]
     You cannot set a resolution for open [% terms.bugs %].