From 98c47acbcb8c0ecfbf43081b3db785c82bc0c713 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 15 Sep 2023 16:42:25 +0100 Subject: [PATCH] Bug 31503: (follow-up) Use KohaPlugins.feature_enabled This patch switches the code from using Koha.preference('OPACCustomConsentTypes') to using KohaPlugins.feature_enabled('patron_consent_type'). Signed-off-by: Martin Renvoize --- Koha/Patron/Consents.pm | 11 ++++------- Koha/Template/Plugin/KohaPlugins.pm | 2 +- .../opac-tmpl/bootstrap/en/includes/usermenu.inc | 3 ++- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Koha/Patron/Consents.pm b/Koha/Patron/Consents.pm index 7dcb14d6a94..43572e796ad 100644 --- a/Koha/Patron/Consents.pm +++ b/Koha/Patron/Consents.pm @@ -42,8 +42,7 @@ Koha::Objects class for handling patron consents Returns an HASHref of available consent types like: { type1 => {}, type2 => {}, .. } - Checks preferences OPACCustomConsentTypes and PrivacyPolicyConsent. - Calls patron_consent_type plugins (if pref enabled). + Checks PrivacyPolicyConsent preference and any patron_consent_type plugins (if pref enabled). Note: The plugins return an ARRAYref with type, title and description like: [ my_type => { title => { lang => 1, .. }, description => { lang => 2, .. } } ] @@ -54,11 +53,9 @@ sub available_types { my ($self) = shift; my $response = {}; $response->{GDPR_PROCESSING} = 1 if C4::Context->preference('PrivacyPolicyConsent'); - if ( C4::Context->preference('OPACCustomConsentTypes') ) { - foreach my $return ( Koha::Plugins->call('patron_consent_type') ) { - next if ref($return) ne 'ARRAY' or @$return != 2; # ignoring bad input - $response->{ $return->[0] } = $return->[1]; - } + foreach my $return ( Koha::Plugins->call('patron_consent_type') ) { + next if ref($return) ne 'ARRAY' or @$return != 2; # ignoring bad input + $response->{ $return->[0] } = $return->[1]; } return $response; } diff --git a/Koha/Template/Plugin/KohaPlugins.pm b/Koha/Template/Plugin/KohaPlugins.pm index 35ac34bcf3f..73b295dbaac 100644 --- a/Koha/Template/Plugin/KohaPlugins.pm +++ b/Koha/Template/Plugin/KohaPlugins.pm @@ -291,7 +291,7 @@ This method returns true if the passed plugin hook method name is found to be in =cut sub feature_enabled { - my ($self, $method) = @_; + my ( $self, $method ) = @_; my $p = Koha::Plugins->new(); return 0 unless $p; diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc index 5d594989e50..863ab70be4d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc @@ -1,4 +1,5 @@ [% USE Koha %] +[% USE KohaPlugins %] [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && loggedinusername ) %]