View | Details | Raw Unified | Return to bug 38769
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-2 / +32 lines)
Lines 1356-1361 Link Here
1356
                            <!-- /.row -->
1356
                            <!-- /.row -->
1357
                        [% END %]
1357
                        [% END %]
1358
1358
1359
                        [% IF consent_types.size && op != 'edit' %]
1360
                            [% FOREACH consent_type IN consent_types.keys %]
1361
                                [% IF consent_type != 'GDPR_PROCESSING' %]
1362
                                    [% SET consent_title = ( consent_types.$consent_type.title.$lang || consent_types.$consent_type.title.en ) %]
1363
                                    [% SET consent_desc  = ( consent_types.$consent_type.description.$lang || consent_types.$consent_type.description.en ) %]
1364
                                    <div class="row">
1365
                                        <div class="col">
1366
                                            <h2 class="sr-only">[% consent_title | html %]</h2>
1367
                                            <fieldset class="rows memberentry_plugin_consent">
1368
                                                <legend>[% consent_title | html %]</legend>
1369
                                                <ol>
1370
                                                    <li>
1371
                                                        <div class="label"></div>
1372
                                                        <p>[% consent_desc | html %]</p>
1373
                                                        <label class="checkbox-label" for="consent_[% consent_type | html %]">
1374
                                                            <input type="checkbox" name="consent_[% consent_type | html %]" id="consent_[% consent_type | html %]" value="agreed" />
1375
                                                            <span>I agree</span>
1376
                                                        </label>
1377
                                                    </li>
1378
                                                </ol>
1379
                                            </fieldset>
1380
                                        </div>
1381
                                        <!-- /.col -->
1382
                                    </div>
1383
                                    <!-- /.row -->
1384
                                [% END %]
1385
                            [% END %]
1386
                        [% END %]
1387
1359
                        <div class="row">
1388
                        <div class="row">
1360
                            <div class="col">
1389
                            <div class="col">
1361
                                [% IF op == 'edit' %]
1390
                                [% IF op == 'edit' %]
Lines 1375-1382 Link Here
1375
                            <!-- /.col -->
1404
                            <!-- /.col -->
1376
                        </div>
1405
                        </div>
1377
                        <!-- /.row -->
1406
                        <!-- /.row -->
1378
                    </form> </div
1407
                    </form>
1379
                ><!--/div#update-account -->
1408
                </div>
1409
                <!--/div#update-account -->
1380
            </div>
1410
            </div>
1381
        </div>
1411
        </div>
1382
        <!-- / .row -->
1412
        <!-- / .row -->
(-)a/opac/opac-memberentry.pl (-4 / +50 lines)
Lines 33-38 use C4::Members::Messaging qw( SetMessagingPreferencesFromDefaults ); Link Here
33
use Koha::AuthUtils;
33
use Koha::AuthUtils;
34
use Koha::Patrons;
34
use Koha::Patrons;
35
use Koha::Patron::Consent;
35
use Koha::Patron::Consent;
36
use Koha::Patron::Consents;
36
use Koha::Patron::Modification;
37
use Koha::Patron::Modification;
37
use Koha::Patron::Modifications;
38
use Koha::Patron::Modifications;
38
use C4::Scrubber;
39
use C4::Scrubber;
Lines 205-211 if ( $op eq 'cud-create' ) { Link Here
205
            $borrower{verification_token} = $verification_token;
206
            $borrower{verification_token} = $verification_token;
206
207
207
            $borrower{extended_attributes} = to_json($attributes);
208
            $borrower{extended_attributes} = to_json($attributes);
208
            $borrower{borrowernumber}      = 0;                      # prevent warn Missing value for PK column
209
210
            # Store plugin consents for processing after email verification
211
            my $plugin_consents = ParsePluginConsents($cgi);
212
            $borrower{consents} = to_json($plugin_consents) if keys %$plugin_consents;
213
214
            $borrower{borrowernumber} = 0;    # prevent warn Missing value for PK column
209
            Koha::Patron::Modification->new( \%borrower )->store();
215
            Koha::Patron::Modification->new( \%borrower )->store();
210
216
211
            #Send verification email
217
            #Send verification email
Lines 230-236 if ( $op eq 'cud-create' ) { Link Here
230
        } else {
236
        } else {
231
            $borrower{password} ||=
237
            $borrower{password} ||=
232
                Koha::AuthUtils::generate_password( Koha::Patron::Categories->find( $borrower{categorycode} ) );
238
                Koha::AuthUtils::generate_password( Koha::Patron::Categories->find( $borrower{categorycode} ) );
233
            my $consent_dt = delete $borrower{gdpr_proc_consent};
239
            my $consent_dt      = delete $borrower{gdpr_proc_consent};
240
            my $plugin_consents = ParsePluginConsents($cgi);
234
            my $patron;
241
            my $patron;
235
            try {
242
            try {
236
                $patron = Koha::Patron->new( \%borrower )->store;
243
                $patron = Koha::Patron->new( \%borrower )->store;
Lines 238-243 if ( $op eq 'cud-create' ) { Link Here
238
                    { borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt } )
245
                    { borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt } )
239
                    ->store
246
                    ->store
240
                    if $patron && $consent_dt;
247
                    if $patron && $consent_dt;
248
249
                # Store plugin consents
250
                foreach my $consent_type ( keys %$plugin_consents ) {
251
                    Koha::Patron::Consent->new(
252
                        {
253
                            borrowernumber => $patron->borrowernumber,
254
                            type           => $consent_type,
255
                            given_on       => $plugin_consents->{$consent_type}
256
                        }
257
                        )->store
258
                        if $patron;
259
                }
260
241
                C4::Members::Messaging::SetMessagingPreferencesFromDefaults(
261
                C4::Members::Messaging::SetMessagingPreferencesFromDefaults(
242
                    { borrowernumber => $patron->borrowernumber, categorycode => $patron->categorycode } );
262
                    { borrowernumber => $patron->borrowernumber, categorycode => $patron->categorycode } );
243
            } catch {
263
            } catch {
Lines 277-283 if ( $op eq 'cud-create' ) { Link Here
277
                            my $letter = GetPreparedLetter(
297
                            my $letter = GetPreparedLetter(
278
                                module      => 'members',
298
                                module      => 'members',
279
                                letter_code => 'WELCOME',
299
                                letter_code => 'WELCOME',
280
                                branchcode  => $patron->branchcode,,
300
                                branchcode  => $patron->branchcode,
281
                                lang        => $patron->lang || 'default',
301
                                lang        => $patron->lang || 'default',
282
                                tables      => {
302
                                tables      => {
283
                                    'branches'  => $patron->branchcode,
303
                                    'branches'  => $patron->branchcode,
Lines 404-410 if ( $op eq 'cud-create' ) { Link Here
404
} else {
424
} else {
405
425
406
    # Render self-registration page
426
    # Render self-registration page
407
    $template->param( patron_attribute_classes => GeneratePatronAttributesForm() );
427
    my $consent_types = Koha::Patron::Consents->available_types;
428
    $template->param(
429
        consent_types            => $consent_types,
430
        patron_attribute_classes => GeneratePatronAttributesForm()
431
    );
408
}
432
}
409
433
410
my $captcha      = random_string("CCCCC");
434
my $captcha      = random_string("CCCCC");
Lines 817-820 sub ParsePatronAttributes { Link Here
817
    return \@attributes;
841
    return \@attributes;
818
}
842
}
819
843
844
sub ParsePluginConsents {
845
    my ($cgi) = @_;
846
847
    my $consent_types = Koha::Patron::Consents->available_types;
848
    my %consents;
849
850
    foreach my $consent_type ( keys %$consent_types ) {
851
852
        # Skip GDPR_PROCESSING as it's handled separately
853
        next if $consent_type eq 'GDPR_PROCESSING';
854
855
        my $param_name = "consent_$consent_type";
856
        my $value      = $cgi->param($param_name);
857
858
        if ( $value && $value eq 'agreed' ) {
859
            $consents{$consent_type} = dt_from_string();
860
        }
861
    }
862
863
    return \%consents;
864
}
865
820
1;
866
1;
(-)a/opac/opac-registration-verify.pl (-4 / +21 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use CGI qw ( -utf8 );
20
use CGI  qw ( -utf8 );
21
use JSON qw( from_json );
21
use Try::Tiny;
22
use Try::Tiny;
22
23
23
use C4::Auth qw( get_template_and_user );
24
use C4::Auth qw( get_template_and_user );
Lines 28-33 use C4::Members; Link Here
28
use C4::Members::Messaging qw( SetMessagingPreferencesFromDefaults );
29
use C4::Members::Messaging qw( SetMessagingPreferencesFromDefaults );
29
use C4::Form::MessagingPreferences;
30
use C4::Form::MessagingPreferences;
30
use Koha::AuthUtils;
31
use Koha::AuthUtils;
32
use Koha::DateUtils qw( dt_from_string );
31
use Koha::Patrons;
33
use Koha::Patrons;
32
use Koha::Patron::Consent;
34
use Koha::Patron::Consent;
33
use Koha::Patron::Modifications;
35
use Koha::Patron::Modifications;
Lines 80-86 if ( $rego_found Link Here
80
    my $patron_attrs = $m->unblessed;
82
    my $patron_attrs = $m->unblessed;
81
    $patron_attrs->{password} ||=
83
    $patron_attrs->{password} ||=
82
        Koha::AuthUtils::generate_password( Koha::Patron::Categories->find( $patron_attrs->{categorycode} ) );
84
        Koha::AuthUtils::generate_password( Koha::Patron::Categories->find( $patron_attrs->{categorycode} ) );
83
    my $consent_dt = delete $patron_attrs->{gdpr_proc_consent};
85
    my $consent_dt    = delete $patron_attrs->{gdpr_proc_consent};
86
    my $consents_json = delete $patron_attrs->{consents};
84
    $patron_attrs->{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory');
87
    $patron_attrs->{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory');
85
    delete $patron_attrs->{timestamp};
88
    delete $patron_attrs->{timestamp};
86
    delete $patron_attrs->{verification_token};
89
    delete $patron_attrs->{verification_token};
Lines 93-98 if ( $rego_found Link Here
93
        Koha::Patron::Consent->new(
96
        Koha::Patron::Consent->new(
94
            { borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt } )->store
97
            { borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt } )->store
95
            if $patron && $consent_dt;
98
            if $patron && $consent_dt;
99
100
        # Process plugin consents
101
        if ( $patron && $consents_json ) {
102
            my $plugin_consents = from_json($consents_json);
103
            foreach my $consent_type ( keys %$plugin_consents ) {
104
                Koha::Patron::Consent->new(
105
                    {
106
                        borrowernumber => $patron->borrowernumber,
107
                        type           => $consent_type,
108
                        given_on       => dt_from_string( $plugin_consents->{$consent_type} )
109
                    }
110
                )->store;
111
            }
112
        }
113
96
        C4::Members::Messaging::SetMessagingPreferencesFromDefaults(
114
        C4::Members::Messaging::SetMessagingPreferencesFromDefaults(
97
            { borrowernumber => $patron->borrowernumber, categorycode => $patron->categorycode } );
115
            { borrowernumber => $patron->borrowernumber, categorycode => $patron->categorycode } );
98
    } catch {
116
    } catch {
Lines 133-139 if ( $rego_found Link Here
133
                    my $letter = GetPreparedLetter(
151
                    my $letter = GetPreparedLetter(
134
                        module      => 'members',
152
                        module      => 'members',
135
                        letter_code => 'WELCOME',
153
                        letter_code => 'WELCOME',
136
                        branchcode  => $patron->branchcode,,
154
                        branchcode  => $patron->branchcode,
137
                        lang        => $patron->lang || 'default',
155
                        lang        => $patron->lang || 'default',
138
                        tables      => {
156
                        tables      => {
139
                            'branches'  => $patron->branchcode,
157
                            'branches'  => $patron->branchcode,
140
- 

Return to bug 38769