1998-09-15 21:49:26 +00:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
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-09-15 21:49:26 +00:00
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
1999-11-01 23:33:56 +00:00
|
|
|
#
|
1998-09-15 21:49:26 +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-09-15 21:49:26 +00:00
|
|
|
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
2000-03-28 21:31:24 +00:00
|
|
|
# Dan Mosedale <dmose@mozilla.org>
|
2002-08-27 04:28:05 +00:00
|
|
|
# Jacob Steenhagen <jake@bugzilla.org>
|
2002-11-19 07:19:34 +00:00
|
|
|
# Bradley Baetz <bbaetz@student.usyd.edu.au>
|
2001-11-17 10:29:55 +00:00
|
|
|
# Christopher Aillon <christopher@aillon.com>
|
2005-02-24 22:43:28 +00:00
|
|
|
# Joel Peshkin <bugreport@peshkin.net>
|
|
|
|
# Dave Lawrence <dkl@redhat.com>
|
2005-06-15 03:55:00 +00:00
|
|
|
# Max Kanat-Alexander <mkanat@bugzilla.org>
|
2005-10-24 19:21:05 +00:00
|
|
|
# Lance Larsh <lance.larsh@oracle.com>
|
1998-09-15 21:49:26 +00:00
|
|
|
|
|
|
|
# Contains some global variables and routines used throughout bugzilla.
|
|
|
|
|
|
|
|
use strict;
|
1999-10-18 23:57:58 +00:00
|
|
|
|
2003-01-14 20:00:11 +00:00
|
|
|
use Bugzilla::DB qw(:DEFAULT :deprecated);
|
2002-11-24 19:56:34 +00:00
|
|
|
use Bugzilla::Constants;
|
2002-08-19 13:59:45 +00:00
|
|
|
use Bugzilla::Util;
|
2002-08-29 09:25:54 +00:00
|
|
|
# Bring ChmodDataFile in until this is all moved to the module
|
2003-11-22 03:50:42 +00:00
|
|
|
use Bugzilla::Config qw(:DEFAULT ChmodDataFile $localconfig $datadir);
|
2005-02-24 23:42:48 +00:00
|
|
|
use Bugzilla::User;
|
2005-08-10 01:30:41 +00:00
|
|
|
use Bugzilla::Error;
|
2002-08-19 13:59:45 +00:00
|
|
|
|
1999-10-18 23:57:58 +00:00
|
|
|
# Shut up misguided -w warnings about "used only once". For some reason,
|
|
|
|
# "use vars" chokes on me when I try it here.
|
|
|
|
|
|
|
|
sub globals_pl_sillyness {
|
|
|
|
my $zz;
|
|
|
|
$zz = @main::legal_bug_status;
|
|
|
|
$zz = @main::legal_opsys;
|
|
|
|
$zz = @main::legal_platform;
|
|
|
|
$zz = @main::legal_priority;
|
|
|
|
$zz = @main::legal_severity;
|
|
|
|
}
|
|
|
|
|
2000-01-29 20:22:44 +00:00
|
|
|
#
|
|
|
|
# Here are the --LOCAL-- variables defined in 'localconfig' that we'll use
|
|
|
|
# here
|
|
|
|
#
|
|
|
|
|
2002-08-29 09:25:54 +00:00
|
|
|
# XXX - Move this to Bugzilla::Config once code which uses these has moved out
|
|
|
|
# of globals.pl
|
2003-11-22 03:50:42 +00:00
|
|
|
do $localconfig;
|
2000-01-29 20:22:44 +00:00
|
|
|
|
2000-05-20 01:22:07 +00:00
|
|
|
use DBI;
|
1998-09-15 21:49:26 +00:00
|
|
|
|
|
|
|
use Date::Format; # For time2str().
|
2000-01-20 21:31:22 +00:00
|
|
|
use Date::Parse; # For str2time().
|
1998-09-15 21:49:26 +00:00
|
|
|
|
2002-03-12 13:55:07 +00:00
|
|
|
# Use standard Perl libraries for cross-platform file/directory manipulation.
|
|
|
|
use File::Spec;
|
2001-07-04 04:41:27 +00:00
|
|
|
|
2002-08-29 09:25:54 +00:00
|
|
|
# XXXX - this needs to go away
|
1998-09-15 21:49:26 +00:00
|
|
|
sub GenerateVersionTable {
|
2005-03-10 08:07:34 +00:00
|
|
|
my $dbh = Bugzilla->dbh;
|
|
|
|
|
2005-02-24 22:43:28 +00:00
|
|
|
@::legal_priority = get_legal_field_values("priority");
|
|
|
|
@::legal_severity = get_legal_field_values("bug_severity");
|
|
|
|
@::legal_platform = get_legal_field_values("rep_platform");
|
|
|
|
@::legal_opsys = get_legal_field_values("op_sys");
|
|
|
|
@::legal_bug_status = get_legal_field_values("bug_status");
|
|
|
|
@::legal_resolution = get_legal_field_values("resolution");
|
2000-07-14 03:20:17 +00:00
|
|
|
|
|
|
|
# 'settable_resolution' is the list of resolutions that may be set
|
|
|
|
# directly by hand in the bug form. Start with the list of legal
|
|
|
|
# resolutions and remove 'MOVED' and 'DUPLICATE' because setting
|
|
|
|
# bugs to those resolutions requires a special process.
|
|
|
|
#
|
|
|
|
@::settable_resolution = @::legal_resolution;
|
|
|
|
my $w = lsearch(\@::settable_resolution, "DUPLICATE");
|
1998-09-15 21:49:26 +00:00
|
|
|
if ($w >= 0) {
|
2000-07-14 03:20:17 +00:00
|
|
|
splice(@::settable_resolution, $w, 1);
|
|
|
|
}
|
|
|
|
my $z = lsearch(\@::settable_resolution, "MOVED");
|
|
|
|
if ($z >= 0) {
|
|
|
|
splice(@::settable_resolution, $z, 1);
|
1998-09-15 21:49:26 +00:00
|
|
|
}
|
|
|
|
|
2003-04-24 21:17:31 +00:00
|
|
|
require File::Temp;
|
|
|
|
my ($fh, $tmpname) = File::Temp::tempfile("versioncache.XXXXX",
|
2003-11-22 03:50:42 +00:00
|
|
|
DIR => "$datadir");
|
2003-04-24 21:17:31 +00:00
|
|
|
|
|
|
|
print $fh "#\n";
|
|
|
|
print $fh "# DO NOT EDIT!\n";
|
|
|
|
print $fh "# This file is automatically generated at least once every\n";
|
|
|
|
print $fh "# hour by the GenerateVersionTable() sub in globals.pl.\n";
|
|
|
|
print $fh "# Any changes you make will be overwritten.\n";
|
|
|
|
print $fh "#\n";
|
2001-10-19 23:49:37 +00:00
|
|
|
|
2002-10-16 10:49:56 +00:00
|
|
|
require Data::Dumper;
|
1998-09-15 21:49:26 +00:00
|
|
|
|
2006-03-15 21:51:35 +00:00
|
|
|
print $fh (Data::Dumper->Dump([\@::legal_priority, \@::legal_severity,
|
2003-04-25 00:47:17 +00:00
|
|
|
\@::legal_platform, \@::legal_opsys,
|
|
|
|
\@::legal_bug_status, \@::legal_resolution],
|
2006-03-15 21:51:35 +00:00
|
|
|
['*::legal_priority', '*::legal_severity',
|
2003-04-25 00:47:17 +00:00
|
|
|
'*::legal_platform', '*::legal_opsys',
|
|
|
|
'*::legal_bug_status', '*::legal_resolution']));
|
2002-08-29 09:25:54 +00:00
|
|
|
|
2006-05-21 22:15:05 +00:00
|
|
|
print $fh (Data::Dumper->Dump([\@::settable_resolution],
|
|
|
|
['*::settable_resolution']));
|
2000-01-06 21:16:15 +00:00
|
|
|
|
2003-04-24 21:17:31 +00:00
|
|
|
print $fh "1;\n";
|
|
|
|
close $fh;
|
2002-08-29 09:25:54 +00:00
|
|
|
|
2005-07-12 22:35:04 +00:00
|
|
|
rename ($tmpname, "$datadir/versioncache")
|
|
|
|
|| die "Can't rename $tmpname to versioncache";
|
2003-11-22 03:50:42 +00:00
|
|
|
ChmodDataFile("$datadir/versioncache", 0666);
|
1998-09-15 21:49:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-07 21:26:49 +00:00
|
|
|
$::VersionTableLoaded = 0;
|
1998-09-15 21:49:26 +00:00
|
|
|
sub GetVersionTable {
|
2001-06-07 21:26:49 +00:00
|
|
|
return if $::VersionTableLoaded;
|
2005-07-19 14:52:59 +00:00
|
|
|
my $file_generated = 0;
|
|
|
|
if (!-r "$datadir/versioncache") {
|
1998-09-15 21:49:26 +00:00
|
|
|
GenerateVersionTable();
|
2005-07-19 14:52:59 +00:00
|
|
|
$file_generated = 1;
|
1998-09-15 21:49:26 +00:00
|
|
|
}
|
2003-11-22 03:50:42 +00:00
|
|
|
require "$datadir/versioncache";
|
2001-06-07 21:26:49 +00:00
|
|
|
$::VersionTableLoaded = 1;
|
1998-09-15 21:49:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub DBID_to_name {
|
|
|
|
my ($id) = (@_);
|
2005-03-15 05:20:48 +00:00
|
|
|
return "__UNKNOWN__" if !defined $id;
|
2001-07-04 04:41:27 +00:00
|
|
|
# $id should always be a positive integer
|
|
|
|
if ($id =~ m/^([1-9][0-9]*)$/) {
|
|
|
|
$id = $1;
|
|
|
|
} else {
|
|
|
|
$::cachedNameArray{$id} = "__UNKNOWN__";
|
|
|
|
}
|
1998-09-15 21:49:26 +00:00
|
|
|
if (!defined $::cachedNameArray{$id}) {
|
2001-03-19 21:03:52 +00:00
|
|
|
PushGlobalSQLState();
|
2005-05-02 18:52:02 +00:00
|
|
|
SendSQL("SELECT login_name FROM profiles WHERE userid = $id");
|
1998-09-15 21:49:26 +00:00
|
|
|
my $r = FetchOneColumn();
|
2001-03-19 21:03:52 +00:00
|
|
|
PopGlobalSQLState();
|
2000-05-08 18:23:55 +00:00
|
|
|
if (!defined $r || $r eq "") {
|
1998-09-15 21:49:26 +00:00
|
|
|
$r = "__UNKNOWN__";
|
|
|
|
}
|
|
|
|
$::cachedNameArray{$id} = $r;
|
|
|
|
}
|
|
|
|
return $::cachedNameArray{$id};
|
|
|
|
}
|
|
|
|
|
2005-02-24 22:43:28 +00:00
|
|
|
# Returns a list of all the legal values for a field that has a
|
|
|
|
# list of legal values, like rep_platform or resolution.
|
|
|
|
sub get_legal_field_values {
|
|
|
|
my ($field) = @_;
|
|
|
|
my $dbh = Bugzilla->dbh;
|
2005-02-27 01:11:22 +00:00
|
|
|
my $result_ref = $dbh->selectcol_arrayref(
|
2005-04-12 01:27:57 +00:00
|
|
|
"SELECT value FROM $field
|
|
|
|
WHERE isactive = ?
|
|
|
|
ORDER BY sortkey, value", undef, (1));
|
2005-02-24 22:43:28 +00:00
|
|
|
return @$result_ref;
|
1998-09-15 21:49:26 +00:00
|
|
|
}
|
|
|
|
|
2002-12-20 07:21:43 +00:00
|
|
|
############# Live code below here (that is, not subroutine defs) #############
|
2002-02-03 09:28:48 +00:00
|
|
|
|
2002-12-20 07:21:43 +00:00
|
|
|
use Bugzilla;
|
2002-07-26 18:16:39 +00:00
|
|
|
|
1998-09-15 21:49:26 +00:00
|
|
|
1;
|