From 29f2018b6fd17cd96cc4801febfb379e9fa24da4 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 7 Sep 2007 21:38:31 +0000 Subject: [PATCH] include form parameters in sql report download link --- docs/changelog/7.x.x.txt | 1 + docs/upgrades/templates-7.4.6/sqlreport.tmpl | 161 +++++++++++++++++++ lib/WebGUI/Asset/Wobject/SQLReport.pm | 29 +++- 3 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 docs/upgrades/templates-7.4.6/sqlreport.tmpl diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index d6023e21f..5e509a48f 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -31,6 +31,7 @@ - fix: SQLReport templatable download doesn't run nested queries - fix: Edit branch copies hide from navigation setting from events and posts to rest of branch - Dashboard now shows default view if user hasn't configured their own view + - fix: SQL Report download link doesn't include form parameters 7.4.5 - fix: Apostrophy incorrectly escaped as double quote in some places diff --git a/docs/upgrades/templates-7.4.6/sqlreport.tmpl b/docs/upgrades/templates-7.4.6/sqlreport.tmpl new file mode 100644 index 000000000..325f9f4e4 --- /dev/null +++ b/docs/upgrades/templates-7.4.6/sqlreport.tmpl @@ -0,0 +1,161 @@ +#PBtmpl0000000000000059 + + + +

+
+ + +

+
+ + + +

+ + + + Download this data + + + +

    + +
  • +
    +
+
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + + + + + + + +
+ + + + + +
  + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+ + + + + diff --git a/lib/WebGUI/Asset/Wobject/SQLReport.pm b/lib/WebGUI/Asset/Wobject/SQLReport.pm index 534724c35..51cdc481e 100644 --- a/lib/WebGUI/Asset/Wobject/SQLReport.pm +++ b/lib/WebGUI/Asset/Wobject/SQLReport.pm @@ -477,10 +477,12 @@ sub view { #use Data::Dumper; return '
'.Dumper($var).'
'; # Add the "Download data" link if the user is allowed to download - $var->{'canDownload'} = 1 - if ($self->getValue("downloadType") ne "none" + if ($self->getValue("downloadType") ne "none" && $self->session->user->isInGroup($self->getValue("downloadUserGroup")) - ); + ) { + $var->{'canDownload'} = 1; + $var->{'downloadLink'} = $self->_getDownloadLink($self); + } my $out = $self->processTemplate($var,undef,$self->{_viewTemplate}); if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { @@ -489,6 +491,27 @@ sub view { return $out; } +#------------------------------------------------------------------- +# Create download link be adding all the passed in parameters and values to the url +sub _getDownloadLink { + my $self = shift; + my %params; + for my $nr (1 .. 5) { + foreach my $row (split(/\n/,$self->{_query}{$nr}{placeholderParams})) { + $row =~ s/^\s+//; + $row =~ s/\s+$//; + if ($row =~ /^form:(.*)/) { + $params{$1} ||= $self->session->form->param($1); + } + } + } + my $url = "func=download"; + for my $param (sort keys %params) { + $url .= ";$param=" . $self->session->url->escape($params{$param}); + } + return $self->getUrl($url); +} + #------------------------------------------------------------------- sub _storeQueries { my $self = shift;