XUL based holds work. Need to test from within the staff client.
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 9 Dec 2005 16:31:43 +0000 (16:31 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 9 Dec 2005 16:31:43 +0000 (16:31 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2303 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/ils_events.xml
Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/web/opac/skin/default/js/holds.js
Open-ILS/web/opac/skin/default/xml/ilsevents.xml

index f8839f4..e049cf1 100644 (file)
                </desc>
        </event>
 
+       <event code='1002' textcode='USER_NOT_FOUND'>
+               <desc>
+                       Someone attempted to retrieve a user from the system and the user
+                       was not found.
+               </desc>
+       </event>
+
        <event code='5000' textcode='PERM_FAILURE'>
                <desc> 
                        Permission Error.  * The object returning this code shall also 
index 94c5d5d..e80d52f 100644 (file)
@@ -702,12 +702,13 @@ sub user_retrieve_by_barcode {
 
        if(!$card || !$card->[0]) {
                $session->disconnect();
-               return undef;
+               return OpenILS::Event->new( 'USER_NOT_FOUND' );
        }
 
        $card = $card->[0];
        my $user = flesh_user($card->usr(), $session);
        $session->disconnect();
+       if(!$user) { return OpenILS::Event->new( 'USER_NOT_FOUND' ); }
        return $user;
 
 }
index a3d91df..2fdcade 100644 (file)
@@ -40,7 +40,7 @@ sub start_db_session {
 sub check_user_perms {
        my($self, $user_id, $org_id, @perm_types ) = @_;
 
-       warn "Checking perm with user : $user_id , org: $org_id, @perm_types\n";
+       $logger->debug("Checking perms with user : $user_id , org: $org_id, @perm_types");
 
        throw OpenSRF::EX::ERROR ("Invalid call to check_user_perms()")
                unless( defined($user_id) and defined($org_id) and @perm_types); 
@@ -136,10 +136,19 @@ sub check_user_session {
        my $response = $request->recv();
 
        if(!$response) {
-               throw OpenSRF::EX::User ("Session [$user_session] cannot be authenticated" );
+               throw OpenSRF::EX::User 
+                       ("Error communication with storage server");
        }
 
-       if($response->isa("OpenSRF::EX")) {
+       if( ref($response) eq 'HASH' ) {
+               if(defined($response->{ilsevent}) and $response->{ilsevent} ne '0' ) {
+                       throw OpenSRF::EX::ERROR 
+                               ("Session [$user_session] cannot be authenticated" );
+               }
+       }
+
+
+       if(ref($response) and $response->isa("OpenSRF::EX")) {
                throw $response ($response->stringify);
        }
 
index a05cb41..3e25b6a 100644 (file)
@@ -22,6 +22,7 @@ my $apputils = "OpenILS::Application::AppUtils";
 use OpenILS::EX;
 use OpenSRF::EX qw(:try);
 use OpenILS::Perm;
+use OpenILS::Event;
 
 
 
@@ -49,7 +50,8 @@ sub create_hold {
        my( $self, $client, $login_session, @holds) = @_;
 
        if(!@holds){return 0;}
-       my $user = $apputils->check_user_session($login_session);
+       my( $user, $evt ) = $apputils->check_ses($login_session);
+       return $evt if $evt;
 
 
        my $holds;
@@ -69,6 +71,8 @@ sub create_hold {
 
                my $recipient;
                if($user->id ne $hold->usr) {
+                       $recipient = $apputils->fetch_user($hold->usr);
+                       if(!$recipient) { return OpenILS::Event->new('USER_NOT_FOUND'); }
 
                } else {
                        $recipient = $user;
@@ -81,7 +85,7 @@ sub create_hold {
 
                # see if the requestor even has permission to request
                if($hold->requestor ne $hold->usr) {
-                       $perm = _check_request_holds_perm($type, $user->id, $user->home_ou);
+                       $perm = _check_request_holds_perm($user->id, $user->home_ou);
                        if($perm) { return $perm; }
                }
 
@@ -118,24 +122,29 @@ sub create_hold {
 sub _check_holds_perm {
        my($type, $user_id, $org_id) = @_;
 
+       my $evt;
        if($type eq "M") {
-               if($apputils->check_user_perms($user_id, $org_id, "MR_HOLDS")) {
-                       return OpenILS::Perm->new("MR_HOLDS");
+               if($evt = $apputils->check_perms(
+                       $user_id, $org_id, "MR_HOLDS")) {
+                       return $evt;
                } 
 
        } elsif ($type eq "T") {
-               if($apputils->check_user_perms($user_id, $org_id, "TITLE_HOLDS")) {
-                       return OpenILS::Perm->new("TITLE_HOLDS");
+               if($evt = $apputils->check_perms(
+                       $user_id, $org_id, "TITLE_HOLDS")) {
+                       return $evt;
                }
 
        } elsif($type eq "V") {
-               if($apputils->check_user_perms($user_id, $org_id, "VOLUME_HOLDS")) {
-                       return OpenILS::Perm->new("VOLUME_HOLDS");
+               if($evt = $apputils->check_perms(
+                       $user_id, $org_id, "VOLUME_HOLDS")) {
+                       return $evt;
                }
 
        } elsif($type eq "C") {
-               if($apputils->check_user_perms($user_id, $org_id, "COPY_HOLDS")) {
-                       return OpenILS::Perm->new("COPY_HOLDS");
+               if($evt = $apputils->check_perms(
+                       $user_id, $org_id, "COPY_HOLDS")) {
+                       return $evt;
                }
        }
 
@@ -146,16 +155,18 @@ sub _check_holds_perm {
 sub _check_request_holds_perm {
        my $user_id = shift;
        my $org_id = shift;
-       if($apputils->check_user_perms($user_id, $org_id, "REQUEST_HOLDS")) {
-               return OpenILS::Perm->new("REQUEST_HOLDS");
+       if(my $evt = $apputils->check_perms(
+               $user_id, $org_id, "REQUEST_HOLDS")) {
+               return $evt;
        }
 }
 
 sub _check_request_holds_override {
        my $user_id = shift;
        my $org_id = shift;
-       if($apputils->check_user_perms($user_id, $org_id, "REQUEST_HOLDS_OVERRIDE")) {
-               return OpenILS::Perm->new("REQUEST_HOLDS_OVERRIDE");
+       if(my $evt = $apputils->check_perms(
+               $user_id, $org_id, "REQUEST_HOLDS_OVERRIDE")) {
+               return $evt;
        }
 }
 
index e7cce81..d17fd89 100644 (file)
@@ -59,7 +59,7 @@ var STYPE_SUBJECT     = "subject";
 var STYPE_SERIES       = "series";
 var STYPE_KEYWORD      = "keyword";
 
-var LOGOUT_WARNING_TIME = 20; /* "head up" for session timeout */
+var LOGOUT_WARNING_TIME = 30; /* "head up" for session timeout */
 
 
 /* container for global variables shared accross pages */
index 494e0b6..11bfbdf 100644 (file)
@@ -616,8 +616,8 @@ function checkILSEvent(obj) {
                return parseInt(obj.ilsevent);
        return null;
 }
-function alertILSEvent(code) {
-       alert( $('ilsevent.' + code).innerHTML );
+function alertILSEvent(code, msg) {
+       alert( msg + '\n' + $('ilsevent.' + code).innerHTML );
 }
 
 
index f6ec32b..aa8ff05 100644 (file)
@@ -30,6 +30,8 @@
                ILS Events
                ======================================================================================= -->
 <!ENTITY ilsevent.1000 "Login failed.  The username or password entered was incorrect.">
+<!ENTITY ilsevent.1001 "Login session has timed out or does not exist">
+<!ENTITY ilsevent.1002 "User was not found in the database">
 <!ENTITY ilsevent.5000 "Permission Denied">
 
 <!--   ======================================================================================= 
index 142e897..a96c4dd 100644 (file)
@@ -19,8 +19,9 @@ function holdsHandleStaff() {
 function _holdsHandleStaff() {
        var barcode = $('xul_recipient_barcode').value;
        var user = grabUserByBarcode( G.user.session, barcode );
-       if(!user) {
-               alert( '(' + barcode + ') => ' + $('user_not_found').innerHTML );
+       var code = checkILSEvent(user);
+       if(code || !user) {
+               alertILSEvent(code, barcode);
                showCanvas();
                return;
        }
@@ -36,8 +37,8 @@ function holdsDrawWindow(recid, type) {
        }       
        currentHoldRecord = recid;
        
-       //if(isXUL() && holdRecipient == null ) { 
-       if(holdRecipient == null ) { 
+       if(isXUL() && holdRecipient == null ) { 
+       //if(holdRecipient == null ) { 
                holdsHandleStaff();
                return;
        }
index 3279ca4..671430d 100644 (file)
@@ -1,5 +1,7 @@
 <span class='hide_me'>
        <span id='ilsevent.1000'>&ilsevent.1000;</span>
+       <span id='ilsevent.1001'>&ilsevent.1001;</span>
+       <span id='ilsevent.1002'>&ilsevent.1002;</span>
        <span id='ilsevent.5000'>&ilsevent.5000;</span>
        <span id='ilsperm.CREATE_HOLD'>&ilsperm.CREATE_HOLD;</span>