]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Add support for a new "keywords" feature. This lets some central
authorterry%mozilla.org <>
Fri, 7 Jan 2000 05:16:13 +0000 (05:16 +0000)
committerterry%mozilla.org <>
Fri, 7 Jan 2000 05:16:13 +0000 (05:16 +0000)
authority maintain a list of keywords, and users can associate any
keyword with any bug.

The new functionality won't appear until at least one keyword is
defined.

Note that you *must* run the "checksetup.pl" script after updating
this change, in order to create the new required tables "keywords" and
"keyworddefs".

bug_form.pl
buglist.cgi
checksetup.pl
describekeywords.cgi [new file with mode: 0755]
editkeywords.cgi [new file with mode: 0755]
globals.pl
process_bug.cgi
query.cgi

index 3d7179d78150cc392d3716e3f9766ab30afab215..63db92d020608ee7c0b86e34d2c0b66370d82cfd 100644 (file)
@@ -37,6 +37,7 @@ sub bug_form_pl_sillyness {
     $zz = @::legal_priority;
     $zz = @::legal_resolution_no_dup;
     $zz = @::legal_severity;
+    $zz = @::keywordsbyname;
 }
 
 my %knownattachments;
@@ -329,6 +330,24 @@ if (Param("usestatuswhiteboard")) {
   </TR>";
 }
 
+if (@::legal_keywords) {
+    SendSQL("SELECT keyworddefs.name 
+             FROM keyworddefs, keywords
+             WHERE keywords.bug_id = $id AND keyworddefs.id = keywords.keywordid
+             ORDER BY keyworddefs.name");
+    my @list;
+    while (MoreSQLData()) {
+        push(@list, FetchOneColumn());
+    }
+    my $value = value_quote(join(',', @list));
+    print qq{
+<TR>
+<TD ALIGN=right><B><A HREF="describekeywords.cgi">Keywords</A>:</B>
+<TD COLSPAN=6><INPUT NAME="keywords" VALUE="$value" SIZE=60></TD>
+</TR>
+};
+}
+
 print "<tr><td align=right><B>Attachments:</b></td>\n";
 SendSQL("select attach_id, creation_ts, description from attachments where bug_id = $id");
 while (MoreSQLData()) {
index 403a689dd07a5f34c03293e6a52dd6bce73a7359..211259dca49299903d64308a7fa9ee2bc455cd02 100755 (executable)
@@ -235,7 +235,8 @@ from   bugs,
        profiles assign,
        profiles report
        left join profiles qacont on bugs.qa_contact = qacont.userid,
-       versions projector
+       versions projector,
+       keywords
 
 where  bugs.assigned_to = assign.userid 
 and    bugs.reporter = report.userid
@@ -292,6 +293,27 @@ if (defined $::FORM{'sql'}) {
   }
 }
 
+if ($::FORM{'keywords'}) {
+    GetVersionTable();
+    my @list;
+    foreach my $v (split(',', $::FORM{'keywords'})) {
+        my $id = $::keywordsbyname{trim($v)};
+        if ($id) {
+            push(@list, "keywords.keywordid = $id");
+        } else {
+            print "Unknown keyword named <code>$v</code>.\n";
+            print "<P>The legal keyword names are <A HREF=describekeywords.cgi>";
+            print "listed here</A>.\n";
+            print "<P>Please click the <B>Back</B> button and try again.\n";
+            exit;
+        }
+    }
+    if (@list) {
+        $query .= "and keywords.bug_id = bugs.bug_id and (" .
+            join(" $::FORM{'keywords_type'} ", @list) . ")\n";
+    }
+}
+
 
 foreach my $id ("1", "2") {
     if (!defined ($::FORM{"email$id"})) {
@@ -750,8 +772,22 @@ document.write(\" <input type=button value=\\\"Uncheck All\\\" onclick=\\\"SetCh
     }
         
 
-    print "
-</TABLE>
+    if (@::legal_keywords) {
+        print qq{
+<TR><TD><B><A HREF="describekeywords.cgi">Keywords</A>:</TD>
+<TD COLSPAN=3><INPUT NAME=keywords SIZE=32 VALUE="">
+<SELECT NAME="keywordaction">
+<OPTION VALUE="add">Add these keywords
+<OPTION VALUE="delete">Delete these keywords
+<OPTION VALUE="makeexact">Make the keywords be exactly this list
+</SELECT>
+</TD>
+</TR>
+};
+    }
+
+
+    print "</TABLE>
 
 <INPUT NAME=multiupdate value=Y TYPE=hidden>
 
index 7b02ec0d5a82669ba9bcca91f67ccebbb87fb022..cf7a8397841af9bc1b8de588976d7317299967da 100755 (executable)
@@ -637,7 +637,19 @@ $table{votes} =
     index(who),
     index(bug_id)';
 
+$table{keywords} =
+    'bug_id mediumint not null,
+     keywordid smallint not null,
 
+     index(bug_id),
+     index(keywordid)';
+
+$table{keyworddefs} =
+    'id smallint not null primary key,
+     name varchar(64) not null,
+     description mediumtext,
+
+     unique(name)';
 
 
 
@@ -727,6 +739,7 @@ AddGroup 'tweakparams',      'Can tweak operating parameters';
 AddGroup 'editgroupmembers', 'Can put people in and out of groups that they are members of.';
 AddGroup 'creategroups',     'Can create and destroy groups.';
 AddGroup 'editcomponents',   'Can create, destroy, and edit components.';
+AddGroup 'editkeywords',   'Can create, destroy, and edit keywords.';
 
 
 
diff --git a/describekeywords.cgi b/describekeywords.cgi
new file mode 100755 (executable)
index 0000000..4da535c
--- /dev/null
@@ -0,0 +1,74 @@
+#!/usr/bonsaitools/bin/perl -w
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# 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/
+#
+# 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 Terry Weissman.
+# Portions created by Terry Weissman are
+# Copyright (C) 2000 Terry Weissman. All
+# Rights Reserved.
+#
+# Contributor(s): Terry Weissman <terry@mozilla.org>
+
+use diagnostics;
+use strict;
+
+require "CGI.pl";
+
+ConnectToDatabase();
+
+print "Content-type: text/html\n\n";
+
+PutHeader("Bugzilla keyword description");
+
+print qq{
+<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0>
+<TR BGCOLOR="#6666FF">
+<TH ALIGN="left">Name</TH>
+<TH ALIGN="left">Description</TH>
+<TH ALIGN="left">Bugs</TH>
+</TR>
+};
+
+SendSQL("SELECT keyworddefs.name, keyworddefs.description, 
+                COUNT(keywords.bug_id)
+         FROM keyworddefs LEFT JOIN keywords ON keyworddefs.id=keywords.keywordid
+         GROUP BY keyworddefs.id
+         ORDER BY keyworddefs.name");
+
+while (MoreSQLData()) {
+    my ($name, $description, $bugs) = FetchSQLData();
+    if ($bugs) {
+        my $q = url_quote($name);
+        $bugs = qq{<A HREF="buglist.cgi?keywords=$q">$bugs</A>};
+    } else {
+        $bugs = "none";
+    }
+    print qq{
+<TR>
+<TH>$name</TH>
+<TD>$description</TD>
+<TD ALIGN="right">$bugs</TD>
+</TR>
+};
+}
+
+print "</TABLE><P>\n";
+
+quietly_check_login();
+
+if (UserInGroup("editkeywords")) {
+    print "<p><a href=editkeywords.cgi>Edit keywords</a><p>\n";
+}
+
+navigation_header();
diff --git a/editkeywords.cgi b/editkeywords.cgi
new file mode 100755 (executable)
index 0000000..03525f7
--- /dev/null
@@ -0,0 +1,379 @@
+#!/usr/bonsaitools/bin/perl -w
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# 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/
+#
+# 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 Terry Weissman.
+# Portions created by Terry Weissman are
+# Copyright (C) 2000 Terry Weissman. All
+# Rights Reserved.
+#
+# Contributor(s): Terry Weissman <terry@mozilla.org>
+
+use diagnostics;
+use strict;
+
+require "CGI.pl";
+
+my $localtrailer = "<A HREF=\"editkeywords.cgi\">edit</A> more keywords";
+
+
+#
+# Displays a text like "a.", "a or b.", "a, b or c.", "a, b, c or d."
+#
+
+sub PutTrailer (@)
+{
+    my (@links) = ("Back to the <A HREF=\"query.cgi\">query page</A>", @_);
+
+    my $count = $#links;
+    my $num = 0;
+    print "<P>\n";
+    foreach (@links) {
+        print $_;
+        if ($num == $count) {
+            print ".\n";
+        }
+        elsif ($num == $count-1) {
+            print " or ";
+        }
+        else {
+            print ", ";
+        }
+        $num++;
+    }
+    print "</BODY>\n</HTML>\n";
+}
+
+
+#
+# Displays the form to edit a keyword's parameters
+#
+
+sub EmitFormElements ($$$)
+{
+    my ($id, $name, $description) = @_;
+
+    $name = value_quote($name);
+    $description = value_quote($description);
+
+    print qq{<INPUT TYPE="HIDDEN" NAME=id VALUE=$id>};
+
+    print "  <TR><TH ALIGN=\"right\">Name:</TH>\n";
+    print "  <TD><INPUT SIZE=64 MAXLENGTH=64 NAME=\"name\" VALUE=\"$name\"></TD>\n";
+    print "</TR><TR>\n";
+
+    print "  <TH ALIGN=\"right\">Description:</TH>\n";
+    print "  <TD><TEXTAREA ROWS=4 COLS=64 WRAP=VIRTUAL NAME=\"description\">$description</TEXTAREA></TD>\n";
+    print "</TR>\n";
+
+}
+
+
+sub Validate ($$) {
+    my ($name, $description) = @_;
+    if ($name eq "") {
+        print "You must enter a non-blank name for the keyword. Please press\n";
+        print "<b>Back</b> and try again.\n";
+        PutTrailer($localtrailer);
+        exit;
+    }
+    if ($name =~ /,/) {
+        print "You may not use commas in a keyword name.\n";
+        print "Please press <b>Back</b> and try again.\n";
+        PutTrailer($localtrailer);
+        exit;
+    }    
+    if ($description eq "") {
+        print "You must enter a non-blank description of the keyword.\n";
+        print "Please press <b>Back</b> and try again.\n";
+        PutTrailer($localtrailer);
+        exit;
+    }
+}
+
+
+#
+# Preliminary checks:
+#
+
+confirm_login();
+
+print "Content-type: text/html\n\n";
+
+unless (UserInGroup("editkeywords")) {
+    PutHeader("Not allowed");
+    print "Sorry, you aren't a member of the 'editkeywords' group.\n";
+    print "And so, you aren't allowed to add, modify or delete keywords.\n";
+    PutTrailer();
+    exit;
+}
+
+
+my $action  = trim($::FORM{action}  || '');
+
+
+if ($action eq "") {
+    PutHeader("Select keyword");
+    print qq{
+<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0>
+<TR BGCOLOR="#6666FF">
+<TH ALIGN="left">Edit keyword ...</TH>
+<TH ALIGN="left">Description</TH>
+<TH ALIGN="left">Bugs</TH>
+<TH ALIGN="left">Action</TH>
+</TR>
+};
+    SendSQL("SELECT keyworddefs.id, keyworddefs.name, keyworddefs.description,
+                    COUNT(keywords.bug_id)
+             FROM keyworddefs LEFT JOIN keywords ON keyworddefs.id = keywords.keywordid
+             GROUP BY keyworddefs.id
+             ORDER BY keyworddefs.name");
+    while (MoreSQLData()) {
+        my ($id, $name, $description, $bugs) = FetchSQLData();
+        $description ||= "<FONT COLOR=\"red\">missing</FONT>";
+        $bugs ||= 'none';
+        print qq{
+<TR>
+<TH VALIGN="top"><A HREF="editkeywords.cgi?action=edit&id=$id">$name</TH>
+<TD VALIGN="top">$description</TD>
+<TD VALIGN="top" ALIGN="right">$bugs</TD>
+<TH VALIGN="top"><A HREF="editkeywords.cgi?action=delete&id=$id">Delete</TH>
+</TR>
+};
+    }
+    print qq{
+<TR>
+<TD VALIGN="top" COLSPAN=3>Add a new keyword</TD><TD><A HREF="editkeywords.cgi?action=add">Add</TD>
+</TR>
+</TABLE>
+};
+    PutTrailer();
+    exit;
+}
+    
+
+if ($action eq 'add') {
+    PutHeader("Add keyword");
+    print "<FORM METHOD=POST ACTION=editkeywords.cgi>\n";
+    print "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0>\n";
+
+    EmitFormElements(-1, '', '');
+
+    print "</TABLE>\n<HR>\n";
+    print "<INPUT TYPE=SUBMIT VALUE=\"Add\">\n";
+    print "<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"new\">\n";
+    print "</FORM>";
+
+    my $other = $localtrailer;
+    $other =~ s/more/other/;
+    PutTrailer($other);
+    exit;
+}
+
+#
+# action='new' -> add keyword entered in the 'action=add' screen
+#
+
+if ($action eq 'new') {
+    PutHeader("Adding new keyword");
+
+    # Cleanups and valididy checks
+
+    my $name = trim($::FORM{name} || '');
+    my $description  = trim($::FORM{description}  || '');
+
+    Validate($name, $description);
+    
+    SendSQL("SELECT id FROM keyworddefs WHERE name = " . SqlQuote($name));
+
+    if (FetchOneColumn()) {
+        print "The keyword '$name' already exists. Please press\n";
+        print "<b>Back</b> and try again.\n";
+        PutTrailer($localtrailer);
+        exit;
+    }
+
+
+    # Pick an unused number.  Be sure to recycle numbers that may have been
+    # deleted in the past.  This code is potentially slow, but it happens
+    # rarely enough, and there really aren't ever going to be that many
+    # keywords anyway.
+
+    SendSQL("SELECT id FROM keyworddefs ORDER BY id");
+
+    my $newid = 1;
+
+    while (MoreSQLData()) {
+        my $oldid = FetchOneColumn();
+        if ($oldid > $newid) {
+            last;
+        }
+        $newid = $oldid + 1;
+    }
+
+    # Add the new keyword.
+    SendSQL("INSERT INTO keyworddefs (id, name, description) VALUES ($newid, " .
+            SqlQuote($name) . "," .
+            SqlQuote($description) . ")");
+
+    # Make versioncache flush
+    unlink "data/versioncache";
+
+    print "OK, done.<p>\n";
+    PutTrailer($localtrailer);
+    exit;
+}
+
+    
+
+#
+# action='edit' -> present the edit keywords from
+#
+# (next action would be 'update')
+#
+
+if ($action eq 'edit') {
+    PutHeader("Edit keyword");
+
+    my $id  = trim($::FORM{id} || 0);
+    # get data of keyword
+    SendSQL("SELECT name,description
+             FROM keyworddefs
+             WHERE id=$id");
+    my ($name, $description) = FetchSQLData();
+    if (!$name) {
+        print "Something screwy is going on.  Please try again.\n";
+        PutTrailer($localtrailer);
+        exit;
+    }
+    print "<FORM METHOD=POST ACTION=editkeywords.cgi>\n";
+    print "<TABLE  BORDER=0 CELLPADDING=4 CELLSPACING=0>\n";
+
+    EmitFormElements($id, $name, $description);
+    
+    print "<TR>\n";
+    print "  <TH ALIGN=\"right\">Bugs:</TH>\n";
+    print "  <TD>";
+    SendSQL("SELECT count(*)
+             FROM keywords
+             WHERE keywordid = $id");
+    my $bugs = '';
+    $bugs = FetchOneColumn() if MoreSQLData();
+    print $bugs || 'none';
+
+    print "</TD>\n</TR></TABLE>\n";
+
+    print "<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"update\">\n";
+    print "<INPUT TYPE=SUBMIT VALUE=\"Update\">\n";
+
+    print "</FORM>";
+
+    my $x = $localtrailer;
+    $x =~ s/more/other/;
+    PutTrailer($x);
+    exit;
+}
+
+
+#
+# action='update' -> update the keyword
+#
+
+if ($action eq 'update') {
+    PutHeader("Update keyword");
+
+    my $id = $::FORM{id};
+    my $name  = trim($::FORM{name} || '');
+    my $description  = trim($::FORM{description}  || '');
+
+    Validate($name, $description);
+
+    SendSQL("SELECT id FROM keyworddefs WHERE name = " . SqlQuote($name));
+
+    my $tmp = FetchOneColumn();
+
+    if ($tmp && $tmp != $id) {
+        print "The keyword '$name' already exists. Please press\n";
+        print "<b>Back</b> and try again.\n";
+        PutTrailer($localtrailer);
+        exit;
+    }
+
+    SendSQL("UPDATE keyworddefs SET name = " . SqlQuote($name) .
+            ", description = " . SqlQuote($description) .
+            " WHERE id = $id");
+
+    print "Keyword updated.<BR>\n";
+
+    # Make versioncache flush
+    unlink "data/versioncache";
+
+    PutTrailer($localtrailer);
+    exit;
+}
+
+
+if ($action eq 'delete') {
+    PutHeader("Delete keyword");
+    my $id = $::FORM{id};
+
+    SendSQL("SELECT name FROM keyworddefs WHERE id=$id");
+    my $name = FetchOneColumn();
+
+    if (!$::FORM{reallydelete}) {
+
+        SendSQL("SELECT count(*)
+                 FROM keywords
+                 WHERE keywordid = $id");
+        
+        my $bugs = FetchOneColumn();
+        
+        if ($bugs) {
+            
+            
+            print qq{
+There are $bugs bugs which have this keyword set.  Are you <b>sure</b> you want
+to delete the <code>$name</code> keyword?
+
+<FORM METHOD=POST ACTION=editkeywords.cgi>
+<INPUT TYPE=HIDDEN NAME="id" VALUE="$id">
+<INPUT TYPE=HIDDEN NAME="action" VALUE="delete">
+<INPUT TYPE=HIDDEN NAME="reallydelete" VALUE="1">
+<INPUT TYPE=SUBMIT VALUE="Yes, really delete the keyword">
+</FORM>
+};
+
+            PutTrailer($localtrailer);
+            exit;
+        }
+    }
+
+    SendSQL("DELETE FROM keywords WHERE keywordid = $id");
+    SendSQL("DELETE FROM keyworddefs WHERE id = $id");
+
+    print "Keyword $name deleted.\n";
+
+    # Make versioncache flush
+    unlink "data/versioncache";
+
+    PutTrailer($localtrailer);
+    exit;
+}
+
+PutHeader("Error");
+print "I don't have a clue what you want.<BR>\n";
+
+foreach ( sort keys %::FORM) {
+    print "$_: $::FORM{$_}<BR>\n";
+}
index e6f426af820109b5139307325d4223dc4fe6ef81..63998f8591901bf5149c05eaa6191f506e79523a 100644 (file)
@@ -336,6 +336,18 @@ sub GenerateVersionTable {
         print FID GenerateCode('@::legal_target_milestone');
         print FID GenerateCode('%::milestoneurl');
     }
+
+    SendSQL("SELECT id, name FROM keyworddefs ORDER BY name");
+    while (MoreSQLData()) {
+        my ($id, $name) = FetchSQLData();
+        $::keywordsbyid{$id} = $name;
+        $::keywordsbyname{$name} = $id;
+        push(@::legal_keywords, $name);
+    }
+    print FID GenerateCode('@::legal_keywords');
+    print FID GenerateCode('%::keywordsbyname');
+    print FID GenerateCode('%::keywordsbyid');
+
     print FID "1;\n";
     close FID;
     rename $tmpname, "data/versioncache" || die "Can't rename $tmpname to versioncache";
index 858f04319f927a00db94e436d1dc31ef1359aacc..3919dadb097f52e85395c107527bab9e513ed23b 100755 (executable)
@@ -30,7 +30,13 @@ require "CGI.pl";
 
 use vars %::versions,
     %::components,
-    %::COOKIE;
+    %::COOKIE,
+    %::keywordsbyname,
+    %::legal_keywords,
+    %::legal_opsys,
+    %::legal_platform,
+    %::legal_priority,
+    %::legal_severity;
 
 confirm_login();
 
@@ -351,6 +357,28 @@ if ($#idlist < 0) {
     exit;
 }
 
+
+my @keywordlist;
+my %keywordseen;
+
+if ($::FORM{'keywords'}) {
+    foreach my $keyword (split(/,/, $::FORM{'keywords'})) {
+        $keyword = trim($keyword);
+        my $i = $::keywordsbyname{$keyword};
+        if (!$i) {
+            print "Unknown keyword named <code>$keyword</code>.\n";
+            print "<P>The legal keyword names are <A HREF=describekeywords.cgi>";
+            print "listed here</A>.\n";
+            print "<P>Please click the <B>Back</B> button and try again.\n";
+            exit;
+        }
+        if (!$keywordseen{$i}) {
+            push(@keywordlist, $i);
+            $keywordseen{$i} = 1;
+        }
+    }
+}
+
 if ($::comma eq "") {
     if (!defined $::FORM{'comment'} || $::FORM{'comment'} =~ /^\s*$/) {
         print "Um, you apparently did not change anything on the selected\n";
@@ -385,6 +413,23 @@ sub SnapShotDeps {
 }
 
 
+sub SnapShotKeywords {
+    my ($id) = (@_);
+    SendSQL("SELECT keyworddefs.name 
+             FROM keyworddefs, keywords
+             WHERE keywords.bug_id = $id AND keyworddefs.id = keywords.keywordid
+             ORDER BY keyworddefs.name");
+    my @list;
+    while (MoreSQLData()) {
+        push(@list, FetchOneColumn());
+    }
+    return join(',', @list);
+}
+    
+
+my $keywordaction = $::FORM{'keywordaction'} || "makeexact";
+
+
 my $whoid = DBNameToIdAndCheck($::FORM{'who'});
 my $timestamp;
 
@@ -399,13 +444,14 @@ sub LogDependencyActivity {
 }
 
 # this loop iterates once for each bug to be processed (eg when this script
-# is called by  with multiple bugs selected from buglist.cgi instead of
+# is called with multiple bugs selected from buglist.cgi instead of
 # show_bug.cgi).
 #
 foreach my $id (@idlist) {
     my %dependencychanged;
-    SendSQL("lock tables bugs write, bugs_activity write, cc write, profiles write, dependencies write, votes write");
+    SendSQL("lock tables bugs write, bugs_activity write, cc write, profiles write, dependencies write, votes write, keywords write, keyworddefs read");
     my @oldvalues = SnapShotBug($id);
+    my $oldkeywords = SnapShotKeywords($id);
 
     if (defined $::FORM{'delta_ts'} && $::FORM{'delta_ts'} ne $delta_ts) {
         print "
@@ -494,6 +540,27 @@ The changes made were:
         }
     }
 
+    if (@::legal_keywords) {
+        # There are three kinds of "keywordsaction": makeexact, add, delete.
+        # For makeexact, we delete everything, and then add our things.
+        # For add, we delete things we're adding (to make sure we don't
+        # end up having them twice), and then we add them.
+        # For delete, we just delete things on the list.
+        if ($keywordaction eq "makeexact") {
+            SendSQL("DELETE FROM keywords WHERE bug_id = $id");
+        }
+        foreach my $keyword (@keywordlist) {
+            if ($keywordaction ne "makeexact") {
+                SendSQL("DELETE FROM keywords
+                         WHERE bug_id = $id AND keywordid = $keyword");
+            }
+            if ($keywordaction ne "delete") {
+                SendSQL("INSERT INTO keywords 
+                         (bug_id, keywordid) VALUES ($id, $keyword)");
+            }
+        }
+    }
+
     my $query = "$basequery\nwhere bug_id = $id";
     
 # print "<PRE>$query</PRE>\n";
@@ -582,7 +649,12 @@ The changes made were:
     # what has changed since before we wrote out the new values.
     #
     my @newvalues = SnapShotBug($id);
-    foreach my $col (@::log_columns) {
+
+    push(@oldvalues, $oldkeywords);
+    push(@newvalues, SnapShotKeywords($id));
+    foreach my $c (@::log_columns, "keywords") {
+        my $col = $c;           # We modify it, don't want to modify array
+                                # values in place.
         my $old = shift @oldvalues;
         my $new = shift @newvalues;
         if (!defined $old) {
index 5cb40f147f6b432980de06acea50e218af0e5d75..a0ae1f0b32c9f4721b34332423cd6b1985323f4b 100755 (executable)
--- a/query.cgi
+++ b/query.cgi
@@ -77,7 +77,7 @@ foreach my $name ("bug_status", "resolution", "assigned_to", "rep_platform",
                   "changedin", "votes", "short_desc", "short_desc_type",
                   "long_desc", "long_desc_type", "bug_file_loc",
                   "bug_file_loc_type", "status_whiteboard",
-                  "status_whiteboard_type") {
+                  "status_whiteboard_type", "keywords") {
     $default{$name} = "";
     $type{$name} = 0;
 }
@@ -367,17 +367,20 @@ print $jscript;
 
 my @logfields = ("[Bug creation]", @::log_columns);
 
-print "
-<FORM METHOD=GET ACTION=\"buglist.cgi\">
+print qq{
+<FORM METHOD=GET ACTION="buglist.cgi">
 
 <table>
 <tr>
-<th align=left><A HREF=\"bug_status.html\">Status</a>:</th>
-<th align=left><A HREF=\"bug_status.html\">Resolution</a>:</th>
-<th align=left><A HREF=\"bug_status.html#rep_platform\">Platform</a>:</th>
-<th align=left><A HREF=\"bug_status.html#op_sys\">OpSys</a>:</th>
-<th align=left><A HREF=\"bug_status.html#priority\">Priority</a>:</th>
-<th align=left><A HREF=\"bug_status.html#severity\">Severity</a>:</th>
+<th align=left><A HREF="bug_status.html">Status</a>:</th>
+<th align=left><A HREF="bug_status.html">Resolution</a>:</th>
+<th align=left><A HREF="bug_status.html#rep_platform">Platform</a>:</th>
+<th align=left><A HREF="bug_status.html#op_sys">OpSys</a>:</th>
+<th align=left><A HREF="bug_status.html#priority">Priority</a>:</th>
+<th align=left><A HREF="bug_status.html#severity">Severity</a>:</th>
+};
+
+print "
 </tr>
 <tr>
 <td align=left valign=top>
@@ -538,6 +541,25 @@ if (Param("usestatuswhiteboard")) {
     StringSearch("Status whiteboard", "status_whiteboard");
 }
 
+if (@::legal_keywords) {
+    my $def = value_quote($default{'keywords'});
+    print qq{
+<TR>
+<TD ALIGN="right"><A HREF="describekeywords.cgi">Keywords</A>:</TD>
+<TD><INPUT NAME="keywords" SIZE=30 VALUE=$def></TD>
+<TD><SELECT NAME=keywords_type>
+};
+    foreach my $i (["or", "Any of the listed keywords set"]) {
+                my ($n, $d) = (@$i);
+        my $sel = "";
+        if ($default{"keywords"} eq $n) {
+            $sel = " SELECTED";
+        }
+        print qq{<OPTION VALUE="$n"$sel>$d\n};
+    }
+    print qq{</SELECT></TD></TR>};
+}
+
 print "
 </table>
 <p>
@@ -591,6 +613,9 @@ if (UserInGroup("tweakparams")) {
 if (UserInGroup("editcomponents")) {
     print "<a href=editproducts.cgi>Edit Bugzilla products and components</a><br>\n";
 }
+if (UserInGroup("editkeywords")) {
+    print "<a href=editkeywords.cgi>Edit Bugzilla keywords</a><br>\n";
+}
 if (defined $::COOKIE{"Bugzilla_login"}) {
     print "<a href=relogin.cgi>Log in as someone besides <b>$::COOKIE{'Bugzilla_login'}</b></a><br>\n";
 }