diff options
author | mkanat%bugzilla.org <> | 2009-02-08 19:42:19 +0000 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2009-02-08 19:42:19 +0000 |
commit | f65a3e7e20fdfe2f136ecdaa228f0784bb56b9ad (patch) | |
tree | 276bfe21eed5f29153cd15f1f7a16846b8709956 /Bugzilla | |
parent | 88463d2b267baefbfc788f192ffa9f08ea972d51 (diff) | |
download | bugs-f65a3e7e20fdfe2f136ecdaa228f0784bb56b9ad.tar bugs-f65a3e7e20fdfe2f136ecdaa228f0784bb56b9ad.tar.gz bugs-f65a3e7e20fdfe2f136ecdaa228f0784bb56b9ad.tar.bz2 bugs-f65a3e7e20fdfe2f136ecdaa228f0784bb56b9ad.tar.xz bugs-f65a3e7e20fdfe2f136ecdaa228f0784bb56b9ad.zip |
Bug 371995: Allow the Product field to restrict visibility of custom fields
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Field.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Field/Choice.pm | 9 | ||||
-rw-r--r-- | Bugzilla/Product.pm | 24 |
3 files changed, 32 insertions, 3 deletions
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 91e9bb8b4..1cc89239e 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -158,7 +158,7 @@ use constant DEFAULT_FIELDS => ( {name => 'classification', desc => 'Classification', in_new_bugmail => 1, buglist => 1}, {name => 'product', desc => 'Product', in_new_bugmail => 1, - buglist => 1}, + type => FIELD_TYPE_SINGLE_SELECT, buglist => 1}, {name => 'version', desc => 'Version', in_new_bugmail => 1, buglist => 1}, {name => 'rep_platform', desc => 'Platform', in_new_bugmail => 1, diff --git a/Bugzilla/Field/Choice.pm b/Bugzilla/Field/Choice.pm index 9e8fb1235..00fa52f99 100644 --- a/Bugzilla/Field/Choice.pm +++ b/Bugzilla/Field/Choice.pm @@ -62,6 +62,7 @@ use constant VALIDATORS => { use constant CLASS_MAP => { bug_status => 'Bugzilla::Status', + product => 'Bugzilla::Product', }; use constant DEFAULT_MAP => { @@ -189,6 +190,13 @@ sub remove_from_db { ThrowUserError("fieldvalue_still_has_bugs", { field => $self->field, value => $self }); } + $self->_check_if_controller(); + $self->SUPER::remove_from_db(); +} + +# Factored out to make life easier for subclasses. +sub _check_if_controller { + my $self = shift; my $vis_fields = $self->controls_visibility_of_fields; my $values = $self->controlled_values; if (@$vis_fields || @$values) { @@ -196,7 +204,6 @@ sub remove_from_db { { value => $self, fields => [map($_->name, @$vis_fields)], vals => $values }); } - $self->SUPER::remove_from_db(); } diff --git a/Bugzilla/Product.pm b/Bugzilla/Product.pm index 396aaa346..88292d27e 100644 --- a/Bugzilla/Product.pm +++ b/Bugzilla/Product.pm @@ -31,7 +31,9 @@ use Bugzilla::Install::Requirements; use Bugzilla::Mailer; use Bugzilla::Series; -use base qw(Bugzilla::Object); +# Currently, we only implement enough of the Bugzilla::Field::Choice +# interface to control the visibility of other fields. +use base qw(Bugzilla::Field::Choice); use constant DEFAULT_CLASSIFICATION_ID => 1; @@ -40,6 +42,10 @@ use constant DEFAULT_CLASSIFICATION_ID => 1; ############################### use constant DB_TABLE => 'products'; +# Reset these back to the Bugzilla::Object defaults, instead of the +# Bugzilla::Field::Choice defaults. +use constant NAME_FIELD => 'name'; +use constant LIST_ORDER => 'name'; use constant DB_COLUMNS => qw( id @@ -372,6 +378,8 @@ sub remove_from_db { $dbh->bz_start_transaction(); + $self->_check_if_controller(); + if ($self->bug_count) { if (Bugzilla->params->{'allowbugdeletion'}) { require Bugzilla::Bug; @@ -523,6 +531,20 @@ sub _check_votes { return $votes; } +##################################### +# Implement Bugzilla::Field::Choice # +##################################### + +sub field { + my $invocant = shift; + my $class = ref $invocant || $invocant; + my $cache = Bugzilla->request_cache; + $cache->{"field_$class"} ||= new Bugzilla::Field({ name => 'product' }); + return $cache->{"field_$class"}; +} + +use constant is_default => 0; + ############################### #### Methods #### ############################### |