summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2009-10-06 07:38:29 +0200
committermkanat%bugzilla.org <>2009-10-06 07:38:29 +0200
commit4671e0ffd9920d000fb6191999288ed12d4dac52 (patch)
treea4592302ace3162d0482751a4019a1a31b65923e /Bugzilla
parent6e282d384995d9c8067302a6cbaae04eaba308a5 (diff)
downloadbugzilla-4671e0ffd9920d000fb6191999288ed12d4dac52.tar.gz
bugzilla-4671e0ffd9920d000fb6191999288ed12d4dac52.tar.xz
Bug 512618: Make Bugzilla::Bug::choices return Field::Choice objects, not just values
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm49
1 files changed, 25 insertions, 24 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 567c130f4..98547cd95 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -2108,6 +2108,7 @@ sub set_resolution {
my $old_res = $self->resolution;
$self->set('resolution', $value);
+ delete $self->{choices};
my $new_res = $self->resolution;
if ($new_res ne $old_res) {
@@ -2899,38 +2900,38 @@ sub user {
return $self->{'user'};
}
+# This is intended to get values that can be selected by the user in the
+# UI. It should not be used for security or validation purposes.
sub choices {
my $self = shift;
return $self->{'choices'} if exists $self->{'choices'};
return {} if $self->{'error'};
+ my $user = Bugzilla->user;
- $self->{'choices'} = {};
-
- my @prodlist = map {$_->name} @{Bugzilla->user->get_enterable_products};
+ my @products = @{ $user->get_enterable_products };
# The current product is part of the popup, even if new bugs are no longer
# allowed for that product
- if (lsearch(\@prodlist, $self->product) < 0) {
- push(@prodlist, $self->product);
- @prodlist = sort @prodlist;
- }
-
- # Hack - this array contains "". See bug 106589.
- my @res = grep ($_, @{get_legal_field_values('resolution')});
-
- $self->{'choices'} =
- {
- 'product' => \@prodlist,
- 'rep_platform' => get_legal_field_values('rep_platform'),
- 'priority' => get_legal_field_values('priority'),
- 'bug_severity' => get_legal_field_values('bug_severity'),
- 'op_sys' => get_legal_field_values('op_sys'),
- 'bug_status' => get_legal_field_values('bug_status'),
- 'resolution' => \@res,
- 'component' => [map($_->name, @{$self->product_obj->components})],
- 'version' => [map($_->name, @{$self->product_obj->versions})],
- 'target_milestone' => [map($_->name, @{$self->product_obj->milestones})],
- };
+ if (!grep($_->name eq $self->product_obj->name, @products)) {
+ unshift(@products, $self->product_obj);
+ }
+
+ my %choices = (
+ product => \@products,
+ component => $self->product_obj->components,
+ version => $self->product_obj->versions,
+ target_milestone => $self->product_obj->milestones,
+ );
+
+ my $resolution_field = new Bugzilla::Field({ name => 'resolution' });
+ # Don't include the empty resolution in drop-downs.
+ my @resolutions = grep($_->name, @{ $resolution_field->legal_values });
+ # And don't include MOVED in the list unless the bug is already MOVED.
+ if ($self->resolution ne 'MOVED') {
+ @resolutions= grep { $_->name ne 'MOVED' } @resolutions;
+ }
+ $choices{'resolution'} = \@resolutions;
+ $self->{'choices'} = \%choices;
return $self->{'choices'};
}