Bug 17153: Redirect to search when logging in from search
authorLee Jamison <ldjamison@marywood.edu>
Wed, 30 May 2018 00:26:56 +0000 (00:26 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 29 Jun 2018 20:49:51 +0000 (20:49 +0000)
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>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt
koha-tmpl/opac-tmpl/bootstrap/js/authtoresults.js [new file with mode: 0644]
opac/opac-user.pl

index 3ace3a4..15d185f 100644 (file)
             <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 ) %]
index c30f330..b0bf5a6 100644 (file)
 [% 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 (file)
index 0000000..8471eac
--- /dev/null
@@ -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
index 4e54afc..78bd30b 100755 (executable)
@@ -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 };