Now pushing all objects into 'environment'
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 24 Jan 2006 15:30:44 +0000 (15:30 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 24 Jan 2006 15:30:44 +0000 (15:30 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2813 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/javascript/backend/circ/circ_lib.js
Open-ILS/src/javascript/backend/circ/circ_permit.js
Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm

index f1751c3..544ec56 100644 (file)
@@ -8,14 +8,12 @@ function getScratch(key)      { return __SCRATCH[ key ]; }
 
 
 /* -- Copy functions ----------------------------------------------------- */
-try { 
-
-       copy.fetchHold = function() {
+if( environment.copy ) {
+       environment.copy.fetchHold = function() {
                var key = scratchKey();
-               copy.__OILS_FUNC_fetch_hold(scratchPad(key));
+               environment.copy.__OILS_FUNC_fetch_hold(scratchPad(key));
                var val = getScratch(key);
                return (val) ? val : null;
        }
-
-} catch(E) { log_warn( "Copy function definitions failed: " + E ); }
+} 
 
index 4038563..1563b4e 100644 (file)
@@ -6,6 +6,9 @@ load_lib('circ_lib.js');
 
 
 /* collect some useful variables */
+var copy                       = environment.copy;
+var patron             = environment.patron;
+var result             = environment.result;
 var standing   = patron.standing.value.toLowerCase();
 var profile            = patron.profile.name.toLowerCase();
 var status             = copy.status.name.toLowerCase();
@@ -13,6 +16,7 @@ var itemsOut  = environment.patronItemsOut;
 var fines              = environment.patronFines;
 var isRenewal  = environment.isRenewal;
 
+
 log_debug('CIRC PERMIT: permit circ on ' +
        ' Copy: '                                       + copy.id + 
        ', Patron:'                                     + patron.id +
index 69cde27..5c7e313 100644 (file)
@@ -142,6 +142,8 @@ sub _doctor_circ_objects {
 sub _get_patron_profile { 
        my( $patron, $group_tree ) = @_;
        return $group_tree if ($group_tree->id eq $patron->profile);
+       return undef unless ($group_tree->children);
+
        for my $child (@{$group_tree->children}) {
                my $ret = _get_patron_profile( $patron, $child );
                return $ret if $ret;
@@ -186,15 +188,14 @@ sub _build_circ_script_runner {
                $runner->add_path( $_ );
        }
 
-       $runner->insert( 'patron',              $ctx->{patron}, 1);
-       $runner->insert( 'title',               $ctx->{title}, 1);
-       $runner->insert( 'copy',                $ctx->{copy}, 1);
+       $runner->insert( 'environment.patron',          $ctx->{patron}, 1);
+       $runner->insert( 'environment.title',           $ctx->{title}, 1);
+       $runner->insert( 'environment.copy',            $ctx->{copy}, 1);
 
        # circ script result
-       $runner->insert( 'result', {} );
-       $runner->insert( 'result.event', 'SUCCESS' );
+       $runner->insert( 'environment.result', {} );
+       $runner->insert( 'environment.result.event', 'SUCCESS' );
 
-       $runner->insert('environment', {}, 1);
        $runner->insert('environment.isRenewal', 1) if $ctx->{isrenew};
 
        if(ref($ctx->{patron_circ_summary})) {
@@ -213,7 +214,7 @@ sub _add_script_runner_methods {
 
        # allows a script to fetch a hold that is currently targeting the
        # copy in question
-       $runner->insert_method( 'copy', '__OILS_FUNC_fetch_hold', sub {
+       $runner->insert_method( 'environment.copy', '__OILS_FUNC_fetch_hold', sub {
                        my $key = shift;
                        my $hold = $holdcode->fetch_open_hold_by_current_copy($ctx->{copy}->id);
                        $hold = undef unless $hold;
@@ -274,7 +275,7 @@ sub permit_circ {
        $runner->load($scripts{circ_permit});
        $runner->run or throw OpenSRF::EX::ERROR ("Circ Permit Script Died: $@");
 
-       my $evtname = $runner->retrieve('result.event');
+       my $evtname = $runner->retrieve('environment.result.event');
        $logger->activity("Permit Circ for user $patronid and barcode $barcode returned event: $evtname");
        return OpenILS::Event->new($evtname);
 }