X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=opac%2Fopac-memberentry.pl;h=dbb6d99e5c3892eceeca68ad7c10c34a01d4a0ab;hb=e0b1f945f9cdb4efd8b4403855cdc995023dc8be;hp=9d3bed837e8974b432b98d4a8143aac732fb74ad;hpb=7809a6bd132e6bd2c98d69179fc2c2f0788decb0;p=koha.git diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 9d3bed837e..dbb6d99e5c 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -30,6 +30,7 @@ use C4::Members::Attributes qw( GetBorrowerAttributes ); use C4::Form::MessagingPreferences; use Koha::AuthUtils; use Koha::Patrons; +use Koha::Patron::Consent; use Koha::Patron::Modification; use Koha::Patron::Modifications; use C4::Scrubber; @@ -88,7 +89,7 @@ if ( defined $min ) { $template->param( action => $action, - hidden => GetHiddenFields( $mandatory, 'registration' ), + hidden => GetHiddenFields( $mandatory, $action ), mandatory => $mandatory, libraries => \@libraries, OPACPatronDetails => C4::Context->preference('OPACPatronDetails'), @@ -169,7 +170,7 @@ if ( $action eq 'create' ) { $verification_token = md5_hex( time().{}.rand().{}.$$ ); } - $borrower{password} = Koha::AuthUtils::generate_password unless $borrower{password}; + $borrower{password} = Koha::AuthUtils::generate_password unless $borrower{password}; $borrower{verification_token} = $verification_token; Koha::Patron::Modification->new( \%borrower )->store(); @@ -207,13 +208,28 @@ if ( $action eq 'create' ) { $template->param( OpacPasswordChange => C4::Context->preference('OpacPasswordChange') ); - my ( $borrowernumber, $password ) = AddMember_Opac(%borrower); - C4::Members::Attributes::SetBorrowerAttributes( $borrowernumber, $attributes ); - C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if $borrowernumber && C4::Context->preference('EnhancedMessagingPreferences'); + $borrower{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory'); + $borrower{password} ||= Koha::AuthUtils::generate_password; + my $consent_dt = delete $borrower{gdpr_proc_consent}; + my $patron = Koha::Patron->new( \%borrower )->store; + Koha::Patron::Consent->new({ borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt })->store if $consent_dt; + if ( $patron ) { + C4::Members::Attributes::SetBorrowerAttributes( $patron->borrowernumber, $attributes ); + if ( C4::Context->preference('EnhancedMessagingPreferences') ) { + C4::Form::MessagingPreferences::handle_form_action( + $cgi, + { borrowernumber => $patron->borrowernumber }, + $template, + 1, + C4::Context->preference('PatronSelfRegistrationDefaultCategory') + ); + } - $template->param( password_cleartext => $password ); - my $patron = Koha::Patrons->find( $borrowernumber ); - $template->param( borrower => $patron->unblessed ); + $template->param( password_cleartext => $patron->plain_text_password ); + $template->param( borrower => $patron->unblessed ); + } else { + # FIXME Handle possible errors here + } $template->param( PatronSelfRegistrationAdditionalInstructions => C4::Context->preference( @@ -300,7 +316,7 @@ elsif ( $action eq 'edit' ) { #Display logged in borrower's data $template->param( borrower => $borrower, guarantor => scalar Koha::Patrons->find($borrowernumber)->guarantor(), - hidden => GetHiddenFields( $mandatory, 'modification' ), + hidden => GetHiddenFields( $mandatory, 'edit' ), csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $cgi->cookie('CGISESSID'), }), @@ -329,7 +345,7 @@ sub GetHiddenFields { my ( $mandatory, $action ) = @_; my %hidden_fields; - my $BorrowerUnwantedField = $action eq 'modification' ? + my $BorrowerUnwantedField = $action eq 'edit' || $action eq 'update' ? C4::Context->preference( "PatronSelfModificationBorrowerUnwantedField" ) : C4::Context->preference( "PatronSelfRegistrationBorrowerUnwantedField" ); @@ -353,6 +369,7 @@ sub GetMandatoryFields { C4::Context->preference("PatronSelfRegistrationBorrowerMandatoryField"); my @fields = split( /\|/, $BorrowerMandatoryField ); + push @fields, 'gdpr_proc_consent' if C4::Context->preference('GDPR_Policy'); foreach (@fields) { $mandatory_fields{$_} = 1; @@ -459,6 +476,9 @@ sub ParseCgiForBorrower { $borrower{'dateofbirth'} = undef; } + # Replace checkbox 'agreed' by datetime in gdpr_proc_consent + $borrower{gdpr_proc_consent} = dt_from_string if $borrower{gdpr_proc_consent} && $borrower{gdpr_proc_consent} eq 'agreed'; + return %borrower; }