2003-03-27 03:07:02 +03:00
|
|
|
#!/usr/bin/perl -wT
|
1998-09-16 01:49:26 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
1998-08-26 10:14:20 +04:00
|
|
|
#
|
1999-11-02 02:33:56 +03: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 10:14:20 +04:00
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
1999-11-02 02:33:56 +03:00
|
|
|
#
|
1998-08-26 10:14:20 +04:00
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
1999-11-02 02:33:56 +03:00
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
1998-08-26 10:14:20 +04:00
|
|
|
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
1999-03-20 00:40:14 +03:00
|
|
|
# David Gardiner <david.gardiner@unisa.edu.au>
|
2000-11-20 22:42:36 +03:00
|
|
|
# Matthias Radestock <matthias@sorted.org>
|
2001-11-19 01:23:31 +03:00
|
|
|
# Gervase Markham <gerv@gerv.net>
|
2004-07-07 10:02:33 +04:00
|
|
|
# Byron Jones <bugzilla@glob.com.au>
|
2005-02-16 21:59:36 +03:00
|
|
|
# Max Kanat-Alexander <mkanat@kerio.com>
|
1998-08-26 10:14:20 +04:00
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
use strict;
|
2001-11-19 01:23:31 +03:00
|
|
|
use lib ".";
|
1998-08-26 10:14:20 +04:00
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
require "CGI.pl";
|
1998-08-26 10:14:20 +04:00
|
|
|
|
2004-03-27 06:51:44 +03:00
|
|
|
use Bugzilla::Constants;
|
2004-12-31 11:00:51 +03:00
|
|
|
use Bugzilla::Search;
|
2004-03-27 06:51:44 +03:00
|
|
|
|
2002-02-13 05:27:24 +03: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-16 01:49:26 +04:00
|
|
|
|
2003-05-05 05:15:38 +04:00
|
|
|
my $cgi = Bugzilla->cgi;
|
2005-02-16 21:59:36 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
2003-05-05 05:15:38 +04:00
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
if (defined $::FORM{"GoAheadAndLogIn"}) {
|
1998-08-26 10:14:20 +04:00
|
|
|
# We got here from a login page, probably from relogin.cgi. We better
|
|
|
|
# make sure the password is legit.
|
2004-03-27 06:51:44 +03:00
|
|
|
Bugzilla->login(LOGIN_REQUIRED);
|
2000-01-23 23:31:50 +03:00
|
|
|
} else {
|
2004-03-27 06:51:44 +03:00
|
|
|
Bugzilla->login();
|
2000-01-23 23:31:50 +03:00
|
|
|
}
|
1998-08-26 10:14:20 +04:00
|
|
|
|
2004-07-31 06:27:26 +04:00
|
|
|
my $userid = Bugzilla->user->id;
|
2003-06-03 13:48:15 +04:00
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
# Backwards compatibility hack -- if there are any of the old QUERY_*
|
2000-01-23 23:31:50 +03:00
|
|
|
# cookies around, and we are logged in, then move them into the database
|
2001-11-19 01:23:31 +03:00
|
|
|
# and nuke the cookie. This is required for Bugzilla 2.8 and earlier.
|
2004-07-31 06:27:26 +04:00
|
|
|
if ($userid) {
|
2000-01-23 23:31:50 +03:00
|
|
|
my @oldquerycookies;
|
2004-07-22 01:17:05 +04:00
|
|
|
foreach my $i ($cgi->cookie()) {
|
2000-01-23 23:31:50 +03:00
|
|
|
if ($i =~ /^QUERY_(.*)$/) {
|
2004-07-22 01:17:05 +04:00
|
|
|
push(@oldquerycookies, [$1, $i, $cgi->cookie($i)]);
|
2000-01-23 23:31:50 +03:00
|
|
|
}
|
|
|
|
}
|
2004-07-22 01:17:05 +04:00
|
|
|
if (defined $cgi->cookie('DEFAULTQUERY')) {
|
2005-01-18 19:53:50 +03:00
|
|
|
push(@oldquerycookies, [DEFAULT_QUERY_NAME, 'DEFAULTQUERY',
|
2004-07-22 01:17:05 +04:00
|
|
|
$cgi->cookie('DEFAULTQUERY')]);
|
2000-01-23 23:31:50 +03:00
|
|
|
}
|
|
|
|
if (@oldquerycookies) {
|
|
|
|
foreach my $ref (@oldquerycookies) {
|
|
|
|
my ($name, $cookiename, $value) = (@$ref);
|
|
|
|
if ($value) {
|
2005-02-16 21:59:36 +03:00
|
|
|
# If the query name contains invalid characters, don't import.
|
|
|
|
$name =~ /[<>&]/ && next;
|
|
|
|
trick_taint($name);
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_lock_tables('namedqueries WRITE');
|
2005-02-16 21:59:36 +03:00
|
|
|
my $query = $dbh->selectrow_array(
|
|
|
|
"SELECT query FROM namedqueries " .
|
|
|
|
"WHERE userid = ? AND name = ?",
|
|
|
|
undef, ($userid, $name));
|
2000-01-23 23:31:50 +03:00
|
|
|
if (!$query) {
|
2005-02-16 21:59:36 +03:00
|
|
|
$dbh->do("INSERT INTO namedqueries " .
|
2000-01-23 23:31:50 +03:00
|
|
|
"(userid, name, query) VALUES " .
|
2005-02-16 21:59:36 +03:00
|
|
|
"(?, ?, ?)", undef, ($userid, $name, $value));
|
2000-01-23 23:31:50 +03:00
|
|
|
}
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_unlock_tables();
|
2000-01-23 23:31:50 +03:00
|
|
|
}
|
2003-05-05 05:15:38 +04:00
|
|
|
$cgi->send_cookie(-name => $cookiename,
|
|
|
|
-expires => "Fri, 01-Jan-2038 00:00:00 GMT");
|
2000-01-23 23:31:50 +03:00
|
|
|
}
|
|
|
|
}
|
2000-01-23 20:14:09 +03:00
|
|
|
}
|
1998-08-26 10:14:20 +04:00
|
|
|
|
2000-01-23 23:31:50 +03:00
|
|
|
if ($::FORM{'nukedefaultquery'}) {
|
2004-07-31 06:27:26 +04:00
|
|
|
if ($userid) {
|
2005-02-16 21:59:36 +03:00
|
|
|
$dbh->do("DELETE FROM namedqueries" .
|
|
|
|
" WHERE userid = ? AND name = ?",
|
|
|
|
undef, ($userid, DEFAULT_QUERY_NAME));
|
2000-01-23 23:31:50 +03:00
|
|
|
}
|
|
|
|
$::buffer = "";
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
|
2000-01-23 23:31:50 +03:00
|
|
|
my $userdefaultquery;
|
2004-07-31 06:27:26 +04:00
|
|
|
if ($userid) {
|
2005-02-16 21:59:36 +03:00
|
|
|
$userdefaultquery = $dbh->selectrow_array(
|
|
|
|
"SELECT query FROM namedqueries " .
|
|
|
|
"WHERE userid = ? AND name = ?",
|
|
|
|
undef, ($userid, DEFAULT_QUERY_NAME));
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
|
2000-01-23 23:31:50 +03:00
|
|
|
my %default;
|
1998-09-16 01:49:26 +04:00
|
|
|
|
2001-11-19 01:23:31 +03: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 23:31:50 +03:00
|
|
|
my ($buf) = (@_);
|
|
|
|
my $foundone = 0;
|
2001-11-19 01:23:31 +03:00
|
|
|
|
|
|
|
# Nothing must be undef, otherwise the template complains.
|
2000-01-23 23:31:50 +03:00
|
|
|
foreach my $name ("bug_status", "resolution", "assigned_to",
|
|
|
|
"rep_platform", "priority", "bug_severity",
|
2004-08-21 01:49:20 +04:00
|
|
|
"classification", "product", "reporter", "op_sys",
|
2000-01-23 23:31:50 +03:00
|
|
|
"component", "version", "chfield", "chfieldfrom",
|
2001-04-10 07:49:01 +04:00
|
|
|
"chfieldto", "chfieldvalue", "target_milestone",
|
2001-11-19 01:23:31 +03:00
|
|
|
"email", "emailtype", "emailreporter",
|
|
|
|
"emailassigned_to", "emailcc", "emailqa_contact",
|
2003-09-03 06:03:48 +04:00
|
|
|
"emaillongdesc", "content",
|
2000-01-23 23:31:50 +03:00
|
|
|
"changedin", "votes", "short_desc", "short_desc_type",
|
|
|
|
"long_desc", "long_desc_type", "bug_file_loc",
|
|
|
|
"bug_file_loc_type", "status_whiteboard",
|
2000-01-27 00:48:36 +03:00
|
|
|
"status_whiteboard_type", "bug_id",
|
2002-09-25 11:11:45 +04:00
|
|
|
"bugidtype", "keywords", "keywords_type",
|
2002-10-29 10:44:18 +03:00
|
|
|
"x_axis_field", "y_axis_field", "z_axis_field",
|
2003-06-26 03:23:13 +04:00
|
|
|
"chart_format", "cumulate", "x_labels_vertical",
|
|
|
|
"category", "subcategory", "name", "newcategory",
|
|
|
|
"newsubcategory", "public", "frequency")
|
2002-09-25 11:11:45 +04:00
|
|
|
{
|
2001-11-19 01:23:31 +03: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-16 01:49:26 +04:00
|
|
|
}
|
2001-11-19 01:23:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
# Iterate over the URL parameters
|
2000-01-23 23:31:50 +03: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 10:14:20 +04:00
|
|
|
} else {
|
2000-01-23 23:31:50 +03:00
|
|
|
$value = "";
|
|
|
|
}
|
2001-11-19 01:23:31 +03:00
|
|
|
|
2004-12-31 10:00:03 +03: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-19 01:23:31 +03: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 10:00:03 +03:00
|
|
|
elsif ($name =~ m/^(.+)(\d)$/ && defined($default{$1})) {
|
2000-01-23 23:31:50 +03:00
|
|
|
$foundone = 1;
|
2001-11-19 01:23:31 +03:00
|
|
|
$default{$1}->[$2] = $value;
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
2001-11-19 01:23:31 +03: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 23:31:50 +03:00
|
|
|
return $foundone;
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
|
1999-03-24 01:32:21 +03:00
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
if (!PrefillForm($::buffer)) {
|
2000-01-23 23:31:50 +03:00
|
|
|
# Ah-hah, there was no form stuff specified. Do it again with the
|
|
|
|
# default query.
|
|
|
|
if ($userdefaultquery) {
|
2001-11-19 01:23:31 +03:00
|
|
|
PrefillForm($userdefaultquery);
|
2000-01-23 23:31:50 +03:00
|
|
|
} else {
|
2001-11-19 01:23:31 +03:00
|
|
|
PrefillForm(Param("defaultquery"));
|
2000-01-23 23:31:50 +03:00
|
|
|
}
|
|
|
|
}
|
1999-03-24 01:32:21 +03:00
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
if ($default{'chfieldto'}->[0] eq "") {
|
|
|
|
$default{'chfieldto'} = ["Now"];
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
GetVersionTable();
|
1999-01-19 03:07:46 +03:00
|
|
|
|
2002-11-24 22:56:34 +03: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 19:28:19 +04:00
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
my @products = ();
|
2000-11-20 22:42:36 +03:00
|
|
|
my %component_set;
|
|
|
|
my %version_set;
|
|
|
|
my %milestone_set;
|
2002-12-10 17:17:05 +03:00
|
|
|
foreach my $p (GetSelectableProducts()) {
|
2001-11-19 01:23:31 +03: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-31 02:56:53 +04:00
|
|
|
}
|
|
|
|
}
|
2001-11-19 01:23:31 +03:00
|
|
|
foreach my $v (@{$::versions{$p}}) {
|
|
|
|
$version_set{$v} = 1;
|
1999-03-20 00:40:14 +03:00
|
|
|
}
|
2001-11-19 01:23:31 +03:00
|
|
|
foreach my $m (@{$::target_milestone{$p}}) {
|
|
|
|
$milestone_set{$m} = 1;
|
1999-03-20 00:40:14 +03:00
|
|
|
}
|
2001-08-31 02:56:53 +04:00
|
|
|
}
|
|
|
|
|
2001-11-19 01:23:31 +03: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 19:47:06 +03:00
|
|
|
|
2001-11-19 01:23:31 +03: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 19:47:06 +03:00
|
|
|
}
|
1999-03-20 00:40:14 +03:00
|
|
|
}
|
2001-11-19 01:23:31 +03:00
|
|
|
foreach my $v (@::legal_versions) {
|
|
|
|
if ($version_set{$v}) {
|
|
|
|
push @versions, $v;
|
1999-03-20 00:40:14 +03:00
|
|
|
}
|
2001-08-31 02:56:53 +04:00
|
|
|
}
|
2001-11-19 01:23:31 +03:00
|
|
|
foreach my $m (@::legal_target_milestone) {
|
|
|
|
if ($milestone_set{$m}) {
|
|
|
|
push @milestones, $m;
|
2001-08-31 02:56:53 +04:00
|
|
|
}
|
2001-03-01 02:00:28 +03:00
|
|
|
}
|
|
|
|
|
2002-08-11 11:50:59 +04:00
|
|
|
# Create data structures representing each product.
|
|
|
|
for (my $i = 0; $i < @products; ++$i) {
|
|
|
|
my $p = $products[$i];
|
|
|
|
|
2003-10-31 22:06:59 +03:00
|
|
|
# Bug 190611: band-aid to avoid crashing with no versions defined
|
|
|
|
if (!defined ($::components{$p})) {
|
|
|
|
$::components{$p} = [];
|
|
|
|
}
|
|
|
|
|
2002-08-11 11:50:59 +04: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 07:45:17 +03:00
|
|
|
# Sorting here is required for ordering multiple selections
|
|
|
|
# correctly; see bug 97736 for discussion on how to fix this
|
2002-08-11 11:50:59 +04:00
|
|
|
$product{'milestones'} =
|
|
|
|
[ sort { lc($a) cmp lc($b) } @{$::target_milestone{$p}} ];
|
|
|
|
}
|
|
|
|
|
|
|
|
# Assign hash back to product array.
|
|
|
|
$products[$i] = \%product;
|
1999-01-28 00:17:10 +03:00
|
|
|
}
|
2001-11-19 01:23:31 +03:00
|
|
|
$vars->{'product'} = \@products;
|
1999-05-25 01:16:18 +04:00
|
|
|
|
2004-08-21 01:49:20 +04:00
|
|
|
# Create data structures representing each classification
|
|
|
|
if (Param('useclassification')) {
|
|
|
|
my @classifications = ();
|
|
|
|
|
2004-12-05 17:18:59 +03:00
|
|
|
foreach my $c (GetSelectableClassifications()) {
|
2004-08-21 01:49:20 +04: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-19 01:23:31 +03:00
|
|
|
# We use 'component_' because 'component' is a Template Toolkit reserved word.
|
|
|
|
$vars->{'component_'} = \@components;
|
1998-08-26 10:14:20 +04:00
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
$vars->{'version'} = \@versions;
|
1999-01-28 00:17:10 +03:00
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
if (Param('usetargetmilestone')) {
|
|
|
|
$vars->{'target_milestone'} = \@milestones;
|
2000-01-07 00:16:15 +03:00
|
|
|
}
|
|
|
|
|
2002-02-19 23:50:18 +03:00
|
|
|
$vars->{'have_keywords'} = scalar(@::legal_keywords);
|
2000-01-28 04:01:40 +03:00
|
|
|
|
2001-11-19 01:23:31 +03: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 05:01:41 +04:00
|
|
|
my @chfields;
|
|
|
|
|
2002-10-13 08:26:24 +04:00
|
|
|
push @chfields, "[Bug creation]";
|
2002-10-26 05:01:41 +04: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-21 01:49:20 +04:00
|
|
|
if ($val eq 'classification_id') {
|
|
|
|
$val = 'classification';
|
|
|
|
} elsif ($val eq 'product_id') {
|
2002-10-26 05:01:41 +04:00
|
|
|
$val = 'product';
|
|
|
|
} elsif ($val eq 'component_id') {
|
|
|
|
$val = 'component';
|
|
|
|
}
|
|
|
|
push @chfields, $val;
|
|
|
|
}
|
|
|
|
|
2002-10-13 08:26:24 +04: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-19 01:23:31 +03: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 04:01:40 +03:00
|
|
|
my @fields;
|
2001-11-19 01:23:31 +03:00
|
|
|
push(@fields, { name => "noop", description => "---" });
|
2005-02-18 00:57:27 +03:00
|
|
|
push(@fields, $dbh->bz_get_field_defs());
|
2001-11-19 01:23:31 +03:00
|
|
|
$vars->{'fields'} = \@fields;
|
2000-01-31 21:19:44 +03:00
|
|
|
|
2001-11-19 01:23:31 +03: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 04:01:40 +03:00
|
|
|
foreach my $cmd (grep(/^cmd-/, keys(%::FORM))) {
|
|
|
|
if ($cmd =~ /^cmd-add(\d+)-(\d+)-(\d+)$/) {
|
2001-10-13 05:36:17 +04:00
|
|
|
$::FORM{"field$1-$2-$3"} = "xyzzy";
|
2000-01-28 04:01:40 +03:00
|
|
|
}
|
|
|
|
}
|
2001-10-13 05:36:17 +04:00
|
|
|
|
2000-01-28 04:01:40 +03:00
|
|
|
if (!exists $::FORM{'field0-0-0'}) {
|
|
|
|
$::FORM{'field0-0-0'} = "xyzzy";
|
|
|
|
}
|
|
|
|
|
2001-11-19 01:23:31 +03: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 04:01:40 +03:00
|
|
|
my @rows;
|
2001-11-19 01:23:31 +03:00
|
|
|
for (my $row = 0; $::FORM{"field$chart-$row-0"}; $row++) {
|
2001-10-13 05:36:17 +04:00
|
|
|
my @cols;
|
2001-11-19 01:23:31 +03: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 05:36:17 +04:00
|
|
|
}
|
2001-11-19 01:23:31 +03:00
|
|
|
push(@rows, \@cols);
|
2000-01-28 04:01:40 +03:00
|
|
|
}
|
2004-07-21 01:46:47 +04:00
|
|
|
push(@charts, {'rows' => \@rows, 'negate' => $::FORM{"negate$chart"}});
|
2000-01-28 04:01:40 +03:00
|
|
|
}
|
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
$default{'charts'} = \@charts;
|
2000-01-28 04:01:40 +03:00
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
# Named queries
|
2004-07-31 06:27:26 +04:00
|
|
|
if ($userid) {
|
2005-02-16 21:59:36 +03: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 23:31:50 +03:00
|
|
|
}
|
1998-08-26 10:14:20 +04:00
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
# Sort order
|
|
|
|
my $deforder;
|
|
|
|
my @orders = ('Bug Number', 'Importance', 'Assignee', 'Last Changed');
|
2000-01-22 22:08:57 +03:00
|
|
|
|
2004-07-22 01:17:05 +04:00
|
|
|
if ($cgi->cookie('LASTORDER')) {
|
2000-01-22 22:08:57 +03:00
|
|
|
$deforder = "Reuse same sort as last time";
|
|
|
|
unshift(@orders, $deforder);
|
|
|
|
}
|
2000-01-23 20:14:09 +03:00
|
|
|
|
2000-09-14 02:04:30 +04:00
|
|
|
if ($::FORM{'order'}) { $deforder = $::FORM{'order'} }
|
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
$vars->{'userdefaultquery'} = $userdefaultquery;
|
|
|
|
$vars->{'orders'} = \@orders;
|
|
|
|
$default{'querytype'} = $deforder || 'Importance';
|
1998-08-26 10:14:20 +04:00
|
|
|
|
2003-09-08 02:06:39 +04:00
|
|
|
if (($::FORM{'query_format'} || $::FORM{'format'} || "") eq "create-series") {
|
2003-06-26 03:23:13 +04:00
|
|
|
require Bugzilla::Chart;
|
|
|
|
$vars->{'category'} = Bugzilla::Chart::getVisibleSeries();
|
|
|
|
}
|
|
|
|
|
2004-07-22 09:14:14 +04:00
|
|
|
$vars->{'known_name'} = $cgi->param('known_name');
|
|
|
|
|
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
# Add in the defaults.
|
|
|
|
$vars->{'default'} = \%default;
|
2000-01-15 01:35:49 +03:00
|
|
|
|
2004-07-07 10:02:33 +04: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 09:07:33 +04:00
|
|
|
# Set cookie to current format as default, but only if the format
|
|
|
|
# one that we should remember.
|
2005-02-18 20:34:19 +03:00
|
|
|
if (defined($vars->{'format'}) && IsValidQueryType($vars->{'format'})) {
|
2004-07-07 10:02:33 +04:00
|
|
|
$cgi->send_cookie(-name => 'DEFAULTFORMAT',
|
|
|
|
-value => $vars->{'format'},
|
|
|
|
-expires => "Fri, 01-Jan-2038 00:00:00 GMT");
|
|
|
|
}
|
2002-09-20 01:05:17 +04:00
|
|
|
|
2001-11-19 01:23:31 +03:00
|
|
|
# Generate and return the UI (HTML page) from the appropriate template.
|
2002-09-20 01:05:17 +04: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 10:02:33 +04:00
|
|
|
$vars->{'query_format'} || $vars->{'format'},
|
|
|
|
$cgi->param('ctype'));
|
2003-05-05 05:15:38 +04:00
|
|
|
|
|
|
|
print $cgi->header($format->{'ctype'});
|
|
|
|
|
2002-09-18 03:28:24 +04:00
|
|
|
$template->process($format->{'template'}, $vars)
|
2002-04-24 11:24:50 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|