summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Bug.pm
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-04-30 08:06:06 +0200
committerByron Jones <glob@mozilla.com>2015-04-30 08:06:06 +0200
commitdac9873a61b108133ee00bda5b1862404712dd63 (patch)
treee54a93f442672073ce6ee48e0979580ca0e2e1e1 /Bugzilla/Bug.pm
parent0d154533510e72467e1073c52095a1622f04f334 (diff)
downloadbugzilla-dac9873a61b108133ee00bda5b1862404712dd63.tar.gz
bugzilla-dac9873a61b108133ee00bda5b1862404712dd63.tar.xz
Bug 1151745: add ui to minimise steps required to move bugs between products
Diffstat (limited to 'Bugzilla/Bug.pm')
-rw-r--r--Bugzilla/Bug.pm72
1 files changed, 50 insertions, 22 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 6dbcffe34..78bb1dff4 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -52,7 +52,7 @@ use Bugzilla::Comment;
use Bugzilla::BugUrl;
use Bugzilla::BugUserLastVisit;
-use List::MoreUtils qw(firstidx uniq part);
+use List::MoreUtils qw(firstidx uniq part any);
use List::Util qw(min max first);
use Storable qw(dclone);
use URI;
@@ -2689,7 +2689,32 @@ sub _set_product {
# other part of Bugzilla that checks $@.
undef $@;
Bugzilla->error_mode($old_error_mode);
-
+
+ my $invalid_groups;
+ my @idlist = ($self->id);
+ push(@idlist, map { $_->id } @{ $params->{other_bugs} })
+ if $params->{other_bugs};
+ @idlist = uniq @idlist;
+
+ # BMO - if everything is ok then we can skip the verfication page
+ if ($component_ok && $version_ok && $milestone_ok) {
+ $invalid_groups = $self->get_invalid_groups({ bug_ids => \@idlist, product => $product });
+ my $has_invalid_group = 0;
+ foreach my $group (@$invalid_groups) {
+ if (any { $_ eq $group->name } @{ $params->{groups}->{add} }) {
+ $has_invalid_group = 1;
+ last;
+ }
+ }
+ $params->{product_change_confirmed} =
+ # always check for invalid groups
+ !$has_invalid_group
+ # never skip verification when changing multiple bugs
+ && scalar(@idlist) == 1
+ # ensure the user has seen the group ui for private bugs
+ && (!@{ $self->groups_in } || Bugzilla->input_params->{group_verified});
+ }
+
my $verified = $params->{product_change_confirmed};
my %vars;
if (!$verified || !$component_ok || !$version_ok || !$milestone_ok) {
@@ -2709,27 +2734,9 @@ sub _set_product {
if (!$verified) {
$vars{verify_bug_groups} = 1;
- my $dbh = Bugzilla->dbh;
- my @idlist = ($self->id);
- push(@idlist, map {$_->id} @{ $params->{other_bugs} })
- if $params->{other_bugs};
- # Get the ID of groups which are no longer valid in the new product.
- my $gids = $dbh->selectcol_arrayref(
- 'SELECT bgm.group_id
- FROM bug_group_map AS bgm
- WHERE bgm.bug_id IN (' . join(',', ('?') x @idlist) . ')
- AND bgm.group_id NOT IN
- (SELECT gcm.group_id
- FROM group_control_map AS gcm
- WHERE gcm.product_id = ?
- AND ( (gcm.membercontrol != ?
- AND gcm.group_id IN ('
- . Bugzilla->user->groups_as_string . '))
- OR gcm.othercontrol != ?) )',
- undef, (@idlist, $product->id, CONTROLMAPNA, CONTROLMAPNA));
- $vars{'old_groups'} = Bugzilla::Group->new_from_list($gids);
+ $vars{old_groups} = $invalid_groups || $self->get_invalid_groups({ bug_ids => \@idlist, product => $product });
}
-
+
if (%vars) {
$vars{product} = $product;
$vars{bug} = $self;
@@ -4301,6 +4308,27 @@ sub map_fields {
return \%field_values;
}
+# Return the groups which are no longer valid in the specified product
+sub get_invalid_groups {
+ my ($invocant, $params) = @_;
+ my @idlist = @{ $params->{bug_ids} };
+ my $product = $params->{product};
+ my $gids = Bugzilla->dbh->selectcol_arrayref(
+ 'SELECT bgm.group_id
+ FROM bug_group_map AS bgm
+ WHERE bgm.bug_id IN (' . join(',', ('?') x @idlist) . ')
+ AND bgm.group_id NOT IN
+ (SELECT gcm.group_id
+ FROM group_control_map AS gcm
+ WHERE gcm.product_id = ?
+ AND ( (gcm.membercontrol != ?
+ AND gcm.group_id IN ('
+ . Bugzilla->user->groups_as_string . '))
+ OR gcm.othercontrol != ?) )',
+ undef, (@idlist, $product->id, CONTROLMAPNA, CONTROLMAPNA));
+ return Bugzilla::Group->new_from_list($gids);
+}
+
################################################################################
# check_can_change_field() defines what users are allowed to change. You
# can add code here for site-specific policy changes, according to the