use CGI qw ( -utf8 );
use Digest::MD5 qw( md5_base64 md5_hex );
-use JSON;
+use JSON qw( to_json );
use List::MoreUtils qw( any each_array uniq );
use String::Random qw( random_string );
-use C4::Auth;
-use C4::Output;
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_html_with_http_headers );
use C4::Context;
-use C4::Members;
+use C4::Members qw( checkcardnumber );
use C4::Form::MessagingPreferences;
use Koha::AuthUtils;
use Koha::Patrons;
use Koha::Patron::Modification;
use Koha::Patron::Modifications;
use C4::Scrubber;
-use Email::Valid;
-use Koha::DateUtils;
+use Koha::DateUtils qw( dt_from_string output_pref );
+use Koha::Email;
use Koha::Libraries;
use Koha::Patron::Attribute::Types;
use Koha::Patron::Attributes;
}
my $action = $cgi->param('action') || q{};
+if ( $borrowernumber && ( $action eq 'create' || $action eq 'new' ) ) {
+ print $cgi->redirect("/cgi-bin/koha/opac-main.pl");
+ exit;
+}
+
if ( $action eq q{} ) {
if ($borrowernumber) {
$action = 'edit';
my $borrower = shift;
my @invalidFields;
if ($borrower->{'email'}) {
- unless ( Email::Valid->address($borrower->{'email'}) ) {
+ unless ( Koha::Email->is_valid($borrower->{email}) ) {
push(@invalidFields, "email");
} elsif ( C4::Context->preference("PatronSelfRegistrationEmailMustBeUnique") ) {
my $patrons_with_same_email = Koha::Patrons->search( # FIXME Should be search_limited?
delete $borrower->{'repeat_email'};
}
if ($borrower->{'emailpro'}) {
- push(@invalidFields, "emailpro") if (!Email::Valid->address($borrower->{'emailpro'}));
+ push(@invalidFields, "emailpro") unless Koha::Email->is_valid($borrower->{'emailpro'});
}
if ($borrower->{'B_email'}) {
- push(@invalidFields, "B_email") if (!Email::Valid->address($borrower->{'B_email'}));
+ push(@invalidFields, "B_email") unless Koha::Email->is_valid($borrower->{'B_email'});
}
if ( defined $borrower->{'password'}
and $borrower->{'password'} ne $borrower->{'password2'} )
# 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';
+ delete $borrower{$_} for qw/borrowernumber date_renewed debarred debarredcomment flags privacy privacy_guarantor_fines privacy_guarantor_checkouts checkprevcheckout updated_on lastseen lang login_attempts overdrive_auth_token anonymized/; # See also members/memberentry.pl
+ delete $borrower{$_} for qw/dateenrolled dateexpiry borrowernotes opacnote sort1 sort2 sms_provider_id autorenew_checkouts gonenoaddress lost relationship/; # On OPAC only
+ delete $borrower{$_} for split( /\s*\|\s*/, C4::Context->preference('PatronSelfRegistrationBorrowerUnwantedField') || q{} );
+
return %borrower;
}