Bugzilla – Attachment 74076 Details for
Bug 19936
Move Check_userid and Generate_Userid to Koha::Patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19936: Add the Koha::Patron->generate_userid method
Bug-19936-Add-the-KohaPatron-generateuserid-method.patch (text/plain), 2.13 KB, created by
Katrin Fischer
on 2018-04-12 12:26:04 UTC
(
hide
)
Description:
Bug 19936: Add the Koha::Patron->generate_userid method
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-04-12 12:26:04 UTC
Size:
2.13 KB
patch
obsolete
>From c8fa323b1f4d6fdbc62b64d00412ee6fd3fb2252 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 8 Jan 2018 18:44:56 -0300 >Subject: [PATCH] Bug 19936: Add the Koha::Patron->generate_userid method > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > Koha/Patron.pm | 37 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 5acdea51d0..8a37d2aab4 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > > use Carp; > use List::MoreUtils qw( uniq ); >+use Text::Unaccent qw( unac_string ); > > use C4::Context; > use C4::Log; >@@ -897,6 +898,42 @@ sub has_valid_userid { > return $already_exists ? 0 : 1; > } > >+=head3 generate_userid >+ >+my $patron = Koha::Patron->new( $params ); >+my $userid = $patron->generate_userid >+ >+Generate a userid using the $surname and the $firstname (if there is a value in $firstname). >+ >+Return the generate userid ($firstname.$surname if there is a $firstname, or $surname if there is no value in $firstname) plus offset (0 if the $userid is unique, or a higher numeric value if not unique). >+ >+# Note: Should we set $self->userid with the generated value? >+# Certainly yes, but we AddMember and ModMember will be rewritten >+ >+=cut >+ >+sub generate_userid { >+ my ($self) = @_; >+ my $userid; >+ my $offset = 0; >+ my $patron = Koha::Patron->new; >+ my $firstname = $self->firstname; >+ my $surname = $self->surname; >+ #The script will "do" the following code and increment the $offset until the generated userid is unique >+ do { >+ $firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; >+ $surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; >+ $userid = lc(($firstname)? "$firstname.$surname" : $surname); >+ $userid = unac_string('utf-8',$userid); >+ $userid .= $offset unless $offset == 0; >+ $patron->userid( $userid ); >+ $offset++; >+ } while (! $patron->has_valid_userid ); >+ >+ return $userid; >+ >+} >+ > =head2 Internal methods > > =head3 _type >-- >2.14.1
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 19936
:
70365
|
70366
|
70367
|
70368
|
70369
|
70370
|
70371
|
70372
|
70373
|
70374
|
71787
|
71788
|
71789
|
71790
|
71791
|
71792
|
71793
|
71794
|
71795
|
71796
|
72129
|
72130
|
72131
|
72132
|
72133
|
72134
|
72135
|
72136
|
72137
|
72138
|
72139
|
72140
|
72141
|
72142
|
72143
|
72144
|
72145
|
72146
|
72147
|
72148
|
72149
|
72150
|
72151
|
72152
|
73630
|
73631
|
73632
|
73633
|
73634
|
73635
|
73636
|
73637
|
73638
|
73639
|
73640
|
73641
|
73963
|
73964
|
73965
|
73966
|
73967
|
73968
|
73969
|
73970
|
73971
|
73972
|
73973
|
73974
|
74071
|
74072
|
74073
|
74074
|
74075
| 74076 |
74077
|
74078
|
74079
|
74080
|
74081
|
74082