summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorKent Rogers <kar@cray.com>2010-07-05 23:49:52 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-05 23:49:52 +0200
commitbcab6fcb10aa88683490bef03c607173f9c0b063 (patch)
treea7ed63d95f2cdce804e79e9869d813fda121a06a /Bugzilla
parent65528cc7177689bee757fd26510bbb2a10954931 (diff)
downloadbugzilla-bcab6fcb10aa88683490bef03c607173f9c0b063.tar.gz
bugzilla-bcab6fcb10aa88683490bef03c607173f9c0b063.tar.xz
Bug 514618: Allow restricting the visibility and values of fields by
classification. r=mkanat, r=timello, a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm4
-rw-r--r--Bugzilla/Classification.pm11
-rw-r--r--Bugzilla/Constants.pm1
-rw-r--r--Bugzilla/Field.pm2
-rw-r--r--Bugzilla/Field/Choice.pm1
-rw-r--r--Bugzilla/Product.pm16
6 files changed, 33 insertions, 2 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index ea8e4bc3d..23a92b080 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -3415,9 +3415,13 @@ sub choices {
if (!grep($_->name eq $self->product_obj->name, @products)) {
unshift(@products, $self->product_obj);
}
+ my %class_ids = map { $_->classification_id => 1 } @products;
+ my $classifications =
+ Bugzilla::Classification->new_from_list([keys %class_ids]);
my %choices = (
bug_status => $self->statuses_available,
+ classification => $classifications,
product => \@products,
component => $self->product_obj->components,
version => $self->product_obj->versions,
diff --git a/Bugzilla/Classification.pm b/Bugzilla/Classification.pm
index c7cda11be..88ec4eb3b 100644
--- a/Bugzilla/Classification.pm
+++ b/Bugzilla/Classification.pm
@@ -20,11 +20,12 @@ use strict;
package Bugzilla::Classification;
use Bugzilla::Constants;
+use Bugzilla::Field;
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::Product;
-use base qw(Bugzilla::Object);
+use base qw(Bugzilla::Field::ChoiceInterface Bugzilla::Object);
###############################
#### Initialization ####
@@ -111,6 +112,14 @@ sub _check_sortkey {
return $sortkey;
}
+#####################################
+# Implement Bugzilla::Field::Choice #
+#####################################
+
+use constant FIELD_NAME => 'classification';
+use constant is_default => 0;
+use constant is_active => 1;
+
###############################
#### Methods ####
###############################
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index a003ce739..9c2a3e353 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -403,6 +403,7 @@ use constant EMPTY_DATETIME_REGEX => qr/^[0\-:\sA-Za-z]+$/;
# See the POD for Bugzilla::Field/is_abnormal to see why these are listed
# here.
use constant ABNORMAL_SELECTS => qw(
+ classification
product
component
);
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index 15b494762..76bb1d41e 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -166,7 +166,7 @@ use constant DEFAULT_FIELDS => (
{name => 'short_desc', desc => 'Summary', in_new_bugmail => 1,
is_mandatory => 1, buglist => 1},
{name => 'classification', desc => 'Classification', in_new_bugmail => 1,
- buglist => 1},
+ type => FIELD_TYPE_SINGLE_SELECT, buglist => 1},
{name => 'product', desc => 'Product', in_new_bugmail => 1,
type => FIELD_TYPE_SINGLE_SELECT, buglist => 1},
{name => 'version', desc => 'Version', in_new_bugmail => 1,
diff --git a/Bugzilla/Field/Choice.pm b/Bugzilla/Field/Choice.pm
index 0c44134ef..773dbd4ce 100644
--- a/Bugzilla/Field/Choice.pm
+++ b/Bugzilla/Field/Choice.pm
@@ -64,6 +64,7 @@ use constant VALIDATORS => {
use constant CLASS_MAP => {
bug_status => 'Bugzilla::Status',
+ classification => 'Bugzilla::Classification',
component => 'Bugzilla::Component',
product => 'Bugzilla::Product',
};
diff --git a/Bugzilla/Product.pm b/Bugzilla/Product.pm
index 514649763..80e1752e6 100644
--- a/Bugzilla/Product.pm
+++ b/Bugzilla/Product.pm
@@ -791,6 +791,13 @@ sub flag_types {
return $self->{'flag_types'};
}
+sub classification {
+ my $self = shift;
+ $self->{'classification'} ||=
+ new Bugzilla::Classification($self->classification_id);
+ return $self->{'classification'};
+}
+
###############################
#### Accessors ######
###############################
@@ -853,6 +860,7 @@ Bugzilla::Product - Bugzilla product class.
my $bug_ids = $product->bug_ids();
my $has_access = $product->user_has_access($user);
my $flag_types = $product->flag_types();
+ my $classification = $product->classification();
my $id = $product->id;
my $name = $product->name;
@@ -1021,6 +1029,14 @@ a group is valid in a particular product.)
Returns: Two references to an array of flagtype objects.
+=item C<classification()>
+
+ Description: Returns the classification the product belongs to.
+
+ Params: none.
+
+ Returns: A Bugzilla::Classification object.
+
=back
=head1 SUBROUTINES