diff --git a/webtools/bugzilla/css/edit_bug.css b/webtools/bugzilla/css/edit_bug.css index 64fa4cd71d0b..d5576f39130d 100644 --- a/webtools/bugzilla/css/edit_bug.css +++ b/webtools/bugzilla/css/edit_bug.css @@ -2,4 +2,6 @@ .bz_private { color: darkred ; background : #f3eeee ; } .bz_disabled { color: #a0a0a0 ; } +.bz_obsolete { text-decoration: line-through underline; } + table#flags th, table#flags td { vertical-align: baseline; text-align: left; } diff --git a/webtools/bugzilla/globals.pl b/webtools/bugzilla/globals.pl index 73445f98ae53..134bddb287cb 100644 --- a/webtools/bugzilla/globals.pl +++ b/webtools/bugzilla/globals.pl @@ -905,10 +905,12 @@ sub quoteUrls { # attachment links - handle both cases separatly for simplicity $text =~ s~((?:^Created\ an\ |\b)attachment\s*\(id=(\d+)\)) - ~$1~igx; + ~GetAttachmentLink($2, $1) + ~egmx; $text =~ s~\b(attachment\s*\#?\s*(\d+)) - ~$1~igx; + ~GetAttachmentLink($2, $1) + ~egmx; # 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. @@ -937,6 +939,60 @@ sub quoteUrls { return $text; } +# 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 = ""; + if (CanSeeBug($bugid, $::userid)) { + $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}}; + # $title will be undefined if the bug didn't exist in the database. + if (defined $title) { + my $linkval = "attachment.cgi?id=$attachid&action=view"; + return qq{$link_text}; + } + else { + return qq{$link_text}; + } +} + # GetBugLink creates a link to a bug, including its title. # It takes either two or three parameters: # - The bug number diff --git a/webtools/bugzilla/template/en/default/attachment/list.html.tmpl b/webtools/bugzilla/template/en/default/attachment/list.html.tmpl index 10112ae2fd38..fc58529237f9 100644 --- a/webtools/bugzilla/template/en/default/attachment/list.html.tmpl +++ b/webtools/bugzilla/template/en/default/attachment/list.html.tmpl @@ -35,11 +35,7 @@ [% IF !attachment.isprivate || canseeprivate %]