From a5f780c219fd80dc88f7d27317aff66d26452f88 Mon Sep 17 00:00:00 2001 From: Larry Baerveldt Date: Fri, 6 May 2016 12:32:11 -0700 Subject: [PATCH] Bug 26370: Add ability to disable demagnetizing items via SIP2 for arbitrary patron categories Some libraries have certain patron categories that can only do in house checkouts via SIP self check machines. In these cases, the items should not be demagnetized since the items cannot leave the library. --- C4/SIP/Sip/MsgType.pm | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index d9f8901c06..0560e3f70a 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -552,7 +552,7 @@ sub handle_checkout { } # We never return the obsolete 'U' value for 'desensitize' - $resp .= sipbool( $status->desensitize ); + $resp .= sipbool( desensitize( { status => $status, patron => $patron, server => $server } ) ); $resp .= timestamp; # Now for the variable fields @@ -1447,7 +1447,7 @@ sub handle_renew { } else { $resp .= 'U'; } - $resp .= sipbool( $status->desensitize ); + $resp .= sipbool( desensitize( { status => $status, patron => $patron, server => $server } ) ); $resp .= timestamp; $resp .= add_field( FID_PATRON_ID, $patron->id, $server ); $resp .= add_field( FID_ITEM_ID, $item->id, $server ); @@ -1688,6 +1688,29 @@ sub api_auth { return $status; } +sub desensitize { + my ($params) = @_; + + my $status = $params->{status}; + my $desensitize = $status->desensitize(); + + # If desenstize is already false, no need to do anything + return unless $desensitize; + + my $patron = $params->{patron}; + my $server = $params->{server}; + + my $patron_categories = $server->{account}->{never_demagnitize}; + + # If no patron categories are set for never desensitize, no need to do anything + return $desensitize unless $patron_categories; + + my $patron_category = $patron->ptype(); + my @patron_categories = split( /,/, $patron_categories ); + + return !grep( /^$patron_category$/, @patron_categories ); +} + 1; __END__ -- 2.24.1 (Apple Git-126)