From b2e180e0337cd8606cecef982c1032837f929dad Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Mar 2025 01:41:26 +0000 Subject: [PATCH] Bug 39374: Add feature to block sending of lists from OPAC This change adds a system preference OPACDisableSendList which disables the ability to send lists from the OPAC, and hides the "Send list" link on the opac-shelves.pl page. This is useful in situations where you do not want OPAC users to be able to generate emails to arbitrary addresses with arbitrary comments. Test plan: 0. Apply the patch and koha-plack --restart kohadev 1. Create a public list with at least one record and view it in the OPAC 2. Click "Send list" and note you can fill out boxes for "Email address" and "Comment" 3. Change syspref OPACDisableSendList to "Don't allow" and click "Send list" again 4. Note the popup window now says "You do not have permission to send this list." 5. Reload the list web page and notice "Send list" no longer appears on the toolbar next to "Print list" Signed-off-by: Brendan Gallagher Signed-off-by: Baptiste Wojtkowski --- .../prog/en/modules/admin/preferences/opac.pref | 7 +++++++ .../opac-tmpl/bootstrap/en/modules/opac-sendshelfform.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 2 +- opac/opac-sendshelf.pl | 6 ++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index ec83b17a..c3d273b6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -572,6 +572,13 @@ OPAC: summary: "in user summary box on OPAC homepage (the system preference 'OPACUserSummary' must be enabled)" user: "on patron's 'your summary' page" - ". Note that displayed savings may be inaccurate if checkout history is anonymized." + - + - pref: OPACDisableSendList + default: 0 + choices: + 1: "Don't allow" + 0: Allow + - "OPAC users to email lists via a 'Send list' button" OpenURL: - - 'Complete URL of OpenURL resolver (starting with http:// or https://):' diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelfform.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelfform.tt index 0b67a027..459ced00 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelfform.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelfform.tt @@ -25,7 +25,7 @@ [% END %] [% ELSE %] - [% IF ( invalidlist ) %] + [% IF ( invalidlist || Koha.Preference('OPACDisableSendList') ) %]

You do not have permission to send this list.

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index 22dcb2a5..a6f76a74 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -258,7 +258,7 @@ - [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] + [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( ! Koha.Preference('OPACDisableSendList') ) %] Send list diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index 6674509c..7168f9d6 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -52,6 +52,12 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); +if ( C4::Context->preference('OPACDisableSendList') ) { + output_html_with_http_headers $query, $cookie, $template->output, undef, + { force_no_caching => 1 }; + exit; +} + my $shelfid = $query->param('shelfid'); my $email = $query->param('email'); my $op = $query->param('op') // q{}; -- 2.30.2