}
}
+sub check_bugs_resolution {
+ my $idlist = shift;
+ 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 =
+ $dbh->selectrow_array("SELECT 1 FROM bugs WHERE bug_id IN ($idlist)
+ AND bug_status IN ($open_states)");
+
+ # If there is at least one open bug, then the test failed.
+ return !$is_open;
+}
+
SWITCH: for ($cgi->param('knob')) {
/^none$/ && do {
last SWITCH;
else {
# You cannot use change_resolution if there is at least
# one open bug.
- my $open_states = join(',', map {$dbh->quote($_)} BUG_STATE_OPEN);
- my $idlist = join(',', @idlist);
- my $is_open =
- $dbh->selectrow_array("SELECT 1 FROM bugs WHERE bug_id IN ($idlist)
- AND bug_status IN ($open_states)");
-
- ThrowUserError('resolution_not_allowed') if $is_open;
+ check_bugs_resolution(\@idlist) || ThrowUserError('resolution_not_allowed');
}
ChangeResolution($bug, $cgi->param('resolution'));
last SWITCH;
};
/^verify$/ && CheckonComment( "verify" ) && do {
+ check_bugs_resolution(\@idlist)
+ || ThrowUserError('bug_status_not_allowed', {status => 'VERIFIED'});
+
ChangeStatus('VERIFIED');
last SWITCH;
};
/^close$/ && CheckonComment( "close" ) && do {
+ check_bugs_resolution(\@idlist)
+ || ThrowUserError('bug_status_not_allowed', {status => 'CLOSED'});
+
# CLOSED bugs should have no time remaining.
_remove_remaining_time();
[% title = "Classification Not Enabled" %]
Sorry, classification is not enabled.
+ [% ELSIF error == "bug_status_not_allowed" %]
+ [% title = "Bug Status Not Allowed" %]
+ You cannot mark open [% terms.bugs %] as [% status_descs.$status FILTER html %].
+ You have to mark them as [% status_descs.RESOLVED FILTER html %] first.
+
[% ELSIF error == "classification_not_specified" %]
[% title = "You Must Supply A Classification Name" %]
You must enter a classification name.