fleshing user via cstore
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 29 Jun 2006 15:42:57 +0000 (15:42 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 29 Jun 2006 15:42:57 +0000 (15:42 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4839 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm

index d23b37f..b87bc4e 100644 (file)
@@ -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
 }
 
index 307d1e8..71ce84b 100644 (file)
@@ -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;
-
-
 }