From fd85c30ff158e6b2b3e7f0c47e4ce50f5394f08c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 2 Sep 2022 07:41:27 +0000 Subject: [PATCH] Bug 31503: (Experimental) Configurable consent text Content-Type: text/plain; charset=utf-8 This patch allows you to add title and content from the Additional Contents module but it is still slightly experimental since we depend on setting the code column to a value that is not yet supported. Will open a report for that. Note however that the template contains a fallback in case you might not be able to add contents yet. Test plan: [1] Add a NEWSLETTER value under AV category PATRON_CONSENT. [2] Add a PatronConsent record under html customizations. Only add title and content for Default. [3] Change code via SQL (awaiting further AC development): update additional_contents set code='PatronConsent_NEWSLETTER' where location='PatronConsent' and idnew=[YOUR_ID] Note: YOUR_ID refers to the record you added. After this change, you will be able to add translations under Additional contents. The code will be copied. [4] Finally, check patron consent page for your text. Signed-off-by: Marcel de Rooy --- .../en/modules/tools/additional-contents.tt | 2 +- .../en/modules/opac-patron-consent.tt | 18 ++++++++++++++---- opac/opac-patron-consent.pl | 12 +++++++++++- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt index 070b3063d5..051debbbf6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -484,7 +484,7 @@ [% END %] [% END %] [% ELSE %] - [% FOREACH l IN [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote' ] %] + [% FOREACH l IN [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'PatronConsent' ] %] [% IF l == location %] [% ELSE %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-patron-consent.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-patron-consent.tt index 512a0a8078..f64706fde1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-patron-consent.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-patron-consent.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE AdditionalContents %] +[% USE raw %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET consentview = 1 %] @@ -41,15 +42,24 @@ [% FOREACH consent IN consents %] -

Consent for [% consent.type | html %]

+ [% SET ac_key = 'PatronConsent_' _ consent.type %] +

+ [% IF additional_contents.$ac_key && additional_contents.$ac_key.title %] + [% additional_contents.$ac_key.title | html %] + [% ELSE %] + Consent for [% consent.type | html %] + [% END %] +

  • - [% IF consent.type == 'GDPR_PROCESSING' %] + [% IF additional_contents.$ac_key && additional_contents.$ac_key.content %] + [% additional_contents.$ac_key.content | $raw %] + [% ELSIF consent.type == 'GDPR_PROCESSING' # Backward compatbility ;) %]

    Please read the privacy policy.

    In order to keep you logged in, we need your consent to process personal data as specified in the EU General Data Protection Regulation of May 25, 2018. If you would not agree, we will need to remove your account within a reasonable time.

    Do you agree with our processing of your personal data as outlined in the policy?

    - [% ELSE %] -

    Description for [% consent.type | html #TODO %]. Do you agree?

    + [% ELSE # Fallback only %] +

    Description for [% consent.type | html %]. Do you agree?

    [% END %]

    Yes
    diff --git a/opac/opac-patron-consent.pl b/opac/opac-patron-consent.pl index fdf0aa90b0..0072d596f7 100755 --- a/opac/opac-patron-consent.pl +++ b/opac/opac-patron-consent.pl @@ -22,6 +22,7 @@ use CGI qw/-utf8/; use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); +use Koha::AdditionalContents; use Koha::AuthorisedValueCategories; use Koha::DateUtils qw( dt_from_string ); use Koha::Patrons; @@ -72,6 +73,15 @@ if( C4::Context->preference('GDPR_Policy') eq 'Enforced' && $needs_redirect ) { exit; } -$template->param( patron => $patron, consents => $consents ); +my $rs = Koha::AdditionalContents->search({ + # This could be moved to the template some day when both AC and TT plugin allow for it + category => 'html_customizations', + location => 'PatronConsent', + branchcode => undef, # TODO Branch limits +}); +my $additional_contents = { map { ( $_->code => { title => $_->title, content => $_->content } ) } $rs->as_list }; + #FIXME This assumes that the code contains PatronConsent_{CONTENT_TYPE}. This still needs AC adjustments. + +$template->param( patron => $patron, consents => $consents, additional_contents => $additional_contents ); output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; -- 2.20.1