1
# -*- Mode: perl; indent-tabs-mode: nil -*-
3
# The contents of this file are subject to the Mozilla Public
4
# License Version 1.1 (the "License"); you may not use this file
5
# except in compliance with the License. You may obtain a copy of
6
# the License at http://www.mozilla.org/MPL/
8
# Software distributed under the License is distributed on an "AS
9
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
# implied. See the License for the specific language governing
11
# rights and limitations under the License.
13
# The Original Code is the Bugzilla Bug Tracking System.
15
# The Initial Developer of the Original Code is Netscape Communications
16
# Corporation. Portions created by Netscape are
17
# Copyright (C) 1998 Netscape Communications Corporation. All
20
# Contributor(s): Terry Weissman <terry@mozilla.org>
21
# Myk Melez <myk@mozilla.org>
23
############################################################################
24
# Module Initialization
25
############################################################################
32
# This module requires that its caller have said "require CGI.pl" to import
33
# relevant functions from that script and its companion globals.pl.
35
############################################################################
37
############################################################################
41
# Retrieves and returns an array of attachment records for a given bug.
42
# This data should be given to attachment/list.atml in an
43
# "attachments" variable.
46
my $in_editbugs = &::UserInGroup("editbugs");
48
# Retrieve a list of attachments for this bug and write them into an array
49
# of hashes in which each hash represents a single attachment.
51
SELECT attach_id, creation_ts, mimetype, description, ispatch,
52
isobsolete, submitter_id
53
FROM attachments WHERE bug_id = $bugid ORDER BY attach_id
56
while (&::MoreSQLData()) {
59
($a{'attachid'}, $a{'date'}, $a{'contenttype'}, $a{'description'},
60
$a{'ispatch'}, $a{'isobsolete'}, $submitter_id) = &::FetchSQLData();
62
# Format the attachment's creation/modification date into a standard
63
# format (YYYY-MM-DD HH:MM)
64
if ($a{'date'} =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
65
$a{'date'} = "$1-$2-$3 $4:$5";
68
# Retrieve a list of status flags that have been set on the attachment.
69
&::PushGlobalSQLState();
72
FROM attachstatuses, attachstatusdefs
73
WHERE attach_id = $a{'attachid'}
74
AND attachstatuses.statusid = attachstatusdefs.id
78
while (&::MoreSQLData()) {
79
my ($status) = &::FetchSQLData();
80
push @statuses , $status;
82
$a{'statuses'} = \@statuses;
83
&::PopGlobalSQLState();
85
# We will display the edit link if the user can edit the attachment;
86
# ie the are the submitter, or they have canedit.
87
# Also show the link if the user is not logged in - in that cae,
88
# They'll be prompted later
89
$a{'canedit'} = ($::userid == 0 || $submitter_id == $::userid ||
91
push @attachments, \%a;