|
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; |