fixing some bugs, adding permission calls, adding some batch interfaces
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Jul 2005 12:41:22 +0000 (12:41 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Jul 2005 12:41:22 +0000 (12:41 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1138 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Open-ILS/src/perlmods/OpenILS/Application/Auth.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm
Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm

index ba999f6..70f6145 100644 (file)
@@ -118,6 +118,8 @@ sub flesh_user {
                        "open-ils.storage.direct.actor.user.retrieve", $id);
        my $user = $ureq->gather(1);
 
+       if(!$user) { return undef; }
+
        # grab the cards
        my $cards_req = $session->request(
                        "open-ils.storage.direct.actor.card.search.usr.atomic",
@@ -836,10 +838,26 @@ sub update_password {
 
 __PACKAGE__->register_method(
        method  => "check_user_perms",
-       api_name        => "open-ils.actor.user.perm.check");
+       api_name        => "open-ils.actor.user.perm.check",
+       notes           => <<"  NOTES"
+       Takes a user id, an org id, and an array of perm type strings.  For each
+       perm type, if the user does *not* have the given permission it is added
+       to a list which is returned from the method.  If all permissions
+       are allowed, an empty list is returned
+       NOTES
+       );
 
 sub check_user_perms {
-       my( $self, $client, $user_id, $org_id, @perm_types ) = @_;
+       my( $self, $client, $user_id, $org_id, $perm_types ) = @_;
+
+       my @not_allowed;
+       for my $perm (@$perm_types) {
+               if($apputils->check_user_perms($user_id, $org_id, $perm)) {
+                       push @not_allowed, $perm;
+               }
+       }
+
+       return \@not_allowed
 }
 
 
@@ -853,6 +871,38 @@ sub check_user_perms {
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 __END__
 
 
index b4fffb4..0bb2fb4 100644 (file)
@@ -156,6 +156,13 @@ sub complete_authenticate {
                        if($apputils->check_user_perms($user->id(), 1, "OPAC_LOGIN")) {
                                return OpenILS::Perm->new("OPAC_LOGIN");
                        }
+
+               } else {
+                       # 1 is the top level org unit (we should probably load the tree and get id from it)
+                       warn "Checking user perms for Staff login\n";
+                       if($apputils->check_user_perms($user->id(), 1, "STAFF_LOGIN")) {
+                               return OpenILS::Perm->new("STAFF_LOGIN");
+                       }
                }
 
                my $session_id = md5_hex(time() . $$ . rand()); 
index 15b011b..1024a03 100644 (file)
@@ -170,10 +170,11 @@ NOTE
 
 sub retrieve_holds {
        my($self, $client, $login_session, $user_id) = @_;
+
        my $user = $apputils->check_user_session($login_session);
 
        if($user->id ne $user_id) {
-               if($apputils->check_user_perms($user_id, $user->home_ou, "VIEW_HOLDS")) {
+               if($apputils->check_user_perms($user->id, $user->home_ou, "VIEW_HOLDS")) {
                        return OpenILS::Perm->new("VIEW_HOLDS");
                }
        }
index d5a56fe..4ebdb2b 100644 (file)
@@ -67,6 +67,7 @@ my $cache_handle;
 use constant NO_COPY => 100;
 
 sub initialize {
+
        my $self = shift;
        my $conf = OpenSRF::Utils::SettingsClient->new;
 
index 028eef0..238fad6 100644 (file)
@@ -24,6 +24,15 @@ my $apputils = "OpenILS::Application::AppUtils";
 
 # Houses biblio search utilites 
 
+
+__PACKAGE__->register_method(
+       method  => "test",
+       api_name        => "open-ils.search.test");
+
+sub test { return "test"; }
+
+
+
 __PACKAGE__->register_method(
        method  => "biblio_search_marc",
        api_name        => "open-ils.search.biblio.marc",
@@ -134,6 +143,7 @@ sub record_id_to_mods {
 }
 
 
+
 __PACKAGE__->register_method(
        method  => "record_id_to_mods_slim",
        api_name        => "open-ils.search.biblio.record.mods_slim.retrieve",
@@ -143,11 +153,12 @@ __PACKAGE__->register_method(
 
 # converts a record into a mods object with NO copy counts attached
 sub record_id_to_mods_slim {
-
        my( $self, $client, $id ) = @_;
-       warn "Retrieving MODS object for record $id\n";
-       return undef unless(defined $id);
+       return undef unless defined $id;
 
+       if(ref($id) and ref($id) == 'ARRAY') {
+               return _records_to_mods( @$id );
+       }
        my $mods_list = _records_to_mods( $id );
        my $mods_obj = $mods_list->[0];
        return $mods_obj;
@@ -773,12 +784,31 @@ sub biblio_search_class {
 }
 
 
+__PACKAGE__->register_method(
+       method  => "biblio_mrid_to_modsbatch_batch",
+       api_name        => "open-ils.search.biblio.metarecord.mods_slim.batch.retrieve");
+
+sub biblio_mrid_to_modsbatch_batch {
+       my( $self, $client, $mrids) = @_;
+       warn "Performing mrid_to_modsbatch_batch...";
+       my @mods;
+       my $method = $self->method_lookup("open-ils.search.biblio.metarecord.mods_slim.retrieve");
+       use Data::Dumper;
+       warn "Grabbing mods for " . Dumper($mrids) . "\n";
+
+       for my $id (@$mrids) {
+               next unless defined $id;
+               #push @mods, biblio_mrid_to_modsbatch($self, $client, $id);
+               my ($m) = $method->run($id);
+               push @mods, $m;
+       }
+       return \@mods;
+}
 
 
 __PACKAGE__->register_method(
        method  => "biblio_mrid_to_modsbatch",
-       api_name        => "open-ils.search.biblio.metarecord.mods_slim.retrieve",
-);
+       api_name        => "open-ils.search.biblio.metarecord.mods_slim.retrieve");
 
 sub biblio_mrid_to_modsbatch {
        my( $self, $client, $mrid ) = @_;