]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 752946 - Moving a bug into another product lists inactive components, milestones...
authorDave Lawrence <dlawrence@mozilla.com>
Thu, 17 Jan 2013 16:29:07 +0000 (11:29 -0500)
committerDave Lawrence <dlawrence@mozilla.com>
Thu, 17 Jan 2013 16:29:07 +0000 (11:29 -0500)
r/a=LpSolit

Bugzilla/Bug.pm
template/en/default/global/user-error.html.tmpl

index e47b05779c5cb8d5db43c65d8ff2fe3f72f5a523..f694d062173aa9a8317b1bfcee2aa1d1dcb5255b 100644 (file)
@@ -1462,8 +1462,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 {
@@ -1905,10 +1910,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;
 }
 
@@ -1931,8 +1941,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;
 }
 
@@ -2467,9 +2481,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) {
index 4269d693d70ab7dbbf8ac476bbb2be9dae5509a5..2341cd58fce2ce92a7e4ffc9634c64860e9a11b8 100644 (file)
     [% title = "Unknown Tab" %]
     <code>[% current_tab_name FILTER html %]</code> 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'} %]