From 91b171e7584920d03abb9c45e779c84f3dee975c Mon Sep 17 00:00:00 2001 From: "myk%mozilla.org" <> Date: Sun, 29 Sep 2002 01:42:23 +0000 Subject: Fix for bug 98801: Implementation of the request tracker, a set of enhancements to attachment statuses. r=gerv,bbaetz --- Attachment.pm | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'Attachment.pm') diff --git a/Attachment.pm b/Attachment.pm index 3a6248cf4..53690170e 100644 --- a/Attachment.pm +++ b/Attachment.pm @@ -31,10 +31,32 @@ package Attachment; # This module requires that its caller have said "require CGI.pl" to import # relevant functions from that script and its companion globals.pl. +# Use the Flag module to handle flags. +use Bugzilla::Flag; + ############################################################################ # Functions ############################################################################ +sub new { + # Returns a hash of information about the attachment with the given ID. + + my ($invocant, $id) = @_; + return undef if !$id; + my $self = { 'id' => $id }; + my $class = ref($invocant) || $invocant; + bless($self, $class); + + &::PushGlobalSQLState(); + &::SendSQL("SELECT 1, description, bug_id FROM attachments " . + "WHERE attach_id = $id"); + ($self->{'exists'}, $self->{'summary'}, $self->{'bug_id'}) = + &::FetchSQLData(); + &::PopGlobalSQLState(); + + return $self; +} + sub query { # Retrieves and returns an array of attachment records for a given bug. @@ -65,23 +87,9 @@ sub query $a{'date'} = "$1-$2-$3 $4:$5"; } - # Retrieve a list of status flags that have been set on the attachment. - &::PushGlobalSQLState(); - &::SendSQL(" - SELECT name - FROM attachstatuses, attachstatusdefs - WHERE attach_id = $a{'attachid'} - AND attachstatuses.statusid = attachstatusdefs.id - ORDER BY sortkey - "); - my @statuses = (); - while (&::MoreSQLData()) { - my ($status) = &::FetchSQLData(); - push @statuses , $status; - } - $a{'statuses'} = \@statuses; - &::PopGlobalSQLState(); - + # Retrieve a list of flags for this attachment. + $a{'flags'} = Bugzilla::Flag::match({ 'attach_id' => $a{'attachid'} }); + # We will display the edit link if the user can edit the attachment; # ie the are the submitter, or they have canedit. # Also show the link if the user is not logged in - in that cae, -- cgit v1.2.3-24-g4f1b