summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2008-02-25 23:06:24 +0100
committerlpsolit%gmail.com <>2008-02-25 23:06:24 +0100
commit816eb1e9bd788b2b3468481281793639c824996d (patch)
tree9e272644a04e3dec038785e4d819ff9fe25fe1e6 /Bugzilla
parent8ef50bdaba56ee100821c51ff141e00d26723dc7 (diff)
downloadbugzilla-816eb1e9bd788b2b3468481281793639c824996d.tar.gz
bugzilla-816eb1e9bd788b2b3468481281793639c824996d.tar.xz
Bug 415652: Implement Bugzilla->active_custom_fields - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=mkanat
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm21
-rw-r--r--Bugzilla/Field.pm7
2 files changed, 12 insertions, 16 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 5cbe8a619..a5d25885e 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -68,8 +68,8 @@ use constant LIST_ORDER => ID_FIELD;
# This is a sub because it needs to call other subroutines.
sub DB_COLUMNS {
my $dbh = Bugzilla->dbh;
- my @custom = Bugzilla->get_fields({ custom => 1, obsolete => 0});
- @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT} @custom;
+ my @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT}
+ Bugzilla->active_custom_fields;
my @custom_names = map {$_->name} @custom;
return qw(
alias
@@ -130,8 +130,7 @@ sub VALIDATORS {
};
# Set up validators for custom fields.
- my @custom_fields = Bugzilla->get_fields({custom => 1, obsolete => 0});
- foreach my $field (@custom_fields) {
+ foreach my $field (Bugzilla->active_custom_fields) {
my $validator;
if ($field->type == FIELD_TYPE_SINGLE_SELECT) {
$validator = \&_check_select_field;
@@ -167,8 +166,8 @@ use constant UPDATE_VALIDATORS => {
};
sub UPDATE_COLUMNS {
- my @custom = Bugzilla->get_fields({ custom => 1, obsolete => 0});
- @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT} @custom;
+ my @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT}
+ Bugzilla->active_custom_fields;
my @custom_names = map {$_->name} @custom;
my @columns = qw(
alias
@@ -566,8 +565,8 @@ sub update {
}
# Insert the values into the multiselect value tables
- my @multi_selects = Bugzilla->get_fields(
- { custom => 1, type => FIELD_TYPE_MULTI_SELECT, obsolete => 0 });
+ my @multi_selects = grep {$_->type == FIELD_TYPE_MULTI_SELECT}
+ Bugzilla->active_custom_fields;
foreach my $field (@multi_selects) {
my $name = $field->name;
my ($removed, $added) = diff_arrays($old_bug->$name, $self->$name);
@@ -625,8 +624,8 @@ sub update {
sub _extract_multi_selects {
my ($invocant, $params) = @_;
- my @multi_selects = Bugzilla->get_fields(
- { custom => 1, type => FIELD_TYPE_MULTI_SELECT, obsolete => 0 });
+ my @multi_selects = grep {$_->type == FIELD_TYPE_MULTI_SELECT}
+ Bugzilla->active_custom_fields;
my %ms_values;
foreach my $field (@multi_selects) {
my $name = $field->name;
@@ -1581,7 +1580,7 @@ sub fields {
# Conditional Fields
Bugzilla->params->{'useqacontact'} ? "qa_contact" : (),
# Custom Fields
- Bugzilla->custom_field_names
+ map { $_->name } Bugzilla->active_custom_fields
);
}
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index 5272f0ed6..0d7479034 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -30,17 +30,14 @@ Bugzilla::Field - a particular piece of information about bugs
print Dumper(Bugzilla->get_fields());
# Display information about non-obsolete custom fields.
- print Dumper(Bugzilla->get_fields({ obsolete => 1, custom => 1 }));
-
- # Display a list of the names of non-obsolete custom fields.
- print Bugzilla->custom_field_names;
+ print Dumper(Bugzilla->active_custom_fields);
use Bugzilla::Field;
# Display information about non-obsolete custom fields.
# Bugzilla->get_fields() is a wrapper around Bugzilla::Field->match(),
# so both methods take the same arguments.
- print Dumper(Bugzilla::Field->match({ obsolete => 1, custom => 1 }));
+ print Dumper(Bugzilla::Field->match({ obsolete => 0, custom => 1 }));
# Create or update a custom field or field definition.
my $field = Bugzilla::Field->create(