-
Search history
-
- [% IF Koha.Preference( 'OpacAuthorities' ) == 1 %]
-
-
+
Search history
+ [% IF Koha.Preference( 'OpacAuthorities' ) == 1 %]
+
+
+ [% END %]
+
+
+ [% IF ( current_biblio_searches ) %]
+
Current session
+
[% END %]
-
- [% IF ( current_biblio_searches ) %]
-
Current session
-
-
-
-
- Date |
- Search |
- Results |
-
-
-
- [% FOREACH s IN current_biblio_searches %]
-
- [% s.time |$KohaDates with_hours => 1 %] |
- [% s.query_desc |html %] |
- [% s.total %] |
-
- [% END %]
-
-
- [% END %]
-
- [% IF ( previous_biblio_searches ) %]
-
Previous sessions
-
-
-
-
- Date |
- Search |
- Results |
-
-
-
- [% FOREACH s IN previous_biblio_searches %]
-
- [% s.time |$KohaDates with_hours => 1 %] |
- [% s.query_desc |html %] |
- [% s.total %] |
-
- [% END %]
-
-
- [% END %]
+
- [% IF !current_biblio_searches && !previous_biblio_searches %]
-
Your catalog search history is empty.
- [% END %]
-
+
+ [% IF ( previous_biblio_searches ) %]
+
Previous sessions
+
+ [% END %]
+
+ [% IF !current_biblio_searches && !previous_biblio_searches %]
+
Your catalog search history is empty.
+ [% END %]
+
- [% IF Koha.Preference( 'OpacAuthorities' ) == 1 %]
-
- [% IF ( current_authority_searches ) %]
-
Current session
-
-
+ [% IF Koha.Preference( 'OpacAuthorities' ) == 1 %]
+
+ [% IF ( current_authority_searches ) %]
+
Current session
+
-
+
+ [% END %]
+
+ [% IF ( previous_authority_searches ) %]
+ Previous sessions
+
+ [% END %]
- [% IF !current_authority_searches && !previous_authority_searches %]
- Your authority search history is empty.
- [% END %]
+ [% IF !current_authority_searches && !previous_authority_searches %]
+ Your authority search history is empty.
+ [% END %]
[% END %]
@@ -176,23 +211,67 @@
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
[% INCLUDE 'datatables.inc' %]
+
--- a/opac/opac-search-history.pl
+++ a/opac/opac-search-history.pl
@@ -37,7 +37,7 @@ my $cgi = new CGI;
# Getting the template and auth
my ($template, $loggedinuser, $cookie) = get_template_and_user(
{
- template_name => "opac-search-history.tmpl",
+ template_name => "opac-search-history.tt",
query => $cgi,
type => "opac",
authnotrequired => 1,
@@ -53,13 +53,21 @@ my $previous = $cgi->param('previous');
# If the user is not logged in, we deal with the session
unless ( $loggedinuser ) {
# Deleting search history
- if ($cgi->param('action') && $cgi->param('action') eq 'delete') {
+ if ( $action eq 'delete') {
# Deleting session's search history
+ my @id = $cgi->param('id');
+ my $all = not scalar( @id );
+
my $type = $cgi->param('type');
my @searches = ();
- if ( $type ) {
+ unless ( $all ) {
@searches = C4::Search::History::get_from_session({ cgi => $cgi });
- @searches = map { $_->{type} ne $type ? $_ : () } @searches;
+ if ( $type ) {
+ @searches = map { $_->{type} ne $type ? $_ : () } @searches;
+ }
+ if ( @id ) {
+ @searches = map { my $search = $_; ( grep {/^$search->{id}$/} @id ) ? () : $_ } @searches;
+ }
}
C4::Search::History::set_to_session({ cgi => $cgi, search_history => \@searches });
@@ -92,17 +100,20 @@ unless ( $loggedinuser ) {
# Deleting search history
if ( $action eq 'delete' ) {
- my $sessionid = defined $previous
- ? $cgi->cookie("CGISESSID")
- : q{};
- C4::Search::History::delete(
- {
- userid => $loggedinuser,
- sessionid => $sessionid,
- type => $type,
- previous => $previous
- }
- );
+ my @id = $cgi->param('id');
+ if ( @id ) {
+ C4::Search::History::delete(
+ {
+ id => [ $cgi->param('id') ],
+ }
+ );
+ } else {
+ C4::Search::History::delete(
+ {
+ userid => $loggedinuser,
+ }
+ );
+ }
# Redirecting to this same url so the user won't see the search history link in the header
my $uri = $cgi->url();
print $cgi->redirect($uri);
--