From a6d77da86affe0963447a150dc07fa3aaeff4fdd Mon Sep 17 00:00:00 2001 From: Martin Persson Date: Mon, 9 Nov 2015 14:34:40 +0100 Subject: [PATCH] Bug 14257 - Add show_attributes to GetPatronInfo This patch adds the ability to query the extended patron attributes via the ILSDI web service's GetPatronInfo service. Example: ilsdi.pl?service=GetPatronInfo&patron_id=3&show_attributes=1 A new element will be added if there are any attributes available from the database. We need to discuss the security implications of showing the attributes. At present it will allow querying of non-public (OPAC-visible) information. We might want to change this. Sponsored-By: Halland County Library Test plan: * Configure Koha to make use of extended attributes: Under 'Administration' -> 'Global system preferences' -> 'Patrons' tab -> Set 'ExtendedPatronAttributes' to 'Enable', press save and switch to 'Web services' tab. * Enable the ILS-DI service: Under 'Administration' -> 'Global system preferences' -> 'Web services' tab -> 'ILS-DI' section: Set 'ILS-DI' to 'Enable' and save. * Create an attribute to query: Under 'Administration' -> 'Patrons and circulation' -> 'Patron attribute types' press 'New patron attribute type': Enter a type code, like 'DOORCODE', description and assign a category that your test patron is a member of, then save. * Set value for test user: Locate the test patron, the new attribute should be listed under 'Additional attributes and identifiers'. Click 'Edit' and assign a value, like '1337' and save. * Query the ILS-DI service: http://127.0.1.1/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=1&show_attributes=1 The output XML should have an element named 'attributes' containing the data you entered. Signed-off-by: Mirko Tietgen --- C4/ILSDI/Services.pm | 6 ++++++ opac/ilsdi.pl | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index e69c070..b1db742 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -34,6 +34,7 @@ use HTML::Entities; use CGI qw ( -utf8 ); use DateTime; use C4::Auth; +use C4::Members::Attributes qw(GetBorrowerAttributes); =head1 NAME @@ -428,6 +429,11 @@ sub GetPatronInfo { $borrower->{'loans'}->{'loan'} = $issues; } + if ( $cgi->param('show_attributes') eq "1" ) { + my $attrs = GetBorrowerAttributes( $borrowernumber, 0, 1 ); + $borrower->{'attributes'} = $attrs; + } + return $borrower; } diff --git a/opac/ilsdi.pl b/opac/ilsdi.pl index 05e7c5c..2ff65b5 100755 --- a/opac/ilsdi.pl +++ b/opac/ilsdi.pl @@ -104,7 +104,7 @@ my %optional = ( 'GetAuthorityRecords' => ['schema'], 'LookupPatron' => ['id_type'], 'AuthenticatePatron' => [], - 'GetPatronInfo' => [ 'show_contact', 'show_fines', 'show_holds', 'show_loans' ], + 'GetPatronInfo' => [ 'show_contact', 'show_fines', 'show_holds', 'show_loans', 'show_attributes' ], 'GetPatronStatus' => [], 'GetServices' => [], 'RenewLoan' => ['desired_due_date'], -- 2.1.4