From c894743969b89927d433048c6aba4db8865e48cd Mon Sep 17 00:00:00 2001 From: Benjamin Rokseth Date: Thu, 5 Feb 2015 15:46:50 +0100 Subject: [PATCH] Bug 13666 - Allow SIP2 checkin/checkout to get branch from institution_id field AO This patch adds a policy flag in SIPConfig.xml that allows overriding branch on SIP2 checkout with the AO (institution id) field. Since SIP2 also uses C4::Context this patch has to modify C4::Context->userenv->{'branch'} Test plan: 1) Either use telnet or apply patch from bug #13159 to use sip command line client 2) Checkout book with SIP2 using a modified institution id (field AO) than the one defined in SIPConfig.xml for the account 3) Notice returned AO is still same as in SIPConfig account 4) Also notice checkout history in admin gives same 'checked out from' 5) Apply this patch and add 'allow_branch_override="true" to the policy of your ILS 6) Restart SIP server 7) Repeat 2) 8) Notice that 3) and 4) now reports the modified institution id --- C4/SIP/Sip/MsgType.pm | 8 +++++++- etc/SIPconfig.xml | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 5c6f696..32aedea 100644 --- a/C4/SIP/Sip/MsgType.pm +++ a/C4/SIP/Sip/MsgType.pm @@ -18,6 +18,7 @@ use Sip::Checksum qw(verify_cksum); use Data::Dumper; use CGI qw ( -utf8 ); use C4::Auth qw(&check_api_auth); +use C4::Context; use UNIVERSAL qw(can); # make sure this is *after* C4 modules. @@ -512,6 +512,12 @@ sub handle_checkout { $patron_id = $fields->{(FID_PATRON_ID)}; $item_id = $fields->{(FID_ITEM_ID)}; + # Overriding branch context and institution_id from value in AO + # if allow_branch_override policy is set on institution + if ($server->{policy}->{allow_branch_override}) { + $inst = $fields->{(FID_INST_ID)}; + C4::Context->userenv->{'branch'} = $inst; + } if ($no_block eq 'Y') { # Off-line transactions need to be recorded, but there's # not a lot we can do about it diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml index 8d2d77b..9fdf271 100644 --- a/etc/SIPconfig.xml +++ a/etc/SIPconfig.xml @@ -59,6 +59,7 @@ in our case "ILS".