Fix patron blocking in LookupUser master
authorJeff Godin <jgodin@tadl.org>
Mon, 8 Sep 2014 21:24:39 +0000 (17:24 -0400)
committerJeff Godin <jgodin@tadl.org>
Mon, 8 Sep 2014 22:06:04 +0000 (18:06 -0400)
Not all standing penalties in Evergreen should cause a value to be
returned in the LookupUser BlockOrTrap element.

Uncomment existing code (originally from issa -- thanks, @Dyrcona!)
to iterate over penalties and only block on those whose block list
contains a certain set of block types.

We are now blocking only on standing penalties that contain HOLD or
CIRC in their block list.

Fixes #14.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
iNCIPit.cgi

index 69c8e23..dc9ec00 100644 (file)
@@ -988,22 +988,27 @@ sub lookupUser {
 
     elsif ( $#penalties > -1 ) {
 
-#                my $penalty;
-#                   foreach $penalty (@penalties) {
-#                    if (defined($penalty->standing_penalty->block_list)) {
-#                            my @block_list = split(/\|/, $penalty->standing_penalty->block_list);
-#                            foreach my $block (@block_list) {
-#                                foreach my $block_on (@$block_types) {
-#                                    if ($block eq $block_on) {
-#                                        $block_stanza .= "\n".$penalty->standing_penalty->name;
-#                                        $patron_ok = 0;
-#                                    }
-#                                    last unless ($patron_ok);
-#                            }
-#                                last unless ($patron_ok);
-#                          }
-#                     }
-#                }
+        # Block only on standing penalties that have CIRC or HOLD in their block list
+        my $block_types = [qw/CIRC HOLD/];
+
+        my $penalty;
+        foreach $penalty (@penalties) {
+            if (defined($penalty->standing_penalty->block_list)) {
+                my @block_list = split(/\|/, $penalty->standing_penalty->block_list);
+                foreach my $block (@block_list) {
+                    foreach my $block_on (@$block_types) {
+                        if ($block eq $block_on) {
+                            $block_stanza .= "\n".$penalty->standing_penalty->name;
+                            $patron_ok = 0;
+                        }
+                        last unless ($patron_ok);
+                    }
+                    last unless ($patron_ok);
+                }
+            }
+        }
+    }
+    unless ($patron_ok) {
         $block_stanza = qq(
             <BlockOrTrap>
                 <UniqueAgencyId>