Bug 68430 - automatically clear flags when closing bug (optional parameter), move this and Bug 17481 to a hook
git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@922 6955db30-a419-402b-8a0d-67ecbb4d7f56master
parent
e7949fbe39
commit
2cf1058781
|
@ -138,6 +138,12 @@ sub get_param_list {
|
||||||
default => '',
|
default => '',
|
||||||
checker => \&check_opsys
|
checker => \&check_opsys
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name => 'clear_requests_on_close',
|
||||||
|
type => 'b',
|
||||||
|
default => 1,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
return @param_list;
|
return @param_list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1649,6 +1649,15 @@ sub wants_worktime_reminder {
|
||||||
? 1 : 0;
|
? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub wants_request_reminder {
|
||||||
|
my $self = shift;
|
||||||
|
return $self &&
|
||||||
|
$self->settings->{remind_me_about_flags} &&
|
||||||
|
$self->settings->{remind_me_about_flags}->{value} &&
|
||||||
|
lc $self->settings->{remind_me_about_flags}->{value} ne 'off'
|
||||||
|
? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
sub get_userlist {
|
sub get_userlist {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use Bugzilla::Constants;
|
||||||
|
use Bugzilla::Util qw(trim);
|
||||||
|
use Bugzilla::User;
|
||||||
|
use Bugzilla::Error;
|
||||||
|
|
||||||
|
my $cgi = Bugzilla->cgi;
|
||||||
|
my $bug_objects = Bugzilla->hook_args->{bug_objects};
|
||||||
|
my $vars = Bugzilla->hook_args->{vars};
|
||||||
|
|
||||||
|
my $single = @$bug_objects == 1;
|
||||||
|
my $clear_on_close = $cgi->param('bug_status') eq 'CLOSED' && Bugzilla->params->{clear_requests_on_close};
|
||||||
|
my $verify_flags = $single && Bugzilla->usage_mode != USAGE_MODE_EMAIL && Bugzilla->user->wants_request_reminder;
|
||||||
|
my $reset_own_flags = $verify_flags && $cgi->param('comment') !~ /^\s*$/so;
|
||||||
|
|
||||||
|
if (($clear_on_close || $reset_own_flags) && !$cgi->param('force_flags'))
|
||||||
|
{
|
||||||
|
my $flags;
|
||||||
|
my @requery_flags;
|
||||||
|
my $flag;
|
||||||
|
# 1) Check flag requests and remind user about resetting his own incoming requests.
|
||||||
|
# 2) When closing bugs, clear all flag requests (CustIS Bug 68430).
|
||||||
|
# Not used in mass update and email modes.
|
||||||
|
for my $bug (@$bug_objects)
|
||||||
|
{
|
||||||
|
if ($single)
|
||||||
|
{
|
||||||
|
for ($cgi->param())
|
||||||
|
{
|
||||||
|
if (/^(flag-(\d+))$/)
|
||||||
|
{
|
||||||
|
$flag = Bugzilla::Flag->new({ id => $2 });
|
||||||
|
$flag->{status} = $cgi->param($1);
|
||||||
|
$flag->{requestee_id} = login_to_id(trim($cgi->param("requestee-$2")));
|
||||||
|
push @$flags, $flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$flags = Bugzilla::Flag->match({ bug_id => $bug->id });
|
||||||
|
}
|
||||||
|
foreach $flag (@$flags)
|
||||||
|
{
|
||||||
|
if ($flag->{status} eq '?' &&
|
||||||
|
($clear_on_close || $flag->{requestee_id} eq Bugzilla->user->userid))
|
||||||
|
{
|
||||||
|
if ($clear_on_close)
|
||||||
|
{
|
||||||
|
$flag->{status} = 'X';
|
||||||
|
}
|
||||||
|
if ($verify_flags)
|
||||||
|
{
|
||||||
|
push @requery_flags, $flag;
|
||||||
|
}
|
||||||
|
elsif ($single)
|
||||||
|
{
|
||||||
|
$cgi->param('flag-'.$flag->{id} => 'X');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Bugzilla::Flag->set_flag($bug, $flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($verify_flags && @requery_flags)
|
||||||
|
{
|
||||||
|
push @{$vars->{verify_flags}}, @requery_flags;
|
||||||
|
$vars->{field_filter} = '^('.join('|', map { "flag-".$_->id } @{$vars->{verify_flags}}).')$';
|
||||||
|
Bugzilla->template->process("bug/process/verify-flags.html.tmpl", $vars)
|
||||||
|
|| ThrowTemplateError(Bugzilla->template->error());
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -107,9 +107,9 @@ sub should_set {
|
||||||
# Create a list of objects for all bugs being modified in this request.
|
# Create a list of objects for all bugs being modified in this request.
|
||||||
my @bug_objects;
|
my @bug_objects;
|
||||||
if (defined $cgi->param('id')) {
|
if (defined $cgi->param('id')) {
|
||||||
my $bug = Bugzilla::Bug->check(scalar $cgi->param('id'));
|
my $bug = Bugzilla::Bug->check(scalar $cgi->param('id'));
|
||||||
$cgi->param('id', $bug->id);
|
$cgi->param('id', $bug->id);
|
||||||
push(@bug_objects, $bug);
|
push(@bug_objects, $bug);
|
||||||
} else {
|
} else {
|
||||||
foreach my $i ($cgi->param()) {
|
foreach my $i ($cgi->param()) {
|
||||||
if ($i =~ /^id_([1-9][0-9]*)/) {
|
if ($i =~ /^id_([1-9][0-9]*)/) {
|
||||||
|
@ -280,6 +280,8 @@ foreach my $b (@bug_objects) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bugzilla::Hook::process('process_bug-after_move', { bug_objects => \@bug_objects, vars => $vars });
|
||||||
|
|
||||||
# Flags should be set AFTER the bug has been moved into another product/component.
|
# Flags should be set AFTER the bug has been moved into another product/component.
|
||||||
if ($cgi->param('id')) {
|
if ($cgi->param('id')) {
|
||||||
my ($flags, $new_flags) = Bugzilla::Flag->extract_flags_from_cgi($first_bug, undef, $vars);
|
my ($flags, $new_flags) = Bugzilla::Flag->extract_flags_from_cgi($first_bug, undef, $vars);
|
||||||
|
@ -342,37 +344,6 @@ my %methods = (
|
||||||
|
|
||||||
foreach my $b (@bug_objects)
|
foreach my $b (@bug_objects)
|
||||||
{
|
{
|
||||||
# Validate flag requests and remind user about resetting them
|
|
||||||
if (should_set('comment') && @bug_objects == 1 &&
|
|
||||||
Bugzilla->usage_mode != USAGE_MODE_EMAIL &&
|
|
||||||
!$cgi->param('force_flags') &&
|
|
||||||
$user->settings->{remind_me_about_flags} &&
|
|
||||||
$user->settings->{remind_me_about_flags}->{value} &&
|
|
||||||
(lc $user->settings->{remind_me_about_flags}->{value} ne "off"))
|
|
||||||
{
|
|
||||||
my @ids = map /^flag-(\d+)$/ ? $1 : (), $cgi->param();
|
|
||||||
my @requery_flags;
|
|
||||||
my @filter;
|
|
||||||
foreach my $id (@ids)
|
|
||||||
{
|
|
||||||
my $status = $cgi->param("flag-$id");
|
|
||||||
if (($status eq '?') &&
|
|
||||||
trim($cgi->param("requestee-$id")) eq $user->login)
|
|
||||||
{
|
|
||||||
my $flag = (Bugzilla::Flag->match({ id => $id }) || [])->[0];
|
|
||||||
push @filter, "flag-$id";
|
|
||||||
push @requery_flags, $flag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (@requery_flags)
|
|
||||||
{
|
|
||||||
$vars->{verify_flags} = \@requery_flags;
|
|
||||||
$vars->{field_filter} = '^('.join('|',@filter).')$';
|
|
||||||
$template->process("bug/process/verify-flags.html.tmpl", $vars)
|
|
||||||
|| ThrowTemplateError($template->error());
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (should_set('comment') || $cgi->param('work_time'))
|
if (should_set('comment') || $cgi->param('work_time'))
|
||||||
{
|
{
|
||||||
# Add a comment as needed to each bug. This is done early because
|
# Add a comment as needed to each bug. This is done early because
|
||||||
|
|
|
@ -33,11 +33,11 @@
|
||||||
[% cgi.param("requestee-$flag.id" ) %]
|
[% cgi.param("requestee-$flag.id" ) %]
|
||||||
</td>
|
</td>
|
||||||
<td style="border-width: 0 0 1px 0; border-style: solid; border-color: gray">
|
<td style="border-width: 0 0 1px 0; border-style: solid; border-color: gray">
|
||||||
<select id="flag-[% flag.id %]" name="flag-[% flag.id %]"
|
<select id="flag-[% flag.id %]" name="flag-[% flag.id %]">
|
||||||
<option value="X"></option>
|
<option value="X" [% 'selected="selected"' IF flag.status == 'X' %]>X</option>
|
||||||
<option value="+">+</option>
|
<option value="+">+</option>
|
||||||
<option value="-">-</option>
|
<option value="-">-</option>
|
||||||
<option value="?" selected="selected">?</option>
|
<option value="?" [% 'selected="selected"' IF flag.status == '?' %]>?</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -70,5 +70,7 @@
|
||||||
"entry form.<br> " _
|
"entry form.<br> " _
|
||||||
"You can leave this empty: " _
|
"You can leave this empty: " _
|
||||||
"$terms.Bugzilla will then use the operating system that the browser " _
|
"$terms.Bugzilla will then use the operating system that the browser " _
|
||||||
"reports to be running on as the default." }
|
"reports to be running on as the default.",
|
||||||
%]
|
|
||||||
|
clear_requests_on_close => "Clear all unanswered flag requests when changing bug status to CLOSED",
|
||||||
|
} %]
|
||||||
|
|
Loading…
Reference in New Issue