Bugzilla – Attachment 140048 Details for
Bug 31503
Allow several consent types on the consents tab of OPAC account page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31503: Use patron->consent in opac-patron-consent
Bug-31503-Use-patron-consent-in-opac-patron-consen.patch (text/plain), 8.22 KB, created by
Marcel de Rooy
on 2022-09-01 14:26:55 UTC
(
hide
)
Description:
Bug 31503: Use patron->consent in opac-patron-consent
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-09-01 14:26:55 UTC
Size:
8.22 KB
patch
obsolete
>From ef5a810a8f643cb1083b30452dac97f0011e9871 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 1 Sep 2022 09:04:59 +0000 >Subject: [PATCH] Bug 31503: Use patron->consent in opac-patron-consent >Content-Type: text/plain; charset=utf-8 > >Includes a few small additional changes in template: >[1] op == save (more generic) >[2] agreed/disagreed replaced by 1/0 >[3] toggling display of consent_info paragraph > >Test plan: >Enable GDPR_Policy. >Test adding/removing consent. Check what happens with >alert, consent_info paragraph and save button. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > .../en/modules/opac-patron-consent.tt | 52 +++++++++++-------- > opac/opac-patron-consent.pl | 32 +++--------- > 2 files changed, 38 insertions(+), 46 deletions(-) > >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 68c3e459d6..d00146e7ff 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 >@@ -48,25 +48,25 @@ > <form action="/cgi-bin/koha/opac-patron-consent.pl" method="post"> > [% IF Koha.Preference('GDPR_Policy') %] > <legend><h2 id="GDPR_consents">GDPR consents</h2></legend> >- <input type="hidden" name="op" value="gdpr_proc_save"/> >+ <input type="hidden" name="op" value="save"/> > <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]"/> > <fieldset> > <ul><li> > <p>I have read the <a target="_blank" href="[% Koha.Preference('PrivacyPolicyURL') | url %]">privacy policy</a> and agree with your processing of my personal data as outlined therein.</p> >- <p><input type="radio" name="gdpr_processing" value="agreed"> Yes, I agree.<br> >- <input type="radio" name="gdpr_processing" value="disagreed"> No, I do not agree. Please remove my account within a reasonable time.</p> >- [% IF gdpr_proc_consent %] >- <p>Your consent was registered on [% gdpr_proc_consent | html %].</p> >- [% ELSIF gdpr_proc_refusal %] >- <p>You indicated recently that you do not consent, and we will process your request soon.</p> >+ <p><input type="radio" name="gdpr_processing" value="1"> Yes, I agree.<br> >+ <input type="radio" name="gdpr_processing" value="0"> No, I do not agree. Please remove my account within a reasonable time.</p> >+ [% IF gdpr_proc_consent.given_on %] >+ <p class="consent_info">Your consent was registered on [% gdpr_proc_consent.given_on | html %].</p> >+ [% ELSIF gdpr_proc_consent.refused_on %] >+ <p class="consent_info">You indicated recently that you do not consent, and we will process your request soon.</p> > [% END %] > </li></ul> > </fieldset> >- <fieldset class="action"> >- <input id="saveconsent" type="submit" value="Save" class="btn btn-primary" /> >- </fieldset> > [% END %] > >+ <fieldset class="action"> >+ <input id="saveconsent" type="submit" value="Save" class="btn btn-primary" /> >+ </fieldset> > </form> > > </div> <!-- / #userpasswd --> >@@ -80,23 +80,31 @@ > <script> > var consent = null; > $(document).ready(function() { >- [% IF gdpr_proc_consent %] >- consent=1; >- $("input[type='radio'][value='agreed']").prop('checked',true); >- $(".alert").hide(); >- [% ELSIF gdpr_proc_refusal %] >- consent=0; >- $("input[type='radio'][value='disagreed']").prop('checked',true); >- [% ELSE %] >+ [% IF Koha.Preference('GDPR_Policy') %] >+ [% IF gdpr_proc_consent.given_on %] >+ consent=1; >+ $("input[type='radio'][value='1']").prop('checked',true); >+ $(".alert").hide(); >+ [% ELSIF gdpr_proc_consent.refused_on %] >+ consent=0; >+ $("input[type='radio'][value='0']").prop('checked',true); >+ [% ELSE %] >+ [% END %] > [% END %] >+ // Initially no choice is made or no change, so disable button > $("#saveconsent").prop('disabled', true); > > $("input[type='radio']").click(function() { > var radio = $(this).val(); >- if(radio=='agreed' && (consent==null || consent==0)) $("#saveconsent").prop('disabled', false); >- if(radio=='disagreed' && (consent==null || consent==1)) $("#saveconsent").prop('disabled', false); >- if(radio=='agreed') $(".alert").hide(); >- if(radio=='disagreed') $(".alert").show(); >+ if( radio=='1' && (consent==null || consent==0) ) { >+ $("#saveconsent").prop('disabled', false); >+ $(".consent_info").hide(); >+ } else if( radio=='0' && (consent==null || consent==1) ) { >+ $("#saveconsent").prop('disabled', false); >+ $(".consent_info").hide(); >+ } >+ if( radio=='1' ) $(".alert").hide(); >+ if( radio=='0' ) $(".alert").show(); > }); > > }); >diff --git a/opac/opac-patron-consent.pl b/opac/opac-patron-consent.pl >index 017e04e9be..87b57d7c1e 100755 >--- a/opac/opac-patron-consent.pl >+++ b/opac/opac-patron-consent.pl >@@ -23,7 +23,6 @@ use CGI qw/-utf8/; > use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use Koha::DateUtils qw( dt_from_string ); >-use Koha::Patron::Consents; > use Koha::Patrons; > > use constant GDPR_PROCESSING => 'GDPR_PROCESSING'; >@@ -41,26 +40,17 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user({ > my $patron = Koha::Patrons->find($borrowernumber); > my $gdpr_proc_consent; > if( C4::Context->preference('GDPR_Policy') ) { >- $gdpr_proc_consent = Koha::Patron::Consents->search({ >- borrowernumber => $borrowernumber, >- type => GDPR_PROCESSING, >- })->next; >- $gdpr_proc_consent //= Koha::Patron::Consent->new({ >- borrowernumber => $borrowernumber, >- type => GDPR_PROCESSING, >- }); >+ $gdpr_proc_consent = $patron->consent(GDPR_PROCESSING); > } > > # Handle saves here >-if( $op eq 'gdpr_proc_save' && $gdpr_proc_consent ) { >- if( $gdpr_check eq 'agreed' ) { >- $gdpr_proc_consent->given_on( dt_from_string() ); >- $gdpr_proc_consent->refused_on( undef ); >- } elsif( $gdpr_check eq 'disagreed' ) { >- $gdpr_proc_consent->given_on( undef ); >- $gdpr_proc_consent->refused_on( dt_from_string() ); >+if( $op eq 'save' ) { >+ if( $gdpr_proc_consent ) { >+ $gdpr_proc_consent->set({ >+ given_on => $gdpr_check ? dt_from_string() : undef, >+ refused_on => $gdpr_check ? undef : dt_from_string(), >+ })->store; > } >- $gdpr_proc_consent->store; > } > > # If user refused GDPR consent and we enforce GDPR, logout (when saving) >@@ -70,12 +60,6 @@ if( $op =~ /save/ && C4::Context->preference('GDPR_Policy') eq 'Enforced' && $gd > exit; > } > >-$template->param( patron => $patron ); >-if( $gdpr_proc_consent ) { >- $template->param( >- gdpr_proc_consent => $gdpr_proc_consent->given_on // q{}, >- gdpr_proc_refusal => $gdpr_proc_consent->refused_on // q{}, >- ); >-} >+$template->param( patron => $patron, gdpr_proc_consent => $gdpr_proc_consent ); > > output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31503
:
140047
|
140048
|
140049
|
140050
|
140080
|
140081
|
140082
|
140083
|
140084
|
140085
|
140087
|
140088
|
140089
|
140090
|
140666
|
140667
|
140668
|
140669
|
140670
|
140671
|
140672
|
141216
|
141217
|
141218
|
141219
|
141220
|
141221
|
141222
|
141263
|
141264
|
141265
|
141266
|
141267
|
141268
|
141269
|
141302
|
141570
|
155000
|
155001
|
155002
|
155003
|
155177
|
155178
|
155179
|
155180
|
155189
|
155190
|
155191
|
155656
|
155657
|
155658
|
155659
|
155660
|
155661
|
155691
|
155694
|
155783
|
155784
|
155785
|
155786
|
155787
|
155788
|
155789
|
155790
|
155791
|
157117
|
157118
|
157119
|
157120
|
157121
|
157122
|
157123
|
157124
|
157125
|
157126
|
157773
|
157774
|
157775
|
157776
|
157777
|
157778
|
157779
|
157780
|
157781
|
157782
|
157783