From 62b3d06507eef9bc1fe26cd1bd8e4619017c2bda Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Mar 2025 05:18:27 +0000 Subject: [PATCH] Bug 39372: Limit OPAC list creation This change adds a new system preference OpacAllowPrivateListCreation, which works with the existing system preference OpacAllowPublicListCreation, to determine when "New list", "Save to lists", "Add to list", "Save to another list", and "Add to a list" should appear. If both sysprefs are disabled, then you cannot do these actions. If one of the sysprefs is enabled, then these actions appear, but are limited to the private or public list type respective to the syspref. Test plan: 0. Apply the patch and koha-plack --restart kohadev 1. Perform the following steps using differing combinations of OpacAllowPrivateListCreation, or OpacAllowPublicListCreation, or both disabled 2. Click on Lists in masthead nav and note presence of "New list" link 3. Perform a search 4. Note the presence of "Save to lists" and "Add to list" links 5. Go to a record detail page 6. Note the presence of "Save to your lists" on the sidebar 7. Create a list 8. Go to the list 9. Note the presence of "Save to another list" and "New list" links 10. Add a record to the cart 11. Note the presence of "Add to a list" link --- .../prog/en/modules/admin/preferences/opac.pref | 7 +++++++ .../opac-tmpl/bootstrap/en/includes/masthead.inc | 6 ++++-- .../en/includes/opac-detail-sidebar.inc | 2 +- .../en/includes/result-batch-controls.inc | 8 +++++--- .../bootstrap/en/includes/title-actions-menu.inc | 2 +- .../en/modules/opac-addbybiblionumber.tt | 7 +++++++ .../bootstrap/en/modules/opac-basket.tt | 2 +- .../bootstrap/en/modules/opac-shelves.tt | 16 +++++++++++----- 8 files changed, 37 insertions(+), 13 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 37202dc17c6..5331c314aed 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 @@ -674,6 +674,13 @@ OPAC: 0: "Don't hide" 1: Hide - "the bibliographic record when all its items are hidden by OpacHiddenItems." + - + - pref: OpacAllowPrivateListCreation + default: 1 + choices: + 0: "Don't allow" + 1: Allow + - "OPAC users to create private lists." - - pref: OpacAllowPublicListCreation default: 1 diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index 2b6d4478d6d..a14e185e60d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -98,8 +98,10 @@ [% ELSE %] No private lists [% END %] - New list - [% ELSE %] + [% IF ( Koha.Preference('OpacAllowPublicListCreation') || Koha.Preference('OpacAllowPrivateListCreation') ) %] + New list + [% END %] + [% ELSIF ( Koha.Preference('OpacAllowPublicListCreation') || Koha.Preference('OpacAllowPrivateListCreation') ) %] Log in to create your own lists [% END # / IF loggedinusername %] [% END # / IF opacuserlogin %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc index 03e74f148cf..74f39e80c67 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc @@ -35,7 +35,7 @@ [% END %] [% IF Koha.Preference( 'virtualshelves' ) == 1 %] - [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && loggedinusername ) %] + [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && loggedinusername && ( Koha.Preference('OpacAllowPublicListCreation') || Koha.Preference('OpacAllowPrivateListCreation') ) ) %]
  • Save to your lists
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/result-batch-controls.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/result-batch-controls.inc index 1a9e80aa629..da58793675e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/result-batch-controls.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/result-batch-controls.inc @@ -29,9 +29,11 @@ [% IF ( ListsEnabled ) %]
    - + [% IF ( Koha.Preference('OpacAllowPublicListCreation') || Koha.Preference('OpacAllowPrivateListCreation') ) %] + + [% END %] + [% END %] [% #END %] [% #END %] [% END %] @@ -137,6 +140,7 @@
    [% IF ( authorized ) %] [% UNLESS ( singleshelf ) %] + [% IF ( Koha.Preference('OpacAllowPublicListCreation') || Koha.Preference('OpacAllowPrivateListCreation') ) %]
    [% INCLUDE 'csrf-token.inc' %]
    @@ -148,7 +152,9 @@
    @@ -689,7 +695,7 @@ [% END %] [% SET show_new_list = 0 %] - [% IF !public || Koha.Preference('OpacAllowPublicListCreation') %] + [% IF Koha.Preference('OpacAllowPrivateListCreation') || Koha.Preference('OpacAllowPublicListCreation') %] [% IF loggedinusername %] [% show_new_list = 1 %] [% ELSE %] @@ -804,7 +810,7 @@
    [% ELSIF NOT loggedinusernumber %] - [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] + [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference('OpacAllowPublicListCreation') || Koha.Preference('OpacAllowPrivateListCreation') ) %] [% END %] [% END # IF op == 'add_form' OR op == 'edit_form' %] -- 2.39.5