use Modern::Perl;
-use C4::Auth qw(:DEFAULT get_session);
+use C4::Auth qw( get_template_and_user );
use CGI qw ( -utf8 );
use C4::Context;
-use C4::Output;
-use C4::Log;
-use C4::Items;
-use C4::Debug;
+use C4::Output qw( output_html_with_http_headers );
use C4::Search::History;
-use URI::Escape;
-use POSIX qw(strftime);
-my $cgi = new CGI;
+my $cgi = CGI->new;
# Getting the template and auth
my ($template, $loggedinuser, $cookie) = get_template_and_user(
query => $cgi,
type => "opac",
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
- debug => 1,
}
);
+unless ( C4::Context->preference("EnableOpacSearchHistory") ) {
+ print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
+ exit;
+}
+
my $type = $cgi->param('type');
my $action = $cgi->param('action') || q{};
my $previous = $cgi->param('previous');
@searches = map { $_->{type} ne $type ? $_ : () } @searches;
}
if ( @id ) {
- @searches = map { my $search = $_; ( grep {/^$search->{id}$/} @id ) ? () : $_ } @searches;
+ @searches = map { my $search = $_; ( grep { $_ eq $search->{id} } @id ) ? () : $_ } @searches;
}
}
C4::Search::History::set_to_session({ cgi => $cgi, search_history => \@searches });
C4::Search::History::delete(
{
userid => $loggedinuser,
- id => [ $cgi->param('id') ],
+ id => [ @id ],
}
);
} else {