2003-03-27 00:07:02 +00:00
|
|
|
#!/usr/bin/perl -wT
|
1998-09-15 21:49:26 +00:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
1998-08-26 06:14:20 +00:00
|
|
|
#
|
1999-11-01 23:33:56 +00:00
|
|
|
# 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.
|
|
|
|
#
|
1998-08-26 06:14:20 +00:00
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
1999-11-01 23:33:56 +00:00
|
|
|
#
|
1998-08-26 06:14:20 +00:00
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
1999-11-01 23:33:56 +00:00
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
1998-08-26 06:14:20 +00:00
|
|
|
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
1999-03-19 21:40:14 +00:00
|
|
|
# David Gardiner <david.gardiner@unisa.edu.au>
|
2000-11-20 19:42:36 +00:00
|
|
|
# Matthias Radestock <matthias@sorted.org>
|
2001-11-18 22:23:31 +00:00
|
|
|
# Gervase Markham <gerv@gerv.net>
|
2004-07-07 06:02:33 +00:00
|
|
|
# Byron Jones <bugzilla@glob.com.au>
|
1998-08-26 06:14:20 +00:00
|
|
|
|
1998-09-15 21:49:26 +00:00
|
|
|
use strict;
|
2001-11-18 22:23:31 +00:00
|
|
|
use lib ".";
|
1998-08-26 06:14:20 +00:00
|
|
|
|
1998-09-15 21:49:26 +00:00
|
|
|
require "CGI.pl";
|
1998-08-26 06:14:20 +00:00
|
|
|
|
2004-03-27 03:51:44 +00:00
|
|
|
use Bugzilla::Constants;
|
|
|
|
|
2002-02-13 02:27:24 +00:00
|
|
|
use vars qw(
|
|
|
|
@CheckOptionValues
|
|
|
|
@legal_resolution
|
|
|
|
@legal_bug_status
|
|
|
|
@legal_components
|
|
|
|
@legal_keywords
|
|
|
|
@legal_opsys
|
|
|
|
@legal_platform
|
|
|
|
@legal_priority
|
|
|
|
@legal_product
|
|
|
|
@legal_severity
|
|
|
|
@legal_target_milestone
|
|
|
|
@legal_versions
|
|
|
|
@log_columns
|
|
|
|
%versions
|
|
|
|
%components
|
|
|
|
%FORM
|
|
|
|
$template
|
|
|
|
$vars
|
|
|
|
);
|
1998-09-15 21:49:26 +00:00
|
|
|
|
2003-05-05 01:15:38 +00:00
|
|
|
my $cgi = Bugzilla->cgi;
|
|
|
|
|
1998-09-15 21:49:26 +00:00
|
|
|
if (defined $::FORM{"GoAheadAndLogIn"}) {
|
1998-08-26 06:14:20 +00:00
|
|
|
# We got here from a login page, probably from relogin.cgi. We better
|
|
|
|
# make sure the password is legit.
|
2004-03-27 03:51:44 +00:00
|
|
|
Bugzilla->login(LOGIN_REQUIRED);
|
2000-01-23 20:31:50 +00:00
|
|
|
} else {
|
2004-03-27 03:51:44 +00:00
|
|
|
Bugzilla->login();
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
1998-08-26 06:14:20 +00:00
|
|
|
|
2004-07-31 02:27:26 +00:00
|
|
|
my $userid = Bugzilla->user->id;
|
2003-06-03 09:48:15 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# Backwards compatibility hack -- if there are any of the old QUERY_*
|
2000-01-23 20:31:50 +00:00
|
|
|
# cookies around, and we are logged in, then move them into the database
|
2001-11-18 22:23:31 +00:00
|
|
|
# and nuke the cookie. This is required for Bugzilla 2.8 and earlier.
|
2004-07-31 02:27:26 +00:00
|
|
|
if ($userid) {
|
2000-01-23 20:31:50 +00:00
|
|
|
my @oldquerycookies;
|
2004-07-21 21:17:05 +00:00
|
|
|
foreach my $i ($cgi->cookie()) {
|
2000-01-23 20:31:50 +00:00
|
|
|
if ($i =~ /^QUERY_(.*)$/) {
|
2004-07-21 21:17:05 +00:00
|
|
|
push(@oldquerycookies, [$1, $i, $cgi->cookie($i)]);
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
|
|
|
}
|
2004-07-21 21:17:05 +00:00
|
|
|
if (defined $cgi->cookie('DEFAULTQUERY')) {
|
2000-01-23 20:31:50 +00:00
|
|
|
push(@oldquerycookies, [$::defaultqueryname, 'DEFAULTQUERY',
|
2004-07-21 21:17:05 +00:00
|
|
|
$cgi->cookie('DEFAULTQUERY')]);
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
|
|
|
if (@oldquerycookies) {
|
|
|
|
foreach my $ref (@oldquerycookies) {
|
|
|
|
my ($name, $cookiename, $value) = (@$ref);
|
|
|
|
if ($value) {
|
|
|
|
my $qname = SqlQuote($name);
|
2004-07-08 02:19:42 +00:00
|
|
|
SendSQL("LOCK TABLES namedqueries WRITE");
|
2000-01-23 20:31:50 +00:00
|
|
|
SendSQL("SELECT query FROM namedqueries " .
|
2002-09-22 17:15:13 +00:00
|
|
|
"WHERE userid = $userid AND name = $qname");
|
2000-01-23 20:31:50 +00:00
|
|
|
my $query = FetchOneColumn();
|
|
|
|
if (!$query) {
|
2004-07-08 02:19:42 +00:00
|
|
|
SendSQL("INSERT INTO namedqueries " .
|
2000-01-23 20:31:50 +00:00
|
|
|
"(userid, name, query) VALUES " .
|
2002-09-22 17:15:13 +00:00
|
|
|
"($userid, $qname, " . SqlQuote($value) . ")");
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
2004-07-08 02:19:42 +00:00
|
|
|
SendSQL("UNLOCK TABLES");
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
2003-05-05 01:15:38 +00:00
|
|
|
$cgi->send_cookie(-name => $cookiename,
|
|
|
|
-expires => "Fri, 01-Jan-2038 00:00:00 GMT");
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-23 17:14:09 +00:00
|
|
|
}
|
1998-08-26 06:14:20 +00:00
|
|
|
|
2000-01-23 20:31:50 +00:00
|
|
|
if ($::FORM{'nukedefaultquery'}) {
|
2004-07-31 02:27:26 +00:00
|
|
|
if ($userid) {
|
2000-01-23 20:31:50 +00:00
|
|
|
SendSQL("DELETE FROM namedqueries " .
|
2002-09-22 17:15:13 +00:00
|
|
|
"WHERE userid = $userid AND name = '$::defaultqueryname'");
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
|
|
|
$::buffer = "";
|
1998-08-26 06:14:20 +00:00
|
|
|
}
|
|
|
|
|
2000-01-23 20:31:50 +00:00
|
|
|
my $userdefaultquery;
|
2004-07-31 02:27:26 +00:00
|
|
|
if ($userid) {
|
2000-01-23 20:31:50 +00:00
|
|
|
SendSQL("SELECT query FROM namedqueries " .
|
2002-09-22 17:15:13 +00:00
|
|
|
"WHERE userid = $userid AND name = '$::defaultqueryname'");
|
2000-01-23 20:31:50 +00:00
|
|
|
$userdefaultquery = FetchOneColumn();
|
1998-08-26 06:14:20 +00:00
|
|
|
}
|
|
|
|
|
2000-01-23 20:31:50 +00:00
|
|
|
my %default;
|
1998-09-15 21:49:26 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# We pass the defaults as a hash of references to arrays. For those
|
|
|
|
# Items which are single-valued, the template should only reference [0]
|
|
|
|
# and ignore any multiple values.
|
|
|
|
sub PrefillForm {
|
2000-01-23 20:31:50 +00:00
|
|
|
my ($buf) = (@_);
|
|
|
|
my $foundone = 0;
|
2001-11-18 22:23:31 +00:00
|
|
|
|
|
|
|
# Nothing must be undef, otherwise the template complains.
|
2000-01-23 20:31:50 +00:00
|
|
|
foreach my $name ("bug_status", "resolution", "assigned_to",
|
|
|
|
"rep_platform", "priority", "bug_severity",
|
2004-08-20 21:49:20 +00:00
|
|
|
"classification", "product", "reporter", "op_sys",
|
2000-01-23 20:31:50 +00:00
|
|
|
"component", "version", "chfield", "chfieldfrom",
|
2001-04-10 03:49:01 +00:00
|
|
|
"chfieldto", "chfieldvalue", "target_milestone",
|
2001-11-18 22:23:31 +00:00
|
|
|
"email", "emailtype", "emailreporter",
|
|
|
|
"emailassigned_to", "emailcc", "emailqa_contact",
|
2003-09-03 02:03:48 +00:00
|
|
|
"emaillongdesc", "content",
|
2000-01-23 20:31:50 +00:00
|
|
|
"changedin", "votes", "short_desc", "short_desc_type",
|
|
|
|
"long_desc", "long_desc_type", "bug_file_loc",
|
|
|
|
"bug_file_loc_type", "status_whiteboard",
|
2000-01-26 21:48:36 +00:00
|
|
|
"status_whiteboard_type", "bug_id",
|
2002-09-25 07:11:45 +00:00
|
|
|
"bugidtype", "keywords", "keywords_type",
|
2002-10-29 07:44:18 +00:00
|
|
|
"x_axis_field", "y_axis_field", "z_axis_field",
|
2003-06-25 23:23:13 +00:00
|
|
|
"chart_format", "cumulate", "x_labels_vertical",
|
|
|
|
"category", "subcategory", "name", "newcategory",
|
|
|
|
"newsubcategory", "public", "frequency")
|
2002-09-25 07:11:45 +00:00
|
|
|
{
|
2001-11-18 22:23:31 +00:00
|
|
|
# This is a bit of a hack. The default, empty list has
|
|
|
|
# three entries to accommodate the needs of the email fields -
|
|
|
|
# we use each position to denote the relevant field. Array
|
|
|
|
# position 0 is unused for email fields because the form
|
|
|
|
# parameters historically started at 1.
|
|
|
|
$default{$name} = ["", "", ""];
|
1998-09-15 21:49:26 +00:00
|
|
|
}
|
2001-11-18 22:23:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Iterate over the URL parameters
|
2000-01-23 20:31:50 +00:00
|
|
|
foreach my $item (split(/\&/, $buf)) {
|
|
|
|
my @el = split(/=/, $item);
|
|
|
|
my $name = $el[0];
|
|
|
|
my $value;
|
|
|
|
if ($#el > 0) {
|
|
|
|
$value = url_decode($el[1]);
|
1998-08-26 06:14:20 +00:00
|
|
|
} else {
|
2000-01-23 20:31:50 +00:00
|
|
|
$value = "";
|
|
|
|
}
|
2001-11-18 22:23:31 +00:00
|
|
|
|
|
|
|
# If the name ends in a number (which it does for the fields which
|
|
|
|
# are part of the email searching), we use the array
|
|
|
|
# positions to show the defaults for that number field.
|
|
|
|
if ($name =~ m/^(.+)(\d)$/ && defined($default{$1})) {
|
2000-01-23 20:31:50 +00:00
|
|
|
$foundone = 1;
|
2001-11-18 22:23:31 +00:00
|
|
|
$default{$1}->[$2] = $value;
|
1998-08-26 06:14:20 +00:00
|
|
|
}
|
2001-11-18 22:23:31 +00:00
|
|
|
# If there's no default yet, we replace the blank string.
|
|
|
|
elsif (defined($default{$name}) && $default{$name}->[0] eq "") {
|
|
|
|
$foundone = 1;
|
|
|
|
$default{$name} = [$value];
|
|
|
|
}
|
|
|
|
# If there's already a default, we push on the new value.
|
|
|
|
elsif (defined($default{$name})) {
|
|
|
|
push (@{$default{$name}}, $value);
|
|
|
|
}
|
|
|
|
}
|
2000-01-23 20:31:50 +00:00
|
|
|
return $foundone;
|
1998-08-26 06:14:20 +00:00
|
|
|
}
|
1998-09-15 21:49:26 +00:00
|
|
|
|
1999-03-23 22:32:21 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
if (!PrefillForm($::buffer)) {
|
2000-01-23 20:31:50 +00:00
|
|
|
# Ah-hah, there was no form stuff specified. Do it again with the
|
|
|
|
# default query.
|
|
|
|
if ($userdefaultquery) {
|
2001-11-18 22:23:31 +00:00
|
|
|
PrefillForm($userdefaultquery);
|
2000-01-23 20:31:50 +00:00
|
|
|
} else {
|
2001-11-18 22:23:31 +00:00
|
|
|
PrefillForm(Param("defaultquery"));
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
|
|
|
}
|
1999-03-23 22:32:21 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
if ($default{'chfieldto'}->[0] eq "") {
|
|
|
|
$default{'chfieldto'} = ["Now"];
|
1998-08-26 06:14:20 +00:00
|
|
|
}
|
|
|
|
|
1998-09-15 21:49:26 +00:00
|
|
|
GetVersionTable();
|
1999-01-19 00:07:46 +00:00
|
|
|
|
2002-11-24 19:56:34 +00:00
|
|
|
# if using groups for entry, then we don't want people to see products they
|
|
|
|
# don't have access to. Remove them from the list.
|
2000-07-18 15:28:19 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
my @products = ();
|
2000-11-20 19:42:36 +00:00
|
|
|
my %component_set;
|
|
|
|
my %version_set;
|
|
|
|
my %milestone_set;
|
2002-12-10 14:17:05 +00:00
|
|
|
foreach my $p (GetSelectableProducts()) {
|
2001-11-18 22:23:31 +00:00
|
|
|
# We build up boolean hashes in the "-set" hashes for each of these things
|
|
|
|
# before making a list because there may be duplicates names across products.
|
|
|
|
push @products, $p;
|
|
|
|
if ($::components{$p}) {
|
|
|
|
foreach my $c (@{$::components{$p}}) {
|
|
|
|
$component_set{$c} = 1;
|
2001-08-30 22:56:53 +00:00
|
|
|
}
|
|
|
|
}
|
2001-11-18 22:23:31 +00:00
|
|
|
foreach my $v (@{$::versions{$p}}) {
|
|
|
|
$version_set{$v} = 1;
|
1999-03-19 21:40:14 +00:00
|
|
|
}
|
2001-11-18 22:23:31 +00:00
|
|
|
foreach my $m (@{$::target_milestone{$p}}) {
|
|
|
|
$milestone_set{$m} = 1;
|
1999-03-19 21:40:14 +00:00
|
|
|
}
|
2001-08-30 22:56:53 +00:00
|
|
|
}
|
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# @products is now all the products we are ever concerned with, as a list
|
|
|
|
# %x_set is now a unique "list" of the relevant components/versions/tms
|
|
|
|
@products = sort { lc($a) cmp lc($b) } @products;
|
2000-03-21 16:47:06 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# Create the component, version and milestone lists.
|
|
|
|
my @components = ();
|
|
|
|
my @versions = ();
|
|
|
|
my @milestones = ();
|
|
|
|
foreach my $c (@::legal_components) {
|
|
|
|
if ($component_set{$c}) {
|
|
|
|
push @components, $c;
|
2000-03-21 16:47:06 +00:00
|
|
|
}
|
1999-03-19 21:40:14 +00:00
|
|
|
}
|
2001-11-18 22:23:31 +00:00
|
|
|
foreach my $v (@::legal_versions) {
|
|
|
|
if ($version_set{$v}) {
|
|
|
|
push @versions, $v;
|
1999-03-19 21:40:14 +00:00
|
|
|
}
|
2001-08-30 22:56:53 +00:00
|
|
|
}
|
2001-11-18 22:23:31 +00:00
|
|
|
foreach my $m (@::legal_target_milestone) {
|
|
|
|
if ($milestone_set{$m}) {
|
|
|
|
push @milestones, $m;
|
2001-08-30 22:56:53 +00:00
|
|
|
}
|
2001-02-28 23:00:28 +00:00
|
|
|
}
|
|
|
|
|
2002-08-11 07:50:59 +00:00
|
|
|
# Create data structures representing each product.
|
|
|
|
for (my $i = 0; $i < @products; ++$i) {
|
|
|
|
my $p = $products[$i];
|
|
|
|
|
2003-10-31 19:06:59 +00:00
|
|
|
# Bug 190611: band-aid to avoid crashing with no versions defined
|
|
|
|
if (!defined ($::components{$p})) {
|
|
|
|
$::components{$p} = [];
|
|
|
|
}
|
|
|
|
|
2002-08-11 07:50:59 +00:00
|
|
|
# Create hash to hold attributes for each product.
|
|
|
|
my %product = (
|
|
|
|
'name' => $p,
|
|
|
|
'components' => [ sort { lc($a) cmp lc($b) } @{$::components{$p}} ],
|
|
|
|
'versions' => [ sort { lc($a) cmp lc($b) } @{$::versions{$p}} ]
|
|
|
|
);
|
|
|
|
|
|
|
|
if (Param('usetargetmilestone')) {
|
2004-02-12 04:45:17 +00:00
|
|
|
# Sorting here is required for ordering multiple selections
|
|
|
|
# correctly; see bug 97736 for discussion on how to fix this
|
2002-08-11 07:50:59 +00:00
|
|
|
$product{'milestones'} =
|
|
|
|
[ sort { lc($a) cmp lc($b) } @{$::target_milestone{$p}} ];
|
|
|
|
}
|
|
|
|
|
|
|
|
# Assign hash back to product array.
|
|
|
|
$products[$i] = \%product;
|
1999-01-27 21:17:10 +00:00
|
|
|
}
|
2001-11-18 22:23:31 +00:00
|
|
|
$vars->{'product'} = \@products;
|
1999-05-24 21:16:18 +00:00
|
|
|
|
2004-08-20 21:49:20 +00:00
|
|
|
# Create data structures representing each classification
|
|
|
|
if (Param('useclassification')) {
|
|
|
|
my @classifications = ();
|
|
|
|
|
|
|
|
foreach my $c (sort(GetSelectableClassifications())) {
|
|
|
|
# Create hash to hold attributes for each classification.
|
|
|
|
my %classification = (
|
|
|
|
'name' => $c,
|
|
|
|
'products' => [ GetSelectableProducts(0,$c) ]
|
|
|
|
);
|
|
|
|
# Assign hash back to classification array.
|
|
|
|
push @classifications, \%classification;
|
|
|
|
}
|
|
|
|
$vars->{'classification'} = \@classifications;
|
|
|
|
}
|
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# We use 'component_' because 'component' is a Template Toolkit reserved word.
|
|
|
|
$vars->{'component_'} = \@components;
|
1998-08-26 06:14:20 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
$vars->{'version'} = \@versions;
|
1999-01-27 21:17:10 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
if (Param('usetargetmilestone')) {
|
|
|
|
$vars->{'target_milestone'} = \@milestones;
|
2000-01-06 21:16:15 +00:00
|
|
|
}
|
|
|
|
|
2002-02-19 20:50:18 +00:00
|
|
|
$vars->{'have_keywords'} = scalar(@::legal_keywords);
|
2000-01-28 01:01:40 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
push @::legal_resolution, "---"; # Oy, what a hack.
|
|
|
|
shift @::legal_resolution;
|
|
|
|
# Another hack - this array contains "" for some reason. See bug 106589.
|
|
|
|
$vars->{'resolution'} = \@::legal_resolution;
|
|
|
|
|
2002-10-26 01:01:41 +00:00
|
|
|
my @chfields;
|
|
|
|
|
2002-10-13 04:26:24 +00:00
|
|
|
push @chfields, "[Bug creation]";
|
2002-10-26 01:01:41 +00:00
|
|
|
|
|
|
|
# This is what happens when you have variables whose definition depends
|
|
|
|
# on the DB schema, and then the underlying schema changes...
|
|
|
|
foreach my $val (@::log_columns) {
|
2004-08-20 21:49:20 +00:00
|
|
|
if ($val eq 'classification_id') {
|
|
|
|
$val = 'classification';
|
|
|
|
} elsif ($val eq 'product_id') {
|
2002-10-26 01:01:41 +00:00
|
|
|
$val = 'product';
|
|
|
|
} elsif ($val eq 'component_id') {
|
|
|
|
$val = 'component';
|
|
|
|
}
|
|
|
|
push @chfields, $val;
|
|
|
|
}
|
|
|
|
|
2002-10-13 04:26:24 +00:00
|
|
|
if (UserInGroup(Param('timetrackinggroup'))) {
|
|
|
|
push @chfields, "work_time";
|
|
|
|
} else {
|
|
|
|
@chfields = grep($_ ne "estimated_time", @chfields);
|
|
|
|
@chfields = grep($_ ne "remaining_time", @chfields);
|
|
|
|
}
|
|
|
|
@chfields = (sort(@chfields));
|
|
|
|
$vars->{'chfield'} = \@chfields;
|
2001-11-18 22:23:31 +00:00
|
|
|
$vars->{'bug_status'} = \@::legal_bug_status;
|
|
|
|
$vars->{'rep_platform'} = \@::legal_platform;
|
|
|
|
$vars->{'op_sys'} = \@::legal_opsys;
|
|
|
|
$vars->{'priority'} = \@::legal_priority;
|
|
|
|
$vars->{'bug_severity'} = \@::legal_severity;
|
|
|
|
|
|
|
|
# Boolean charts
|
2000-01-28 01:01:40 +00:00
|
|
|
my @fields;
|
2001-11-18 22:23:31 +00:00
|
|
|
push(@fields, { name => "noop", description => "---" });
|
2003-06-23 18:01:39 +00:00
|
|
|
push(@fields, GetFieldDefs());
|
2001-11-18 22:23:31 +00:00
|
|
|
$vars->{'fields'} = \@fields;
|
2000-01-31 18:19:44 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# Creating new charts - if the cmd-add value is there, we define the field
|
|
|
|
# value so the code sees it and creates the chart. It will attempt to select
|
|
|
|
# "xyzzy" as the default, and fail. This is the correct behaviour.
|
2000-01-28 01:01:40 +00:00
|
|
|
foreach my $cmd (grep(/^cmd-/, keys(%::FORM))) {
|
|
|
|
if ($cmd =~ /^cmd-add(\d+)-(\d+)-(\d+)$/) {
|
2001-10-13 01:36:17 +00:00
|
|
|
$::FORM{"field$1-$2-$3"} = "xyzzy";
|
2000-01-28 01:01:40 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-13 01:36:17 +00:00
|
|
|
|
2000-01-28 01:01:40 +00:00
|
|
|
if (!exists $::FORM{'field0-0-0'}) {
|
|
|
|
$::FORM{'field0-0-0'} = "xyzzy";
|
|
|
|
}
|
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# Create data structure of boolean chart info. It's an array of arrays of
|
|
|
|
# arrays - with the inner arrays having three members - field, type and
|
|
|
|
# value.
|
|
|
|
my @charts;
|
|
|
|
for (my $chart = 0; $::FORM{"field$chart-0-0"}; $chart++) {
|
2000-01-28 01:01:40 +00:00
|
|
|
my @rows;
|
2001-11-18 22:23:31 +00:00
|
|
|
for (my $row = 0; $::FORM{"field$chart-$row-0"}; $row++) {
|
2001-10-13 01:36:17 +00:00
|
|
|
my @cols;
|
2001-11-18 22:23:31 +00:00
|
|
|
for (my $col = 0; $::FORM{"field$chart-$row-$col"}; $col++) {
|
|
|
|
push(@cols, { field => $::FORM{"field$chart-$row-$col"},
|
|
|
|
type => $::FORM{"type$chart-$row-$col"},
|
|
|
|
value => $::FORM{"value$chart-$row-$col"} });
|
2001-10-13 01:36:17 +00:00
|
|
|
}
|
2001-11-18 22:23:31 +00:00
|
|
|
push(@rows, \@cols);
|
2000-01-28 01:01:40 +00:00
|
|
|
}
|
2004-07-20 21:46:47 +00:00
|
|
|
push(@charts, {'rows' => \@rows, 'negate' => $::FORM{"negate$chart"}});
|
2000-01-28 01:01:40 +00:00
|
|
|
}
|
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
$default{'charts'} = \@charts;
|
2000-01-28 01:01:40 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# Named queries
|
2004-07-31 02:27:26 +00:00
|
|
|
if ($userid) {
|
2000-01-23 20:31:50 +00:00
|
|
|
my @namedqueries;
|
2001-11-18 22:23:31 +00:00
|
|
|
SendSQL("SELECT name FROM namedqueries " .
|
2002-09-22 17:15:13 +00:00
|
|
|
"WHERE userid = $userid AND name != '$::defaultqueryname' " .
|
2001-11-18 22:23:31 +00:00
|
|
|
"ORDER BY name");
|
|
|
|
while (MoreSQLData()) {
|
|
|
|
push(@namedqueries, FetchOneColumn());
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
$vars->{'namedqueries'} = \@namedqueries;
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
1998-08-26 06:14:20 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# Sort order
|
|
|
|
my $deforder;
|
|
|
|
my @orders = ('Bug Number', 'Importance', 'Assignee', 'Last Changed');
|
2000-01-22 19:08:57 +00:00
|
|
|
|
2004-07-21 21:17:05 +00:00
|
|
|
if ($cgi->cookie('LASTORDER')) {
|
2000-01-22 19:08:57 +00:00
|
|
|
$deforder = "Reuse same sort as last time";
|
|
|
|
unshift(@orders, $deforder);
|
|
|
|
}
|
2000-01-23 17:14:09 +00:00
|
|
|
|
2000-09-13 22:04:30 +00:00
|
|
|
if ($::FORM{'order'}) { $deforder = $::FORM{'order'} }
|
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
$vars->{'userdefaultquery'} = $userdefaultquery;
|
|
|
|
$vars->{'orders'} = \@orders;
|
|
|
|
$default{'querytype'} = $deforder || 'Importance';
|
1998-08-26 06:14:20 +00:00
|
|
|
|
2003-09-07 22:06:39 +00:00
|
|
|
if (($::FORM{'query_format'} || $::FORM{'format'} || "") eq "create-series") {
|
2003-06-25 23:23:13 +00:00
|
|
|
require Bugzilla::Chart;
|
|
|
|
$vars->{'category'} = Bugzilla::Chart::getVisibleSeries();
|
|
|
|
}
|
|
|
|
|
2004-07-22 05:14:14 +00:00
|
|
|
$vars->{'known_name'} = $cgi->param('known_name');
|
|
|
|
|
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# Add in the defaults.
|
|
|
|
$vars->{'default'} = \%default;
|
2000-01-14 22:35:49 +00:00
|
|
|
|
2004-07-07 06:02:33 +00:00
|
|
|
$vars->{'format'} = $cgi->param('format');
|
|
|
|
$vars->{'query_format'} = $cgi->param('query_format');
|
|
|
|
|
|
|
|
# Set default page to "specific" if none proviced
|
|
|
|
if (!($cgi->param('query_format') || $cgi->param('format'))) {
|
|
|
|
if (defined $cgi->cookie('DEFAULTFORMAT')) {
|
|
|
|
$vars->{'format'} = $cgi->cookie('DEFAULTFORMAT');
|
|
|
|
} else {
|
|
|
|
$vars->{'format'} = 'specific';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-12 05:07:33 +00:00
|
|
|
# Set cookie to current format as default, but only if the format
|
|
|
|
# one that we should remember.
|
|
|
|
if (grep { $_ eq $vars->{'format'} } qw(specific advanced)) {
|
2004-07-07 06:02:33 +00:00
|
|
|
$cgi->send_cookie(-name => 'DEFAULTFORMAT',
|
|
|
|
-value => $vars->{'format'},
|
|
|
|
-expires => "Fri, 01-Jan-2038 00:00:00 GMT");
|
|
|
|
}
|
2002-09-19 21:05:17 +00:00
|
|
|
|
2001-11-18 22:23:31 +00:00
|
|
|
# Generate and return the UI (HTML page) from the appropriate template.
|
2002-09-19 21:05:17 +00:00
|
|
|
# If we submit back to ourselves (for e.g. boolean charts), we need to
|
|
|
|
# preserve format information; hence query_format taking priority over
|
|
|
|
# format.
|
|
|
|
my $format = GetFormat("search/search",
|
2004-07-07 06:02:33 +00:00
|
|
|
$vars->{'query_format'} || $vars->{'format'},
|
|
|
|
$cgi->param('ctype'));
|
2003-05-05 01:15:38 +00:00
|
|
|
|
|
|
|
print $cgi->header($format->{'ctype'});
|
|
|
|
|
2002-09-17 23:28:24 +00:00
|
|
|
$template->process($format->{'template'}, $vars)
|
2002-04-24 07:24:50 +00:00
|
|
|
|| ThrowTemplateError($template->error());
|