Commit 05a0b649 authored by gerv%gerv.net's avatar gerv%gerv.net

Bug 115369 - templatise long_list.cgi.

parent 9cf1d832
...@@ -986,7 +986,7 @@ sub detaint_natural { ...@@ -986,7 +986,7 @@ sub detaint_natural {
# expressions. # expressions.
sub quoteUrls { sub quoteUrls {
my ($knownattachments, $text) = (@_); my ($text) = (@_);
return $text unless $text; return $text unless $text;
my $base = Param('urlbase'); my $base = Param('urlbase');
...@@ -994,8 +994,6 @@ sub quoteUrls { ...@@ -994,8 +994,6 @@ sub quoteUrls {
my $protocol = join '|', my $protocol = join '|',
qw(afs cid ftp gopher http https mid news nntp prospero telnet wais); qw(afs cid ftp gopher http https mid news nntp prospero telnet wais);
my %options = ( metachars => 1, @_ );
my $count = 0; my $count = 0;
# Now, quote any "#" characters so they won't confuse stuff later # Now, quote any "#" characters so they won't confuse stuff later
...@@ -1046,9 +1044,9 @@ sub quoteUrls { ...@@ -1046,9 +1044,9 @@ sub quoteUrls {
$item = GetBugLink($num, $item); $item = GetBugLink($num, $item);
$things[$count++] = $item; $things[$count++] = $item;
} }
while ($text =~ s/\battachment(\s|%\#)*(\d+)/"##$count##"/ei) { while ($text =~ s/\b(Created an )?attachment(\s|%\#)*(\(id=)?(\d+)\)?/"##$count##"/ei) {
my $item = $&; my $item = $&;
my $num = $2; my $num = $4;
$item = value_quote($item); # Not really necessary, since we know $item = value_quote($item); # Not really necessary, since we know
# there's no special chars in it. # there's no special chars in it.
$item = qq{<A HREF="attachment.cgi?id=$num&action=view">$item</A>}; $item = qq{<A HREF="attachment.cgi?id=$num&action=view">$item</A>};
...@@ -1062,14 +1060,6 @@ sub quoteUrls { ...@@ -1062,14 +1060,6 @@ sub quoteUrls {
$item =~ s@\d+@$bug_link@; $item =~ s@\d+@$bug_link@;
$things[$count++] = $item; $things[$count++] = $item;
} }
while ($text =~ s/Created an attachment \(id=(\d+)\)/"##$count##"/e) {
my $item = $&;
my $num = $1;
if ($knownattachments->{$num}) {
$item = qq{<A HREF="attachment.cgi?id=$num&action=view">$item</A>};
}
$things[$count++] = $item;
}
$text = value_quote($text); $text = value_quote($text);
$text =~ s/\&#013;/\n/g; $text =~ s/\&#013;/\n/g;
...@@ -1157,7 +1147,7 @@ sub GetLongDescriptionAsText { ...@@ -1157,7 +1147,7 @@ sub GetLongDescriptionAsText {
" longdescs.thetext " . " longdescs.thetext " .
"FROM longdescs, profiles " . "FROM longdescs, profiles " .
"WHERE profiles.userid = longdescs.who " . "WHERE profiles.userid = longdescs.who " .
" AND longdescs.bug_id = $id "); "AND longdescs.bug_id = $id ");
if ($start && $start =~ /[1-9]/) { if ($start && $start =~ /[1-9]/) {
# If the start is all zeros, then don't do this (because we want to # If the start is all zeros, then don't do this (because we want to
...@@ -1189,11 +1179,6 @@ sub GetLongDescriptionAsHTML { ...@@ -1189,11 +1179,6 @@ sub GetLongDescriptionAsHTML {
my ($id, $start, $end) = (@_); my ($id, $start, $end) = (@_);
my $result = ""; my $result = "";
my $count = 0; my $count = 0;
my %knownattachments;
SendSQL("SELECT attach_id FROM attachments WHERE bug_id = $id");
while (MoreSQLData()) {
$knownattachments{FetchOneColumn()} = 1;
}
my ($query) = ("SELECT profiles.realname, profiles.login_name, longdescs.bug_when, " . my ($query) = ("SELECT profiles.realname, profiles.login_name, longdescs.bug_when, " .
" longdescs.thetext " . " longdescs.thetext " .
...@@ -1226,13 +1211,40 @@ sub GetLongDescriptionAsHTML { ...@@ -1226,13 +1211,40 @@ sub GetLongDescriptionAsHTML {
$result .= time2str("%Y-%m-%d %H:%M", str2time($when)) . " -------</I><BR>\n"; $result .= time2str("%Y-%m-%d %H:%M", str2time($when)) . " -------</I><BR>\n";
} }
$result .= "<PRE>" . quoteUrls(\%knownattachments, $text) . "</PRE>\n"; $result .= "<PRE>" . quoteUrls($text) . "</PRE>\n";
$count++; $count++;
} }
return $result; return $result;
} }
sub GetComments {
my ($id) = (@_);
my @comments;
SendSQL("SELECT profiles.realname, profiles.login_name,
date_format(longdescs.bug_when,'%Y-%m-%d %H:%i'),
longdescs.thetext
FROM longdescs, profiles
WHERE profiles.userid = longdescs.who
AND longdescs.bug_id = $id
ORDER BY longdescs.bug_when");
while (MoreSQLData()) {
my %comment;
($comment{'name'}, $comment{'email'}, $comment{'time'}, $comment{'body'}) = FetchSQLData();
$comment{'email'} .= Param('emailsuffix');
$comment{'name'} = $comment{'name'} || $comment{'email'};
push (@comments, \%comment);
}
return \@comments;
}
# Fills in a hashtable with info about the columns for the given table in the # Fills in a hashtable with info about the columns for the given table in the
# database. The hashtable has the following entries: # database. The hashtable has the following entries:
# -list- the list of column names # -list- the list of column names
......
...@@ -19,111 +19,99 @@ ...@@ -19,111 +19,99 @@
# Rights Reserved. # Rights Reserved.
# #
# Contributor(s): Terry Weissman <terry@mozilla.org> # Contributor(s): Terry Weissman <terry@mozilla.org>
# Gervase Markham <gerv@gerv.net>
use diagnostics; use diagnostics;
use strict; use strict;
use lib qw(.); use lib qw(.);
require "CGI.pl"; require "CGI.pl";
# Shut up misguided -w warnings about "used only once". "use vars" just use vars qw($userid $usergroupset @legal_keywords %FORM);
# doesn't work for me.
sub sillyness {
my $zz;
$zz = $::legal_keywords;
$zz = $::userid;
$zz = $::usergroupset;
$zz = %::FORM;
}
print "Content-type: text/html\n"; # Use global template variables.
#Changing attachment to inline to resolve 46897 use vars qw($template $vars);
#zach@zachlipton.com
print "Content-disposition: inline; filename=bugzilla_bug_list.html\n\n";
PutHeader ("Full Text Bug Listing");
ConnectToDatabase(); ConnectToDatabase();
quietly_check_login(); quietly_check_login();
GetVersionTable(); GetVersionTable();
my $generic_query = " my $generic_query = "
select SELECT
bugs.bug_id, bugs.bug_id,
bugs.product, bugs.product,
bugs.version, bugs.version,
bugs.rep_platform, bugs.rep_platform,
bugs.op_sys, bugs.op_sys,
bugs.bug_status, bugs.bug_status,
bugs.bug_severity,
bugs.priority,
bugs.resolution, bugs.resolution,
bugs.priority,
bugs.bug_severity,
bugs.component,
assign.login_name, assign.login_name,
report.login_name, report.login_name,
bugs.component,
bugs.bug_file_loc, bugs.bug_file_loc,
bugs.short_desc, bugs.short_desc,
bugs.target_milestone, bugs.target_milestone,
bugs.qa_contact, bugs.qa_contact,
bugs.status_whiteboard, bugs.status_whiteboard,
bugs.keywords bugs.keywords
from bugs,profiles assign,profiles report FROM bugs,profiles assign,profiles report
where assign.userid = bugs.assigned_to and report.userid = bugs.reporter and"; WHERE assign.userid = bugs.assigned_to AND report.userid = bugs.reporter";
my $buglist = $::FORM{'buglist'} ||
$::FORM{'bug_id'} ||
$::FORM{'id'} || "";
my @bugs;
$::FORM{'buglist'} = "" unless exists $::FORM{'buglist'}; foreach my $bug_id (split(/[:,]/, $buglist)) {
foreach my $bug (split(/:/, $::FORM{'buglist'})) { detaint_natural($bug_id) || next;
detaint_natural($bug) || next; SendSQL(SelectVisible("$generic_query AND bugs.bug_id = $bug_id",
SendSQL(SelectVisible("$generic_query bugs.bug_id = $bug",
$::userid, $::usergroupset)); $::userid, $::usergroupset));
my @row; my %bug;
if (@row = FetchSQLData()) { my @row = FetchSQLData();
my ($id, $product, $version, $platform, $opsys, $status, $severity,
$priority, $resolution, $assigned, $reporter, $component, $url, foreach my $field ("bug_id", "product", "version", "rep_platform",
$shortdesc, $target_milestone, $qa_contact, "op_sys", "bug_status", "resolution", "priority",
$status_whiteboard, $keywords) = (@row); "bug_severity", "component", "assigned_to", "reporter",
print "<IMG SRC=\"1x1.gif\" WIDTH=1 HEIGHT=80 ALIGN=LEFT>\n"; "bug_file_loc", "short_desc", "target_milestone",
print "<TABLE WIDTH=100%>\n"; "qa_contact", "status_whiteboard", "keywords")
print "<TD COLSPAN=4><TR><DIV ALIGN=CENTER><B><FONT =\"+3\">" . {
html_quote($shortdesc) . $bug{$field} = shift @row;
"</B></FONT></DIV>\n";
print "<TR><TD><B>Bug#:</B> <A HREF=\"show_bug.cgi?id=$id\">$id</A>\n";
print "<TD><B>Product:</B> $product\n";
print "<TD><B>Version:</B> $version\n";
print "<TD><B>Platform:</B> $platform\n";
print "<TR><TD><B>OS/Version:</B> $opsys\n";
print "<TD><B>Status:</B> $status\n";
print "<TD><B>Severity:</B> $severity\n";
print "<TD><B>Priority:</B> $priority\n";
print "<TR><TD><B>Resolution:</B> $resolution</TD>\n";
print "<TD><B>Assigned To:</B> $assigned\n";
print "<TD><B>Reported By:</B> $reporter\n";
if (Param("useqacontact")) {
my $name = "";
if ($qa_contact > 0) {
$name = DBID_to_name($qa_contact);
}
print "<TD><B>QA Contact:</B> $name\n";
}
print "<TR><TD COLSPAN=2><B>Component:</B> $component\n";
if (Param("usetargetmilestone")) {
print "<TD COLSPAN=2><B>Target Milestone:</B> $target_milestone\n";
}
print "<TR><TD COLSPAN=6><B>URL:</B>&nbsp;";
print "<A HREF=\"" . $url . "\">" . html_quote($url) . "</A>\n";
print "<TR><TD COLSPAN=6><B>Summary:</B> " . html_quote($shortdesc) . "\n";
if (@::legal_keywords) {
print "<TR><TD><B>Keywords: </B>$keywords</TD></TR>\n";
}
if (Param("usestatuswhiteboard")) {
print "<TR><TD COLSPAN=6><B>Status Whiteboard:" .
html_quote($status_whiteboard) . "\n";
} }
print "<TR><TD><B>Description:</B>\n</TABLE>\n";
print GetLongDescriptionAsHTML($bug); if ($bug{'bug_id'}) {
print "<HR>\n"; $bug{'comments'} = GetComments($bug{'bug_id'});
$bug{'qa_contact'} = $bug{'qa_contact'} > 0 ?
DBID_to_name($bug{'qa_contact'}) : "";
push (@bugs, \%bug);
} }
} }
# Add the list of bug hashes to the variables
$vars->{'bugs'} = \@bugs;
$vars->{'use_keywords'} = 1 if (@::legal_keywords);
$vars->{'quoteUrls'} = \&quoteUrls;
$vars->{'time2str'} = \&time2str;
$vars->{'str2time'} = \&str2time;
# Work out a sensible filename for Content-Disposition.
# Sadly, I don't think we can tell if this was a named query.
my @time = localtime(time());
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
my $filename = "bugs-$date.html";
print "Content-Type: text/html\n";
print "Content-Disposition: inline; filename=$filename\n\n";
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("show/multiple.tmpl", $vars)
|| DisplayError("Template process failed: " . $template->error())
&& exit;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment