summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Attachment.pm
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-04-28 11:14:25 +0200
committerlpsolit%gmail.com <>2005-04-28 11:14:25 +0200
commit95859bf15300cddd1ece82e8224367638f956f20 (patch)
tree91b595c4452d092da38e7cc876fa6ebdc4337396 /Bugzilla/Attachment.pm
parente1ab613cf4f4324924fe33163b501c1835c5deb4 (diff)
downloadbugzilla-95859bf15300cddd1ece82e8224367638f956f20.tar.gz
bugzilla-95859bf15300cddd1ece82e8224367638f956f20.tar.xz
Bug 274724: The 'Edit Attachment' link is now available even if a user does not have 'editbugs' privs - Patch by Frédéric Buclin <LpSolit@gmail.com> r=myk a=myk
Diffstat (limited to 'Bugzilla/Attachment.pm')
-rw-r--r--Bugzilla/Attachment.pm41
1 files changed, 14 insertions, 27 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm
index 1a1246d86..4d223d633 100644
--- a/Bugzilla/Attachment.pm
+++ b/Bugzilla/Attachment.pm
@@ -64,34 +64,28 @@ sub new {
sub query
{
# Retrieves and returns an array of attachment records for a given bug.
- # This data should be given to attachment/list.atml in an
+ # This data should be given to attachment/list.html.tmpl in an
# "attachments" variable.
my ($bugid) = @_;
my $dbh = Bugzilla->dbh;
- my $in_editbugs = UserInGroup("editbugs");
- &::SendSQL("SELECT product_id
- FROM bugs
- WHERE bug_id = $bugid");
- my $productid = &::FetchOneColumn();
- my $caneditproduct = &::CanEditProductId($productid);
-
# Retrieve a list of attachments for this bug and write them into an array
# of hashes in which each hash represents a single attachment.
- &::SendSQL("SELECT attach_id, " .
- $dbh->sql_date_format('creation_ts', '%Y.%m.%d %H:%i') .
- ", mimetype, description, ispatch, isobsolete, isprivate,
- submitter_id, LENGTH(thedata)
- FROM attachments WHERE bug_id = $bugid ORDER BY attach_id
- ");
+ my $list = $dbh->selectall_arrayref("SELECT attach_id, " .
+ $dbh->sql_date_format('creation_ts', '%Y.%m.%d %H:%i') .
+ ", mimetype, description, ispatch,
+ isobsolete, isprivate, LENGTH(thedata)
+ FROM attachments
+ WHERE bug_id = ? ORDER BY attach_id",
+ undef, $bugid);
+
my @attachments = ();
- while (&::MoreSQLData()) {
+ foreach my $row (@$list) {
my %a;
- my $submitter_id;
- ($a{'attachid'}, $a{'date'}, $a{'contenttype'}, $a{'description'},
- $a{'ispatch'}, $a{'isobsolete'}, $a{'isprivate'}, $submitter_id,
- $a{'datasize'}) = &::FetchSQLData();
+ ($a{'attachid'}, $a{'date'}, $a{'contenttype'},
+ $a{'description'}, $a{'ispatch'}, $a{'isobsolete'},
+ $a{'isprivate'}, $a{'datasize'}) = @$row;
# Retrieve a list of flags for this attachment.
$a{'flags'} = Bugzilla::Flag::match({ 'attach_id' => $a{'attachid'},
@@ -107,16 +101,9 @@ sub query
close(AH);
}
}
-
- # 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,
- # They'll be prompted later
- $a{'canedit'} = ($::userid == 0 || (($submitter_id == $::userid ||
- $in_editbugs) && $caneditproduct));
push @attachments, \%a;
}
-
+
return \@attachments;
}