summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@mozilla.com>2015-05-19 05:48:57 +0200
committerByron Jones <glob@mozilla.com>2015-05-19 05:48:57 +0200
commit64fd94e3c85af86131f34694a188aca380462f99 (patch)
treea97a8168b2bef327e9d0a005b0d5493d159d7ac5 /Bugzilla
parent1e23e69630c37096d05e9a3ef31e824e912987d3 (diff)
downloadbugzilla-64fd94e3c85af86131f34694a188aca380462f99.tar.gz
bugzilla-64fd94e3c85af86131f34694a188aca380462f99.tar.xz
Bug 1160430: Backport bug 69267 to BMO (Add the ability to deactivate keywords)
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm13
-rw-r--r--Bugzilla/Keyword.pm26
-rw-r--r--Bugzilla/Template.pm7
-rw-r--r--Bugzilla/WebService/Bug.pm1
4 files changed, 43 insertions, 4 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index eee35360b..d22ebc1ce 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1894,6 +1894,19 @@ sub _check_keywords {
my $obj = Bugzilla::Keyword->check($keyword);
$keywords{$obj->id} = $obj;
}
+
+ my %old_kw_id;
+ if (blessed $invocant) {
+ my @old_keywords = @{$invocant->keyword_objects};
+ %old_kw_id = map { $_->id => 1 } @old_keywords;
+ }
+
+ foreach my $keyword (values %keywords) {
+ next if $keyword->is_active || exists $old_kw_id{$keyword->id};
+ ThrowUserError('value_inactive',
+ { value => $keyword->name, class => ref $keyword });
+ }
+
return [values %keywords];
}
diff --git a/Bugzilla/Keyword.pm b/Bugzilla/Keyword.pm
index cda401c59..0cdfaa090 100644
--- a/Bugzilla/Keyword.pm
+++ b/Bugzilla/Keyword.pm
@@ -33,6 +33,7 @@ use constant DB_COLUMNS => qw(
keyworddefs.id
keyworddefs.name
keyworddefs.description
+ keyworddefs.is_active
);
use constant DB_TABLE => 'keyworddefs';
@@ -40,11 +41,13 @@ use constant DB_TABLE => 'keyworddefs';
use constant VALIDATORS => {
name => \&_check_name,
description => \&_check_description,
+ is_active => \&_check_is_active,
};
use constant UPDATE_COLUMNS => qw(
name
description
+ is_active
);
###############################
@@ -69,6 +72,7 @@ sub bug_count {
sub set_name { $_[0]->set('name', $_[1]); }
sub set_description { $_[0]->set('description', $_[1]); }
+sub set_is_active { $_[0]->set('is_active', $_[1]); }
###############################
#### Subroutines ######
@@ -132,6 +136,10 @@ sub _check_description {
return $desc;
}
+sub _check_is_active { return $_[1] ? 1 : 0 }
+
+sub is_active { return $_[0]->{is_active} }
+
1;
__END__
@@ -155,10 +163,10 @@ Bugzilla::Keyword represents a keyword that can be added to a bug.
This implements all standard C<Bugzilla::Object> methods. See
L<Bugzilla::Object> for more details.
-=head1 SUBROUTINES
+=head1 METHODS
-This is only a list of subroutines specific to C<Bugzilla::Keyword>.
-See L<Bugzilla::Object> for more subroutines that this object
+This is only a list of methods specific to C<Bugzilla::Keyword>.
+See L<Bugzilla::Object> for more methods that this object
implements.
=over
@@ -173,6 +181,18 @@ implements.
Returns: A reference to an array of Keyword objects, or an empty
arrayref if there are no keywords.
+=item C<is_active>
+
+ Description: Indicates if the keyword may be used on a bug
+ Params: none
+ Returns: a boolean value that is true if the keyword can be applied to bugs.
+
+=item C<set_is_active($is_active)>
+
+ Description: Set the is_active property to a boolean value
+ Params: the new value of the is_active property.
+ Returns: nothing
+
=back
=cut
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 608d612b8..bc0d77084 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -1074,9 +1074,14 @@ sub create {
# Whether or not keywords are enabled, in this Bugzilla.
'use_keywords' => sub { return Bugzilla::Keyword->any_exist; },
- # All the keywords.
+ # All the keywords
'all_keywords' => sub { return Bugzilla::Keyword->get_all(); },
+ # All the active keywords
+ 'active_keywords' => sub {
+ return [grep { $_->is_active } Bugzilla::Keyword->get_all()];
+ },
+
'feature_enabled' => sub { return Bugzilla->feature(@_); },
# field_descs can be somewhat slow to generate, so we generate
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index 2edd2f3d0..0956ddd8d 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -275,6 +275,7 @@ sub _legal_field_values {
elsif ($field_name eq 'keywords') {
my @legal_keywords = Bugzilla::Keyword->get_all;
foreach my $value (@legal_keywords) {
+ next unless $value->is_active;
push (@result, {
name => $self->type('string', $value->name),
description => $self->type('string', $value->description),