summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rwxr-xr-xeditkeywords.cgi6
-rw-r--r--extensions/BugModal/lib/WebService.pm2
-rw-r--r--template/en/default/admin/keywords/edit.html.tmpl11
-rw-r--r--template/en/default/admin/keywords/list.html.tmpl83
-rw-r--r--template/en/default/bug/field.html.tmpl2
-rw-r--r--template/en/default/global/user-error.html.tmpl2
-rw-r--r--template/en/default/reports/keywords.html.tmpl32
11 files changed, 126 insertions, 59 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),
diff --git a/editkeywords.cgi b/editkeywords.cgi
index fd7eaa3e5..2f0cd563b 100755
--- a/editkeywords.cgi
+++ b/editkeywords.cgi
@@ -82,8 +82,9 @@ if ($action eq 'add') {
#
if ($action eq 'new') {
check_token_data($token, 'add_keyword');
- my $name = $cgi->param('name') || '';
- my $desc = $cgi->param('description') || '';
+ my $name = $cgi->param('name') || '';
+ my $is_active = $cgi->param('is_active');
+ my $desc = $cgi->param('description') || '';
my $keyword = Bugzilla::Keyword->create(
{ name => $name, description => $desc });
@@ -134,6 +135,7 @@ if ($action eq 'update') {
$keyword->set_all({
name => scalar $cgi->param('name'),
description => scalar $cgi->param('description'),
+ is_active => scalar $cgi->param('is_active'),
});
my $changes = $keyword->update();
diff --git a/extensions/BugModal/lib/WebService.pm b/extensions/BugModal/lib/WebService.pm
index 5a1ec15c0..2461cf2fa 100644
--- a/extensions/BugModal/lib/WebService.pm
+++ b/extensions/BugModal/lib/WebService.pm
@@ -99,7 +99,7 @@ sub edit {
}
# keywords
- my @keywords = Bugzilla::Keyword->get_all();
+ my @keywords = grep { $_->is_active } Bugzilla::Keyword->get_all();
# results
return {
diff --git a/template/en/default/admin/keywords/edit.html.tmpl b/template/en/default/admin/keywords/edit.html.tmpl
index 65a62290b..d07bf908d 100644
--- a/template/en/default/admin/keywords/edit.html.tmpl
+++ b/template/en/default/admin/keywords/edit.html.tmpl
@@ -33,14 +33,19 @@
<form method="post" action="editkeywords.cgi">
<table border="0" cellpadding="4" cellspacing="0">
<tr>
- <th align="right">Name:</th>
- <td><input size="64" maxlength="64" name="name"
+ <th align="right"><label for="name">Name:</label></th>
+ <td><input size="64" maxlength="64" name="name" id="name"
value="[% keyword.name FILTER html %]"></td>
</tr>
<tr>
- <th align="right">Description:</th>
+ <th><label for="is_active">Enabled For [% terms.Bugs %]</label></th>
+ <td><input id="is_active" name="is_active" type="checkbox" [% "checked" IF keyword.is_active %]></td>
+ </tr>
+ <tr>
+ <th align="right"><label for="description">Description:</label></th>
<td>
[% INCLUDE global/textarea.html.tmpl
+ id = 'description'
name = 'description'
minrows = 4
cols = 64
diff --git a/template/en/default/admin/keywords/list.html.tmpl b/template/en/default/admin/keywords/list.html.tmpl
index c400a2362..9d920036e 100644
--- a/template/en/default/admin/keywords/list.html.tmpl
+++ b/template/en/default/admin/keywords/list.html.tmpl
@@ -1,68 +1,59 @@
-[%# The contents of this file are subject to the Mozilla Public
- # License Version 1.1 (the "License"); you may not use this file
- # except in compliance with the License. You may obtain a copy of
- # the License at http://www.mozilla.org/MPL/
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
- # Software distributed under the License is distributed on an "AS
- # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- # implied. See the License for the specific language governing
- # rights and limitations under the License.
- #
- # The Original Code is the Bugzilla Bug Tracking System.
- #
- # The Initial Developer of the Original Code is Netscape Communications
- # Corporation. Portions created by Netscape are
- # Copyright (C) 1998 Netscape Communications Corporation. All
- # Rights Reserved.
- #
- # Contributor(s): Terry Weissman <terry@mozilla.org>
- # Vlad Dascalu <jocuri@softhome.net>
- # Jouni Heikniemi <jouni@heikniemi.net>
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
#%]
[%# INTERFACE:
# keywords: array keyword objects having the properties:
# - id: number. The ID of the keyword.
# - name: string. The name of the keyword.
+ # - is_active: boolean. true if the keyword can be used.
# - description: string. The description of the keyword.
# - bug_count: number. The number of bugs with the keyword.
#%]
-[% PROCESS global/variables.none.tmpl %]
-
[% PROCESS global/header.html.tmpl
title = "Select keyword"
+ style_urls = ['skins/standard/admin.css']
%]
[% columns = [
- {
- name => "name"
- heading => "Edit keyword..."
- contentlink => "editkeywords.cgi?action=edit&amp;id=%%id%%"
- },
- {
- name => "description"
- heading => "Description"
- allow_html_content => 1
- },
- {
- name => "bug_count"
- heading => "$terms.Bugs"
- align => "right"
- contentlink => "buglist.cgi?keywords=%%name%%"
- },
- {
- heading => "Action"
- content => "Delete"
- contentlink => "editkeywords.cgi?action=del&amp;id=%%id%%"
- }
- ]
+ {
+ name => "name"
+ heading => "Edit keyword..."
+ contentlink => "editkeywords.cgi?action=edit&amp;id=%%id%%"
+ },
+ {
+ name => "description"
+ heading => "Description"
+ allow_html_content => 1
+ },
+ {
+ name => "is_active",
+ heading => "Active",
+ yesno_field => 1
+ },
+ {
+ name => "bug_count"
+ heading => "$terms.Bugs"
+ class => "right"
+ contentlink => "buglist.cgi?keywords=%%name%%"
+ },
+ {
+ heading => "Action"
+ content => "Delete"
+ contentlink => "editkeywords.cgi?action=del&amp;id=%%id%%"
+ }
+]
%]
[% PROCESS admin/table.html.tmpl
- columns = columns
- data = keywords
- footer = footer_row
+ columns = columns
+ data = keywords
+ footer = footer_row
%]
<p><a href="editkeywords.cgi?action=add">Add a new keyword</a></p>
diff --git a/template/en/default/bug/field.html.tmpl b/template/en/default/bug/field.html.tmpl
index 1d1e38874..366fe1144 100644
--- a/template/en/default/bug/field.html.tmpl
+++ b/template/en/default/bug/field.html.tmpl
@@ -243,7 +243,7 @@
</div>
<script type="text/javascript" defer="defer">
YAHOO.bugzilla.keyword_array = [
- [%- FOREACH keyword = all_keywords %]
+ [%- FOREACH keyword = active_keywords %]
[%-# %]"[% keyword.name FILTER js %]"
[%- "," IF NOT loop.last %][% END %]];
YAHOO.bugzilla.keywordAutocomplete.init('[% field.name FILTER js %]',
diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl
index 5e83eef14..10c31b59f 100644
--- a/template/en/default/global/user-error.html.tmpl
+++ b/template/en/default/global/user-error.html.tmpl
@@ -1401,7 +1401,7 @@
Either you mis-typed the name or that user has not yet registered
for a [% terms.Bugzilla %] account.
[% ELSIF class == "Bugzilla::Keyword" %]
- The legal keyword names are <a href="describekeywords.cgi">listed
+ The legal keyword names are <a href="describekeywords.cgi?show_inactive_keywords=1">listed
here</a>.
[% END %]
diff --git a/template/en/default/reports/keywords.html.tmpl b/template/en/default/reports/keywords.html.tmpl
index 045c6ebeb..b99f2c133 100644
--- a/template/en/default/reports/keywords.html.tmpl
+++ b/template/en/default/reports/keywords.html.tmpl
@@ -34,6 +34,33 @@
title = "$terms.Bugzilla Keyword Descriptions"
%]
+<script>
+ $(document).ready(function () {
+ var show_inactive_keywords = [% show_inactive_keywords ? "true" : "false" FILTER none %],
+ link = $("#keywords_show_hide"),
+ rows = $("tr.keyword_inactive");
+
+ link.click(function (event) {
+ if (show_inactive_keywords) {
+ show_inactive_keywords = false;
+ rows.show();
+ link.html("Hide inactive keywords");
+ }
+ else {
+ show_inactive_keywords = true;
+ rows.hide();
+ link.html("Show inactive keywords");
+ }
+ event.preventDefault();
+ }).click();
+ });
+</script>
+
+<p>
+ <a href="[% urlbase FILTER html %]?show_inactive_keywords=[% show_inactive_keywords ? "1" : "0" FILTER none %]"
+ id="keywords_show_hide">[% show_inactive_keywords ? "Show" : "Hide" FILTER html %] inactive keywords</a>
+</p>
+
[% FOREACH keyword = keywords %]
[% IF loop.index % 50 == 0 %]
[% IF loop.index != 0 %]
@@ -44,16 +71,19 @@
<tr bgcolor="#6666FF">
<th align="left">Name</th>
<th align="left">Description</th>
+ <th>Active</th>
<th align="left">Open [% terms.Bugs %]</th>
<th align="left">Total [% terms.Bugs %]</th>
</tr>
[% END %]
- <tr id="[% keyword.name FILTER html %]">
+ <tr id="[% keyword.name FILTER html %]"
+ class="[% keyword.is_active ? "keyword_active" : "keyword_inactive" FILTER html %]">
<th>
[% keyword.name FILTER html %]
</th>
<td>[% keyword.description FILTER html_light %]</td>
+ <td>[% keyword.is_active ? "Yes" : "No" FILTER html %]</td>
<td align="center">
[% IF keyword.bug_count > 0 %]
<a href="buglist.cgi?keywords=[% keyword.name FILTER uri %]&amp;resolution=---">