From 44de8d5f7886fa65ba5f074657c0b154f0072aeb Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Thu, 17 Jan 2013 11:33:07 -0500 Subject: Bug 752946 - Moving a bug into another product lists inactive components, milestones and versions --- Bugzilla/Bug.pm | 28 ++++++++++++++++++------- template/en/default/global/user-error.html.tmpl | 5 +++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 81cb55a43..b8d1cf6bc 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -1481,8 +1481,13 @@ sub _check_component { $name || ThrowUserError("require_component"); my $product = blessed($invocant) ? $invocant->product_obj : $params->{product}; - my $obj = Bugzilla::Component->check({ product => $product, name => $name }); - return $obj; + my $old_comp = blessed($invocant) ? $invocant->component + : $params->{component}; + my $object = Bugzilla::Component->check({ product => $product, name => $name }); + if ($object->name ne $old_comp && !$object->is_active) { + ThrowUserError('value_inactive', { class => ref($object), value => $name }); + } + return $object; } sub _check_creation_ts { @@ -1937,10 +1942,15 @@ sub _check_target_milestone { my ($invocant, $target, undef, $params) = @_; my $product = blessed($invocant) ? $invocant->product_obj : $params->{product}; + my $old_target = blessed($invocant) ? $invocant->target_milestone + : $params->{target_milestone}; $target = trim($target); $target = $product->default_milestone if !defined $target; my $object = Bugzilla::Milestone->check( { product => $product, name => $target }); + if ($object->name ne $old_target && !$object->is_active) { + ThrowUserError('value_inactive', { class => ref($object), value => $target }); + } return $object->name; } @@ -1963,8 +1973,12 @@ sub _check_version { $version = trim($version); my $product = blessed($invocant) ? $invocant->product_obj : $params->{product}; - my $object = - Bugzilla::Version->check({ product => $product, name => $version }); + my $old_vers = blessed($invocant) ? $invocant->version + : $params->{version}; + my $object = Bugzilla::Version->check({ product => $product, name => $version }); + if ($object->name ne $old_vers && !$object->is_active) { + ThrowUserError('value_inactive', { class => ref($object), value => $version }); + } return $object->name; } @@ -2499,9 +2513,9 @@ sub _set_product { milestone => $milestone_ok ? $self->target_milestone : $product->default_milestone }; - $vars{components} = [map { $_->name } @{$product->components}]; - $vars{milestones} = [map { $_->name } @{$product->milestones}]; - $vars{versions} = [map { $_->name } @{$product->versions}]; + $vars{components} = [map { $_->name } grep($_->is_active, @{$product->components})]; + $vars{milestones} = [map { $_->name } grep($_->is_active, @{$product->milestones})]; + $vars{versions} = [map { $_->name } grep($_->is_active, @{$product->versions})]; } if (!$verified) { diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index fca219401..2ec81a6f6 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -1687,6 +1687,11 @@ [% title = "Unknown Tab" %] [% current_tab_name FILTER html %] is not a legal tab name. + [% ELSIF error == "value_inactive" %] + [% title = "Value is Not Active" %] + [% type = BLOCK %][% INCLUDE object_name class = class %][% END %] + The [% type FILTER html %] value '[% value FILTER html %]' is not active. + [% ELSIF error == "version_already_exists" %] [% title = "Version Already Exists" %] [% admindocslinks = {'versions.html' => 'Administering versions'} %] -- cgit v1.2.3-24-g4f1b