summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@mozilla.com>2015-05-01 06:03:57 +0200
committerDylan William Hardison <dylan@hardison.net>2015-05-01 06:03:57 +0200
commitc3c2eccd987259a577108fd05f57dc809950b0e6 (patch)
tree44cbe5438ce68ae36d8f36c205e2e523dd3dd5db /Bugzilla
parent0e68998f22b847d90753daac3808bedc4500cde6 (diff)
downloadbugzilla-c3c2eccd987259a577108fd05f57dc809950b0e6.tar.gz
bugzilla-c3c2eccd987259a577108fd05f57dc809950b0e6.tar.xz
Bug 69267: Add the ability to deactivate keywords
r/a=glob
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm14
-rw-r--r--Bugzilla/DB/Schema.pm3
-rw-r--r--Bugzilla/Install/DB.pm4
-rw-r--r--Bugzilla/Keyword.pm28
-rw-r--r--Bugzilla/Template.pm7
-rw-r--r--Bugzilla/WebService/Bug.pm1
6 files changed, 51 insertions, 6 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 2f34d55e7..6fcf14c5a 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1851,6 +1851,20 @@ 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/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index d340cf03d..c089513e3 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -588,6 +588,8 @@ use constant ABSTRACT_SCHEMA => {
PRIMARYKEY => 1},
name => {TYPE => 'varchar(64)', NOTNULL => 1},
description => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
+ is_active => {TYPE => 'BOOLEAN', NOTNULL => 1,
+ DEFAULT => 'TRUE'},
],
INDEXES => [
keyworddefs_name_idx => {FIELDS => ['name'],
@@ -605,7 +607,6 @@ use constant ABSTRACT_SCHEMA => {
REFERENCES => {TABLE => 'keyworddefs',
COLUMN => 'id',
DELETE => 'CASCADE'}},
-
],
INDEXES => [
keywords_bug_id_idx => {FIELDS => [qw(bug_id keywordid)],
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index ab02fe41d..ddd127be2 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -730,6 +730,10 @@ sub update_table_definitions {
$dbh->bz_add_column('longdescs', 'is_markdown',
{TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'});
+ # 2014-11-18 dylan@mozilla.com - Bug 69267
+ $dbh->bz_add_column('keyworddefs', 'is_active',
+ {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'});
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
diff --git a/Bugzilla/Keyword.pm b/Bugzilla/Keyword.pm
index afa93e1e9..ef044a0c5 100644
--- a/Bugzilla/Keyword.pm
+++ b/Bugzilla/Keyword.pm
@@ -26,6 +26,7 @@ use constant DB_COLUMNS => qw(
keyworddefs.id
keyworddefs.name
keyworddefs.description
+ keyworddefs.is_active
);
use constant DB_TABLE => 'keyworddefs';
@@ -33,11 +34,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
);
###############################
@@ -62,6 +65,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 ######
@@ -125,6 +129,10 @@ sub _check_description {
return $desc;
}
+sub _check_is_active { return $_[1] ? 1 : 0 }
+
+sub is_active { return $_[0]->{is_active} }
+
1;
__END__
@@ -145,13 +153,13 @@ Bugzilla::Keyword - A Keyword that can be added to a bug.
Bugzilla::Keyword represents a keyword that can be added to a bug.
-This implements all standard C<Bugzilla::Object> methods. See
+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
@@ -166,6 +174,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 de72cd71a..70a8197b5 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -1106,11 +1106,16 @@ 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 [map { $_->name } Bugzilla::Keyword->get_all()];
},
+ # All the active keywords
+ 'active_keywords' => sub {
+ return [map { $_->name } 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 fd01afb1b..f034d90d5 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -245,6 +245,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),