[open-ils-commits] [GIT] Evergreen ILS branch master updated. 7adaf791e10d6d5af28389104723e098547f85d8

Evergreen Git git at git.evergreen-ils.org
Thu Aug 4 15:26:21 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  7adaf791e10d6d5af28389104723e098547f85d8 (commit)
      from  5fa01d69f7374c0c8710db4a951edb80ed5ae733 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7adaf791e10d6d5af28389104723e098547f85d8
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Thu Aug 4 15:25:08 2011 -0400

    Revert "remove the unfinished id_as_barcode functionality"
    
    This reverts commit 5fa01d69f7374c0c8710db4a951edb80ed5ae733.
    
    Bit too soon, actually. Staff client still uses the function to
    verify credentials.
    
    Maybe I skipped this the first time on purpose.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>

diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example
index b1d6b49..0b16511 100644
--- a/Open-ILS/examples/opensrf.xml.example
+++ b/Open-ILS/examples/opensrf.xml.example
@@ -575,6 +575,11 @@ vim:et:ts=4:sw=4:
                     <min_spare_children>1</min_spare_children>
                     <max_spare_children>5</max_spare_children>
                 </unix_config>
+                <!-- set this to 'true' to have barcode search also search patron records by unique ID -->
+                <app_settings>
+                    <id_as_barcode>false</id_as_barcode>
+                </app_settings>
+
             </open-ils.actor>
 
             <open-ils.booking>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
index 0e9e1e3..1f0fa93 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
@@ -3117,6 +3117,55 @@ sub verify_user_password {
 }
 
 __PACKAGE__->register_method (
+	method		=> 'retrieve_usr_id_via_barcode_or_usrname',
+	api_name	=> "open-ils.actor.user.retrieve_id_by_barcode_or_username",
+	signature	=> q/
+        Given a barcode or username returns the id for the user or
+        a failure event.
+	/
+);
+
+sub retrieve_usr_id_via_barcode_or_usrname {
+    my($self, $conn, $auth, $barcode, $username) = @_;
+    my $e = new_editor(authtoken => $auth);
+	return $e->die_event unless $e->checkauth;
+    my $id_as_barcode= OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.actor' => app_settings => 'id_as_barcode');
+    my $user;
+    my $user_by_barcode;
+    my $user_by_username;
+    $logger->info("$id_as_barcode is the ID as BARCODE");
+    if($barcode) {
+        my $card = $e->search_actor_card([
+            {barcode => $barcode},
+            {flesh => 1, flesh_fields => {ac => ['usr']}}])->[0];
+        if ($id_as_barcode =~ /^t/i) {
+            if (!$card) {
+                $user = $e->retrieve_actor_user($barcode);
+                return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ) if(!$user);
+            }else {
+                $user_by_barcode = $card->usr;
+                $user = $user_by_barcode;
+            }
+        }else {
+            return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ) if(!$card);
+            $user_by_barcode = $card->usr;
+            $user = $user_by_barcode;
+        }
+    }
+
+    if ($username) {
+        $user_by_username = $e->search_actor_user({usrname => $username})->[0] or return OpenILS::Event->new( 'ACTOR_USR_NOT_FOUND' );
+
+        $user = $user_by_username;
+    }
+	return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ) if (!$user);
+	return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ) if ($user_by_username && $user_by_barcode && $user_by_username->id != $user_by_barcode->id); 
+    return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
+    return $user->id;
+}
+
+
+__PACKAGE__->register_method (
 	method		=> 'merge_users',
 	api_name	=> 'open-ils.actor.user.merge',
 	signature	=> {

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/examples/opensrf.xml.example              |    5 ++
 .../src/perlmods/lib/OpenILS/Application/Actor.pm  |   49 ++++++++++++++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list