2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / BugsSite / config.cgi
blobf1bc5f0f1cfd157690e21027704189910fa6b9b9
1 #!/usr/bin/perl -wT
2 # -*- Mode: perl; indent-tabs-mode: nil -*-
4 # The contents of this file are subject to the Mozilla Public
5 # License Version 1.1 (the "License"); you may not use this file
6 # except in compliance with the License. You may obtain a copy of
7 # the License at http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS
10 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11 # implied. See the License for the specific language governing
12 # rights and limitations under the License.
14 # The Original Code is the Bugzilla Bug Tracking System.
16 # The Initial Developer of the Original Code is Netscape Communications
17 # Corporation. Portions created by Netscape are
18 # Copyright (C) 1998 Netscape Communications Corporation. All
19 # Rights Reserved.
21 # Contributor(s): Terry Weissman <terry@mozilla.org>
22 # Myk Melez <myk@mozilla.org>
24 ################################################################################
25 # Script Initialization
26 ################################################################################
28 # Make it harder for us to do dangerous things in Perl.
29 use strict;
31 # Include the Bugzilla CGI and general utility library.
32 use lib qw(.);
33 require "CGI.pl";
34 use Bugzilla;
35 use Bugzilla::Constants;
37 # Suppress "used only once" warnings.
38 use vars
39 qw(
40 @legal_priority
41 @legal_severity
42 @legal_platform
43 @legal_opsys
44 @legal_resolution
46 @legal_components
47 @legal_target_milestone
48 @legal_versions
49 @legal_keywords
52 # Use the global template variables defined in globals.pl
53 # to generate the output.
54 use vars qw($template $vars);
56 Bugzilla->login(LOGIN_OPTIONAL);
58 # If the 'requirelogin' parameter is on and the user is not
59 # authenticated, return empty fields.
60 if (Param('requirelogin') && !Bugzilla->user->id) {
61 display_data();
64 # Retrieve this installation's configuration.
65 GetVersionTable();
67 # Pass a bunch of Bugzilla configuration to the templates.
68 $vars->{'priority'} = \@::legal_priority;
69 $vars->{'severity'} = \@::legal_severity;
70 $vars->{'platform'} = \@::legal_platform;
71 $vars->{'op_sys'} = \@::legal_opsys;
72 $vars->{'keyword'} = \@::legal_keywords;
73 $vars->{'resolution'} = \@::legal_resolution;
74 $vars->{'status'} = \@::legal_bug_status;
76 # Include lists of products, components, versions, and target milestones.
77 my $selectables = GetSelectableProductHash();
78 foreach my $selectable (keys %$selectables) {
79 $vars->{$selectable} = $selectables->{$selectable};
82 # Create separate lists of open versus resolved statuses. This should really
83 # be made part of the configuration.
84 my @open_status;
85 my @closed_status;
86 foreach my $status (@::legal_bug_status) {
87 IsOpenedState($status) ? push(@open_status, $status)
88 : push(@closed_status, $status);
90 $vars->{'open_status'} = \@open_status;
91 $vars->{'closed_status'} = \@closed_status;
93 # Generate a list of fields that can be queried.
94 $vars->{'field'} = [Bugzilla->dbh->bz_get_field_defs()];
96 display_data($vars);
99 sub display_data {
100 my $vars = shift;
102 my $cgi = Bugzilla->cgi;
103 # Determine how the user would like to receive the output;
104 # default is JavaScript.
105 my $format = GetFormat("config", scalar($cgi->param('format')),
106 scalar($cgi->param('ctype')) || "js");
108 # Return HTTP headers.
109 print "Content-Type: $format->{'ctype'}\n\n";
111 # Generate the configuration file and return it to the user.
112 $template->process($format->{'template'}, $vars)
113 || ThrowTemplateError($template->error());
114 exit;