From b9103e622ee60a854832d1830584abdbf160d540 Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Wed, 2 Oct 2013 11:36:16 -0400 Subject: [PATCH] Add option to use patron id instead of barcode Add a new config option to use patron database id instead of patron barcode. Set this in the ini file's [behavior] section to enable: patron_id_as_identifier = yes Signed-off-by: Jeff Godin --- iNCIPit-example.ini | 1 + iNCIPit.cgi | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/iNCIPit-example.ini b/iNCIPit-example.ini index 68d5b83..ee72494 100644 --- a/iNCIPit-example.ini +++ b/iNCIPit-example.ini @@ -10,6 +10,7 @@ password = EXAMPLE [behavior] #no_item_agency_holds = no #omit_patron_email = no +#patron_id_as_identifier = no [copy] circ_modifier = DCB diff --git a/iNCIPit.cgi b/iNCIPit.cgi index b19fce0..5eca6fa 100644 --- a/iNCIPit.cgi +++ b/iNCIPit.cgi @@ -40,6 +40,15 @@ my $U = "OpenILS::Application::AppUtils"; my $conf = load_config( 'iNCIPit.ini' ); +# Set some variables from config (or defaults) +my $patron_id_type; + +if ($conf->{behavior}->{patron_id_as_identifier} =~ m/^yes$/i) { + $patron_id_type = "id"; +} else { + $patron_id_type = "barcode"; +} + # reject non-https access unless configured otherwise unless ($conf->{access}->{permit_plaintext} =~ m/^yes$/i) { unless ($ENV{HTTPS} eq 'on') { @@ -799,7 +808,14 @@ sub lookupUser { my $taidValue = $doc->find('/NCIPMessage/LookupUser/InitiationHeader/ToAgencyId/UniqueAgencyId/Value'); my $id = $doc->findvalue('/NCIPMessage/LookupUser/VisibleUserId/VisibleUserIdentifier'); - my $uidValue = user_id_from_barcode($id); + + my $uidValue; + + if ($patron_id_type eq 'barcode') { + $uidValue = user_id_from_barcode($id); + } else { + $uidValue = $id; + } if ( !defined($uidValue) || ( ref($uidValue) && reftype($uidValue) eq 'HASH' ) ) @@ -889,7 +905,12 @@ sub lookupUser { # die; #} my $uniqid = $patron->id; - my $visid = $patron->card->barcode; + my $visid; + if ($patron_id_type eq 'barcode') { + $visid = $patron->card->barcode; + } else { + $visid = $patron->id; + } my $hd = <create('open-ils.circ')->request( -- 2.3.6