Remove duplicate get_legal_field_values() API
parent
c9e2139fbf
commit
b2d8118048
|
@ -48,6 +48,13 @@ use constant USENAMES => {
|
|||
useopsys => 'op_sys',
|
||||
};
|
||||
|
||||
use constant DEFAULTNAMES => {
|
||||
defaultpriority => 'priority',
|
||||
defaultseverity => 'bug_severity',
|
||||
defaultplatform => 'platform',
|
||||
defaultopsys => 'op_sys',
|
||||
};
|
||||
|
||||
our $sortkey = 600;
|
||||
|
||||
# A bridge from products.classification_id to fielddefs.visibility_field
|
||||
|
@ -76,143 +83,140 @@ sub set_usefield
|
|||
return '';
|
||||
}
|
||||
|
||||
sub get_param_list {
|
||||
my $class = shift;
|
||||
sub check_value
|
||||
{
|
||||
my ($value, $param) = @_;
|
||||
my $f = DEFAULTNAMES->{$param->{name}};
|
||||
my $legal = Bugzilla->get_field($f)->legal_value_names;
|
||||
if (!grep { $_ eq $value } @$legal)
|
||||
{
|
||||
return "Must be a valid $f: one of ".join(', ', @$legal);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
my @legal_priorities = @{get_legal_field_values('priority')};
|
||||
my @legal_severities = @{get_legal_field_values('bug_severity')};
|
||||
my @legal_platforms = @{get_legal_field_values('rep_platform')};
|
||||
my @legal_OS = @{get_legal_field_values('op_sys')};
|
||||
sub get_param_list
|
||||
{
|
||||
my $class = shift;
|
||||
|
||||
my @param_list = (
|
||||
{
|
||||
name => 'useclassification',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_useclassification,
|
||||
},
|
||||
my $legal = {};
|
||||
for (qw(priority bug_severity platform op_sys))
|
||||
{
|
||||
$legal->{$_} = [ Bugzilla->get_field($_)->legal_value_names ];
|
||||
}
|
||||
|
||||
{
|
||||
name => 'usetargetmilestone',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'useqacontact',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'usestatuswhiteboard',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'usevotes',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'usebugaliases',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'use_see_also',
|
||||
type => 'b',
|
||||
default => 1,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'defaultpriority',
|
||||
type => 's',
|
||||
choices => \@legal_priorities,
|
||||
default => $legal_priorities[-1],
|
||||
checker => \&check_priority
|
||||
},
|
||||
|
||||
{
|
||||
name => 'defaultseverity',
|
||||
type => 's',
|
||||
choices => \@legal_severities,
|
||||
default => $legal_severities[-1],
|
||||
checker => \&check_severity
|
||||
},
|
||||
|
||||
{
|
||||
name => 'useplatform',
|
||||
type => 'b',
|
||||
default => 1,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'defaultplatform',
|
||||
type => 's',
|
||||
choices => ['', @legal_platforms],
|
||||
default => '',
|
||||
checker => \&check_platform
|
||||
},
|
||||
|
||||
{
|
||||
name => 'auto_add_flag_requestees_to_cc',
|
||||
type => 'b',
|
||||
default => 1,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'useopsys',
|
||||
type => 'b',
|
||||
default => 1,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'defaultopsys',
|
||||
type => 's',
|
||||
choices => ['', @legal_OS],
|
||||
default => '',
|
||||
checker => \&check_opsys
|
||||
},
|
||||
|
||||
{
|
||||
name => 'clear_requests_on_close',
|
||||
type => 'b',
|
||||
default => 1,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'unauth_bug_details',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
},
|
||||
|
||||
{
|
||||
name => 'comment_line_length',
|
||||
type => 't',
|
||||
default => '80',
|
||||
checker => \&check_numeric
|
||||
},
|
||||
|
||||
{
|
||||
name => 'preview_comment_lines',
|
||||
type => 't',
|
||||
default => '30',
|
||||
checker => \&check_numeric
|
||||
},
|
||||
);
|
||||
return @param_list;
|
||||
my @param_list = (
|
||||
{
|
||||
name => 'useclassification',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_useclassification,
|
||||
},
|
||||
{
|
||||
name => 'usetargetmilestone',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
{
|
||||
name => 'useqacontact',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
{
|
||||
name => 'usestatuswhiteboard',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
{
|
||||
name => 'usevotes',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
{
|
||||
name => 'usebugaliases',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
{
|
||||
name => 'use_see_also',
|
||||
type => 'b',
|
||||
default => 1,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
{
|
||||
name => 'defaultpriority',
|
||||
type => 's',
|
||||
choices => $legal->{priority},
|
||||
default => $legal->{priority}->[-1],
|
||||
checker => \&check_value,
|
||||
},
|
||||
{
|
||||
name => 'defaultseverity',
|
||||
type => 's',
|
||||
choices => $legal->{bug_severity},
|
||||
default => $legal->{bug_severity}->[-1],
|
||||
checker => \&check_value,
|
||||
},
|
||||
{
|
||||
name => 'useplatform',
|
||||
type => 'b',
|
||||
default => 1,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
{
|
||||
name => 'defaultplatform',
|
||||
type => 's',
|
||||
choices => ['', @{$legal->{platform}}],
|
||||
default => '',
|
||||
checker => \&check_value,
|
||||
},
|
||||
{
|
||||
name => 'auto_add_flag_requestees_to_cc',
|
||||
type => 'b',
|
||||
default => 1,
|
||||
},
|
||||
{
|
||||
name => 'useopsys',
|
||||
type => 'b',
|
||||
default => 1,
|
||||
checker => \&set_usefield,
|
||||
},
|
||||
{
|
||||
name => 'defaultopsys',
|
||||
type => 's',
|
||||
choices => ['', @{$legal->{op_sys}}],
|
||||
default => '',
|
||||
checker => \&check_value,
|
||||
},
|
||||
{
|
||||
name => 'clear_requests_on_close',
|
||||
type => 'b',
|
||||
default => 1,
|
||||
},
|
||||
{
|
||||
name => 'unauth_bug_details',
|
||||
type => 'b',
|
||||
default => 0,
|
||||
},
|
||||
{
|
||||
name => 'comment_line_length',
|
||||
type => 't',
|
||||
default => '80',
|
||||
checker => \&check_numeric,
|
||||
},
|
||||
{
|
||||
name => 'preview_comment_lines',
|
||||
type => 't',
|
||||
default => '30',
|
||||
checker => \&check_numeric,
|
||||
},
|
||||
);
|
||||
return @param_list;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -46,8 +46,7 @@ use Bugzilla::Status;
|
|||
use base qw(Exporter);
|
||||
@Bugzilla::Config::Common::EXPORT =
|
||||
qw(check_multi check_numeric check_regexp check_url check_group
|
||||
check_sslbase check_priority check_severity check_platform
|
||||
check_opsys check_shadowdb check_urlbase check_webdotbase
|
||||
check_sslbase check_shadowdb check_urlbase check_webdotbase
|
||||
check_user_verify_class
|
||||
check_mail_delivery_method check_notification check_utf8
|
||||
check_bug_status check_smtp_auth check_theschwartz_available
|
||||
|
@ -141,50 +140,6 @@ sub check_utf8 {
|
|||
return "";
|
||||
}
|
||||
|
||||
sub check_priority {
|
||||
my ($value) = (@_);
|
||||
my $legal_priorities = get_legal_field_values('priority');
|
||||
if (!grep { $_ eq $value } @$legal_priorities)
|
||||
{
|
||||
return "Must be a legal priority value: one of " .
|
||||
join(", ", @$legal_priorities);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
sub check_severity {
|
||||
my ($value) = (@_);
|
||||
my $legal_severities = get_legal_field_values('bug_severity');
|
||||
if (!grep { $_ eq $value } @$legal_severities)
|
||||
{
|
||||
return "Must be a legal severity value: one of " .
|
||||
join(", ", @$legal_severities);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
sub check_platform {
|
||||
my ($value) = (@_);
|
||||
my $legal_platforms = get_legal_field_values('rep_platform');
|
||||
if (!grep { $_ eq $value } '', @$legal_platforms)
|
||||
{
|
||||
return "Must be empty or a legal platform value: one of " .
|
||||
join(", ", @$legal_platforms);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
sub check_opsys {
|
||||
my ($value) = (@_);
|
||||
my $legal_OS = get_legal_field_values('op_sys');
|
||||
if (!grep { $_ eq $value } '', @$legal_OS)
|
||||
{
|
||||
return "Must be empty or a legal operating system value: one of " .
|
||||
join(", ", @$legal_OS);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
sub check_bug_status {
|
||||
my $bug_status = shift;
|
||||
my @closed_bug_statuses = map {$_->name} closed_bug_statuses();
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
# Frédéric Buclin <LpSolit@gmail.com>
|
||||
# Myk Melez <myk@mozilla.org>
|
||||
# Greg Hendricks <ghendricks@novell.com>
|
||||
#
|
||||
# Deep refactoring by Vitaliy Filippov <vitalif@mail.ru>
|
||||
# http://wiki.4intra.net/Bugzilla4Intranet
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
@ -71,7 +74,7 @@ package Bugzilla::Field;
|
|||
use strict;
|
||||
|
||||
use base qw(Exporter Bugzilla::Object);
|
||||
@Bugzilla::Field::EXPORT = qw(get_field_id get_legal_field_values update_visibility_values);
|
||||
@Bugzilla::Field::EXPORT = qw(get_field_id update_visibility_values);
|
||||
|
||||
use Bugzilla::Constants;
|
||||
use Bugzilla::Error;
|
||||
|
@ -343,13 +346,13 @@ sub _check_add_to_deps
|
|||
|
||||
the name of the field in the database; begins with "cf_" if field
|
||||
is a custom field, but test the value of the boolean "custom" property
|
||||
to determine if a given field is a custom field;
|
||||
to determine if a given field is a custom field
|
||||
|
||||
=item C<description>
|
||||
|
||||
a short string describing the field; displayed to Bugzilla users
|
||||
in several places within Bugzilla's UI, f.e. as the form field label
|
||||
on the "show bug" page;
|
||||
on the "show bug" page
|
||||
|
||||
=back
|
||||
|
||||
|
@ -376,7 +379,7 @@ sub type { return $_[0]->{type} }
|
|||
|
||||
a boolean specifying whether or not the field is a custom field;
|
||||
if true, field name should start "cf_", but use this property to determine
|
||||
which fields are custom fields;
|
||||
which fields are custom fields
|
||||
|
||||
=back
|
||||
|
||||
|
@ -401,7 +404,7 @@ sub in_new_bugmail { return $_[0]->{mailhead} }
|
|||
|
||||
=item C<sortkey>
|
||||
|
||||
an integer specifying the sortkey of the field.
|
||||
an integer specifying the sortkey of the field
|
||||
|
||||
=back
|
||||
|
||||
|
@ -413,7 +416,7 @@ sub sortkey { return $_[0]->{sortkey} }
|
|||
|
||||
=item C<obsolete>
|
||||
|
||||
a boolean specifying whether or not the field is obsolete;
|
||||
a boolean specifying whether or not the field is obsolete
|
||||
|
||||
=back
|
||||
|
||||
|
@ -475,9 +478,10 @@ objects.
|
|||
|
||||
=cut
|
||||
|
||||
sub is_select {
|
||||
sub is_select
|
||||
{
|
||||
return ($_[0]->type == FIELD_TYPE_SINGLE_SELECT
|
||||
|| $_[0]->type == FIELD_TYPE_MULTI_SELECT) ? 1 : 0
|
||||
|| $_[0]->type == FIELD_TYPE_MULTI_SELECT) ? 1 : 0;
|
||||
}
|
||||
|
||||
sub has_activity { $_[0]->{has_activity} }
|
||||
|
@ -562,13 +566,14 @@ Returns undef if there is no field that controls this field's visibility.
|
|||
|
||||
=cut
|
||||
|
||||
sub visibility_field {
|
||||
sub visibility_field
|
||||
{
|
||||
my $self = shift;
|
||||
if ($self->{visibility_field_id}) {
|
||||
$self->{visibility_field} ||=
|
||||
$self->new($self->{visibility_field_id});
|
||||
if ($self->{visibility_field_id})
|
||||
{
|
||||
return Bugzilla->get_field($self->{visibility_field_id});
|
||||
}
|
||||
return $self->{visibility_field};
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub visibility_field_id
|
||||
|
@ -654,7 +659,8 @@ field controls the visibility of.
|
|||
|
||||
=cut
|
||||
|
||||
sub controls_visibility_of {
|
||||
sub controls_visibility_of
|
||||
{
|
||||
my $self = shift;
|
||||
$self->{controls_visibility_of} ||= [ Bugzilla->get_fields({ visibility_field_id => $self->id, obsolete => 0 }) ];
|
||||
return $self->{controls_visibility_of};
|
||||
|
@ -674,9 +680,11 @@ Returns undef if there is no field that controls this field's visibility.
|
|||
|
||||
=cut
|
||||
|
||||
sub value_field {
|
||||
sub value_field
|
||||
{
|
||||
my $self = shift;
|
||||
if ($self->{value_field_id}) {
|
||||
if ($self->{value_field_id})
|
||||
{
|
||||
$self->{value_field} ||= $self->new($self->{value_field_id});
|
||||
}
|
||||
return $self->{value_field};
|
||||
|
@ -701,7 +709,8 @@ field controls the values of.
|
|||
|
||||
=cut
|
||||
|
||||
sub controls_values_of {
|
||||
sub controls_values_of
|
||||
{
|
||||
my $self = shift;
|
||||
$self->{controls_values_of} ||= [ Bugzilla->get_fields({ value_field_id => $self->id }) ];
|
||||
return $self->{controls_values_of};
|
||||
|
@ -978,35 +987,6 @@ sub run_create_validators
|
|||
return $params;
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=over
|
||||
|
||||
=item C<get_legal_field_values($field)>
|
||||
|
||||
Description: returns all the legal values for a field that has a
|
||||
list of legal values, like rep_platform or resolution.
|
||||
The table where these values are stored must at least have
|
||||
the following columns: value, isactive, sortkey.
|
||||
|
||||
Params: C<$field> - Name of the table where valid values are.
|
||||
|
||||
Returns: a reference to a list of valid values.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub get_legal_field_values {
|
||||
my ($field) = @_;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
my $result_ref = $dbh->selectcol_arrayref(
|
||||
"SELECT value FROM $field
|
||||
WHERE isactive = ?
|
||||
ORDER BY sortkey, value", undef, (1));
|
||||
return $result_ref;
|
||||
}
|
||||
|
||||
=over
|
||||
|
||||
=item C<populate_field_definitions()>
|
||||
|
@ -1022,21 +1002,26 @@ Returns: nothing
|
|||
|
||||
=cut
|
||||
|
||||
sub populate_field_definitions {
|
||||
sub populate_field_definitions
|
||||
{
|
||||
my $dbh = Bugzilla->dbh;
|
||||
|
||||
# ADD and UPDATE field definitions
|
||||
foreach my $def (DEFAULT_FIELDS) {
|
||||
foreach my $def (DEFAULT_FIELDS)
|
||||
{
|
||||
my $field = new Bugzilla::Field({ name => $def->{name} });
|
||||
if ($field) {
|
||||
if ($field)
|
||||
{
|
||||
$field->set_description($def->{desc});
|
||||
$field->set_in_new_bugmail($def->{in_new_bugmail});
|
||||
$field->set_buglist($def->{buglist});
|
||||
$field->_set_type($def->{type}) if $def->{type};
|
||||
$field->update();
|
||||
}
|
||||
else {
|
||||
if (exists $def->{in_new_bugmail}) {
|
||||
else
|
||||
{
|
||||
if (exists $def->{in_new_bugmail})
|
||||
{
|
||||
$def->{mailhead} = $def->{in_new_bugmail};
|
||||
delete $def->{in_new_bugmail};
|
||||
}
|
||||
|
@ -1064,62 +1049,68 @@ sub populate_field_definitions {
|
|||
my $new_field_name = 'days_elapsed';
|
||||
my $field_description = 'Days since bug changed';
|
||||
|
||||
my ($old_field_id, $old_field_name) =
|
||||
$dbh->selectrow_array('SELECT id, name FROM fielddefs
|
||||
WHERE description = ?',
|
||||
undef, $field_description);
|
||||
my ($old_field_id, $old_field_name) = $dbh->selectrow_array(
|
||||
'SELECT id, name FROM fielddefs WHERE description = ?',
|
||||
undef, $field_description
|
||||
);
|
||||
|
||||
if ($old_field_id && ($old_field_name ne $new_field_name)) {
|
||||
if ($old_field_id && ($old_field_name ne $new_field_name))
|
||||
{
|
||||
print "SQL fragment found in the 'fielddefs' table...\n";
|
||||
print "Old field name: " . $old_field_name . "\n";
|
||||
# We have to fix saved searches first. Queries have been escaped
|
||||
# before being saved. We have to do the same here to find them.
|
||||
$old_field_name = url_quote($old_field_name);
|
||||
my $broken_named_queries =
|
||||
$dbh->selectall_arrayref('SELECT userid, name, query
|
||||
FROM namedqueries WHERE ' .
|
||||
$dbh->sql_istrcmp('query', '?', 'LIKE'),
|
||||
undef, "%=$old_field_name%");
|
||||
my $broken_named_queries = $dbh->selectall_arrayref(
|
||||
'SELECT userid, name, query FROM namedqueries WHERE ' .
|
||||
$dbh->sql_istrcmp('query', '?', 'LIKE'),
|
||||
undef, "%=$old_field_name%"
|
||||
);
|
||||
|
||||
my $sth_UpdateQueries = $dbh->prepare('UPDATE namedqueries SET query = ?
|
||||
WHERE userid = ? AND name = ?');
|
||||
my $sth_UpdateQueries = $dbh->prepare(
|
||||
'UPDATE namedqueries SET query = ? WHERE userid = ? AND name = ?'
|
||||
);
|
||||
|
||||
print "Fixing saved searches...\n" if scalar(@$broken_named_queries);
|
||||
foreach my $named_query (@$broken_named_queries) {
|
||||
print "Fixing saved searches...\n" if scalar @$broken_named_queries;
|
||||
foreach my $named_query (@$broken_named_queries)
|
||||
{
|
||||
my ($userid, $name, $query) = @$named_query;
|
||||
$query =~ s/=\Q$old_field_name\E(&|$)/=$new_field_name$1/gi;
|
||||
$sth_UpdateQueries->execute($query, $userid, $name);
|
||||
}
|
||||
|
||||
# We now do the same with saved chart series.
|
||||
my $broken_series =
|
||||
$dbh->selectall_arrayref('SELECT series_id, query
|
||||
FROM series WHERE ' .
|
||||
$dbh->sql_istrcmp('query', '?', 'LIKE'),
|
||||
undef, "%=$old_field_name%");
|
||||
my $broken_series = $dbh->selectall_arrayref(
|
||||
'SELECT series_id, query FROM series WHERE ' .
|
||||
$dbh->sql_istrcmp('query', '?', 'LIKE'),
|
||||
undef, "%=$old_field_name%"
|
||||
);
|
||||
|
||||
my $sth_UpdateSeries = $dbh->prepare('UPDATE series SET query = ?
|
||||
WHERE series_id = ?');
|
||||
my $sth_UpdateSeries = $dbh->prepare('UPDATE series SET query = ? WHERE series_id = ?');
|
||||
|
||||
print "Fixing saved chart series...\n" if scalar(@$broken_series);
|
||||
foreach my $series (@$broken_series) {
|
||||
print "Fixing saved chart series...\n" if scalar @$broken_series;
|
||||
foreach my $series (@$broken_series)
|
||||
{
|
||||
my ($series_id, $query) = @$series;
|
||||
$query =~ s/=\Q$old_field_name\E(&|$)/=$new_field_name$1/gi;
|
||||
$sth_UpdateSeries->execute($query, $series_id);
|
||||
}
|
||||
|
||||
# Now that saved searches have been fixed, we can fix the field name.
|
||||
print "Fixing the 'fielddefs' table...\n";
|
||||
print "New field name: " . $new_field_name . "\n";
|
||||
$dbh->do('UPDATE fielddefs SET name = ? WHERE id = ?',
|
||||
undef, ($new_field_name, $old_field_id));
|
||||
$dbh->do('UPDATE fielddefs SET name = ? WHERE id = ?', undef, $new_field_name, $old_field_id);
|
||||
}
|
||||
|
||||
# This field has to be created separately, or the above upgrade code
|
||||
# might not run properly.
|
||||
Bugzilla::Field->create({ name => $new_field_name,
|
||||
description => $field_description })
|
||||
unless new Bugzilla::Field({ name => $new_field_name });
|
||||
|
||||
unless (new Bugzilla::Field({ name => $new_field_name }))
|
||||
{
|
||||
Bugzilla::Field->create({
|
||||
name => $new_field_name,
|
||||
description => $field_description
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
=pod
|
||||
|
@ -1145,7 +1136,7 @@ sub get_field_id
|
|||
my ($name) = @_;
|
||||
trick_taint($name);
|
||||
my $field = Bugzilla->get_field($name);
|
||||
ThrowCodeError('invalid_field_name', {field => $name}) unless $field;
|
||||
ThrowCodeError('invalid_field_name', { field => $name }) unless $field;
|
||||
return $field->id;
|
||||
}
|
||||
|
||||
|
@ -1200,7 +1191,7 @@ sub update_controlled_values
|
|||
if ($visibility_value_id)
|
||||
{
|
||||
my $type = Bugzilla::Field::Choice->type($vis_field);
|
||||
$visibility_value_id = $type->new($visibility_value_id)->{'id'};
|
||||
$visibility_value_id = $type->new($visibility_value_id)->{id};
|
||||
}
|
||||
Bugzilla->dbh->do(
|
||||
"DELETE FROM fieldvaluecontrol WHERE field_id=? AND visibility_value_id=? AND value_id!=0",
|
||||
|
|
|
@ -642,37 +642,45 @@ use constant is_default => 0;
|
|||
#### Methods ####
|
||||
###############################
|
||||
|
||||
sub _create_bug_group {
|
||||
sub _create_bug_group
|
||||
{
|
||||
my $self = shift;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
|
||||
my $group_name = $self->name;
|
||||
while (new Bugzilla::Group({name => $group_name})) {
|
||||
$group_name .= '_';
|
||||
my $i = 1;
|
||||
while (new Bugzilla::Group({ name => $group_name }))
|
||||
{
|
||||
$group_name = $self->name . ($i++);
|
||||
}
|
||||
my $group_description = get_text('bug_group_description', {product => $self});
|
||||
my $group_description = get_text('bug_group_description', { product => $self });
|
||||
|
||||
my $group = Bugzilla::Group->create({name => $group_name,
|
||||
description => $group_description,
|
||||
isbuggroup => 1});
|
||||
my $group = Bugzilla::Group->create({
|
||||
name => $group_name,
|
||||
description => $group_description,
|
||||
isbuggroup => 1,
|
||||
});
|
||||
|
||||
# Associate the new group and new product.
|
||||
$dbh->do('INSERT INTO group_control_map
|
||||
(group_id, product_id, membercontrol, othercontrol)
|
||||
VALUES (?, ?, ?, ?)',
|
||||
undef, ($group->id, $self->id, CONTROLMAPDEFAULT, CONTROLMAPNA));
|
||||
$dbh->do(
|
||||
'INSERT INTO group_control_map (group_id, product_id, membercontrol, othercontrol)'.
|
||||
' VALUES (?, ?, ?, ?)', undef, $group->id, $self->id, CONTROLMAPDEFAULT, CONTROLMAPNA
|
||||
);
|
||||
}
|
||||
|
||||
sub _create_series {
|
||||
sub _create_series
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
my @series;
|
||||
# We do every status, every resolution, and an "opened" one as well.
|
||||
foreach my $bug_status (@{get_legal_field_values('bug_status')}) {
|
||||
foreach my $bug_status (@{ Bugzilla->get_field('bug_status')->legal_value_names })
|
||||
{
|
||||
push(@series, [$bug_status, "bug_status=" . url_quote($bug_status)]);
|
||||
}
|
||||
|
||||
foreach my $resolution (@{get_legal_field_values('resolution')}) {
|
||||
foreach my $resolution (@{ Bugzilla->get_field('resolution')->legal_value_names })
|
||||
{
|
||||
next if !$resolution;
|
||||
push(@series, [$resolution, "resolution=" . url_quote($resolution)]);
|
||||
}
|
||||
|
@ -681,11 +689,13 @@ sub _create_series {
|
|||
my $query = join("&", map { "bug_status=" . url_quote($_) } @openedstatuses);
|
||||
push(@series, [get_text('series_all_open'), $query]);
|
||||
|
||||
foreach my $sdata (@series) {
|
||||
my $series = new Bugzilla::Series(undef, $self->name,
|
||||
get_text('series_subcategory'),
|
||||
$sdata->[0], Bugzilla->user->id, 1,
|
||||
$sdata->[1] . "&product=" . url_quote($self->name), 1);
|
||||
foreach my $sdata (@series)
|
||||
{
|
||||
my $series = new Bugzilla::Series(
|
||||
undef, $self->name, get_text('series_subcategory'),
|
||||
$sdata->[0], Bugzilla->user->id, 1,
|
||||
$sdata->[1] . "&product=" . url_quote($self->name), 1
|
||||
);
|
||||
$series->writeToDatabase();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,9 +196,11 @@ sub quicksearch {
|
|||
$cgi->param('content', $self->{content});
|
||||
|
||||
# If we have wanted resolutions, allow closed states
|
||||
if (keys %{$self->{resolutions}}) {
|
||||
foreach (@{get_legal_field_values('bug_status')}) {
|
||||
$self->{states}->{$_} = 1 unless is_open_state($_);
|
||||
if (keys %{$self->{resolutions}})
|
||||
{
|
||||
foreach (@{ Bugzilla->get_field('bug_status')->legal_values })
|
||||
{
|
||||
$self->{states}->{$_->name} = 1 if !$_->is_open;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,9 +291,9 @@ sub _handle_alias {
|
|||
sub _handle_status_and_resolution
|
||||
{
|
||||
my $self = shift;
|
||||
$self->{legal_statuses} = get_legal_field_values('bug_status');
|
||||
$self->{legal_statuses} = Bugzilla->get_field('bug_status')->legal_value_names;
|
||||
push @{$self->{legal_statuses}}, 'OPEN';
|
||||
$self->{legal_resolutions} = get_legal_field_values('resolution');
|
||||
$self->{legal_resolutions} = Bugzilla->get_field('resolution')->legal_value_names;
|
||||
|
||||
my (%st, %res);
|
||||
if ($self->{words}->[0] =~ /^[A-Z]+(,[A-Z]+)*$/ &&
|
||||
|
@ -502,7 +504,7 @@ sub _special_field_syntax {
|
|||
# P1-5 Syntax
|
||||
if ($word =~ m/^P(\d+)(?:-(\d+))?$/i) {
|
||||
my ($p_start, $p_end) = ($1, $2);
|
||||
my $legal_priorities = get_legal_field_values('priority');
|
||||
my $legal_priorities = Bugzilla->get_field('priority')->legal_value_names;
|
||||
|
||||
# If Pn exists explicitly, use it.
|
||||
my $start = lsearch($legal_priorities, "P$p_start");
|
||||
|
|
|
@ -562,7 +562,7 @@ sub legal_values {
|
|||
if (grep($_->name eq $field, @global_selects)) {
|
||||
# The field is a valid one.
|
||||
trick_taint($field);
|
||||
$values = get_legal_field_values($field);
|
||||
$values = Bugzilla->get_field($field)->legal_value_names;
|
||||
}
|
||||
elsif (grep($_ eq $field, PRODUCT_SPECIFIC_FIELDS)) {
|
||||
my $id = $params->{product_id};
|
||||
|
|
12
buglist.cgi
12
buglist.cgi
|
@ -1113,7 +1113,7 @@ $vars->{'closedstates'} = [map {$_->name} closed_bug_statuses()];
|
|||
if ($format->{'extension'} eq 'ics') {
|
||||
my $n = 1;
|
||||
$vars->{'ics_priorities'} = {};
|
||||
my $priorities = get_legal_field_values('priority');
|
||||
my $priorities = Bugzilla->get_field('priority')->legal_value_names;
|
||||
foreach my $p (@$priorities) {
|
||||
$vars->{'ics_priorities'}->{$p} = ($n > 9) ? 9 : $n++;
|
||||
}
|
||||
|
@ -1199,11 +1199,11 @@ if ($dotweak && scalar @bugs) {
|
|||
Bugzilla->switch_to_shadow_db();
|
||||
|
||||
$vars->{'products'} = Bugzilla->user->get_enterable_products;
|
||||
$vars->{'platforms'} = get_legal_field_values('rep_platform') if Bugzilla->params->{useplatform};
|
||||
$vars->{'op_sys'} = get_legal_field_values('op_sys') if Bugzilla->params->{useopsys};
|
||||
$vars->{'priorities'} = get_legal_field_values('priority');
|
||||
$vars->{'severities'} = get_legal_field_values('bug_severity');
|
||||
$vars->{'resolutions'} = get_legal_field_values('resolution');
|
||||
$vars->{'platforms'} = Bugzilla->get_field('platform')->legal_value_names if Bugzilla->params->{useplatform};
|
||||
$vars->{'op_sys'} = Bugzilla->get_field('op_sys')->legal_value_names if Bugzilla->params->{useopsys};
|
||||
$vars->{'priorities'} = Bugzilla->get_field('priority')->legal_value_names;
|
||||
$vars->{'severities'} = Bugzilla->get_field('bug_severity')->legal_value_names;
|
||||
$vars->{'resolutions'} = Bugzilla->get_field('resolution')->legal_value_names
|
||||
|
||||
# Convert bug statuses to their ID.
|
||||
my @bug_statuses = map {$dbh->quote($_)} keys %$bugstatuses;
|
||||
|
|
|
@ -80,7 +80,7 @@ unshift(@myproducts, "-All-");
|
|||
# may have existed in the past, or have been renamed. We want them all.
|
||||
my $fields = {};
|
||||
foreach my $field ('bug_status', 'resolution') {
|
||||
my $values = get_legal_field_values($field);
|
||||
my $values = Bugzilla->get_field($field)->legal_value_names;
|
||||
my $old_values = $dbh->selectcol_arrayref(
|
||||
"SELECT bugs_activity.added
|
||||
FROM bugs_activity
|
||||
|
|
12
config.cgi
12
config.cgi
|
@ -55,13 +55,13 @@ Bugzilla->switch_to_shadow_db;
|
|||
|
||||
# Pass a bunch of Bugzilla configuration to the templates.
|
||||
my $vars = {};
|
||||
$vars->{'priority'} = get_legal_field_values('priority');
|
||||
$vars->{'severity'} = get_legal_field_values('bug_severity');
|
||||
$vars->{'platform'} = get_legal_field_values('rep_platform') if Bugzilla->params->{useplatform};
|
||||
$vars->{'op_sys'} = get_legal_field_values('op_sys') if Bugzilla->params->{useopsys};
|
||||
$vars->{'priority'} = Bugzilla->get_field('priority')->legal_value_names;
|
||||
$vars->{'severity'} = Bugzilla->get_field('bug_severity')->legal_value_names;
|
||||
$vars->{'platform'} = Bugzilla->get_field('rep_platform')->legal_value_names if Bugzilla->params->{useplatform};
|
||||
$vars->{'op_sys'} = Bugzilla->get_field('op_sys')->legal_value_names if Bugzilla->params->{useopsys};
|
||||
$vars->{'keyword'} = [map($_->name, Bugzilla::Keyword->get_all)];
|
||||
$vars->{'resolution'} = get_legal_field_values('resolution');
|
||||
$vars->{'status'} = get_legal_field_values('bug_status');
|
||||
$vars->{'resolution'} = Bugzilla->get_field('resolution')->legal_value_names;
|
||||
$vars->{'status'} = Bugzilla->get_field('bug_status')->legal_value_names;
|
||||
$vars->{'custom_fields'} =
|
||||
[ grep {$_->is_select} Bugzilla->active_custom_fields ];
|
||||
|
||||
|
|
|
@ -401,10 +401,10 @@ $vars->{'product'} = $product;
|
|||
$vars->{product_flag_types} = $types;
|
||||
}
|
||||
|
||||
$vars->{'priority'} = get_legal_field_values('priority');
|
||||
$vars->{'bug_severity'} = get_legal_field_values('bug_severity');
|
||||
$vars->{'rep_platform'} = get_legal_field_values('rep_platform') if Bugzilla->params->{useplatform};
|
||||
$vars->{'op_sys'} = get_legal_field_values('op_sys') if Bugzilla->params->{useopsys};
|
||||
$vars->{'priority'} = Bugzilla->get_field('priority')->legal_value_names;
|
||||
$vars->{'bug_severity'} = Bugzilla->get_field('bug_severity')->legal_value_names;
|
||||
$vars->{'rep_platform'} = Bugzilla->get_field('rep_platform')->legal_value_names if Bugzilla->params->{useplatform};
|
||||
$vars->{'op_sys'} = Bugzilla->get_field('op_sys')->legal_value_names if Bugzilla->params->{useopsys};
|
||||
|
||||
$vars->{'assigned_to'} = formvalue('assigned_to');
|
||||
$vars->{'assigned_to_disabled'} = !$has_editbugs;
|
||||
|
@ -615,7 +615,7 @@ unless ($has_editbugs || $has_canconfirm) {
|
|||
}
|
||||
|
||||
$vars->{bug_status} = \@status;
|
||||
$vars->{resolution} = [ grep ($_, @{get_legal_field_values('resolution')}) ];
|
||||
$vars->{resolution} = [ grep ($_, @{Bugzilla->get_field('resolution')->legal_value_names}) ];
|
||||
|
||||
# Get the default from a template value if it is legitimate.
|
||||
# Otherwise, and only if the user has privs, set the default
|
||||
|
|
Loading…
Reference in New Issue