From 522af7987ff16c008ee7d2856889e35542dc8c85 Mon Sep 17 00:00:00 2001 From: Lee Jamison <ldjamison@marywood.edu> Date: Wed, 30 May 2018 00:26:56 +0000 Subject: [PATCH] Bug 17153: Redirect to search when logging in from search This patch is a fresh attempt at redirecting back to search results after logging in on opac-search.pl To test: - Perform an OPAC search - Login on opac-search.pl with the search results displayed - The page is redirected to opac-user.pl - Log out - Apply the patch - Perform a new OPAC search - Note the URL query string - Login on opac-search.pl with the search results displayed - The opac-search.pl page should be displayed with the correct query string and the page should indicate a logged in status Signed-off-by: Maryse Simard <maryse.simard@inlibro.com> Followed the test plan and the patch works. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> --- koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc | 1 + koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt | 1 + koha-tmpl/opac-tmpl/bootstrap/js/authtoresults.js | 10 ++++++++++ opac/opac-user.pl | 12 ++++++++++++ 4 files changed, 24 insertions(+) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/authtoresults.js diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index 0984563..b91328a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -301,6 +301,7 @@ <h3 id="modalLoginLabel">Log in to your account</h3> </div> <form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="modalAuth"> + <input type="hidden" name="has-search-query" id="has-search-query" value="" /> <div class="modal-body"> [% IF ( shibbolethAuthentication ) %] [% IF ( invalidShibLogin ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index c30f330..b0bf5a6 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -594,6 +594,7 @@ [% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %][% Asset.js("lib/jquery/plugins/jquery.rating.js") %][% END %] [% IF ( OverDriveEnabled ) %][% Asset.js("js/overdrive.js") %][% END %] [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %] +[% Asset.js("js/authtoresults.js") %] [% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") %] [% END %]<script> //<![CDATA[ diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/authtoresults.js b/koha-tmpl/opac-tmpl/bootstrap/js/authtoresults.js new file mode 100644 index 0000000..8471eac --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/js/authtoresults.js @@ -0,0 +1,10 @@ +if (window.location.href.indexOf("opac-search.pl") > -1) { + + // extract search params + var searchUrl = location.href; + var searchParams = searchUrl.substring(searchUrl.indexOf("?")+1); + + // store search params in loginModal to pass back on redirect + var query = document.getElementById("has-search-query"); + query.value = searchParams; +} \ No newline at end of file diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 4e54afc..78bd30b 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -362,4 +362,16 @@ $template->param( failed_holds => scalar $query->param('failed_holds'), ); +# if not an empty string this indicates to return +# back to the opac-results page +my $search_query = $query->param('has-search-query'); + +if ($search_query ne '') { + + print $query->redirect( + -uri => "/cgi-bin/koha/opac-search.pl?$search_query", + -cookie => $cookie, + ); +} + output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; -- 2.1.4