Bug 39680: "Clear" menu item doesn't delete search history

This patch fixes the behavior of the OPAC's "Clear" link, which was not
updated to work with CSRF protection.

To test:

- If necessary, go to Administration -> System preferences in the staff
  interface and set the EnableOpacSearchHistory preference to "Keep."
- Log in to the OPAC.
- If necessary, perform several catalog searches in order to populate
  your search history.
- Expand the user menu in the upper right-hand corner and click the
  "Clear" link next to "Search history."
  - You should be prompted to confirm.
  - After confirming your search history should be empty.

Sponsored-by: Athens County Public Libraries
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Owen Leonard 2025-05-19 11:16:43 +00:00 committed by Katrin Fischer
parent 4564ed5ef1
commit fa557624e9
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 10 additions and 4 deletions

View File

@ -170,7 +170,16 @@
<p>
<a tabindex="0" role="menuitem" class="login-link" href="/cgi-bin/koha/opac-search-history.pl" title="View your search history">Search history</a>
<span class="divider-vertical"></span>
<a class="clearsh" href="/cgi-bin/koha/opac-search-history.pl?action=delete" title="Delete your search history"><i class="fa fa-trash-can" aria-hidden="true"></i> Clear</a>
<a
class="clearsh submit-form-link"
href="#"
data-method="post"
data-action="/cgi-bin/koha/opac-search-history.pl"
data-op="cud-delete"
data-confirmation-msg="[% t('Are you sure you want to delete your search history?') | html %]"
title="Delete your search history"
><i class="fa fa-trash-can" aria-hidden="true"></i> Clear</a
>
</p>
[% END %]
<a tabindex="0" role="menuitem" class="logout" id="logout" href="/cgi-bin/koha/opac-main.pl?logout.x=1">Log out</a>

View File

@ -136,9 +136,6 @@
var biblionumber = $(this).data("biblionumber");
delSingleRecord( biblionumber );
});
$(".clearsh").on("click", function(){
return confirmDelete( _("Are you sure you want to delete your search history?") );
});
</script>
[% IF Koha.Preference( 'opacbookbag' ) == 1 %]
[% Asset.js("js/basket.js") | $raw %]