From 05a0b649b38a3f81cebeb2b0851b3c43fe5f646e Mon Sep 17 00:00:00 2001 From: "gerv%gerv.net" <> Date: Wed, 20 Feb 2002 07:22:24 +0000 Subject: Bug 115369 - templatise long_list.cgi. --- long_list.cgi | 168 +++++++++++++++++++++++++++------------------------------- 1 file changed, 78 insertions(+), 90 deletions(-) (limited to 'long_list.cgi') diff --git a/long_list.cgi b/long_list.cgi index 552457b06..b25c10ebf 100755 --- a/long_list.cgi +++ b/long_list.cgi @@ -19,111 +19,99 @@ # Rights Reserved. # # Contributor(s): Terry Weissman - +# Gervase Markham use diagnostics; use strict; - use lib qw(.); require "CGI.pl"; -# Shut up misguided -w warnings about "used only once". "use vars" just -# doesn't work for me. +use vars qw($userid $usergroupset @legal_keywords %FORM); -sub sillyness { - my $zz; - $zz = $::legal_keywords; - $zz = $::userid; - $zz = $::usergroupset; - $zz = %::FORM; -} - -print "Content-type: text/html\n"; -#Changing attachment to inline to resolve 46897 -#zach@zachlipton.com -print "Content-disposition: inline; filename=bugzilla_bug_list.html\n\n"; -PutHeader ("Full Text Bug Listing"); +# Use global template variables. +use vars qw($template $vars); ConnectToDatabase(); + quietly_check_login(); GetVersionTable(); -my $generic_query = " -select - bugs.bug_id, - bugs.product, - bugs.version, - bugs.rep_platform, - bugs.op_sys, - bugs.bug_status, - bugs.bug_severity, - bugs.priority, - bugs.resolution, - assign.login_name, - report.login_name, - bugs.component, - bugs.bug_file_loc, - bugs.short_desc, - bugs.target_milestone, - bugs.qa_contact, - bugs.status_whiteboard, - bugs.keywords -from bugs,profiles assign,profiles report -where assign.userid = bugs.assigned_to and report.userid = bugs.reporter and"; - -$::FORM{'buglist'} = "" unless exists $::FORM{'buglist'}; -foreach my $bug (split(/:/, $::FORM{'buglist'})) { - detaint_natural($bug) || next; - SendSQL(SelectVisible("$generic_query bugs.bug_id = $bug", +my $generic_query = " + SELECT + bugs.bug_id, + bugs.product, + bugs.version, + bugs.rep_platform, + bugs.op_sys, + bugs.bug_status, + bugs.resolution, + bugs.priority, + bugs.bug_severity, + bugs.component, + assign.login_name, + report.login_name, + bugs.bug_file_loc, + bugs.short_desc, + bugs.target_milestone, + bugs.qa_contact, + bugs.status_whiteboard, + bugs.keywords + FROM bugs,profiles assign,profiles report + WHERE assign.userid = bugs.assigned_to AND report.userid = bugs.reporter"; + +my $buglist = $::FORM{'buglist'} || + $::FORM{'bug_id'} || + $::FORM{'id'} || ""; + +my @bugs; + +foreach my $bug_id (split(/[:,]/, $buglist)) { + detaint_natural($bug_id) || next; + SendSQL(SelectVisible("$generic_query AND bugs.bug_id = $bug_id", $::userid, $::usergroupset)); - my @row; - if (@row = FetchSQLData()) { - my ($id, $product, $version, $platform, $opsys, $status, $severity, - $priority, $resolution, $assigned, $reporter, $component, $url, - $shortdesc, $target_milestone, $qa_contact, - $status_whiteboard, $keywords) = (@row); - print "\n"; - print "\n"; - print "
" . - html_quote($shortdesc) . - "
\n"; - print "\n"; - print "\n"; - } - if (Param("usestatuswhiteboard")) { - print "
Bug#: $id\n"; - print "Product: $product\n"; - print "Version: $version\n"; - print "Platform: $platform\n"; - print "
OS/Version: $opsys\n"; - print "Status: $status\n"; - print "Severity: $severity\n"; - print "Priority: $priority\n"; - print "
Resolution: $resolutionAssigned To: $assigned\n"; - print "Reported By: $reporter\n"; - if (Param("useqacontact")) { - my $name = ""; - if ($qa_contact > 0) { - $name = DBID_to_name($qa_contact); - } - print "QA Contact: $name\n"; - } - print "
Component: $component\n"; - if (Param("usetargetmilestone")) { - print "Target Milestone: $target_milestone\n"; - } - print "
URL: "; - print "" . html_quote($url) . "\n"; - print "
Summary: " . html_quote($shortdesc) . "\n"; - if (@::legal_keywords) { - print "
Keywords: $keywords
Status Whiteboard:" . - html_quote($status_whiteboard) . "\n"; - } - print "
Description:\n
\n"; - print GetLongDescriptionAsHTML($bug); - print "
\n"; + my %bug; + my @row = FetchSQLData(); + + foreach my $field ("bug_id", "product", "version", "rep_platform", + "op_sys", "bug_status", "resolution", "priority", + "bug_severity", "component", "assigned_to", "reporter", + "bug_file_loc", "short_desc", "target_milestone", + "qa_contact", "status_whiteboard", "keywords") + { + $bug{$field} = shift @row; + } + + if ($bug{'bug_id'}) { + $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'} = \"eUrls; +$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; -- cgit v1.2.3-24-g4f1b