Bugzilla – Attachment 15751 Details for
Bug 9718
Add POD and comments for Check_Userid and Generate_Userid subs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9718 - Add POD and comments for Check_Userid and Generate_Userid subs
Bug-9718---Add-POD-and-comments-for-CheckUserid-an.patch (text/plain), 3.01 KB, created by
Chris Cormack
on 2013-02-28 06:38:34 UTC
(
hide
)
Description:
Bug 9718 - Add POD and comments for Check_Userid and Generate_Userid subs
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2013-02-28 06:38:34 UTC
Size:
3.01 KB
patch
obsolete
>From 060758ef166548b530498bf523c73454860687ec Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Wed, 27 Feb 2013 15:26:08 +1100 >Subject: [PATCH] Bug 9718 - Add POD and comments for Check_Userid and > Generate_Userid subs > >Add plain English explanations in POD blocks for how the Check_Userid and Generate_Userid subs work. > >Also add a comment explaining how the do loop works with the while condition in Generate_Userid, since the condition is worded awkwardly. > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >--- > C4/Members.pm | 29 +++++++++++++++++++++++++++-- > 1 file changed, 27 insertions(+), 2 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index 8042840..ac16bdd 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -791,12 +791,23 @@ sub AddMember { > return $data{'borrowernumber'}; > } > >+=head2 Check_Userid >+ >+ my $uniqueness = Check_Userid($userid,$borrowernumber); >+ >+ $borrowernumber is optional (i.e. it can contain a blank value). If $userid is passed with a blank $borrowernumber variable, the database will be checked for all instances of that userid (i.e. userid=? AND borrowernumber != ''). >+ >+ If $borrowernumber is provided, the database will be checked for every instance of that userid coupled with a different borrower(number) than the one provided. >+ >+ return : >+ 0 for not unique (i.e. this $userid already exists) >+ 1 for unique (i.e. this $userid does not exist, or this $userid/$borrowernumber combination already exists) >+ >+=cut > > sub Check_Userid { > my ($uid,$member) = @_; > my $dbh = C4::Context->dbh; >- # Make sure the userid chosen is unique and not theirs if non-empty. If it is not, >- # Then we need to tell the user and have them create a new one. > my $sth = > $dbh->prepare( > "SELECT * FROM borrowers WHERE userid=? AND borrowernumber != ?"); >@@ -809,10 +820,24 @@ sub Check_Userid { > } > } > >+=head2 Generate_Userid >+ >+ my $newuid = Generate_Userid($borrowernumber, $firstname, $surname); >+ >+ Generate a userid using the $surname and the $firstname (if there is a value in $firstname). >+ >+ $borrowernumber is optional (i.e. it can contain a blank value). A value is passed when generating a new userid for an existing borrower. When a new userid is created for a new borrower, a blank value is passed to this sub. >+ >+ return : >+ new userid ($firstname.$surname if there is a $firstname, or $surname if there is no value in $firstname) plus offset (0 if the $newuid is unique, or a higher numeric value if Check_Userid finds an existing match for the $newuid in the database). >+ >+=cut >+ > sub Generate_Userid { > my ($borrowernumber, $firstname, $surname) = @_; > my $newuid; > my $offset = 0; >+ #The script will "do" the following code and increment the $offset until Check_Userid = 1 (i.e. until $newuid comes back as unique) > do { > $firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; > $surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; >-- >1.7.10.4
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 9718
:
15719
|
15751
|
16565