From bdb89a00961cee1028787b1e74b1b9bb95abb640 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 29 Jun 2006 15:42:57 +0000 Subject: [PATCH] fleshing user via cstore git-svn-id: svn://svn.open-ils.org/ILS/trunk@4839 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Actor.pm | 59 ++++++++++++++----- .../perlmods/OpenILS/Utils/CStoreEditor.pm | 7 +-- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index d23b37fd24..b87bc4e95c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -26,7 +26,7 @@ use DateTime::Format::ISO8601; use OpenILS::Application::Actor::Container; use OpenILS::Application::Actor::ClosedDates; -use OpenILS::Utils::Editor qw/:funcs/; +use OpenILS::Utils::CStoreEditor qw/:funcs/; use OpenILS::Application::Actor::UserGroups; sub initialize { @@ -262,7 +262,8 @@ sub user_retrieve_fleshed_by_id { # fleshes: card, cards, address, addresses, stat_cat_entries, standing_penalties -sub flesh_user { +# XXX DEPRECATE ME +sub __flesh_user { my $id = shift; my $session = shift; @@ -336,6 +337,37 @@ sub flesh_user { return $user; } +sub flesh_user { + my $id = shift; + my $e = new_editor(); + my $user = $e->retrieve_actor_user( + [ + $id, + { + "flesh" => 1, + "flesh_fields" => { + "au" => [ + "cards", + "card", + "standing_penalties", + "addresses", + "billing_address", + "mailing_address", + "stat_cat_entries" + ] + } + } + ] + ) or return $e->event; + + $user->clear_passwd(); + return $user; +} + + + + + # clone and clear stuff that would break the database sub _clone_patron { @@ -840,14 +872,13 @@ __PACKAGE__->register_method( api_name => "open-ils.actor.user.retrieve",); sub get_user_by_id { - my ($self, $client, $user_session, $id) = @_; - - my $user_obj = $apputils->check_user_session( $user_session ); - - return $apputils->simple_scalar_request( - "open-ils.storage", - "open-ils.storage.direct.actor.user.retrieve", - $id ); + 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; + return $e->event unless $e->allowed('VIEW_USER', $user->home_ou); + return $user; } @@ -1072,10 +1103,10 @@ __PACKAGE__->register_method( api_name => "open-ils.actor.patron.search.advanced" ); sub patron_adv_search { my( $self, $client, $auth, $search_hash, $search_limit, $search_sort ) = @_; - my $e = OpenILS::Utils::Editor->new(authtoken=>$auth); + my $e = new_editor(authtoken=>$auth); return $e->event unless $e->checkauth; return $e->event unless $e->allowed('VIEW_USER'); - return $e->request( + return $U->storagereq( "open-ils.storage.actor.user.crazy_search", $search_hash, $search_limit, $search_sort); } @@ -2051,7 +2082,7 @@ sub _register_workstation { sub register_workstation { my( $self, $conn, $authtoken, $name, $owner ) = @_; - my $e = OpenILS::Utils::Editor->new(authtoken=>$authtoken, xact=>1); + my $e = new_editor(authtoken=>$authtoken, xact=>1); return $e->event unless $e->checkauth; return $e->event unless $e->allowed('REGISTER_WORKSTATION'); # XXX rely on editor perms my $existing = $e->search_actor_workstation({name => $name}); @@ -2069,7 +2100,7 @@ sub register_workstation { $ws->owning_lib($owner); $ws->name($name); $e->create_actor_workstation($ws) or return $e->event; - $e->finish; + $e->commit; return $ws->id; # note: editor sets the id on the new object for us } diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm b/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm index 307d1e8abe..71ce84b07c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm @@ -25,7 +25,7 @@ sub new_editor { return OpenILS::Utils::CStoreEditor->new(@_); } # ----------------------------------------------------------------------------- -# These need to be auto-generated +# Log levels # ----------------------------------------------------------------------------- use constant E => 'error'; use constant W => 'warn'; @@ -361,12 +361,11 @@ sub __arg_to_string { sub runmethod { my( $self, $action, $type, $arg, $options ) = @_; - my @arg = ($arg); + my @arg = ( ref($arg) eq 'ARRAY' ) ? @$arg : ($arg); my $method = "open-ils.cstore.direct.$type.$action"; if( $action eq 'search' ) { $method = "$method.atomic"; - @arg = @$arg if ref($arg) eq 'ARRAY'; } elsif( $action eq 'batch_retrieve' ) { $action = 'search'; @@ -522,8 +521,6 @@ for my $object (keys %$map) { my $retrieveallf = "sub $retrieveall {return shift()->runmethod('retrieve_all', '$type', \@_);}"; eval $retrieveallf; - - } -- 2.43.2