summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormyk%mozilla.org <>2003-06-24 03:01:35 +0200
committermyk%mozilla.org <>2003-06-24 03:01:35 +0200
commitda6143f4aae6af35f60b8230b82f649b3b0cbd05 (patch)
tree0836c9c54e5434471a77eaa00c4447da3e60804a
parent9da012f1026019ade284e4d08c63f9d39993777f (diff)
downloadbugzilla-da6143f4aae6af35f60b8230b82f649b3b0cbd05.tar.gz
bugzilla-da6143f4aae6af35f60b8230b82f649b3b0cbd05.tar.xz
Fix for bug 204631: enhances config.cgi to generate a list of queryable fields so third-party clients can populate search forms with the list.
r=gerv a=myk
-rwxr-xr-xconfig.cgi3
-rw-r--r--globals.pl20
-rwxr-xr-xquery.cgi14
-rw-r--r--template/en/default/config.js.tmpl12
-rw-r--r--template/en/default/config.rdf.tmpl13
5 files changed, 48 insertions, 14 deletions
diff --git a/config.cgi b/config.cgi
index d1ad3cdc9..a02ff8c7b 100755
--- a/config.cgi
+++ b/config.cgi
@@ -87,6 +87,9 @@ foreach my $status (@::legal_bug_status) {
$vars->{'open_status'} = \@open_status;
$vars->{'closed_status'} = \@closed_status;
+# Generate a list of fields that can be queried.
+$vars->{'field'} = [GetFieldDefs()];
+
# Determine how the user would like to receive the output;
# default is JavaScript.
my $format = GetFormat("config", $::FORM{'format'}, $::FORM{'ctype'} || "js");
diff --git a/globals.pl b/globals.pl
index 9c36e9003..d8d11be53 100644
--- a/globals.pl
+++ b/globals.pl
@@ -627,6 +627,26 @@ sub GetSelectableProductHash {
}
+sub GetFieldDefs {
+ my $extra = "";
+ if (!UserInGroup(Param('timetrackinggroup'))) {
+ $extra = "WHERE name NOT IN ('estimated time', 'remaining_time', " .
+ "'work_time', 'percentage_complete')";
+ }
+
+ my @fields;
+ PushGlobalSQLState();
+ SendSQL("SELECT name, description FROM fielddefs $extra ORDER BY sortkey");
+ while (MoreSQLData()) {
+ my ($name, $description) = FetchSQLData();
+ push(@fields, { name => $name, description => $description });
+ }
+ PopGlobalSQLState();
+
+ return(@fields);
+}
+
+
sub CanSeeBug {
my ($id, $userid) = @_;
diff --git a/query.cgi b/query.cgi
index e450898da..2a8051b6b 100755
--- a/query.cgi
+++ b/query.cgi
@@ -314,19 +314,7 @@ $vars->{'bug_severity'} = \@::legal_severity;
# Boolean charts
my @fields;
push(@fields, { name => "noop", description => "---" });
-SendSQL("SELECT name, description FROM fielddefs ORDER BY sortkey");
-while (MoreSQLData()) {
- my ($name, $description) = FetchSQLData();
- if (($name eq "estimated_time" ||
- $name eq "remaining_time" ||
- $name eq "work_time" ||
- $name eq "percentage_complete" ) &&
- (!UserInGroup(Param('timetrackinggroup')))) {
- next;
- }
- push(@fields, { name => $name, description => $description });
-}
-
+push(@fields, GetFieldDefs());
$vars->{'fields'} = \@fields;
# Creating new charts - if the cmd-add value is there, we define the field
diff --git a/template/en/default/config.js.tmpl b/template/en/default/config.js.tmpl
index 26d089fd6..a74c5d34d 100644
--- a/template/en/default/config.js.tmpl
+++ b/template/en/default/config.js.tmpl
@@ -101,8 +101,18 @@ var component_exceptions = new Array(
// // ^^^^
);
+// Queryable Fields
+// ================
+[% PROCESS "global/field-descs.none.tmpl" %]
+var field = [
+[% FOREACH x = field %]
+ { name: '[% x.name FILTER js %]',
+ description: '[% (field_descs.${x.name} OR x.description) FILTER js %]' },
+[% END %]
+];
+
// Deprecated Variables
-// ================================
+// ====================
//
// Other names for various variables. These are deprecated
// and could go away at any time. Use them at your own risk!
diff --git a/template/en/default/config.rdf.tmpl b/template/en/default/config.rdf.tmpl
index 6aa51f657..884c26a0c 100644
--- a/template/en/default/config.rdf.tmpl
+++ b/template/en/default/config.rdf.tmpl
@@ -180,6 +180,19 @@
</bz:target_milestones>
[% END %]
+ <bz:fields>
+ <Seq>
+ [% PROCESS "global/field-descs.none.tmpl" %]
+ [% FOREACH item = field %]
+ <li>
+ <bz:field rdf:about="[% Param('urlbase') %]field.cgi?name=[% item.name FILTER uri %]">
+ <bz:name>[% item.name FILTER html %]</bz:name>
+ <bz:description>[% (field_descs.${item.name} OR item.description) FILTER html %]</bz:description>
+ </bz:field>
+ </li>
+ [% END %]
+ </Seq>
+ </bz:fields>
</bz:installation>
</RDF>