Bugzilla – Attachment 68655 Details for
Bug 17826
Allow extended patron attributes to be sent in arbitrary SIP2 fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17826 - Allow extended patron attributes to be sent in arbitrary SIP2 fields
Bug-17826---Allow-extended-patron-attributes-to-be.patch (text/plain), 6.80 KB, created by
Marcel de Rooy
on 2017-10-27 06:31:36 UTC
(
hide
)
Description:
Bug 17826 - Allow extended patron attributes to be sent in arbitrary SIP2 fields
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-10-27 06:31:36 UTC
Size:
6.80 KB
patch
obsolete
>From 8d412619ec447e0679e9700a910377a377433ed1 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 29 Dec 2016 15:39:28 +0000 >Subject: [PATCH] Bug 17826 - Allow extended patron attributes to be sent in > arbitrary SIP2 fields >Content-Type: text/plain; charset=utf-8 > >Some libraries need to be able to send additional patron data from the >extended patron attributes in made up SIP2 fields for the patron >information and patron status responses. > >Test Plan: >1) Apply this patch >2) Create 3 new patron attributes with the codes CODE1, CODE2, CODE3. > Make a least one repeatable. >3) Create a patron, add those attibutes for the patron, make sure there > are at least two instances of the repeatable code >4) Edit your SIP2 config file, add the following within the login stanza: > <patron_attribute field="XX" code="CODE1" /> > <patron_attribute field="XY" code="CODE2" /> > <patron_attribute field="XZ" code="CODE3" /> >5) Using the sip cli emulator, run patron_information and > patron_status_request messages for the patron >6) Note the values you set for the patron attributes are sent in the > corrosponding fields! > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Daniel Mauchley <dmauchley@duchesne.utah.gov> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Amended: added parentheses on line 488 when assigning hashref to array. >--- > C4/SIP/ILS/Patron.pm | 31 +++++++++++++++++++++++++++++++ > C4/SIP/Sip/MsgType.pm | 6 ++++++ > etc/SIPconfig.xml | 1 + > t/db_dependent/SIP/Patron.t | 44 +++++++++++++++++++++++++++++++++++++++++++- > 4 files changed, 81 insertions(+), 1 deletion(-) > >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index 6cd3300..ddfb743 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -15,6 +15,8 @@ use Carp; > use Sys::Syslog qw(syslog); > use Data::Dumper; > >+use C4::SIP::Sip qw(add_field); >+ > use C4::Debug; > use C4::Context; > use C4::Koha; >@@ -474,6 +476,35 @@ sub _get_outstanding_holds { > return \@holds; > } > >+sub build_patron_attributes_string { >+ my ( $self, $server ) = @_; >+ >+ my $string = q{}; >+ >+ if ( $server->{account}->{patron_attribute} ) { >+ my @attributes_to_send = >+ ref $server->{account}->{patron_attribute} eq "ARRAY" >+ ? @{ $server->{account}->{patron_attribute} } >+ : ( $server->{account}->{patron_attribute} ); >+ >+ foreach my $a ( @attributes_to_send ) { >+ my @attributes = Koha::Patron::Attributes->search( >+ { >+ borrowernumber => $self->{borrowernumber}, >+ code => $a->{code} >+ } >+ ); >+ >+ foreach my $attribute ( @attributes ) { >+ my $value = $attribute->attribute(); >+ $string .= add_field( $a->{field}, $value ); >+ } >+ } >+ } >+ >+ return $string; >+} >+ > 1; > __END__ > >diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm >index dded51e..599c040 100644 >--- a/C4/SIP/Sip/MsgType.pm >+++ b/C4/SIP/Sip/MsgType.pm >@@ -19,6 +19,8 @@ use Data::Dumper; > use CGI qw ( -utf8 ); > use C4::Auth qw(&check_api_auth); > >+use Koha::Patron::Attributes; >+ > use UNIVERSAL::can; > > use vars qw(@ISA @EXPORT_OK); >@@ -443,6 +445,8 @@ sub build_patron_status { > if ( $server->{account}->{send_patron_home_library_in_af} ); > $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line ); > >+ $resp .= $patron->build_patron_attributes_string( $server ); >+ > } else { > # Invalid patron (cardnumber) > # Report that the user has no privs. >@@ -1001,6 +1005,8 @@ sub handle_patron_info { > $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server); > } > $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line ); >+ >+ $resp .= $patron->build_patron_attributes_string( $server ); > } else { > > # Invalid patron ID: >diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml >index f51f093..1b43c3e 100644 >--- a/etc/SIPconfig.xml >+++ b/etc/SIPconfig.xml >@@ -56,6 +56,7 @@ > av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]" > > <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" /> > <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" /> >+ <patron_attribute field="XY" code="CODE" /> > </login> > </accounts> > >diff --git a/t/db_dependent/SIP/Patron.t b/t/db_dependent/SIP/Patron.t >index 3008888..f0a6f66 100755 >--- a/t/db_dependent/SIP/Patron.t >+++ b/t/db_dependent/SIP/Patron.t >@@ -4,12 +4,13 @@ > # This needs to be extended! Your help is appreciated.. > > use Modern::Perl; >-use Test::More tests => 3; >+use Test::More tests => 4; > > use Koha::Database; > use t::lib::TestBuilder; > use t::lib::Mocks; > use C4::SIP::ILS::Patron; >+use Koha::Patron::Attributes; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -72,4 +73,45 @@ subtest "OverduesBlockCirc tests" => sub { > > }; > >+subtest "Test build_patron_attribute_string" => sub { >+ >+ plan tests => 2; >+ >+ my $patron = $builder->build( { source => 'Borrower' } ); >+ >+ my $attribute_type = $builder->build( { source => 'BorrowerAttributeType' } ); >+ my $attribute = Koha::Patron::Attribute->new( >+ { >+ borrowernumber => $patron->{borrowernumber}, >+ code => $attribute_type->{code}, >+ attribute => 'Test Attribute' >+ } >+ )->store(); >+ >+ my $attribute_type2 = $builder->build( { source => 'BorrowerAttributeType' } ); >+ my $attribute2 = Koha::Patron::Attribute->new( >+ { >+ borrowernumber => $patron->{borrowernumber}, >+ code => $attribute_type2->{code}, >+ attribute => 'Another Test Attribute' >+ } >+ )->store(); >+ >+ my $ils_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber} ); >+ >+ my $server = {}; >+ $server->{account}->{patron_attribute}->{code} = $attribute->code; >+ $server->{account}->{patron_attribute}->{field} = 'XY'; >+ my $attribute_string = $ils_patron->build_patron_attributes_string( $server ); >+ is( $attribute_string, "XYTest Attribute|", 'Attribute field generated correctly with single param' ); >+ >+ $server = {}; >+ $server->{account}->{patron_attribute}->[0]->{code} = $attribute->code; >+ $server->{account}->{patron_attribute}->[0]->{field} = 'XY'; >+ $server->{account}->{patron_attribute}->[1]->{code} = $attribute2->code; >+ $server->{account}->{patron_attribute}->[1]->{field} = 'YZ'; >+ $attribute_string = $ils_patron->build_patron_attributes_string( $server ); >+ is( $attribute_string, "XYTest Attribute|YZAnother Test Attribute|", 'Attribute field generated correctly with multiple params' ); >+}; >+ > $schema->storage->txn_rollback; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17826
:
58499
|
58500
|
60063
|
68622
| 68655 |
72614