From 10aa9024bec3cb7c0c411b134293d4db1949e82f Mon Sep 17 00:00:00 2001 From: Lee Jamison Date: Tue, 15 Nov 2016 16:12:33 -0500 Subject: [PATCH] Bug 17153 - Add logic to pass URL to output so redirct to search results can occur --- C4/Output.pm | 14 ++++++++++++-- opac/opac-search.pl | 2 ++ opac/opac-user.pl | 9 ++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index af7dd5a..bb3f9f9 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -271,6 +271,8 @@ sub output_with_http_headers { }; $options->{expires} = 'now' if $extra_options->{force_no_caching}; + my $redirect_url = $extra_options->{redirect_url}; + $options->{cookie} = $cookie if $cookie; if ($content_type eq 'html') { # guaranteed to be one of the content_type_map keys, else we'd have died $options->{'Content-Style-Type' } = 'text/css'; @@ -281,7 +283,16 @@ sub output_with_http_headers { # We need to fix the encoding as it comes out of the database, or when we pass the variables to templates $data =~ s/\&\;amp\; /\&\; /g; - print $query->header($options), $data; + + if ( $redirect_url =~ /opac-search/ ) { + print $query->redirect( + -URL => $redirect_url, + -COOKIE => $cookie, + ); + } + else { + print $query->header($options), $data; + } } sub output_html_with_http_headers { @@ -289,7 +300,6 @@ sub output_html_with_http_headers { output_with_http_headers( $query, $cookie, $data, 'html', $status, $extra_options ); } - sub output_ajax_with_http_headers { my ( $query, $js ) = @_; print $query->header( diff --git a/opac/opac-search.pl b/opac/opac-search.pl index ccbc025..740f02f 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -985,6 +985,8 @@ if (C4::Context->preference('GoogleIndicTransliteration')) { $template->param('GoogleIndicTransliteration' => 1); } +$template->param( full_url => $cgi->url() ); + $template->{VARS}->{DidYouMean} = ( defined C4::Context->preference('OPACdidyoumean') && C4::Context->preference('OPACdidyoumean') =~ m/enable/ ); diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 84ee660..ef537d0 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -80,6 +80,8 @@ my $canrenew = 1; $template->param( shibbolethAuthentication => C4::Context->config('useshibboleth') ); +my $full_url = $ENV{HTTP_REFERER}; + if (!$borrowernumber) { $template->param( adminWarning => 1 ); } @@ -338,4 +340,9 @@ $template->param( failed_holds => scalar $query->param('failed_holds'), ); -output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; +if ( $full_url =~ /opac-search/ ) { + output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1, redirect_url => $full_url }; +} +else { + output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; +} -- 2.1.4