Commit da6143f4 authored by myk%mozilla.org's avatar myk%mozilla.org

Fix for bug 204631: enhances config.cgi to generate a list of queryable fields…

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
parent 9da012f1
......@@ -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");
......
......@@ -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) = @_;
......
......@@ -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
......
......@@ -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!
......
......@@ -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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment