Bugzilla – Attachment 76902 Details for
Bug 20287
Move AddMember and ModMember to Koha::Patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20287: Move trim values to a method
Bug-20287-Move-trim-values-to-a-method.patch (text/plain), 2.53 KB, created by
Jonathan Druart
on 2018-07-12 18:48:58 UTC
(
hide
)
Description:
Bug 20287: Move trim values to a method
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-07-12 18:48:58 UTC
Size:
2.53 KB
patch
obsolete
>From 5f5fb67125e7e82d0dbf6fa8787e29e9c61b32f8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 21 Feb 2018 17:32:00 -0300 >Subject: [PATCH] Bug 20287: Move trim values to a method > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Auth_with_ldap.pm | 2 +- > C4/Members.pm | 7 ------- > Koha/Patron.pm | 18 ++++++++++++++++++ > 3 files changed, 19 insertions(+), 8 deletions(-) > >diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm >index bbb1094229..03fab46da8 100644 >--- a/C4/Auth_with_ldap.pm >+++ b/C4/Auth_with_ldap.pm >@@ -223,7 +223,7 @@ sub checkpw_ldap { > return(1, $cardnumber, $local_userid); > } > } elsif ($config{replicate}) { # A2, C2 >- $borrowernumber = C4::Members::AddMember(%borrower) or die "AddMember failed"; >+ Koha::Patron->new( \%borrower )->store; > C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrowernumber, categorycode => $borrower{'categorycode'} } ); > } else { > return 0; # B2, D2 >diff --git a/C4/Members.pm b/C4/Members.pm >index bd339d5dbb..18f8f67b87 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -405,13 +405,6 @@ sub AddMember { > ); > } > >- # trim whitespace from data which has some non-whitespace in it. >- foreach my $field_name (keys(%data)) { >- if ( defined $data{$field_name} && $data{$field_name} =~ /\S/ ) { >- $data{$field_name} =~ s/^\s*|\s*$//g; >- } >- } >- > my $p = Koha::Patron->new( { userid => $data{userid}, firstname => $data{firstname}, surname => $data{surname} } ); > # generate a proper login if none provided > $data{'userid'} = $p->generate_userid >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index f8efe5b15a..6396b50f27 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -104,6 +104,24 @@ sub fixup_cardnumber { > $self->cardnumber($max+1); > } > >+# trim whitespace from data which has some non-whitespace in it. >+# Could be moved to Koha::Object if need to be reused >+sub trim_whitespaces { >+ my( $self ) = @_; >+ >+ my $schema = Koha::Database->new->schema; >+ my @columns = $schema->source('Borrowers')->columns; >+ >+ for my $column( @columns ) { >+ my $value = $self->$column; >+ if ( defined $value ) { >+ $value =~ s/^\s*|\s*$//g; >+ $self->$column($value); >+ } >+ } >+ return $self; >+} >+ > sub store { > my( $self ) = @_; > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20287
:
73436
|
76901
| 76902 |
76903
|
76904
|
76905
|
76906
|
76907
|
76908
|
76909
|
76910
|
76911
|
76912
|
76913
|
76914
|
76915
|
76916
|
76917
|
76918
|
76919
|
76920
|
76921
|
76922
|
76923
|
76924
|
76927
|
77221