[open-ils-commits] r16698 - trunk/Open-ILS/src/perlmods/OpenILS/Application (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Jun 14 09:06:52 EDT 2010


Author: erickson
Date: 2010-06-14 09:06:51 -0400 (Mon, 14 Jun 2010)
New Revision: 16698

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Log:
some minor code cleanup of the retrieve user by barcode method

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2010-06-14 13:06:50 UTC (rev 16697)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2010-06-14 13:06:51 UTC (rev 16698)
@@ -1023,31 +1023,17 @@
 	api_name	=> "open-ils.actor.user.fleshed.retrieve_by_barcode",);
 
 sub user_retrieve_by_barcode {
-	my($self, $client, $user_session, $barcode) = @_;
+	my($self, $client, $auth, $barcode) = @_;
 
-	$logger->debug("Searching for user with barcode $barcode");
-	my ($user_obj, $evt) = $apputils->checkses($user_session);
-	return $evt if $evt;
+    my $e = new_editor(authtoken => $auth);
+    return $e->event unless $e->checkauth;
 
-	my $card = OpenILS::Application::AppUtils->simple_scalar_request(
-			"open-ils.cstore", 
-			"open-ils.cstore.direct.actor.card.search.atomic",
-			{ barcode => $barcode }
-	);
+    my $card = $e->search_actor_card({barcode => $barcode})->[0]
+        or return $e->event;
 
-	if(!$card || !$card->[0]) {
-		return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' );
-	}
-
-	$card = $card->[0];
-	my $user = flesh_user($card->usr(), new_editor(requestor => $user_obj));
-
-	$evt = $U->check_perms($user_obj->id, $user->home_ou, 'VIEW_USER');
-	return $evt if $evt;
-
-	if(!$user) { return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ); }
-	return $user;
-
+	my $user = flesh_user($card->usr, $e);
+    return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
+    return $user;
 }
 
 
@@ -1062,8 +1048,7 @@
 	my ($self, $client, $auth, $id) = @_;
 	my $e = new_editor(authtoken=>$auth);
 	return $e->event unless $e->checkauth;
-	my $user = $e->retrieve_actor_user($id)
-		or return $e->event;
+	my $user = $e->retrieve_actor_user($id) or return $e->event;
 	return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);	
 	return $user;
 }



More information about the open-ils-commits mailing list