|
|
|
|
@@ -6,6 +6,7 @@
|
|
|
|
|
# defined by the Mozilla Public License, v. 2.0.
|
|
|
|
|
|
|
|
|
|
package Bugzilla::Extension::Testopia::Reports::CaseRun;
|
|
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
|
|
@@ -25,63 +26,60 @@ sub report {
|
|
|
|
|
|
|
|
|
|
my $type = $input->{'type'} || '';
|
|
|
|
|
|
|
|
|
|
if ($type eq 'status-breakdown') {
|
|
|
|
|
return if $type eq 'status-breakdown';
|
|
|
|
|
|
|
|
|
|
$input->{'current_tab'} = 'case_run';
|
|
|
|
|
$input->{'viewall'} = 1;
|
|
|
|
|
my $report = Bugzilla::Extension::Testopia::Report->new('caserun', 'tr_list_caseruns.cgi', $cgi);
|
|
|
|
|
$vars->{'report'} = $report;
|
|
|
|
|
$vars->{'qname'} = $input->{'qname'};
|
|
|
|
|
|
|
|
|
|
### From Bugzilla report.cgi by Gervase Markham
|
|
|
|
|
my $formatparam = $input->{'format'};
|
|
|
|
|
my $report_action = $input->{'report_action'};
|
|
|
|
|
if ($report_action eq "data") {
|
|
|
|
|
# So which template are we using? If action is "wrap", we will be using
|
|
|
|
|
# no format (it gets passed through to be the format of the actual data),
|
|
|
|
|
# and either report.csv.tmpl (CSV), or report.html.tmpl (everything else).
|
|
|
|
|
# report.html.tmpl produces an HTML framework for either tables of HTML
|
|
|
|
|
# data, or images generated by calling report.cgi again with action as
|
|
|
|
|
# "plot".
|
|
|
|
|
$formatparam =~ s/[^a-zA-Z\-]//g;
|
|
|
|
|
trick_taint($formatparam);
|
|
|
|
|
$vars->{'format'} = $formatparam;
|
|
|
|
|
$formatparam = '';
|
|
|
|
|
}
|
|
|
|
|
elsif ($report_action eq "plot") {
|
|
|
|
|
# If action is "plot", we will be using a format as normal (pie, bar etc.)
|
|
|
|
|
# and a ctype as normal (currently only png.)
|
|
|
|
|
$vars->{'cumulate'} = $input->{'cumulate'} ? 1 : 0;
|
|
|
|
|
$vars->{'x_labels_vertical'} = $input->{'x_labels_vertical'} ? 1 : 0;
|
|
|
|
|
$vars->{'data'} = $report->{'image_data'};
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$input->{'current_tab'} = 'case_run';
|
|
|
|
|
$input->{'viewall'} = 1;
|
|
|
|
|
my $report = Bugzilla::Extension::Testopia::Report->new('caserun', 'tr_list_caseruns.cgi', $cgi);
|
|
|
|
|
$vars->{'report'} = $report;
|
|
|
|
|
$vars->{'qname'} = $input->{'qname'};
|
|
|
|
|
|
|
|
|
|
### From Bugzilla report.cgi by Gervase Markham
|
|
|
|
|
my $formatparam = $input->{'format'};
|
|
|
|
|
my $report_action = $input->{'report_action'};
|
|
|
|
|
if ($report_action eq "data") {
|
|
|
|
|
# So which template are we using? If action is "wrap", we will be using
|
|
|
|
|
# no format (it gets passed through to be the format of the actual data),
|
|
|
|
|
# and either report.csv.tmpl (CSV), or report.html.tmpl (everything else).
|
|
|
|
|
# report.html.tmpl produces an HTML framework for either tables of HTML
|
|
|
|
|
# data, or images generated by calling report.cgi again with action as
|
|
|
|
|
# "plot".
|
|
|
|
|
$formatparam =~ s/[^a-zA-Z\-]//g;
|
|
|
|
|
trick_taint($formatparam);
|
|
|
|
|
$vars->{'format'} = $formatparam;
|
|
|
|
|
$formatparam = '';
|
|
|
|
|
}
|
|
|
|
|
elsif ($report_action eq "plot") {
|
|
|
|
|
# If action is "plot", we will be using a format as normal (pie, bar etc.)
|
|
|
|
|
# and a ctype as normal (currently only png.)
|
|
|
|
|
$vars->{'cumulate'} = $input->{'cumulate'} ? 1 : 0;
|
|
|
|
|
$vars->{'x_labels_vertical'} = $input->{'x_labels_vertical'} ? 1 : 0;
|
|
|
|
|
$vars->{'data'} = $report->{'image_data'};
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ThrowUserError("unknown_action", {action => $input->{'report_action'}});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my $format = $template->get_format("testopia/reports/report", $formatparam,
|
|
|
|
|
scalar($input->{'ctype'}));
|
|
|
|
|
|
|
|
|
|
my @time = localtime(time());
|
|
|
|
|
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
|
|
|
|
|
my $filename = "report-" . $date . ".$format->{extension}";
|
|
|
|
|
|
|
|
|
|
my $disp = "inline";
|
|
|
|
|
# We set CSV files to be downloaded, as they are designed for importing
|
|
|
|
|
# into other programs.
|
|
|
|
|
if ($format->{'extension'} eq "csv" || $format->{'extension'} eq "xml") {
|
|
|
|
|
$disp = "attachment";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print $cgi->header( -type => $format->{'ctype'},
|
|
|
|
|
-content_disposition => "$disp; filename=$filename");
|
|
|
|
|
|
|
|
|
|
$vars->{'time'} = $date;
|
|
|
|
|
$template->process("$format->{'template'}", $vars)
|
|
|
|
|
or ThrowTemplateError($template->error());
|
|
|
|
|
exit;
|
|
|
|
|
ThrowUserError("unknown_action", {action => $input->{'report_action'}});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my $format = $template->get_format("testopia/reports/report", $formatparam,
|
|
|
|
|
scalar($input->{'ctype'}));
|
|
|
|
|
|
|
|
|
|
my @time = localtime(time());
|
|
|
|
|
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
|
|
|
|
|
my $filename = "report-" . $date . ".$format->{extension}";
|
|
|
|
|
|
|
|
|
|
my $disp = "inline";
|
|
|
|
|
# We set CSV files to be downloaded, as they are designed for importing
|
|
|
|
|
# into other programs.
|
|
|
|
|
if ($format->{'extension'} eq "csv" || $format->{'extension'} eq "xml") {
|
|
|
|
|
$disp = "attachment";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print $cgi->header(-type => $format->{'ctype'},
|
|
|
|
|
-content_disposition => "$disp; filename=$filename");
|
|
|
|
|
|
|
|
|
|
$vars->{'time'} = $date;
|
|
|
|
|
$template->process("$format->{'template'}", $vars)
|
|
|
|
|
or ThrowTemplateError($template->error());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
1;
|
|
|
|
|
|