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>
|
2005-06-15 03:55:00 +00:00
|
|
|
# Max Kanat-Alexander <mkanat@bugzilla.org>
|
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
|
|
|
|
2005-08-10 01:30:41 +00:00
|
|
|
require "globals.pl";
|
1998-08-26 06:14:20 +00:00
|
|
|
|
2004-03-27 03:51:44 +00:00
|
|
|
use Bugzilla::Constants;
|
2004-12-31 08:00:51 +00:00
|
|
|
use Bugzilla::Search;
|
2005-03-15 22:10:14 +00:00
|
|
|
use Bugzilla::User;
|
2005-07-20 21:30:58 +00:00
|
|
|
use Bugzilla::Util;
|
2004-03-27 03:51:44 +00:00
|
|
|
|
2002-02-13 02:27:24 +00:00
|
|
|
use vars qw(
|
|
|
|
@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
|
|
|
|
$template
|
|
|
|
$vars
|
|
|
|
);
|
1998-09-15 21:49:26 +00:00
|
|
|
|
2003-05-05 01:15:38 +00:00
|
|
|
my $cgi = Bugzilla->cgi;
|
2005-02-16 18:59:36 +00:00
|
|
|
my $dbh = Bugzilla->dbh;
|
2005-08-10 01:30:41 +00:00
|
|
|
my $buffer = $cgi->query_string();
|
2003-05-05 01:15:38 +00:00
|
|
|
|
2005-03-15 16:04:00 +00:00
|
|
|
if ($cgi->param("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')) {
|
2005-01-18 16:53:50 +00:00
|
|
|
push(@oldquerycookies, [DEFAULT_QUERY_NAME, '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) {
|
2005-02-16 18:59:36 +00:00
|
|
|
# If the query name contains invalid characters, don't import.
|
|
|
|
$name =~ /[<>&]/ && next;
|
|
|
|
trick_taint($name);
|
2005-02-17 21:57:27 +00:00
|
|
|
$dbh->bz_lock_tables('namedqueries WRITE');
|
2005-02-16 18:59:36 +00:00
|
|
|
my $query = $dbh->selectrow_array(
|
|
|
|
"SELECT query FROM namedqueries " .
|
|
|
|
"WHERE userid = ? AND name = ?",
|
|
|
|
undef, ($userid, $name));
|
2000-01-23 20:31:50 +00:00
|
|
|
if (!$query) {
|
2005-02-16 18:59:36 +00:00
|
|
|
$dbh->do("INSERT INTO namedqueries " .
|
2000-01-23 20:31:50 +00:00
|
|
|
"(userid, name, query) VALUES " .
|
2005-02-16 18:59:36 +00:00
|
|
|
"(?, ?, ?)", undef, ($userid, $name, $value));
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
2005-02-17 21:57:27 +00:00
|
|
|
$dbh->bz_unlock_tables();
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
2005-07-07 11:53:38 +00:00
|
|
|
$cgi->remove_cookie($cookiename);
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-23 17:14:09 +00:00
|
|
|
}
|
1998-08-26 06:14:20 +00:00
|
|
|
|
2005-03-15 16:04:00 +00:00
|
|
|
if ($cgi->param('nukedefaultquery')) {
|
2004-07-31 02:27:26 +00:00
|
|
|
if ($userid) {
|
2005-02-16 18:59:36 +00:00
|
|
|
$dbh->do("DELETE FROM namedqueries" .
|
|
|
|
" WHERE userid = ? AND name = ?",
|
|
|
|
undef, ($userid, DEFAULT_QUERY_NAME));
|
2000-01-23 20:31:50 +00:00
|
|
|
}
|
2005-08-10 01:30:41 +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) {
|
2005-02-16 18:59:36 +00:00
|
|
|
$userdefaultquery = $dbh->selectrow_array(
|
|
|
|
"SELECT query FROM namedqueries " .
|
|
|
|
"WHERE userid = ? AND name = ?",
|
|
|
|
undef, ($userid, DEFAULT_QUERY_NAME));
|
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) {
|
2005-07-20 21:30:58 +00:00
|
|
|
$value = Bugzilla::Util::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
|
|
|
|
2004-12-31 07:00:03 +00:00
|
|
|
# If the name begins with field, type, or value, then it is part of
|
|
|
|
# the boolean charts. Because these are built different than the rest
|
|
|
|
# of the form, we don't need to save a default value. We do, however,
|
|
|
|
# need to indicate that we found something so the default query isn't
|
|
|
|
# added in if all we have are boolean chart items.
|
|
|
|
if ($name =~ m/^(?:field|type|value)/) {
|
|
|
|
$foundone = 1;
|
|
|
|
}
|
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.
|
2004-12-31 07:00:03 +00:00
|
|
|
elsif ($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
|
|
|
|
2005-08-10 01:30:41 +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 = ();
|
|
|
|
|
2004-12-05 14:18:59 +00:00
|
|
|
foreach my $c (GetSelectableClassifications()) {
|
2004-08-20 21:49:20 +00:00
|
|
|
# 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 => "---" });
|
2005-02-17 21:57:27 +00:00
|
|
|
push(@fields, $dbh->bz_get_field_defs());
|
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.
|
2005-03-15 16:04:00 +00:00
|
|
|
foreach my $cmd (grep(/^cmd-/, $cgi->param)) {
|
2000-01-28 01:01:40 +00:00
|
|
|
if ($cmd =~ /^cmd-add(\d+)-(\d+)-(\d+)$/) {
|
2005-03-15 16:04:00 +00:00
|
|
|
$cgi->param(-name => "field$1-$2-$3", -value => "xyzzy");
|
2000-01-28 01:01:40 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-13 01:36:17 +00:00
|
|
|
|
2005-03-15 16:04:00 +00:00
|
|
|
if (!$cgi->param('field0-0-0')) {
|
|
|
|
$cgi->param(-name => 'field0-0-0', -value => "xyzzy");
|
2000-01-28 01:01:40 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2005-03-15 16:04:00 +00:00
|
|
|
for (my $chart = 0; $cgi->param("field$chart-0-0"); $chart++) {
|
2000-01-28 01:01:40 +00:00
|
|
|
my @rows;
|
2005-03-15 16:04:00 +00:00
|
|
|
for (my $row = 0; $cgi->param("field$chart-$row-0"); $row++) {
|
2001-10-13 01:36:17 +00:00
|
|
|
my @cols;
|
2005-03-15 16:04:00 +00:00
|
|
|
for (my $col = 0; $cgi->param("field$chart-$row-$col"); $col++) {
|
|
|
|
push(@cols, { field => $cgi->param("field$chart-$row-$col"),
|
|
|
|
type => $cgi->param("type$chart-$row-$col"),
|
|
|
|
value => $cgi->param("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
|
|
|
}
|
2005-04-10 17:37:57 +00:00
|
|
|
push(@charts, {'rows' => \@rows, 'negate' => scalar($cgi->param("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) {
|
2005-02-16 18:59:36 +00:00
|
|
|
$vars->{'namedqueries'} = $dbh->selectcol_arrayref(
|
|
|
|
"SELECT name FROM namedqueries " .
|
|
|
|
"WHERE userid = ? AND name != ?" .
|
|
|
|
"ORDER BY name",
|
|
|
|
undef, ($userid, DEFAULT_QUERY_NAME));
|
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
|
|
|
|
2005-03-15 16:04:00 +00:00
|
|
|
if ($cgi->param('order')) { $deforder = $cgi->param('order') }
|
2000-09-13 22:04:30 +00:00
|
|
|
|
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
|
|
|
|
2005-03-15 16:04:00 +00:00
|
|
|
if (($cgi->param('query_format') || $cgi->param('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.
|
2005-02-18 17:34:19 +00:00
|
|
|
if (defined($vars->{'format'}) && IsValidQueryType($vars->{'format'})) {
|
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'},
|
2005-03-15 16:04:00 +00:00
|
|
|
scalar $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());
|