1998-09-16 01:49:26 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
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-09-16 01:49:26 +04:00
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
1999-11-02 02:33:56 +03:00
|
|
|
#
|
1998-09-16 01:49:26 +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-09-16 01:49:26 +04:00
|
|
|
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
2000-03-29 01:31:24 +04:00
|
|
|
# Dan Mosedale <dmose@mozilla.org>
|
2002-08-27 08:28:05 +04:00
|
|
|
# Jacob Steenhagen <jake@bugzilla.org>
|
2002-11-19 10:19:34 +03:00
|
|
|
# Bradley Baetz <bbaetz@student.usyd.edu.au>
|
2001-11-17 13:29:55 +03:00
|
|
|
# Christopher Aillon <christopher@aillon.com>
|
2005-02-25 01:43:28 +03:00
|
|
|
# Joel Peshkin <bugreport@peshkin.net>
|
|
|
|
# Dave Lawrence <dkl@redhat.com>
|
2005-06-15 07:55:00 +04:00
|
|
|
# Max Kanat-Alexander <mkanat@bugzilla.org>
|
2005-10-24 23:21:05 +04:00
|
|
|
# Lance Larsh <lance.larsh@oracle.com>
|
1998-09-16 01:49:26 +04:00
|
|
|
|
|
|
|
# Contains some global variables and routines used throughout bugzilla.
|
|
|
|
|
|
|
|
use strict;
|
1999-10-19 03:57:58 +04:00
|
|
|
|
2003-01-14 23:00:11 +03:00
|
|
|
use Bugzilla::DB qw(:DEFAULT :deprecated);
|
2002-11-24 22:56:34 +03:00
|
|
|
use Bugzilla::Constants;
|
2002-08-19 17:59:45 +04:00
|
|
|
use Bugzilla::Util;
|
2002-08-29 13:25:54 +04:00
|
|
|
# Bring ChmodDataFile in until this is all moved to the module
|
2003-11-22 06:50:42 +03:00
|
|
|
use Bugzilla::Config qw(:DEFAULT ChmodDataFile $localconfig $datadir);
|
2005-02-25 02:42:48 +03:00
|
|
|
use Bugzilla::User;
|
2005-08-10 05:30:41 +04:00
|
|
|
use Bugzilla::Error;
|
2002-08-19 17:59:45 +04:00
|
|
|
|
1999-10-19 03:57:58 +04: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;
|
2002-02-14 04:25:25 +03:00
|
|
|
$zz = @main::enterable_products;
|
2000-01-15 01:35:49 +03:00
|
|
|
$zz = %main::keywordsbyname;
|
1999-10-19 03:57:58 +04:00
|
|
|
$zz = @main::legal_bug_status;
|
|
|
|
$zz = @main::legal_components;
|
2000-01-15 01:35:49 +03:00
|
|
|
$zz = @main::legal_keywords;
|
1999-10-19 03:57:58 +04:00
|
|
|
$zz = @main::legal_opsys;
|
|
|
|
$zz = @main::legal_platform;
|
|
|
|
$zz = @main::legal_priority;
|
|
|
|
$zz = @main::legal_product;
|
|
|
|
$zz = @main::legal_severity;
|
|
|
|
$zz = @main::legal_target_milestone;
|
|
|
|
$zz = @main::legal_versions;
|
|
|
|
$zz = @main::milestoneurl;
|
2002-02-14 04:25:25 +03:00
|
|
|
$zz = %main::proddesc;
|
1999-10-19 03:57:58 +04:00
|
|
|
$zz = @main::prodmaxvotes;
|
|
|
|
}
|
|
|
|
|
2000-01-29 23:22:44 +03:00
|
|
|
#
|
|
|
|
# Here are the --LOCAL-- variables defined in 'localconfig' that we'll use
|
|
|
|
# here
|
|
|
|
#
|
|
|
|
|
2002-08-29 13:25:54 +04:00
|
|
|
# XXX - Move this to Bugzilla::Config once code which uses these has moved out
|
|
|
|
# of globals.pl
|
2003-11-22 06:50:42 +03:00
|
|
|
do $localconfig;
|
2000-01-29 23:22:44 +03:00
|
|
|
|
2000-05-20 05:22:07 +04:00
|
|
|
use DBI;
|
1998-09-16 01:49:26 +04:00
|
|
|
|
|
|
|
use Date::Format; # For time2str().
|
2000-01-21 00:31:22 +03:00
|
|
|
use Date::Parse; # For str2time().
|
1998-09-16 01:49:26 +04:00
|
|
|
|
2002-03-12 16:55:07 +03:00
|
|
|
# Use standard Perl libraries for cross-platform file/directory manipulation.
|
|
|
|
use File::Spec;
|
|
|
|
|
2001-10-23 19:44:53 +04:00
|
|
|
# Some environment variables are not taint safe
|
2002-11-22 03:36:13 +03:00
|
|
|
delete @::ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
|
2001-07-04 08:41:27 +04:00
|
|
|
|
2002-03-23 06:51:05 +03:00
|
|
|
# Cwd.pm in perl 5.6.1 gives a warning if $::ENV{'PATH'} isn't defined
|
|
|
|
# Set this to '' so that we don't get warnings cluttering the logs on every
|
|
|
|
# system call
|
|
|
|
$::ENV{'PATH'} = '';
|
|
|
|
|
2002-03-28 10:57:05 +03:00
|
|
|
# Ignore SIGTERM and SIGPIPE - this prevents DB corruption. If the user closes
|
|
|
|
# their browser window while a script is running, the webserver sends these
|
|
|
|
# signals, and we don't want to die half way through a write.
|
|
|
|
$::SIG{TERM} = 'IGNORE';
|
|
|
|
$::SIG{PIPE} = 'IGNORE';
|
|
|
|
|
2003-08-06 05:46:14 +04:00
|
|
|
# The following subroutine is for debugging purposes only.
|
|
|
|
# Uncommenting this sub and the $::SIG{__DIE__} trap underneath it will
|
|
|
|
# cause any fatal errors to result in a call stack trace to help track
|
|
|
|
# down weird errors.
|
|
|
|
#sub die_with_dignity {
|
|
|
|
# use Carp; # for confess()
|
|
|
|
# my ($err_msg) = @_;
|
|
|
|
# print $err_msg;
|
|
|
|
# confess($err_msg);
|
|
|
|
#}
|
|
|
|
#$::SIG{__DIE__} = \&die_with_dignity;
|
2001-07-04 08:41:27 +04:00
|
|
|
|
2002-08-29 13:25:54 +04:00
|
|
|
# XXXX - this needs to go away
|
1998-09-16 01:49:26 +04:00
|
|
|
sub GenerateVersionTable {
|
2005-03-10 11:07:34 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
|
|
|
|
2002-08-12 09:43:05 +04:00
|
|
|
SendSQL("SELECT versions.value, products.name " .
|
|
|
|
"FROM versions, products " .
|
|
|
|
"WHERE products.id = versions.product_id " .
|
|
|
|
"ORDER BY versions.value");
|
1998-09-16 01:49:26 +04:00
|
|
|
my @line;
|
|
|
|
my %varray;
|
|
|
|
my %carray;
|
|
|
|
while (@line = FetchSQLData()) {
|
|
|
|
my ($v,$p1) = (@line);
|
|
|
|
if (!defined $::versions{$p1}) {
|
|
|
|
$::versions{$p1} = [];
|
|
|
|
}
|
|
|
|
push @{$::versions{$p1}}, $v;
|
|
|
|
$varray{$v} = 1;
|
|
|
|
}
|
2002-08-12 09:43:05 +04:00
|
|
|
SendSQL("SELECT components.name, products.name " .
|
|
|
|
"FROM components, products " .
|
|
|
|
"WHERE products.id = components.product_id " .
|
|
|
|
"ORDER BY components.name");
|
1998-09-16 01:49:26 +04:00
|
|
|
while (@line = FetchSQLData()) {
|
|
|
|
my ($c,$p) = (@line);
|
|
|
|
if (!defined $::components{$p}) {
|
|
|
|
$::components{$p} = [];
|
|
|
|
}
|
|
|
|
my $ref = $::components{$p};
|
|
|
|
push @$ref, $c;
|
|
|
|
$carray{$c} = 1;
|
|
|
|
}
|
|
|
|
|
2004-08-21 01:49:20 +04:00
|
|
|
SendSQL("SELECT products.name, classifications.name " .
|
|
|
|
"FROM products, classifications " .
|
|
|
|
"WHERE classifications.id = products.classification_id " .
|
|
|
|
"ORDER BY classifications.name");
|
|
|
|
while (@line = FetchSQLData()) {
|
|
|
|
my ($p,$c) = (@line);
|
|
|
|
if (!defined $::classifications{$c}) {
|
|
|
|
$::classifications{$c} = [];
|
|
|
|
}
|
|
|
|
my $ref = $::classifications{$c};
|
|
|
|
push @$ref, $p;
|
|
|
|
}
|
|
|
|
|
2000-03-24 03:43:40 +03:00
|
|
|
my $dotargetmilestone = 1; # This used to check the param, but there's
|
|
|
|
# enough code that wants to pretend we're using
|
|
|
|
# target milestones, even if they don't get
|
|
|
|
# shown to the user. So we cache all the data
|
|
|
|
# about them anyway.
|
1999-02-03 05:46:51 +03:00
|
|
|
|
|
|
|
my $mpart = $dotargetmilestone ? ", milestoneurl" : "";
|
2004-08-21 01:49:20 +04:00
|
|
|
|
2005-05-02 22:52:02 +04:00
|
|
|
SendSQL("SELECT name, description, votesperuser, disallownew$mpart " .
|
|
|
|
"FROM products ORDER BY name");
|
1998-10-07 00:23:40 +04:00
|
|
|
while (@line = FetchSQLData()) {
|
1999-10-08 03:54:52 +04:00
|
|
|
my ($p, $d, $votesperuser, $dis, $u) = (@line);
|
1998-10-07 00:23:40 +04:00
|
|
|
$::proddesc{$p} = $d;
|
2003-11-07 00:55:25 +03:00
|
|
|
if (!$dis && scalar($::components{$p})) {
|
2002-02-14 04:25:25 +03:00
|
|
|
push @::enterable_products, $p;
|
1999-03-03 21:16:24 +03:00
|
|
|
}
|
1999-02-03 05:46:51 +03:00
|
|
|
if ($dotargetmilestone) {
|
|
|
|
$::milestoneurl{$p} = $u;
|
|
|
|
}
|
1999-10-08 03:54:52 +04:00
|
|
|
$::prodmaxvotes{$p} = $votesperuser;
|
1998-10-07 00:23:40 +04:00
|
|
|
}
|
|
|
|
|
2005-03-10 11:07:34 +03:00
|
|
|
@::log_columns = $dbh->bz_table_columns('bugs');
|
1998-09-16 01:49:26 +04:00
|
|
|
|
2000-01-22 07:24:42 +03:00
|
|
|
foreach my $i ("bug_id", "creation_ts", "delta_ts", "lastdiffed") {
|
1998-09-16 01:49:26 +04:00
|
|
|
my $w = lsearch(\@::log_columns, $i);
|
|
|
|
if ($w >= 0) {
|
|
|
|
splice(@::log_columns, $w, 1);
|
|
|
|
}
|
|
|
|
}
|
1999-03-24 01:32:21 +03:00
|
|
|
@::log_columns = (sort(@::log_columns));
|
1998-09-16 01:49:26 +04:00
|
|
|
|
2005-02-25 01:43:28 +03: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 07:20:17 +04: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-16 01:49:26 +04:00
|
|
|
if ($w >= 0) {
|
2000-07-14 07:20:17 +04:00
|
|
|
splice(@::settable_resolution, $w, 1);
|
|
|
|
}
|
|
|
|
my $z = lsearch(\@::settable_resolution, "MOVED");
|
|
|
|
if ($z >= 0) {
|
|
|
|
splice(@::settable_resolution, $z, 1);
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
my @list = sort { uc($a) cmp uc($b)} keys(%::versions);
|
|
|
|
@::legal_product = @list;
|
|
|
|
|
2003-04-25 01:17:31 +04:00
|
|
|
require File::Temp;
|
|
|
|
my ($fh, $tmpname) = File::Temp::tempfile("versioncache.XXXXX",
|
2003-11-22 06:50:42 +03:00
|
|
|
DIR => "$datadir");
|
2003-04-25 01:17:31 +04: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-20 03:49:37 +04:00
|
|
|
|
2002-10-16 14:49:56 +04:00
|
|
|
require Data::Dumper;
|
2003-04-25 04:47:17 +04:00
|
|
|
print $fh (Data::Dumper->Dump([\@::log_columns, \%::versions],
|
|
|
|
['*::log_columns', '*::versions']));
|
1998-09-16 01:49:26 +04:00
|
|
|
|
|
|
|
foreach my $i (@list) {
|
|
|
|
if (!defined $::components{$i}) {
|
2001-07-01 06:00:56 +04:00
|
|
|
$::components{$i} = [];
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@::legal_versions = sort {uc($a) cmp uc($b)} keys(%varray);
|
2003-04-25 04:47:17 +04:00
|
|
|
print $fh (Data::Dumper->Dump([\@::legal_versions, \%::components],
|
|
|
|
['*::legal_versions', '*::components']));
|
1998-09-16 01:49:26 +04:00
|
|
|
@::legal_components = sort {uc($a) cmp uc($b)} keys(%carray);
|
2002-08-29 13:25:54 +04:00
|
|
|
|
2003-04-25 04:47:17 +04:00
|
|
|
print $fh (Data::Dumper->Dump([\@::legal_components, \@::legal_product,
|
|
|
|
\@::legal_priority, \@::legal_severity,
|
|
|
|
\@::legal_platform, \@::legal_opsys,
|
|
|
|
\@::legal_bug_status, \@::legal_resolution],
|
|
|
|
['*::legal_components', '*::legal_product',
|
|
|
|
'*::legal_priority', '*::legal_severity',
|
|
|
|
'*::legal_platform', '*::legal_opsys',
|
|
|
|
'*::legal_bug_status', '*::legal_resolution']));
|
2002-08-29 13:25:54 +04:00
|
|
|
|
2003-04-25 04:47:17 +04:00
|
|
|
print $fh (Data::Dumper->Dump([\@::settable_resolution, \%::proddesc,
|
2005-10-12 02:13:06 +04:00
|
|
|
\%::classifications,
|
2003-04-25 04:47:17 +04:00
|
|
|
\@::enterable_products, \%::prodmaxvotes],
|
|
|
|
['*::settable_resolution', '*::proddesc',
|
2005-10-12 02:13:06 +04:00
|
|
|
'*::classifications',
|
2003-04-25 04:47:17 +04:00
|
|
|
'*::enterable_products', '*::prodmaxvotes']));
|
1998-09-16 01:49:26 +04:00
|
|
|
|
1999-02-03 05:46:51 +03:00
|
|
|
if ($dotargetmilestone) {
|
2000-03-21 19:47:06 +03:00
|
|
|
# reading target milestones in from the database - matthew@zeroknowledge.com
|
2002-08-12 09:43:05 +04:00
|
|
|
SendSQL("SELECT milestones.value, products.name " .
|
|
|
|
"FROM milestones, products " .
|
|
|
|
"WHERE products.id = milestones.product_id " .
|
|
|
|
"ORDER BY milestones.sortkey, milestones.value");
|
2000-03-21 19:47:06 +03:00
|
|
|
my @line;
|
|
|
|
my %tmarray;
|
|
|
|
@::legal_target_milestone = ();
|
|
|
|
while(@line = FetchSQLData()) {
|
|
|
|
my ($tm, $pr) = (@line);
|
|
|
|
if (!defined $::target_milestone{$pr}) {
|
|
|
|
$::target_milestone{$pr} = [];
|
|
|
|
}
|
|
|
|
push @{$::target_milestone{$pr}}, $tm;
|
|
|
|
if (!exists $tmarray{$tm}) {
|
|
|
|
$tmarray{$tm} = 1;
|
|
|
|
push(@::legal_target_milestone, $tm);
|
|
|
|
}
|
1999-01-28 00:17:10 +03:00
|
|
|
}
|
2000-03-21 19:47:06 +03:00
|
|
|
|
2003-04-25 04:47:17 +04:00
|
|
|
print $fh (Data::Dumper->Dump([\%::target_milestone,
|
|
|
|
\@::legal_target_milestone,
|
|
|
|
\%::milestoneurl],
|
|
|
|
['*::target_milestone',
|
|
|
|
'*::legal_target_milestone',
|
|
|
|
'*::milestoneurl']));
|
1999-01-28 00:17:10 +03:00
|
|
|
}
|
2000-01-07 00:16:15 +03:00
|
|
|
|
|
|
|
SendSQL("SELECT id, name FROM keyworddefs ORDER BY name");
|
|
|
|
while (MoreSQLData()) {
|
|
|
|
my ($id, $name) = FetchSQLData();
|
2000-07-14 19:31:43 +04:00
|
|
|
push(@::legal_keywords, $name);
|
2000-07-14 00:04:15 +04:00
|
|
|
$name = lc($name);
|
2000-01-07 00:16:15 +03:00
|
|
|
$::keywordsbyname{$name} = $id;
|
|
|
|
}
|
2002-08-29 13:25:54 +04:00
|
|
|
|
2003-04-25 04:47:17 +04:00
|
|
|
print $fh (Data::Dumper->Dump([\@::legal_keywords, \%::keywordsbyname],
|
|
|
|
['*::legal_keywords', '*::keywordsbyname']));
|
2000-01-07 00:16:15 +03:00
|
|
|
|
2003-04-25 01:17:31 +04:00
|
|
|
print $fh "1;\n";
|
|
|
|
close $fh;
|
2002-08-29 13:25:54 +04:00
|
|
|
|
2005-07-13 02:35:04 +04:00
|
|
|
rename ($tmpname, "$datadir/versioncache")
|
|
|
|
|| die "Can't rename $tmpname to versioncache";
|
2003-11-22 06:50:42 +03:00
|
|
|
ChmodDataFile("$datadir/versioncache", 0666);
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-14 00:04:15 +04:00
|
|
|
sub GetKeywordIdFromName {
|
|
|
|
my ($name) = (@_);
|
|
|
|
$name = lc($name);
|
|
|
|
return $::keywordsbyname{$name};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-08 01:26:49 +04:00
|
|
|
$::VersionTableLoaded = 0;
|
1998-09-16 01:49:26 +04:00
|
|
|
sub GetVersionTable {
|
2001-06-08 01:26:49 +04:00
|
|
|
return if $::VersionTableLoaded;
|
2005-07-19 18:52:59 +04:00
|
|
|
my $file_generated = 0;
|
|
|
|
if (!-r "$datadir/versioncache") {
|
1998-09-16 01:49:26 +04:00
|
|
|
GenerateVersionTable();
|
2005-07-19 18:52:59 +04:00
|
|
|
$file_generated = 1;
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
2003-11-22 06:50:42 +03:00
|
|
|
require "$datadir/versioncache";
|
2005-07-19 18:52:59 +04:00
|
|
|
if (!defined %::versions && !$file_generated) {
|
1998-09-16 01:49:26 +04:00
|
|
|
GenerateVersionTable();
|
2003-11-22 06:50:42 +03:00
|
|
|
do "$datadir/versioncache";
|
2005-07-19 18:52:59 +04:00
|
|
|
}
|
|
|
|
if (!defined %::versions) {
|
|
|
|
die "Can't generate file $datadir/versioncache";
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
2001-06-08 01:26:49 +04:00
|
|
|
$::VersionTableLoaded = 1;
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
#
|
|
|
|
# This function checks if there are any entry groups defined.
|
|
|
|
# If called with no arguments, it identifies
|
|
|
|
# entry groups for all products. If called with a product
|
|
|
|
# id argument, it checks for entry groups associated with
|
|
|
|
# one particular product.
|
|
|
|
sub AnyEntryGroups {
|
|
|
|
my $product_id = shift;
|
|
|
|
$product_id = 0 unless ($product_id);
|
|
|
|
return $::CachedAnyEntryGroups{$product_id}
|
|
|
|
if defined($::CachedAnyEntryGroups{$product_id});
|
2005-02-18 19:14:27 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
2002-11-24 22:56:34 +03:00
|
|
|
PushGlobalSQLState();
|
|
|
|
my $query = "SELECT 1 FROM group_control_map WHERE entry != 0";
|
|
|
|
$query .= " AND product_id = $product_id" if ($product_id);
|
2005-02-18 19:14:27 +03:00
|
|
|
$query .= " " . $dbh->sql_limit(1);
|
2002-11-24 22:56:34 +03:00
|
|
|
SendSQL($query);
|
2003-01-23 10:43:06 +03:00
|
|
|
if (MoreSQLData()) {
|
|
|
|
$::CachedAnyEntryGroups{$product_id} = MoreSQLData();
|
|
|
|
FetchSQLData();
|
|
|
|
PopGlobalSQLState();
|
|
|
|
return $::CachedAnyEntryGroups{$product_id};
|
|
|
|
} else {
|
|
|
|
return undef;
|
|
|
|
}
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
|
|
|
#
|
|
|
|
# This function checks if there are any default groups defined.
|
|
|
|
# If so, then groups may have to be changed when bugs move from
|
|
|
|
# one bug to another.
|
|
|
|
sub AnyDefaultGroups {
|
|
|
|
return $::CachedAnyDefaultGroups if defined($::CachedAnyDefaultGroups);
|
2005-02-18 19:14:27 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
2002-11-24 22:56:34 +03:00
|
|
|
PushGlobalSQLState();
|
|
|
|
SendSQL("SELECT 1 FROM group_control_map, groups WHERE " .
|
|
|
|
"groups.id = group_control_map.group_id " .
|
|
|
|
"AND isactive != 0 AND " .
|
|
|
|
"(membercontrol = " . CONTROLMAPDEFAULT .
|
|
|
|
" OR othercontrol = " . CONTROLMAPDEFAULT .
|
2005-02-18 19:14:27 +03:00
|
|
|
") " . $dbh->sql_limit(1));
|
2002-11-24 22:56:34 +03:00
|
|
|
$::CachedAnyDefaultGroups = MoreSQLData();
|
|
|
|
FetchSQLData();
|
|
|
|
PopGlobalSQLState();
|
|
|
|
return $::CachedAnyDefaultGroups;
|
|
|
|
}
|
|
|
|
|
2004-08-21 01:49:20 +04:00
|
|
|
sub IsInClassification {
|
|
|
|
my ($classification,$productname) = @_;
|
|
|
|
|
|
|
|
if (! Param('useclassification')) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
my $query = "SELECT classifications.name " .
|
|
|
|
"FROM products,classifications " .
|
|
|
|
"WHERE products.classification_id=classifications.id ";
|
|
|
|
$query .= "AND products.name = " . SqlQuote($productname);
|
|
|
|
PushGlobalSQLState();
|
|
|
|
SendSQL($query);
|
|
|
|
my ($ret) = FetchSQLData();
|
|
|
|
PopGlobalSQLState();
|
|
|
|
return ($ret eq $classification);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-11 09:29:21 +04:00
|
|
|
sub ValidatePassword {
|
|
|
|
# Determines whether or not a password is valid (i.e. meets Bugzilla's
|
2002-10-06 15:52:37 +04:00
|
|
|
# requirements for length and content).
|
2001-07-11 09:29:21 +04:00
|
|
|
# If a second password is passed in, this function also verifies that
|
|
|
|
# the two passwords match.
|
|
|
|
my ($password, $matchpassword) = @_;
|
|
|
|
|
2002-10-06 15:52:37 +04:00
|
|
|
if (length($password) < 3) {
|
2005-03-05 03:18:48 +03:00
|
|
|
ThrowUserError("password_too_short");
|
2002-10-06 15:52:37 +04:00
|
|
|
} elsif (length($password) > 16) {
|
2005-03-05 03:18:48 +03:00
|
|
|
ThrowUserError("password_too_long");
|
2004-03-03 08:19:28 +03:00
|
|
|
} elsif ((defined $matchpassword) && ($password ne $matchpassword)) {
|
2005-03-05 03:18:48 +03:00
|
|
|
ThrowUserError("passwords_dont_match");
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
2000-04-21 22:45:55 +04:00
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
|
|
|
|
sub DBID_to_name {
|
|
|
|
my ($id) = (@_);
|
2005-03-15 08:20:48 +03:00
|
|
|
return "__UNKNOWN__" if !defined $id;
|
2001-07-04 08:41:27 +04:00
|
|
|
# $id should always be a positive integer
|
|
|
|
if ($id =~ m/^([1-9][0-9]*)$/) {
|
|
|
|
$id = $1;
|
|
|
|
} else {
|
|
|
|
$::cachedNameArray{$id} = "__UNKNOWN__";
|
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
if (!defined $::cachedNameArray{$id}) {
|
2001-03-20 00:03:52 +03:00
|
|
|
PushGlobalSQLState();
|
2005-05-02 22:52:02 +04:00
|
|
|
SendSQL("SELECT login_name FROM profiles WHERE userid = $id");
|
1998-09-16 01:49:26 +04:00
|
|
|
my $r = FetchOneColumn();
|
2001-03-20 00:03:52 +03:00
|
|
|
PopGlobalSQLState();
|
2000-05-08 22:23:55 +04:00
|
|
|
if (!defined $r || $r eq "") {
|
1998-09-16 01:49:26 +04:00
|
|
|
$r = "__UNKNOWN__";
|
|
|
|
}
|
|
|
|
$::cachedNameArray{$id} = $r;
|
|
|
|
}
|
|
|
|
return $::cachedNameArray{$id};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub DBNameToIdAndCheck {
|
2002-04-25 01:41:51 +04:00
|
|
|
my ($name) = (@_);
|
2005-02-25 02:42:48 +03:00
|
|
|
my $result = login_to_id($name);
|
1998-09-16 01:49:26 +04:00
|
|
|
if ($result > 0) {
|
|
|
|
return $result;
|
|
|
|
}
|
2002-04-25 01:41:51 +04:00
|
|
|
|
2005-03-05 03:18:48 +03:00
|
|
|
ThrowUserError("invalid_username", { name => $name });
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
|
2002-08-12 09:43:05 +04:00
|
|
|
sub get_product_id {
|
|
|
|
my ($prod) = @_;
|
|
|
|
PushGlobalSQLState();
|
|
|
|
SendSQL("SELECT id FROM products WHERE name = " . SqlQuote($prod));
|
|
|
|
my ($prod_id) = FetchSQLData();
|
|
|
|
PopGlobalSQLState();
|
|
|
|
return $prod_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub get_product_name {
|
|
|
|
my ($prod_id) = @_;
|
|
|
|
die "non-numeric prod_id '$prod_id' passed to get_product_name"
|
|
|
|
unless ($prod_id =~ /^\d+$/);
|
|
|
|
PushGlobalSQLState();
|
|
|
|
SendSQL("SELECT name FROM products WHERE id = $prod_id");
|
|
|
|
my ($prod) = FetchSQLData();
|
|
|
|
PopGlobalSQLState();
|
|
|
|
return $prod;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub get_component_id {
|
|
|
|
my ($prod_id, $comp) = @_;
|
2004-02-13 23:24:51 +03:00
|
|
|
return undef unless ($prod_id && ($prod_id =~ /^\d+$/));
|
2002-08-12 09:43:05 +04:00
|
|
|
PushGlobalSQLState();
|
|
|
|
SendSQL("SELECT id FROM components " .
|
|
|
|
"WHERE product_id = $prod_id AND name = " . SqlQuote($comp));
|
|
|
|
my ($comp_id) = FetchSQLData();
|
|
|
|
PopGlobalSQLState();
|
|
|
|
return $comp_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub get_component_name {
|
|
|
|
my ($comp_id) = @_;
|
|
|
|
die "non-numeric comp_id '$comp_id' passed to get_component_name"
|
|
|
|
unless ($comp_id =~ /^\d+$/);
|
|
|
|
PushGlobalSQLState();
|
|
|
|
SendSQL("SELECT name FROM components WHERE id = $comp_id");
|
|
|
|
my ($comp) = FetchSQLData();
|
|
|
|
PopGlobalSQLState();
|
|
|
|
return $comp;
|
|
|
|
}
|
|
|
|
|
2000-03-10 21:01:32 +03:00
|
|
|
# This routine quoteUrls contains inspirations from the HTML::FromText CPAN
|
|
|
|
# module by Gareth Rees <garethr@cre.canon.co.uk>. It has been heavily hacked,
|
|
|
|
# all that is really recognizable from the original is bits of the regular
|
|
|
|
# expressions.
|
2002-07-03 06:45:13 +04:00
|
|
|
# This has been rewritten to be faster, mainly by substituting 'as we go'.
|
|
|
|
# If you want to modify this routine, read the comments carefully
|
2000-03-10 21:01:32 +03:00
|
|
|
|
|
|
|
sub quoteUrls {
|
2002-02-20 02:22:24 +03:00
|
|
|
my ($text) = (@_);
|
2000-03-10 21:01:32 +03:00
|
|
|
return $text unless $text;
|
|
|
|
|
2002-07-03 06:45:13 +04:00
|
|
|
# We use /g for speed, but uris can have other things inside them
|
|
|
|
# (http://foo/bug#3 for example). Filtering that out filters valid
|
|
|
|
# bug refs out, so we have to do replacements.
|
|
|
|
# mailto can't contain space or #, so we don't have to bother for that
|
|
|
|
# Do this by escaping \0 to \1\0, and replacing matches with \0\0$count\0\0
|
|
|
|
# \0 is used because its unliklely to occur in the text, so the cost of
|
|
|
|
# doing this should be very small
|
|
|
|
# Also, \0 won't appear in the value_quote'd bug title, so we don't have
|
|
|
|
# to worry about bogus substitutions from there
|
|
|
|
|
|
|
|
# escape the 2nd escape char we're using
|
|
|
|
my $chr1 = chr(1);
|
|
|
|
$text =~ s/\0/$chr1\0/g;
|
|
|
|
|
|
|
|
# However, note that adding the title (for buglinks) can affect things
|
|
|
|
# In particular, attachment matches go before bug titles, so that titles
|
|
|
|
# with 'attachment 1' don't double match.
|
|
|
|
# Dupe checks go afterwards, because that uses ^ and \Z, which won't occur
|
|
|
|
# if it was subsituted as a bug title (since that always involve leading
|
|
|
|
# and trailing text)
|
|
|
|
|
|
|
|
# Because of entities, its easier (and quicker) to do this before escaping
|
2000-03-10 21:01:32 +03:00
|
|
|
|
|
|
|
my @things;
|
2002-07-03 06:45:13 +04:00
|
|
|
my $count = 0;
|
|
|
|
my $tmp;
|
|
|
|
|
|
|
|
# non-mailto protocols
|
2004-01-14 21:07:32 +03:00
|
|
|
my $protocol_re = qr/(afs|cid|ftp|gopher|http|https|irc|mid|news|nntp|prospero|telnet|view-source|wais)/i;
|
2002-07-03 06:45:13 +04:00
|
|
|
|
|
|
|
$text =~ s~\b(${protocol_re}: # The protocol:
|
|
|
|
[^\s<>\"]+ # Any non-whitespace
|
|
|
|
[\w\/]) # so that we end in \w or /
|
|
|
|
~($tmp = html_quote($1)) &&
|
|
|
|
($things[$count++] = "<a href=\"$tmp\">$tmp</a>") &&
|
|
|
|
("\0\0" . ($count-1) . "\0\0")
|
|
|
|
~egox;
|
|
|
|
|
|
|
|
# We have to quote now, otherwise our html is itsself escaped
|
|
|
|
# THIS MEANS THAT A LITERAL ", <, >, ' MUST BE ESCAPED FOR A MATCH
|
|
|
|
|
|
|
|
$text = html_quote($text);
|
|
|
|
|
|
|
|
# mailto:
|
|
|
|
# Use |<nothing> so that $1 is defined regardless
|
|
|
|
$text =~ s~\b(mailto:|)?([\w\.\-\+\=]+\@[\w\-]+(?:\.[\w\-]+)+)\b
|
|
|
|
~<a href=\"mailto:$2\">$1$2</a>~igx;
|
|
|
|
|
2004-05-12 09:08:28 +04:00
|
|
|
# attachment links - handle both cases separately for simplicity
|
2005-09-10 02:22:41 +04:00
|
|
|
$text =~ s~((?:^Created\ an\ |\b)attachment\s*\(id=(\d+)\)(\s\[edit\])?)
|
2004-05-12 09:08:28 +04:00
|
|
|
~($things[$count++] = GetAttachmentLink($2, $1)) &&
|
|
|
|
("\0\0" . ($count-1) . "\0\0")
|
2003-07-27 05:16:45 +04:00
|
|
|
~egmx;
|
2002-07-03 06:45:13 +04:00
|
|
|
|
|
|
|
$text =~ s~\b(attachment\s*\#?\s*(\d+))
|
2004-05-12 09:08:28 +04:00
|
|
|
~($things[$count++] = GetAttachmentLink($2, $1)) &&
|
|
|
|
("\0\0" . ($count-1) . "\0\0")
|
2004-03-22 09:45:21 +03:00
|
|
|
~egmxi;
|
2002-07-03 06:45:13 +04:00
|
|
|
|
|
|
|
# This handles bug a, comment b type stuff. Because we're using /g
|
|
|
|
# we have to do this in one pattern, and so this is semi-messy.
|
|
|
|
# Also, we can't use $bug_re?$comment_re? because that will match the
|
|
|
|
# empty string
|
|
|
|
my $bug_re = qr/bug\s*\#?\s*(\d+)/i;
|
|
|
|
my $comment_re = qr/comment\s*\#?\s*(\d+)/i;
|
|
|
|
$text =~ s~\b($bug_re(?:\s*,?\s*$comment_re)?|$comment_re)
|
|
|
|
~ # We have several choices. $1 here is the link, and $2-4 are set
|
|
|
|
# depending on which part matched
|
|
|
|
(defined($2) ? GetBugLink($2,$1,$3) :
|
|
|
|
"<a href=\"#c$4\">$1</a>")
|
|
|
|
~egox;
|
|
|
|
|
2005-07-26 18:36:13 +04:00
|
|
|
# Old duplicate markers
|
2002-07-03 06:45:13 +04:00
|
|
|
$text =~ s~(?<=^\*\*\*\ This\ bug\ has\ been\ marked\ as\ a\ duplicate\ of\ )
|
|
|
|
(\d+)
|
|
|
|
(?=\ \*\*\*\Z)
|
|
|
|
~GetBugLink($1, $1)
|
|
|
|
~egmx;
|
|
|
|
|
|
|
|
# Now remove the encoding hacks
|
|
|
|
$text =~ s/\0\0(\d+)\0\0/$things[$1]/eg;
|
|
|
|
$text =~ s/$chr1\0/\0/g;
|
2000-03-10 21:01:32 +03:00
|
|
|
|
2001-01-25 01:24:06 +03:00
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
2003-07-27 05:16:45 +04:00
|
|
|
# GetAttachmentLink creates a link to an attachment,
|
|
|
|
# including its title.
|
|
|
|
|
|
|
|
sub GetAttachmentLink {
|
|
|
|
my ($attachid, $link_text) = @_;
|
|
|
|
detaint_natural($attachid) ||
|
|
|
|
die "GetAttachmentLink() called with non-integer attachment number";
|
|
|
|
|
|
|
|
# If we've run GetAttachmentLink() for this attachment before,
|
|
|
|
# %::attachlink will contain an anonymous array ref of relevant
|
|
|
|
# values. If not, we need to get the information from the database.
|
|
|
|
if (! defined $::attachlink{$attachid}) {
|
|
|
|
# Make sure any unfetched data from a currently running query
|
|
|
|
# is saved off rather than overwritten
|
|
|
|
PushGlobalSQLState();
|
|
|
|
|
|
|
|
SendSQL("SELECT bug_id, isobsolete, description
|
|
|
|
FROM attachments WHERE attach_id = $attachid");
|
|
|
|
|
|
|
|
if (MoreSQLData()) {
|
|
|
|
my ($bugid, $isobsolete, $desc) = FetchSQLData();
|
|
|
|
my $title = "";
|
|
|
|
my $className = "";
|
2004-08-04 20:17:10 +04:00
|
|
|
if (Bugzilla->user->can_see_bug($bugid)) {
|
2003-07-27 05:16:45 +04:00
|
|
|
$title = $desc;
|
|
|
|
}
|
|
|
|
if ($isobsolete) {
|
|
|
|
$className = "bz_obsolete";
|
|
|
|
}
|
|
|
|
$::attachlink{$attachid} = [value_quote($title), $className];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# Even if there's nothing in the database, we want to save a blank
|
|
|
|
# anonymous array in the %::attachlink hash so the query doesn't get
|
|
|
|
# run again next time we're called for this attachment number.
|
|
|
|
$::attachlink{$attachid} = [];
|
|
|
|
}
|
|
|
|
# All done with this sidetrip
|
|
|
|
PopGlobalSQLState();
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now that we know we've got all the information we're gonna get, let's
|
|
|
|
# return the link (which is the whole reason we were called :)
|
|
|
|
my ($title, $className) = @{$::attachlink{$attachid}};
|
2004-07-24 04:20:43 +04:00
|
|
|
# $title will be undefined if the attachment didn't exist in the database.
|
2003-07-27 05:16:45 +04:00
|
|
|
if (defined $title) {
|
2005-09-10 02:22:41 +04:00
|
|
|
$link_text =~ s/ \[edit\]$//;
|
|
|
|
my $linkval = "attachment.cgi?id=$attachid&action=";
|
|
|
|
# Whitespace matters here because these links are in <pre> tags.
|
|
|
|
return qq|<span class="$className">|
|
|
|
|
. qq|<a href="${linkval}view" title="$title">$link_text</a>|
|
|
|
|
. qq| <a href="${linkval}edit" title="$title">[edit]</a>|
|
|
|
|
. qq|</span>|;
|
2003-07-27 05:16:45 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return qq{$link_text};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-03 06:45:13 +04:00
|
|
|
# GetBugLink creates a link to a bug, including its title.
|
2002-09-06 07:59:06 +04:00
|
|
|
# It takes either two or three parameters:
|
2002-07-03 06:45:13 +04:00
|
|
|
# - The bug number
|
|
|
|
# - The link text, to place between the <a>..</a>
|
|
|
|
# - An optional comment number, for linking to a particular
|
|
|
|
# comment in the bug
|
2001-01-25 01:24:06 +03:00
|
|
|
|
|
|
|
sub GetBugLink {
|
2002-07-03 06:45:13 +04:00
|
|
|
my ($bug_num, $link_text, $comment_num) = @_;
|
2005-05-12 21:52:46 +04:00
|
|
|
if (! defined $bug_num || $bug_num eq "") {
|
|
|
|
return "<missing bug number>";
|
|
|
|
}
|
|
|
|
my $quote_bug_num = html_quote($bug_num);
|
|
|
|
detaint_natural($bug_num) || return "<invalid bug number: $quote_bug_num>";
|
2001-11-12 16:43:59 +03:00
|
|
|
|
|
|
|
# If we've run GetBugLink() for this bug number before, %::buglink
|
|
|
|
# will contain an anonymous array ref of relevent values, if not
|
|
|
|
# we need to get the information from the database.
|
|
|
|
if (! defined $::buglink{$bug_num}) {
|
|
|
|
# Make sure any unfetched data from a currently running query
|
|
|
|
# is saved off rather than overwritten
|
|
|
|
PushGlobalSQLState();
|
2001-01-25 01:24:06 +03:00
|
|
|
|
2002-09-22 21:15:13 +04:00
|
|
|
SendSQL("SELECT bugs.bug_status, resolution, short_desc " .
|
2001-11-12 16:43:59 +03:00
|
|
|
"FROM bugs WHERE bugs.bug_id = $bug_num");
|
|
|
|
|
|
|
|
# If the bug exists, save its data off for use later in the sub
|
|
|
|
if (MoreSQLData()) {
|
2002-09-22 21:15:13 +04:00
|
|
|
my ($bug_state, $bug_res, $bug_desc) = FetchSQLData();
|
2001-11-12 16:43:59 +03:00
|
|
|
# Initialize these variables to be "" so that we don't get warnings
|
|
|
|
# if we don't change them below (which is highly likely).
|
|
|
|
my ($pre, $title, $post) = ("", "", "");
|
2000-12-12 06:47:40 +03:00
|
|
|
|
2001-11-12 16:43:59 +03:00
|
|
|
$title = $bug_state;
|
2005-02-08 19:22:26 +03:00
|
|
|
if ($bug_state eq 'UNCONFIRMED') {
|
2001-11-12 16:43:59 +03:00
|
|
|
$pre = "<i>";
|
|
|
|
$post = "</i>";
|
|
|
|
}
|
|
|
|
elsif (! IsOpenedState($bug_state)) {
|
2004-03-17 02:53:01 +03:00
|
|
|
$pre = '<span class="bz_closed">';
|
2001-11-12 16:43:59 +03:00
|
|
|
$title .= " $bug_res";
|
2004-03-17 02:53:01 +03:00
|
|
|
$post = '</span>';
|
2001-11-12 16:43:59 +03:00
|
|
|
}
|
2004-08-04 20:17:10 +04:00
|
|
|
if (Bugzilla->user->can_see_bug($bug_num)) {
|
2001-11-12 16:43:59 +03:00
|
|
|
$title .= " - $bug_desc";
|
|
|
|
}
|
|
|
|
$::buglink{$bug_num} = [$pre, value_quote($title), $post];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# Even if there's nothing in the database, we want to save a blank
|
|
|
|
# anonymous array in the %::buglink hash so the query doesn't get
|
|
|
|
# run again next time we're called for this bug number.
|
|
|
|
$::buglink{$bug_num} = [];
|
|
|
|
}
|
|
|
|
# All done with this sidetrip
|
|
|
|
PopGlobalSQLState();
|
|
|
|
}
|
2001-01-25 01:24:06 +03:00
|
|
|
|
2001-11-12 16:43:59 +03:00
|
|
|
# Now that we know we've got all the information we're gonna get, let's
|
|
|
|
# return the link (which is the whole reason we were called :)
|
|
|
|
my ($pre, $title, $post) = @{$::buglink{$bug_num}};
|
|
|
|
# $title will be undefined if the bug didn't exist in the database.
|
|
|
|
if (defined $title) {
|
2002-07-03 06:45:13 +04:00
|
|
|
my $linkval = "show_bug.cgi?id=$bug_num";
|
|
|
|
if (defined $comment_num) {
|
|
|
|
$linkval .= "#c$comment_num";
|
|
|
|
}
|
|
|
|
return qq{$pre<a href="$linkval" title="$title">$link_text</a>$post};
|
2001-11-12 16:43:59 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return qq{$link_text};
|
|
|
|
}
|
2000-03-10 21:01:32 +03:00
|
|
|
}
|
|
|
|
|
2005-02-25 01:43:28 +03: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 04:11:22 +03:00
|
|
|
my $result_ref = $dbh->selectcol_arrayref(
|
2005-04-12 05:27:57 +04:00
|
|
|
"SELECT value FROM $field
|
|
|
|
WHERE isactive = ?
|
|
|
|
ORDER BY sortkey, value", undef, (1));
|
2005-02-25 01:43:28 +03:00
|
|
|
return @$result_ref;
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
|
2002-09-22 21:15:13 +04:00
|
|
|
sub BugInGroupId {
|
|
|
|
my ($bugid, $groupid) = (@_);
|
|
|
|
PushGlobalSQLState();
|
2005-10-24 23:21:05 +04:00
|
|
|
SendSQL("SELECT CASE WHEN bug_id != 0 THEN 1 ELSE 0 END
|
|
|
|
FROM bug_group_map
|
2002-09-22 21:15:13 +04:00
|
|
|
WHERE bug_id = $bugid
|
|
|
|
AND group_id = $groupid");
|
2001-08-11 05:18:24 +04:00
|
|
|
my $bugingroup = FetchOneColumn();
|
|
|
|
PopGlobalSQLState();
|
|
|
|
return $bugingroup;
|
|
|
|
}
|
|
|
|
|
2000-03-10 19:25:03 +03:00
|
|
|
sub GroupExists {
|
|
|
|
my ($groupname) = (@_);
|
2002-06-03 17:36:39 +04:00
|
|
|
PushGlobalSQLState();
|
2002-09-22 21:15:13 +04:00
|
|
|
SendSQL("SELECT id FROM groups WHERE name=" . SqlQuote($groupname));
|
|
|
|
my $id = FetchOneColumn();
|
2002-06-03 17:36:39 +04:00
|
|
|
PopGlobalSQLState();
|
2002-09-22 21:15:13 +04:00
|
|
|
return $id;
|
2000-03-10 19:25:03 +03:00
|
|
|
}
|
1999-03-11 19:30:54 +03:00
|
|
|
|
2002-09-22 21:15:13 +04:00
|
|
|
sub GroupNameToId {
|
2001-08-11 05:18:24 +04:00
|
|
|
my ($groupname) = (@_);
|
|
|
|
PushGlobalSQLState();
|
2002-09-22 21:15:13 +04:00
|
|
|
SendSQL("SELECT id FROM groups WHERE name=" . SqlQuote($groupname));
|
|
|
|
my $id = FetchOneColumn();
|
2001-08-11 05:18:24 +04:00
|
|
|
PopGlobalSQLState();
|
2002-09-22 21:15:13 +04:00
|
|
|
return $id;
|
2001-08-11 05:18:24 +04:00
|
|
|
}
|
|
|
|
|
2002-09-22 21:15:13 +04:00
|
|
|
sub GroupIdToName {
|
|
|
|
my ($groupid) = (@_);
|
|
|
|
PushGlobalSQLState();
|
|
|
|
SendSQL("SELECT name FROM groups WHERE id = $groupid");
|
|
|
|
my $name = FetchOneColumn();
|
|
|
|
PopGlobalSQLState();
|
|
|
|
return $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-06 07:16:52 +04:00
|
|
|
# Determines whether or not a group is active by checking
|
|
|
|
# the "isactive" column for the group in the "groups" table.
|
2002-09-22 21:15:13 +04:00
|
|
|
# Note: This function selects groups by id rather than by name.
|
2001-06-06 07:16:52 +04:00
|
|
|
sub GroupIsActive {
|
2002-09-22 21:15:13 +04:00
|
|
|
my ($groupid) = (@_);
|
|
|
|
$groupid ||= 0;
|
2002-06-03 17:36:39 +04:00
|
|
|
PushGlobalSQLState();
|
2002-09-22 21:15:13 +04:00
|
|
|
SendSQL("SELECT isactive FROM groups WHERE id=$groupid");
|
2001-06-06 07:16:52 +04:00
|
|
|
my $isactive = FetchOneColumn();
|
2002-06-03 17:36:39 +04:00
|
|
|
PopGlobalSQLState();
|
2001-06-06 07:16:52 +04:00
|
|
|
return $isactive;
|
|
|
|
}
|
|
|
|
|
2000-01-23 04:03:15 +03:00
|
|
|
# Determines if the given bug_status string represents an "Opened" bug. This
|
2002-09-06 07:59:06 +04:00
|
|
|
# routine ought to be parameterizable somehow, as people tend to introduce
|
2000-01-23 04:03:15 +03:00
|
|
|
# new states into Bugzilla.
|
|
|
|
|
|
|
|
sub IsOpenedState {
|
|
|
|
my ($state) = (@_);
|
2001-09-15 01:50:08 +04:00
|
|
|
if (grep($_ eq $state, OpenStates())) {
|
2000-01-23 04:03:15 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-09-15 01:50:08 +04:00
|
|
|
# This sub will return an array containing any status that
|
|
|
|
# is considered an open bug.
|
|
|
|
|
|
|
|
sub OpenStates {
|
2005-02-08 19:22:26 +03:00
|
|
|
return ('NEW', 'REOPENED', 'ASSIGNED', 'UNCONFIRMED');
|
2001-09-15 01:50:08 +04:00
|
|
|
}
|
|
|
|
|
2002-12-20 10:21:43 +03:00
|
|
|
############# Live code below here (that is, not subroutine defs) #############
|
2002-02-03 12:28:48 +03:00
|
|
|
|
2002-12-20 10:21:43 +03:00
|
|
|
use Bugzilla;
|
2002-07-26 22:16:39 +04:00
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
1;
|