Bug 32445: (follow-up) Fix availability display on opac-course-details
[srvgit] / opac / opac-memberentry.pl
index 66a6484..0115d78 100755 (executable)
@@ -35,14 +35,12 @@ use Koha::Patron::Consent;
 use Koha::Patron::Modification;
 use Koha::Patron::Modifications;
 use C4::Scrubber;
-use Koha::DateUtils qw( dt_from_string output_pref );
+use Koha::DateUtils qw( dt_from_string );
 use Koha::Email;
 use Koha::Libraries;
 use Koha::Patron::Attribute::Types;
 use Koha::Patron::Attributes;
 use Koha::Patron::Images;
-use Koha::Patron::Modification;
-use Koha::Patron::Modifications;
 use Koha::Patron::Categories;
 use Koha::Token;
 use Koha::AuthorisedValues;
@@ -244,8 +242,8 @@ if ( $action eq 'create' ) {
                 $template->param( password_cleartext => $patron->plain_text_password );
                 $template->param( borrower => $patron->unblessed );
 
-                # If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode.
-                if ( C4::Context->preference("AutoEmailOpacUser") ) {
+                # If 'AutoEmailNewUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode.
+                if ( C4::Context->preference("AutoEmailNewUser") ) {
                     #look for defined primary email address, if blank - attempt to use borr.email and borr.emailpro instead
                     my $emailaddr = $patron->notice_email_address;
                     # if we manage to find a valid email address, send notice
@@ -275,6 +273,13 @@ if ( $action eq 'create' ) {
                         };
                     }
                 }
+
+                # Notify library of new patron registration
+                my $notify_library = C4::Context->preference('EmailPatronRegistrations');
+                if ($notify_library) {
+                    $patron->notify_library_of_registration($notify_library);
+                }
+
             } else {
                 # FIXME Handle possible errors here
             }
@@ -545,20 +550,6 @@ sub ParseCgiForBorrower {
         }
     }
 
-    if ( defined $borrower{'dateofbirth'} ) {
-        my $dob_dt;
-        $dob_dt = eval { dt_from_string( $borrower{'dateofbirth'} ); }
-            if ( $borrower{'dateofbirth'} );
-
-        if ( $dob_dt ) {
-            $borrower{'dateofbirth'} = output_pref( { dt => $dob_dt, dateonly => 1, dateformat => 'iso' } );
-        }
-        else {
-            # Trigger validation
-            $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';
 
@@ -739,6 +730,7 @@ sub ParsePatronAttributes {
 
     my $delete_candidates = {};
 
+    my $scrubber = C4::Scrubber->new();
     while ( my ( $code, $value ) = $ea->() ) {
         if ( any { $_ eq $code } @editable_attribute_types ) {
             # It is an editable attribute
@@ -748,7 +740,7 @@ sub ParsePatronAttributes {
             }
             else {
                 # we've got a value
-                push @attributes, { code => $code, attribute => $value };
+                push @attributes, { code => $code, attribute => $scrubber->scrub( $value ) };
 
                 # 'code' is no longer a delete candidate
                 delete $delete_candidates->{$code}