[open-ils-commits] r15125 - trunk/Open-ILS/src/offline (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Dec 9 14:23:02 EST 2009
Author: erickson
Date: 2009-12-09 14:22:58 -0500 (Wed, 09 Dec 2009)
New Revision: 15125
Modified:
trunk/Open-ILS/src/offline/offline.pl
Log:
added support for using patron usernames in addition to barcodes during offline checkout. to use it, turn on the circ.offline.username_allowed org setting and have a value configured for the opac.barcode_regex org setting
Modified: trunk/Open-ILS/src/offline/offline.pl
===================================================================
--- trunk/Open-ILS/src/offline/offline.pl 2009-12-09 18:48:35 UTC (rev 15124)
+++ trunk/Open-ILS/src/offline/offline.pl 2009-12-09 19:22:58 UTC (rev 15125)
@@ -605,6 +605,7 @@
# Pulls the relevant circ args from the command, fetches data where
# necessary
# --------------------------------------------------------------------
+my %user_id_cache;
sub ol_circ_args_from_command {
my $command = shift;
@@ -621,13 +622,44 @@
", realtime=$realtime, workstation=$ws, checkout_time=$cotime, ".
"patron=$pbc, due_date=$due_date, noncat=$noncat");
+
my $args = {
permit_override => 1,
- barcode => $barcode,
- checkout_time => $cotime,
- patron_barcode => $pbc,
- due_date => $due_date };
+ barcode => $barcode,
+ checkout_time => $cotime,
+ patron_barcode => $pbc,
+ due_date => $due_date
+ };
+ if(ol_get_org_setting('circ.offline.username_allowed')) {
+
+ my $format = ol_get_org_setting('opac.barcode_regex');
+ if($format) {
+
+ $format =~ s/^\/|\/$//g; # remove any couching //'s
+ if($pbc !~ qr/$format/) {
+
+ # the patron barcode does not match the configured barcode format
+ # assume they passed a username instead
+
+ my $user_id = $user_id_cache{$pbc} ||
+ $U->simplereq(
+ 'open-ils.actor',
+ 'open-ils.actor.username.exists',
+ $authtoken, $pbc);
+
+
+ if($user_id) {
+ # a valid username was provided, update the args and cache
+ $user_id_cache{$pbc} = $user_id;
+ $args->{patron_id} = $user_id;
+ delete $args->{patron_barcode};
+ }
+ }
+ }
+ }
+
+
if( $command->{noncat} ) {
$args->{noncat} = 1;
$args->{noncat_type} = $command->{noncat_type};
@@ -637,8 +669,16 @@
return $args;
}
+sub ol_get_org_setting {
+ my $name = shift;
+ return $U->simplereq(
+ 'open-ils.actor',
+ 'open-ils.actor.ou_setting.ancestor_default',
+ $org, $name, $authtoken);
+}
+
# --------------------------------------------------------------------
# Performs a checkout action
# --------------------------------------------------------------------
More information about the open-ils-commits
mailing list