2000-06-09 00:30:10 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Dawn Endico <endico@mozilla.org>
|
|
|
|
# Terry Weissman <terry@mozilla.org>
|
2000-06-28 03:16:08 +04:00
|
|
|
# Chris Yeh <cyeh@bluemartini.com>
|
2000-06-09 00:30:10 +04:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use DBI;
|
|
|
|
use RelationSet;
|
2001-10-31 06:31:00 +03:00
|
|
|
use vars qw($unconfirmedstate $legal_keywords);
|
2002-09-05 02:43:38 +04:00
|
|
|
|
2000-06-09 00:30:10 +04:00
|
|
|
package Bug;
|
|
|
|
use CGI::Carp qw(fatalsToBrowser);
|
|
|
|
my %ok_field;
|
|
|
|
|
2002-08-29 13:25:54 +04:00
|
|
|
use Bugzilla::Config;
|
2002-08-19 17:59:45 +04:00
|
|
|
use Bugzilla::Util;
|
|
|
|
|
2002-07-04 03:07:14 +04:00
|
|
|
for my $key (qw (bug_id alias product version rep_platform op_sys bug_status
|
2000-06-09 00:30:10 +04:00
|
|
|
resolution priority bug_severity component assigned_to
|
|
|
|
reporter bug_file_loc short_desc target_milestone
|
2002-09-22 21:15:13 +04:00
|
|
|
qa_contact status_whiteboard creation_ts
|
|
|
|
delta_ts votes whoid comment query error) ){
|
2000-06-09 00:30:10 +04:00
|
|
|
$ok_field{$key}++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# create a new empty bug
|
|
|
|
#
|
|
|
|
sub new {
|
|
|
|
my $type = shift();
|
2000-06-12 10:52:41 +04:00
|
|
|
my %bug;
|
2000-06-09 00:30:10 +04:00
|
|
|
|
|
|
|
# create a ref to an empty hash and bless it
|
|
|
|
#
|
|
|
|
my $self = {%bug};
|
|
|
|
bless $self, $type;
|
|
|
|
|
|
|
|
# construct from a hash containing a bug's info
|
|
|
|
#
|
|
|
|
if ($#_ == 1) {
|
|
|
|
$self->initBug(@_);
|
|
|
|
} else {
|
|
|
|
confess("invalid number of arguments \($#_\)($_)");
|
|
|
|
}
|
|
|
|
|
|
|
|
# bless as a Bug
|
|
|
|
#
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# dump info about bug into hash unless user doesn't have permission
|
|
|
|
# user_id 0 is used when person is not logged in.
|
|
|
|
#
|
|
|
|
sub initBug {
|
|
|
|
my $self = shift();
|
|
|
|
my ($bug_id, $user_id) = (@_);
|
|
|
|
|
2002-07-04 03:07:14 +04:00
|
|
|
# If the bug ID isn't numeric, it might be an alias, so try to convert it.
|
|
|
|
$bug_id = &::BugAliasToID($bug_id) if $bug_id !~ /^[1-9][0-9]*$/;
|
|
|
|
|
2002-01-20 04:44:52 +03:00
|
|
|
my $old_bug_id = $bug_id;
|
2002-08-19 17:59:45 +04:00
|
|
|
if ((! defined $bug_id) || (!$bug_id) || (!detaint_natural($bug_id))) {
|
2002-07-04 03:07:14 +04:00
|
|
|
# no bug number given or the alias didn't match a bug
|
2002-01-20 04:44:52 +03:00
|
|
|
$self->{'bug_id'} = $old_bug_id;
|
|
|
|
$self->{'error'} = "InvalidBugId";
|
|
|
|
return $self;
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
|
|
|
|
2000-06-28 03:16:08 +04:00
|
|
|
# default userid 0, or get DBID if you used an email address
|
|
|
|
unless (defined $user_id) {
|
2000-06-09 00:30:10 +04:00
|
|
|
$user_id = 0;
|
|
|
|
}
|
2000-06-28 03:16:08 +04:00
|
|
|
else {
|
|
|
|
if ($user_id =~ /^\@/) {
|
2001-10-31 06:31:00 +03:00
|
|
|
$user_id = &::DBname_to_id($user_id);
|
2000-06-28 03:16:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-09 00:30:10 +04:00
|
|
|
|
|
|
|
&::ConnectToDatabase();
|
|
|
|
&::GetVersionTable();
|
|
|
|
|
|
|
|
# this verification should already have been done by caller
|
|
|
|
# my $loginok = quietly_check_login();
|
2000-06-28 03:16:08 +04:00
|
|
|
|
|
|
|
|
|
|
|
$self->{'whoid'} = $user_id;
|
2000-06-09 00:30:10 +04:00
|
|
|
|
|
|
|
my $query = "
|
|
|
|
select
|
2002-08-12 09:43:05 +04:00
|
|
|
bugs.bug_id, alias, products.name, version, rep_platform, op_sys, bug_status,
|
|
|
|
resolution, priority, bug_severity, components.name, assigned_to, reporter,
|
2000-06-09 00:30:10 +04:00
|
|
|
bug_file_loc, short_desc, target_milestone, qa_contact,
|
|
|
|
status_whiteboard, date_format(creation_ts,'%Y-%m-%d %H:%i'),
|
2002-09-22 21:15:13 +04:00
|
|
|
delta_ts, sum(votes.count)
|
2002-08-12 09:43:05 +04:00
|
|
|
from bugs left join votes using(bug_id),
|
|
|
|
products, components
|
2000-06-09 00:30:10 +04:00
|
|
|
where bugs.bug_id = $bug_id
|
2002-08-12 09:43:05 +04:00
|
|
|
AND products.id = bugs.product_id
|
|
|
|
AND components.id = bugs.component_id
|
2000-06-09 00:30:10 +04:00
|
|
|
group by bugs.bug_id";
|
|
|
|
|
2002-09-22 21:15:13 +04:00
|
|
|
&::SendSQL($query);
|
|
|
|
my @row = ();
|
2000-06-09 00:30:10 +04:00
|
|
|
|
2002-09-22 21:15:13 +04:00
|
|
|
if ((@row = &::FetchSQLData()) && &::CanSeeBug($bug_id, $self->{'whoid'})) {
|
2000-06-09 00:30:10 +04:00
|
|
|
my $count = 0;
|
|
|
|
my %fields;
|
2002-07-04 03:07:14 +04:00
|
|
|
foreach my $field ("bug_id", "alias", "product", "version", "rep_platform",
|
2000-06-09 00:30:10 +04:00
|
|
|
"op_sys", "bug_status", "resolution", "priority",
|
|
|
|
"bug_severity", "component", "assigned_to", "reporter",
|
|
|
|
"bug_file_loc", "short_desc", "target_milestone",
|
|
|
|
"qa_contact", "status_whiteboard", "creation_ts",
|
2002-09-22 21:15:13 +04:00
|
|
|
"delta_ts", "votes") {
|
2001-10-31 06:31:00 +03:00
|
|
|
$fields{$field} = shift @row;
|
|
|
|
if ($fields{$field}) {
|
|
|
|
$self->{$field} = $fields{$field};
|
|
|
|
}
|
|
|
|
$count++;
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
2002-09-22 21:15:13 +04:00
|
|
|
} elsif (@row) {
|
2000-06-12 10:52:41 +04:00
|
|
|
$self->{'bug_id'} = $bug_id;
|
|
|
|
$self->{'error'} = "NotPermitted";
|
2000-06-09 00:30:10 +04:00
|
|
|
return $self;
|
2002-09-22 21:15:13 +04:00
|
|
|
} else {
|
2000-06-12 10:52:41 +04:00
|
|
|
$self->{'bug_id'} = $bug_id;
|
|
|
|
$self->{'error'} = "NotFound";
|
2000-06-09 00:30:10 +04:00
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2000-06-21 11:50:16 +04:00
|
|
|
$self->{'assigned_to'} = &::DBID_to_name($self->{'assigned_to'});
|
|
|
|
$self->{'reporter'} = &::DBID_to_name($self->{'reporter'});
|
2000-06-09 00:30:10 +04:00
|
|
|
|
|
|
|
my $ccSet = new RelationSet;
|
|
|
|
$ccSet->mergeFromDB("select who from cc where bug_id=$bug_id");
|
|
|
|
my @cc = $ccSet->toArrayOfStrings();
|
|
|
|
if (@cc) {
|
2000-06-12 10:52:41 +04:00
|
|
|
$self->{'cc'} = \@cc;
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
|
|
|
|
2002-08-29 13:25:54 +04:00
|
|
|
if (Param("useqacontact") && (defined $self->{'qa_contact'}) ) {
|
2000-06-12 10:52:41 +04:00
|
|
|
my $name = $self->{'qa_contact'} > 0 ? &::DBID_to_name($self->{'qa_contact'}) :"";
|
2000-06-09 00:30:10 +04:00
|
|
|
if ($name) {
|
2000-06-12 10:52:41 +04:00
|
|
|
$self->{'qa_contact'} = $name;
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (@::legal_keywords) {
|
|
|
|
&::SendSQL("SELECT keyworddefs.name
|
|
|
|
FROM keyworddefs, keywords
|
|
|
|
WHERE keywords.bug_id = $bug_id
|
|
|
|
AND keyworddefs.id = keywords.keywordid
|
|
|
|
ORDER BY keyworddefs.name");
|
|
|
|
my @list;
|
|
|
|
while (&::MoreSQLData()) {
|
|
|
|
push(@list, &::FetchOneColumn());
|
|
|
|
}
|
|
|
|
if (@list) {
|
2001-11-26 17:16:10 +03:00
|
|
|
$self->{'keywords'} = join(', ', @list);
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-27 02:24:58 +04:00
|
|
|
&::SendSQL("select attach_id, creation_ts, isprivate, description
|
|
|
|
from attachments
|
|
|
|
where bug_id = $bug_id");
|
|
|
|
my @attachments;
|
|
|
|
while (&::MoreSQLData()) {
|
|
|
|
my ($attachid, $date, $isprivate, $desc) = (&::FetchSQLData());
|
|
|
|
my %attach;
|
|
|
|
$attach{'attachid'} = $attachid;
|
|
|
|
$attach{'isprivate'} = $isprivate;
|
|
|
|
$attach{'date'} = $date;
|
|
|
|
$attach{'desc'} = $desc;
|
|
|
|
push @attachments, \%attach;
|
|
|
|
}
|
|
|
|
if (@attachments) {
|
|
|
|
$self->{'attachments'} = \@attachments;
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
|
|
|
|
2002-08-27 02:24:58 +04:00
|
|
|
&::SendSQL("select bug_id, who, bug_when, isprivate, thetext
|
2000-06-09 00:30:10 +04:00
|
|
|
from longdescs
|
|
|
|
where bug_id = $bug_id");
|
2002-08-27 02:24:58 +04:00
|
|
|
my @longdescs;
|
|
|
|
while (&::MoreSQLData()) {
|
|
|
|
my ($bug_id, $who, $bug_when, $isprivate, $thetext) = (&::FetchSQLData());
|
|
|
|
my %longdesc;
|
|
|
|
$longdesc{'who'} = $who;
|
|
|
|
$longdesc{'bug_when'} = $bug_when;
|
|
|
|
$longdesc{'isprivate'} = $isprivate;
|
|
|
|
$longdesc{'thetext'} = $thetext;
|
|
|
|
push @longdescs, \%longdesc;
|
|
|
|
}
|
|
|
|
if (@longdescs) {
|
|
|
|
$self->{'longdescs'} = \@longdescs;
|
|
|
|
}
|
2002-07-29 03:15:53 +04:00
|
|
|
|
|
|
|
my @depends = EmitDependList("blocked", "dependson", $bug_id);
|
|
|
|
if (@depends) {
|
2000-06-12 10:52:41 +04:00
|
|
|
$self->{'dependson'} = \@depends;
|
2002-07-29 03:15:53 +04:00
|
|
|
}
|
|
|
|
my @blocks = EmitDependList("dependson", "blocked", $bug_id);
|
|
|
|
if (@blocks) {
|
|
|
|
$self->{'blocks'} = \@blocks;
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
2000-06-28 03:16:08 +04:00
|
|
|
|
2000-06-09 00:30:10 +04:00
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# given a bug hash, emit xml for it. with file header provided by caller
|
|
|
|
#
|
|
|
|
sub emitXML {
|
|
|
|
( $#_ == 0 ) || confess("invalid number of arguments");
|
|
|
|
my $self = shift();
|
|
|
|
my $xml;
|
|
|
|
|
|
|
|
|
2000-06-12 10:52:41 +04:00
|
|
|
if (exists $self->{'error'}) {
|
|
|
|
$xml .= "<bug error=\"$self->{'error'}\">\n";
|
|
|
|
$xml .= " <bug_id>$self->{'bug_id'}</bug_id>\n";
|
2000-06-09 00:30:10 +04:00
|
|
|
$xml .= "</bug>\n";
|
|
|
|
return $xml;
|
|
|
|
}
|
|
|
|
|
|
|
|
$xml .= "<bug>\n";
|
|
|
|
|
2002-07-04 03:07:14 +04:00
|
|
|
foreach my $field ("bug_id", "alias", "bug_status", "product",
|
2000-06-09 00:30:10 +04:00
|
|
|
"priority", "version", "rep_platform", "assigned_to", "delta_ts",
|
|
|
|
"component", "reporter", "target_milestone", "bug_severity",
|
|
|
|
"creation_ts", "qa_contact", "op_sys", "resolution", "bug_file_loc",
|
|
|
|
"short_desc", "keywords", "status_whiteboard") {
|
2000-06-12 10:52:41 +04:00
|
|
|
if ($self->{$field}) {
|
2001-02-27 02:46:01 +03:00
|
|
|
$xml .= " <$field>" . QuoteXMLChars($self->{$field}) . "</$field>\n";
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $field ("dependson", "blocks", "cc") {
|
2000-06-12 10:52:41 +04:00
|
|
|
if (defined $self->{$field}) {
|
|
|
|
for (my $i=0 ; $i < @{$self->{$field}} ; $i++) {
|
|
|
|
$xml .= " <$field>" . $self->{$field}[$i] . "</$field>\n";
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-27 02:24:58 +04:00
|
|
|
if (defined $self->{'longdescs'}) {
|
|
|
|
for (my $i=0 ; $i < @{$self->{'longdescs'}} ; $i++) {
|
|
|
|
next if ($self->{'longdescs'}[$i]->{'isprivate'}
|
2002-08-29 13:25:54 +04:00
|
|
|
&& Param("insidergroup")
|
|
|
|
&& !&::UserInGroup(Param("insidergroup")));
|
2002-08-27 02:24:58 +04:00
|
|
|
$xml .= " <long_desc>\n";
|
|
|
|
$xml .= " <who>" . &::DBID_to_name($self->{'longdescs'}[$i]->{'who'})
|
|
|
|
. "</who>\n";
|
|
|
|
$xml .= " <bug_when>" . $self->{'longdescs'}[$i]->{'bug_when'}
|
|
|
|
. "</bug_when>\n";
|
|
|
|
$xml .= " <thetext>" . QuoteXMLChars($self->{'longdescs'}[$i]->{'thetext'})
|
|
|
|
. "</thetext>\n";
|
|
|
|
$xml .= " </long_desc>\n";
|
|
|
|
}
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
|
|
|
|
2002-08-27 02:24:58 +04:00
|
|
|
if (defined $self->{'attachments'}) {
|
|
|
|
for (my $i=0 ; $i < @{$self->{'attachments'}} ; $i++) {
|
|
|
|
next if ($self->{'attachments'}[$i]->{'isprivate'}
|
2002-08-29 13:25:54 +04:00
|
|
|
&& Param("insidergroup")
|
|
|
|
&& !&::UserInGroup(Param("insidergroup")));
|
2002-08-27 02:24:58 +04:00
|
|
|
$xml .= " <attachment>\n";
|
|
|
|
$xml .= " <attachid>" . $self->{'attachments'}[$i]->{'attachid'}
|
|
|
|
. "</attachid>\n";
|
|
|
|
$xml .= " <date>" . $self->{'attachments'}[$i]->{'date'} . "</date>\n";
|
|
|
|
$xml .= " <desc>" . QuoteXMLChars($self->{'attachments'}[$i]->{'desc'}) . "</desc>\n";
|
|
|
|
# $xml .= " <type>" . $self->{'attachments'}[$i]->{'type'} . "</type>\n";
|
|
|
|
# $xml .= " <data>" . $self->{'attachments'}[$i]->{'data'} . "</data>\n";
|
|
|
|
$xml .= " </attachment>\n";
|
|
|
|
}
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
|
|
|
|
2002-08-27 02:24:58 +04:00
|
|
|
$xml .= "</bug>\n";
|
|
|
|
return $xml;
|
2000-06-09 00:30:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub EmitDependList {
|
|
|
|
my ($myfield, $targetfield, $bug_id) = (@_);
|
|
|
|
my @list;
|
|
|
|
&::SendSQL("select dependencies.$targetfield, bugs.bug_status
|
|
|
|
from dependencies, bugs
|
|
|
|
where dependencies.$myfield = $bug_id
|
|
|
|
and bugs.bug_id = dependencies.$targetfield
|
|
|
|
order by dependencies.$targetfield");
|
|
|
|
while (&::MoreSQLData()) {
|
|
|
|
my ($i, $stat) = (&::FetchSQLData());
|
|
|
|
push @list, $i;
|
|
|
|
}
|
|
|
|
return @list;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub QuoteXMLChars {
|
2001-11-26 17:16:10 +03:00
|
|
|
$_[0] =~ s/&/&/g;
|
2000-06-09 00:30:10 +04:00
|
|
|
$_[0] =~ s/</</g;
|
|
|
|
$_[0] =~ s/>/>/g;
|
|
|
|
$_[0] =~ s/'/'/g;
|
|
|
|
$_[0] =~ s/"/"/g;
|
|
|
|
# $_[0] =~ s/([\x80-\xFF])/&XmlUtf8Encode(ord($1))/ge;
|
|
|
|
return($_[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub XML_Header {
|
|
|
|
my ($urlbase, $version, $maintainer, $exporter) = (@_);
|
|
|
|
|
|
|
|
my $xml;
|
2002-04-27 10:25:41 +04:00
|
|
|
$xml = "<?xml version=\"1.0\" standalone=\"yes\"?>\n";
|
2000-06-09 00:30:10 +04:00
|
|
|
$xml .= "<!DOCTYPE bugzilla SYSTEM \"$urlbase";
|
|
|
|
if (! ($urlbase =~ /.+\/$/)) {
|
|
|
|
$xml .= "/";
|
|
|
|
}
|
|
|
|
$xml .= "bugzilla.dtd\">\n";
|
|
|
|
$xml .= "<bugzilla";
|
|
|
|
if (defined $exporter) {
|
|
|
|
$xml .= " exporter=\"$exporter\"";
|
|
|
|
}
|
|
|
|
$xml .= " version=\"$version\"";
|
|
|
|
$xml .= " urlbase=\"$urlbase\"";
|
|
|
|
$xml .= " maintainer=\"$maintainer\">\n";
|
|
|
|
return ($xml);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub XML_Footer {
|
|
|
|
return ("</bugzilla>\n");
|
|
|
|
}
|
|
|
|
|
2000-06-28 03:16:08 +04:00
|
|
|
sub CanChangeField {
|
|
|
|
my $self = shift();
|
|
|
|
my ($f, $oldvalue, $newvalue) = (@_);
|
|
|
|
my $UserInEditGroupSet = -1;
|
|
|
|
my $UserInCanConfirmGroupSet = -1;
|
|
|
|
my $ownerid;
|
|
|
|
my $reporterid;
|
|
|
|
my $qacontactid;
|
|
|
|
|
|
|
|
if ($f eq "assigned_to" || $f eq "reporter" || $f eq "qa_contact") {
|
|
|
|
if ($oldvalue =~ /^\d+$/) {
|
|
|
|
if ($oldvalue == 0) {
|
|
|
|
$oldvalue = "";
|
|
|
|
} else {
|
|
|
|
$oldvalue = &::DBID_to_name($oldvalue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($oldvalue eq $newvalue) {
|
|
|
|
return 1;
|
|
|
|
}
|
2002-08-19 17:59:45 +04:00
|
|
|
if (trim($oldvalue) eq trim($newvalue)) {
|
2000-06-28 03:16:08 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if ($f =~ /^longdesc/) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if ($UserInEditGroupSet < 0) {
|
|
|
|
$UserInEditGroupSet = UserInGroup($self, "editbugs");
|
|
|
|
}
|
|
|
|
if ($UserInEditGroupSet) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
&::SendSQL("SELECT reporter, assigned_to, qa_contact FROM bugs " .
|
|
|
|
"WHERE bug_id = $self->{'bug_id'}");
|
|
|
|
($reporterid, $ownerid, $qacontactid) = (&::FetchSQLData());
|
|
|
|
|
|
|
|
# Let reporter change bug status, even if they can't edit bugs.
|
|
|
|
# If reporter can't re-open their bug they will just file a duplicate.
|
|
|
|
# While we're at it, let them close their own bugs as well.
|
|
|
|
if ( ($f eq "bug_status") && ($self->{'whoid'} eq $reporterid) ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if ($f eq "bug_status" && $newvalue ne $::unconfirmedstate &&
|
|
|
|
&::IsOpenedState($newvalue)) {
|
|
|
|
|
|
|
|
# Hmm. They are trying to set this bug to some opened state
|
|
|
|
# that isn't the UNCONFIRMED state. Are they in the right
|
|
|
|
# group? Or, has it ever been confirmed? If not, then this
|
|
|
|
# isn't legal.
|
|
|
|
|
|
|
|
if ($UserInCanConfirmGroupSet < 0) {
|
|
|
|
$UserInCanConfirmGroupSet = &::UserInGroup("canconfirm");
|
|
|
|
}
|
|
|
|
if ($UserInCanConfirmGroupSet) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
&::SendSQL("SELECT everconfirmed FROM bugs WHERE bug_id = $self->{'bug_id'}");
|
|
|
|
my $everconfirmed = FetchOneColumn();
|
|
|
|
if ($everconfirmed) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} elsif ($reporterid eq $self->{'whoid'} || $ownerid eq $self->{'whoid'} ||
|
|
|
|
$qacontactid eq $self->{'whoid'}) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
$self->{'error'} = "
|
|
|
|
Only the owner or submitter of the bug, or a sufficiently
|
|
|
|
empowered user, may make that change to the $f field."
|
|
|
|
}
|
|
|
|
|
|
|
|
sub Collision {
|
|
|
|
my $self = shift();
|
|
|
|
my $write = "WRITE"; # Might want to make a param to control
|
|
|
|
# whether we do LOW_PRIORITY ...
|
|
|
|
&::SendSQL("LOCK TABLES bugs $write, bugs_activity $write, cc $write, " .
|
2001-10-23 19:44:53 +04:00
|
|
|
"cc AS selectVisible_cc $write, " .
|
2000-06-28 03:16:08 +04:00
|
|
|
"profiles $write, dependencies $write, votes $write, " .
|
|
|
|
"keywords $write, longdescs $write, fielddefs $write, " .
|
|
|
|
"keyworddefs READ, groups READ, attachments READ, products READ");
|
|
|
|
&::SendSQL("SELECT delta_ts FROM bugs where bug_id=$self->{'bug_id'}");
|
|
|
|
my $delta_ts = &::FetchOneColumn();
|
|
|
|
&::SendSQL("unlock tables");
|
|
|
|
if ($self->{'delta_ts'} ne $delta_ts) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub AppendComment {
|
|
|
|
my $self = shift();
|
|
|
|
my ($comment) = (@_);
|
|
|
|
$comment =~ s/\r\n/\n/g; # Get rid of windows-style line endings.
|
|
|
|
$comment =~ s/\r/\n/g; # Get rid of mac-style line endings.
|
|
|
|
if ($comment =~ /^\s*$/) { # Nothin' but whitespace.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
&::SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext) " .
|
|
|
|
"VALUES($self->{'bug_id'}, $self->{'whoid'}, now(), " . &::SqlQuote($comment) . ")");
|
|
|
|
|
|
|
|
&::SendSQL("UPDATE bugs SET delta_ts = now() WHERE bug_id = $self->{'bug_id'}");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#from o'reilley's Programming Perl
|
|
|
|
sub display {
|
|
|
|
my $self = shift;
|
|
|
|
my @keys;
|
|
|
|
if (@_ == 0) { # no further arguments
|
|
|
|
@keys = sort keys(%$self);
|
|
|
|
} else {
|
|
|
|
@keys = @_; # use the ones given
|
|
|
|
}
|
|
|
|
foreach my $key (@keys) {
|
|
|
|
print "\t$key => $self->{$key}\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub CommitChanges {
|
|
|
|
|
|
|
|
#snapshot bug
|
|
|
|
#snapshot dependencies
|
|
|
|
#check can change fields
|
|
|
|
#check collision
|
|
|
|
#lock and change fields
|
|
|
|
#notify through mail
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-06-09 00:30:10 +04:00
|
|
|
sub AUTOLOAD {
|
|
|
|
use vars qw($AUTOLOAD);
|
|
|
|
my $self = shift;
|
|
|
|
my $type = ref($self) || $self;
|
|
|
|
my $attr = $AUTOLOAD;
|
|
|
|
|
|
|
|
$attr =~ s/.*:://;
|
|
|
|
return unless $attr=~ /[^A-Z]/;
|
|
|
|
if (@_) {
|
2000-06-12 10:52:41 +04:00
|
|
|
$self->{$attr} = shift;
|
2000-06-09 00:30:10 +04:00
|
|
|
return;
|
|
|
|
}
|
2000-06-12 10:52:41 +04:00
|
|
|
confess ("invalid bug attribute $attr") unless $ok_field{$attr};
|
|
|
|
if (defined $self->{$attr}) {
|
|
|
|
return $self->{$attr};
|
2000-06-09 00:30:10 +04:00
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|