From 070aacf4a85d478e3e90d03cb9969e916651153a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 11 May 2009 14:29:46 +0200 Subject: [PATCH 1/9] Added ILS-DI module Signed-off-by: Galen Charlton --- admin/systempreferences.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index 4c856da96b..05f53966f9 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -368,6 +368,8 @@ $tabsysprefs{'OAI-PMH:MaxCount'} = "OAI-PMH"; $tabsysprefs{'OAI-PMH:Set'} = "OAI-PMH"; $tabsysprefs{'OAI-PMH:Subset'} = "OAI-PMH"; +# ILS-DI variables +$tabsysprefs{'ILS-DI'} = "ILS-DI"; sub StringSearch { my ( $searchstring, $type ) = @_; my $dbh = C4::Context->dbh; From ed92b52b2695c7d8c14da756e950527d1083629d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 2 Jun 2009 11:06:58 +0200 Subject: [PATCH 2/9] Added comments to ILS-DI code Signed-off-by: Galen Charlton --- C4/ILSDI/Services.pm | 794 +++++++++++++++++++++++++++++++++++++++++++ C4/ILSDI/Utility.pm | 144 ++++++++ opac/ilsdi.pl | 219 ++++++++++++ 3 files changed, 1157 insertions(+) create mode 100644 C4/ILSDI/Services.pm create mode 100644 C4/ILSDI/Utility.pm create mode 100755 opac/ilsdi.pl diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm new file mode 100644 index 0000000000..9e907daf36 --- /dev/null +++ b/C4/ILSDI/Services.pm @@ -0,0 +1,794 @@ +package C4::ILSDI::Services; + +# Copyright 2009 SARL Biblibre +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use C4::Members; +use C4::Items; +use C4::Circulation; +use C4::Branch; +use C4::Accounts; +use C4::Biblio; +use C4::Reserves; +use C4::Context; +use C4::AuthoritiesMarc; +use C4::ILSDI::Utility; +use XML::Simple; +use CGI; + +=head1 NAME + +C4::ILS-DI::Services - ILS-DI Services + +=head1 DESCRIPTION + + Each function in this module represents an ILS-DI service. + They all takes a CGI instance as argument and most of them return a + hashref that will be printed by XML::Simple in opac/ilsdi.pl + +=head1 SYNOPSIS + + use C4::ILSDI::Services; + use XML::Simple; + use CGI; + + my $cgi = new CGI; + + $out = LookupPatron($cgi); + + print CGI::header('text/xml'); + print XMLout($out, + noattr => 1, + noescape => 1, + nosort => 1, + xmldecl => '', + RootName => 'LookupPatron', + SuppressEmpty => 1); + +=cut + +=head2 GetAvailability + + Given a set of biblionumbers or itemnumbers, returns a list with + availability of the items associated with the identifiers. + + Parameters : + + - id (Required) + list of either biblionumbers or itemnumbers + - id_type (Required) + defines the type of record identifier being used in the request, + possible values: + - bib + - item + - return_type (Optional) + requests a particular level of detail in reporting availability, + possible values: + - bib + - item + - return_fmt (Optional) + requests a particular format or set of formats in reporting + availability + +=cut + +sub GetAvailability { + my ( $cgi ) = @_; + + my $out = "\n"; + $out .= "\n"; + + foreach $id (split(/ /, $cgi->param('id'))) + { + if ($cgi->param('id_type') eq "item") + { + my ($biblionumber, $status, $msg, $location) = Availability($id); + + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " " . $id . "\n"; + $out .= " " . $status . "\n"; + if ($msg) { $out .= " " . $msg . "\n"; } + if ($location) { $out .= " " . $location . "\n"; } + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + } + else + { + my $status; + my $msg; + my $biblioitem = (GetBiblioItemByBiblioNumber($id, undef))[0]; + if ($biblioitem) { + + } else { + $status = "unknown"; + $msg = "Error: could not retrieve availability for this ID"; + } + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " " . $id . "\n"; + $out .= " " . $status . "\n"; + $out .= " " . $msg . "\n"; + $out .= " \n"; + $out .= " \n"; + } + } + $out .= "\n"; + + return $out; +} + +=head2 GetRecords + + Given a list of biblionumbers, returns a list of record objects that + contain bibliographic information, as well as associated holdings and item + information. The caller may request a specific metadata schema for the + record objects to be returned. + This function behaves similarly to HarvestBibliographicRecords and + HarvestExpandedRecords in Data Aggregation, but allows quick, real time + lookup by bibliographic identifier. + + You can use OAI-PMH ListRecords instead of this service. + + Parameters: + + - id (Required) + list of system record identifiers + - id_type (Optional) + Defines the metadata schema in which the records are returned, + possible values: + - MARCXML + +=cut + +sub GetRecords { + my ( $cgi ) = @_; + + # Check if the schema is supported. For now, GetRecords only supports MARCXML + if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML") { + $out->{'message'} = "UnsupportedSchema"; + return $out; + } + + my @records; + # Loop over biblionumbers + foreach $biblionumber (split(/ /, $cgi->param('id'))) + { + # Get the biblioitem from the biblionumber + my $biblioitem = (GetBiblioItemByBiblioNumber($biblionumber, undef))[0]; + if ( not $biblioitem->{'biblionumber'} ) { + $biblioitem = "RecordNotFound"; + } + + # We don't want MARC to be displayed + delete $biblioitem->{'marc'}; + # nor the XML declaration of MARCXML + $biblioitem->{'marcxml'} =~ s/<\?xml version="1.0" encoding="UTF-8"\?>//go; + + # Get most of the needed data + my $biblioitemnumber = $biblioitem->{'biblioitemnumber'}; + my @reserves = GetReservesFromBiblionumber($biblionumber, undef, undef); + my $issues = GetBiblioIssues($biblionumber); + my $items = GetItemsByBiblioitemnumber($biblioitemnumber); + + # We loop over the items to clean them + foreach $item (@$items) + { + # This hides additionnal XML subfields, we don't need these info + delete $item->{'more_subfields_xml'}; + # Display branch names instead of branch codes + $item->{'homebranchname'} = GetBranchName($item->{'homebranch'}); + $item->{'holdingbranchname'} = GetBranchName($item->{'holdingbranch'}); + } + + # Hashref building... + $biblioitem->{'items'}->{'item'} = $items; + $biblioitem->{'reserves'}->{'reserve'} = @reserves[1]; + $biblioitem->{'issues'}->{'issue'} = $issues; + + push @records, $biblioitem; + } + + $records->{'record'} = \@records; + + return $records; +} + +=head2 GetAuthorityRecords + + Given a list of authority record identifiers, returns a list of record + objects that contain the authority records. The function user may request + a specific metadata schema for the record objects. + + Parameters: + + - id (Required) + list of authority record identifiers + - schema (Optional) + specifies the metadata schema of records to be returned, possible values: + - MARCXML + +=cut + +sub GetAuthorityRecords { + my ( $cgi ) = @_; + + # If the user asks for an unsupported schema, return an error code + if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML") { + $out->{'message'} = "UnsupportedSchema"; + return $out; + } + + my $records; + # Let's loop over the authority IDs + foreach $authid (split(/ /, $cgi->param('id'))) + { + # Get the record as XML string, or error code + my $record= GetAuthorityXML($authid) || "RecordNotFound"; + $record =~ s/<\?xml version="1.0" encoding="UTF-8"\?>//go; + $records .= $record; + } + + return $records; +} + +=head2 LookupPatron + + Looks up a patron in the ILS by an identifier, and returns the borrowernumber. + + Parameters: + + - id (Required) + an identifier used to look up the patron in Koha + - id_type (Optional) + the type of the identifier, possible values: + - cardnumber + - firstname + - userid + - borrowernumber + +=cut + +sub LookupPatron { + my ( $cgi ) = @_; + + # Get the borrower... + my $borrower = GetMember($cgi->param('id'), $cgi->param('id_type')); + if ( not $borrower->{'borrowernumber'} ) { + $out->{'message'} = "PatronNotFound"; + return $out; + } + + # Build the hashref + my $patron->{'id'} = $borrower->{'borrowernumber'}; + + # ...and return his ID + return $patron; +} + +=head2 AuthenticatePatron + + Authenticates a user's login credentials and returns the identifier for + the patron. + + Parameters: + + - username (Required) + user's login identifier + - password (Required) + user's password + +=cut + +sub AuthenticatePatron { + my ( $cgi ) = @_; + + # Check if borrower exists, using a C4::ILSDI::Utility function... + if ( not (BorrowerExists($cgi->param('username'), $cgi->param('password')))) { + $out->{'message'} = "PatronNotFound"; + return $out; + } + + # Get the borrower + my $borrower = GetMember($cgi->param('username'), "userid"); + + # Build the hashref + my $patron->{'id'} = $borrower->{'borrowernumber'}; + + # ... and return his ID + return $patron; +} + +=head2 GetPatronInfo + + Returns specified information about the patron, based on options in the + request. This function can optionally return patron's contact information, + fine information, hold request information, and loan information. + + Parameters: + + - patron_id (Required) + the borrowernumber + - show_contact (Optional, default 1) + whether or not to return patron's contact information in the response + - show_fines (Optional, default 0) + whether or not to return fine information in the response + - show_holds (Optional, default 0) + whether or not to return hold request information in the response + - show_loans (Optional, default 0) + whether or not to return loan information request information in the response + +=cut + +sub GetPatronInfo { + my ( $cgi ) = @_; + + # Get Member details + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails($borrowernumber, undef); + if ( not $borrower->{'borrowernumber'}) { + $out->{'message'} = "PatronNotFound"; + return $out; + } + + # Cleaning the borrower hashref + $borrower->{'charges'} = $borrower->{'flags'}->{'CHARGES'}->{'amount'}; + $borrower->{'branchname'} = GetBranchName($borrower->{'branchcode'}); + delete $borrower->{'flags'}; + delete $borrower->{'userid'}; + delete $borrower->{'password'}; + + # Contact fields management + if ($cgi->param('show_contact') eq "0") { + # Define contact fields + my @contactfields = ('email', 'emailpro', 'fax', 'mobile', + 'phone', 'phonepro', 'streetnumber', 'zipcode', 'city', + 'streettype', 'B_address', 'B_city', 'B_email', 'B_phone', + 'B_zipcode', 'address', 'address2', 'altcontactaddress1', + 'altcontactaddress2', 'altcontactaddress3', 'altcontactfirstname', + 'altcontactphone', 'altcontactsurname', 'altcontactzipcode'); + # and delete them + foreach my $field (@contactfields) { + delete $borrower->{$field}; + } + } + + # Fines management + if ($cgi->param('show_fines') eq "1") { + my @charges; + for(my $i = 1; my @charge = getcharges($borrowernumber, undef, $i); $i++) { + push(@charges, @charge); + } + $borrower->{'fines'}->{'fine'} = \@charges; + } + + # Reserves management + if ($cgi->param('show_holds') eq "1") { + # Get borrower's reserves + my @reserves = GetReservesFromBorrowernumber($borrowernumber, undef); + foreach my $reserve (@reserves) { + # Get additional informations + my $item = GetBiblioFromItemNumber($reserve->{'itemnumber'}, undef); + my $branchname = GetBranchName($reserve->{'branchcode'}); + # Remove unwanted fields + delete $item->{'marc'}; + delete $item->{'marcxml'}; + delete $item->{'more_subfields_xml'}; + # Add additional fields + $reserve->{'item'} = $item; + $reserve->{'branchname'} = $branchname; + $reserve->{'title'} = (GetBiblio($reserve->{'biblionumber'}))[1]->{'title'}; + } + $borrower->{'holds'}->{'hold'} = \@reserves; + } + + # Issues management + if ($cgi->param('show_loans') eq "1") { + my $issues = GetPendingIssues($borrowernumber); + $borrower->{'loans'}->{'loan'} = $issues; + } + + return $borrower; +} + +=head2 GetPatronStatus + + Returns a patron's status information. + + Parameters: + + - patron_id (Required) + the borrower ID + +=cut + +sub GetPatronStatus { + my ( $cgi ) = @_; + + # Get Member details + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails($borrowernumber, undef); + if ( not $borrower->{'borrowernumber'} ) { + $out->{'message'} = "PatronNotFound"; + return $out; + } + + # Hashref building + $patron->{'type'} = $borrower->{'categorycode'}; + $patron->{'status'} = 0; #TODO + $patron->{'expiry'} = $borrower->{'dateexpiry'}; + + return $patron; +} + +=head2 GetServices + + Returns information about the services available on a particular item for + a particular patron. + + Parameters: + + - patron_id (Required) + a borrowernumber + - item_id (Required) + an itemnumber +=cut + +sub GetServices { + my ( $cgi ) = @_; + + # Get the member, or return an error code if not found + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails($borrowernumber, undef); + if ( not $borrower->{'borrowernumber'} ) { + $out->{'message'} = "PatronNotFound"; + return $out; + } + + # Get the item, or return an error code if not found + my $itemnumber = $cgi->param('item_id'); + my $item = GetItem($itemnumber, undef, undef); + if ( not $item->{'itemnumber'} ) { + $out->{'message'} = "RecordNotFound"; + return $out; + } + + my @availablefor; + + # Reserve level management + my $biblionumber = $item->{'biblionumber'}; + my $canbookbereserved = CanBookBeReserved($borrower, $biblionumber); + if ( $canbookbereserved ) { + push @availablefor, 'title level hold'; + my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber); + if ( $canitembereserved ) { + push @availablefor, 'item level hold'; + } + } + + # Reserve cancellation management + my @reserves = GetReservesFromBorrowernumber($borrowernumber, undef); + my @reserveditems; + foreach my $reserve (@reserves) { + push @reserveditems, $reserve->{'itemnumber'}; + } + if ( grep {$itemnumber eq $_} @reserveditems) { + push @availablefor, 'hold cancellation'; + } + + # Renewal management + my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); + if ( @renewal[0] ) { + push @availablefor, 'loan renewal'; + } + + # Issuing management + my $barcode = $item->{'barcode'} || ''; + $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter')); + if ($barcode) { + my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, $barcode ); + # TODO push @availablefor, 'loan'; + } + + $out->{'AvailableFor'} = \@availablefor; + + return $out; +} + +=head2 RenewLoan + + Extends the due date for a borrower's existing issue. + + Parameters: + + - patron_id (Required) + a borrowernumber + - item_id (Required) + an itemnumber + - desired_due_date (Required) + the date the patron would like the item returned by + +=cut + +sub RenewLoan { + my ( $cgi ) = @_; + + # Get borrower infos or return an error code + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails($borrowernumber, undef); + if ( not $borrower->{'borrowernumber'} ) { + $out->{'message'} = "PatronNotFound"; + return $out; + } + + # Get the item, or return an error code + my $itemnumber = $cgi->param('item_id'); + my $item = GetItem($itemnumber, undef, undef); + if ( not $item->{'itemnumber'} ) { + $out->{'message'} = "RecordNotFound"; + return $out; + } + + # Add renewal if possible + my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); + if (@renewal[0]) { AddRenewal( $borrowernumber, $itemnumber ); } + + my $issue = GetItemIssue($itemnumber); + + # Hashref building + $out->{'renewals'} = $issue->{'renewals'}; + $out->{'date_due'} = $issue->{'date_due'}; + $out->{'success'} = @renewal[0]; + $out->{'error'} = @renewal[1]; + + return $out; +} + +=head2 HoldTitle + + Creates, for a borrower, a biblio-level hold reserve. + + Parameters: + + - patron_id (Required) + a borrowernumber + - bib_id (Required) + a biblionumber + - request_location (Required) + IP address where the end user request is being placed + - pickup_location (Optional) + a branch code indicating the location to which to deliver the item for pickup + - needed_before_date (Optional) + date after which hold request is no longer needed + - pickup_expiry_date (Optional) + date after which item returned to shelf if item is not picked up + +=cut + +sub HoldTitle { + my ( $cgi ) = @_; + + # Get the borrower or return an error code + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails($borrowernumber, undef); + if ( not $borrower->{'borrowernumber'} ) { + $out->{'message'} = "PatronNotFound"; + return $out; + } + + # Get the biblio record, or return an error code + my $biblionumber = $cgi->param('bib_id'); + my ($count, $biblio) = GetBiblio($biblionumber); + if ( not $biblio->{'biblionumber'} ) { + $out->{'message'} = "RecordNotFound"; + return $out; + } + my $title = $biblio->{'title'}; + + # Check if the biblio can be reserved + my $canbereserved = CanBookBeReserved($borrower, $biblionumber); + if ( not $canbereserved ) { + $out->{'message'} = "NotHoldable"; + return $out; + } + + my $branch; + # Pickup branch management + if ($cgi->param('pickup_location')) { + $branch = $cgi->param('pickup_location'); + my $branches = GetBranches(); + if ( not $branches->{$branch} ) { + $out->{'message'} = "LocationNotFound"; + return $out; + } + } else { # if user provide no branch, use his own + $branch = C4::Context->userenv->{'branch'}; + } + + # Add the reserve + # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found + AddReserve($branch, $borrowernumber, $biblionumber, 'a', undef, 0, undef, $title, undef, undef); + + # Hashref building + $out->{'title'} = $title; + $out->{'pickup_location'} = GetBranchName($branch); + # TODO $out->{'date_available'} = ''; + + return $out; +} + +=head2 HoldItem + + Creates, for a borrower, an item-level hold request on a specific item of + a bibliographic record in Koha. + + Parameters: + + - patron_id (Required) + a borrowernumber + - bib_id (Required) + a biblionumber + - item_id (Required) + an itemnumber + - pickup_location (Optional) + a branch code indicating the location to which to deliver the item for pickup + - needed_before_date (Optional) + date after which hold request is no longer needed + - pickup_expiry_date (Optional) + date after which item returned to shelf if item is not picked up + +=cut + +sub HoldItem { + my ( $cgi ) = @_; + + # Get the borrower or return an error code + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails($borrowernumber, undef); + if ( not $borrower->{'borrowernumber'} ) { + $out->{'message'} = "PatronNotFound"; + return $out; + } + + # Get the biblio or return an error code + my $biblionumber = $cgi->param('bib_id'); + my ($count, $biblio) = GetBiblio($biblionumber); + if ( not $biblio->{'biblionumber'} ) { + $out->{'message'} = "RecordNotFound"; + return $out; + } + my $title = $biblio->{'title'}; + + # Get the item or return an error code + my $itemnumber = $cgi->param('item_id'); + my $item = GetItem($itemnumber, undef, undef); + if ( not $item->{'itemnumber'} ) { + $out->{'message'} = "RecordNotFound"; + return $out; + } + + # if the biblio does not match the item, return an error code + if ( $item->{'biblionumber'} ne $biblio->{'biblionumber'} ) { + $out->{'message'} = "RecordNotFound"; + return $out; + } + + # Check for item disponibility + my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber); + my $canbookbereserved = CanBookBeReserved($borrower, $biblionumber); + if ( (not $canbookbereserved) or not ($canitembereserved) ) { + $out->{'message'} = "NotHoldable"; + return $out; + } + + my $branch; + # Pickup branch management + if ($cgi->param('pickup_location')) { + $branch = $cgi->param('pickup_location'); + my $branches = GetBranches(); + if ( not $branches->{$branch} ) { + $out->{'message'} = "LocationNotFound"; + return $out; + } + } else { # if user provide no branch, use his own + $branch = C4::Context->userenv->{'branch'}; + } + + my $rank; + my $found; + # Get rank and found + $rank = '0' unless C4::Context->preference('ReservesNeedReturns'); + if ( $item->{'holdingbranch'} eq $branch ){ + $found = 'W' unless C4::Context->preference('ReservesNeedReturns'); + } + + # Add the reserve + # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found + AddReserve($branch, $borrowernumber, $biblionumber, 'a', undef, $rank, undef, $title, $itemnumber, $found); + + # Hashref building + $out->{'title'} = $title; + $out->{'pickup_location'} = GetBranchName($branch); + # TODO $out->{'date_available'} = ''; + + return $out; +} + +=head2 CancelHold + + Cancels an active reserve request for the borrower. + + Parameters: + + - patron_id (Required) + a borrowernumber + - item_id (Required) + an itemnumber + +=cut + +sub CancelHold { + my ( $cgi ) = @_; + + # Get the borrower or return an error code + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails($borrowernumber, undef); + if ( not $borrower->{'borrowernumber'} ) { + $out->{'message'} = "PatronNotFound"; + return $out; + } + + # Get the item or return an error code + my $itemnumber = $cgi->param('item_id'); + my $item = GetItem($itemnumber, undef, undef); + if ( not $item->{'itemnumber'} ) { + $out->{'message'} = "RecordNotFound"; + return $out; + } + + # Get borrower's reserves + my @reserves = GetReservesFromBorrowernumber($borrowernumber, undef); + my @reserveditems; + # ...and loop over it to build an array of reserved itemnumbers + foreach my $reserve (@reserves) { + push @reserveditems, $reserve->{'itemnumber'}; + } + # if the item was not reserved by the borrower, returns an error code + if ( not grep {$itemnumber eq $_} @reserveditems) { + $out->{'message'} = "NotCanceled"; + return $out; + } + + # Cancel the reserve + CancelReserve($itemnumber, undef, $borrowernumber); + + $out->{'message'} = "Canceled"; + + return $out; +} + +1; diff --git a/C4/ILSDI/Utility.pm b/C4/ILSDI/Utility.pm new file mode 100644 index 0000000000..b6a167fd41 --- /dev/null +++ b/C4/ILSDI/Utility.pm @@ -0,0 +1,144 @@ +package C4::ILSDI::Utility; + +# Copyright 2009 SARL Biblibre +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use C4::Members; +use C4::Items; +use C4::Circulation; +use C4::Biblio; +use C4::Reserves; +use C4::Context; +use Digest::MD5 qw(md5_base64); + +=head1 NAME + +C4::ILS-DI::Utility - ILS-DI Utilities + +=cut + +=head2 BorrowerExists + +Checks, for a given userid and password, if the borrower exists. + + if ( BorrowerExists($userid, $password) ) { + # Do stuff + } + +=cut + +sub BorrowerExists { + my ( $userid, $password ) = @_; + $password = md5_base64($password); + my $dbh = C4::Context->dbh; + my $sth = + $dbh->prepare("SELECT COUNT(*) FROM borrowers WHERE userid =? and password=? "); + $sth->execute( $userid, $password ); + return $sth->fetchrow; +} + +=head2 CanBookBeReserved + +Checks if a book (at bibliographic level) can be reserved by a borrower. + + if ( CanBookBeReserved($borrower, $biblionumber) ) { + # Do stuff + } + +=cut + +sub CanBookBeReserved { + my ( $borrower, $biblionumber ) = @_; + + my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves"); + my $MAXOUTSTANDING = C4::Context->preference("maxoutstanding"); + + my $out = 1; + + if ( $borrower->{'amountoutstanding'} > $MAXOUTSTANDING ) { + $out = undef; + } + if ( $borrower->{gonenoaddress} eq 1 ) { + $out = undef; + } + if ( $borrower->{lost} eq 1 ) { + $out = undef; + } + if ( $borrower->{debarred} eq 1 ) { + $out = undef; + } + my @reserves = GetReservesFromBorrowernumber( $borrower->{'borrowernumber'} ); + if ( scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) { + $out = undef; + } + foreach my $res (@reserves) { + if ( $res->{'biblionumber'} == $biblionumber ) { + $out = undef; + } + } + my $issues = GetPendingIssues($borrower->{'borrowernumber'}); + foreach my $issue (@$issues) { + if ( $issue->{'biblionumber'} == $biblionumber ) { + $out = undef; + } + } + + return $out; +} + +=head2 Availability + +Returns, for an itemnumber, an array containing availability information. + + my ($biblionumber, $status, $msg, $location) = Availability($id); + +=cut + +sub Availability { + my ( $itemnumber ) = @_; + my $item = GetItem($itemnumber, undef, undef); + + if ( not $item->{'itemnumber'} ) { + return (undef, 'unknown', 'Error: could not retrieve availability for this ID', undef); + } + + my $biblionumber = $item->{'biblioitemnumber'}; + my $location = GetBranchName($item->{'holdingbranch'}); + + if ($item->{'notforloan'}) { + return ($biblionumber, 'not available', 'Not for loan', $location); + } + elsif ($item->{'onloan'}) { + return ($biblionumber, 'not available', 'Checked out', $location); + } + elsif ($item->{'itemlost'}) { + return ($biblionumber, 'not available', 'Item lost', $location); + } + elsif ($item->{'wthdrawn'}) { + return ($biblionumber, 'not available', 'Item withdrawn', $location); + } + elsif ($item->{'damaged'}) { + return ($biblionumber, 'not available', 'Item damaged', $location); + } + else { + return ($biblionumber, 'available', undef, $location); + } + + die Data::Dumper::Dumper($item); +} + +1; diff --git a/opac/ilsdi.pl b/opac/ilsdi.pl new file mode 100755 index 0000000000..b22bd691c5 --- /dev/null +++ b/opac/ilsdi.pl @@ -0,0 +1,219 @@ +#!/usr/bin/perl + +# Copyright 2009 SARL Biblibre +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use C4::ILSDI::Services; +use C4::Auth; +use C4::Output; +use C4::Context; +use XML::Simple; +use CGI; + +=head1 DLF ILS-DI for Koha + +This script is a basic implementation of ILS-DI protocol for Koha. +It acts like a dispatcher, that get the CGI request, check required and +optionals arguments, call a function from C4::ILS-DI::Services, and finaly +outputs the returned hashref as XML. + +=cut + +# Instanciate the CGI request +my $cgi = new CGI; + +# List of available services, sorted by level +my @services = ( + 'Describe', # Not part of ILS-DI, online API doc +# Level 1: Basic Discovery Interfaces +# 'HarvestBibliographicRecords', # OAI-PMH +# 'HarvestExpandedRecords', # OAI-PMH + 'GetAvailability', # FIXME Add bibbliographic level +# 'GoToBibliographicRequestPage' # I don't understant this one +# Level 2: Elementary OPAC supplement +# 'HarvestAuthorityRecords', # OAI-PMH +# 'HarvestHoldingsRecords', # OAI-PMH + 'GetRecords', # Note that we can use OAI-PMH for this too +# 'Search', # TODO +# 'Scan', # TODO + 'GetAuthorityRecords', +# 'OutputRewritablePage', # I don't understant this one +# 'OutputIntermediateFormat', # I don't understant this one +# Level 3: Elementary OPAC alternative + 'LookupPatron', + 'AuthenticatePatron', + 'GetPatronInfo', + 'GetPatronStatus', + 'GetServices', # FIXME Loans + 'RenewLoan', + 'HoldTitle', # FIXME Add dates support + 'HoldItem', # FIXME Add dates support + 'CancelHold', +# 'RecallItem', # Not supported by Koha +# 'CancelRecall', # Not supported by Koha +# Level 4: Robust/domain specific discovery platforms +# 'SearchCourseReserves', # TODO +# 'Explain' # TODO +); + +# List of required arguments +my %required = ( + 'Describe' => ['verb'], + 'GetAvailability' => ['id', 'id_type'], + 'GetRecords' => ['id'], + 'GetAuthorityRecords' => ['id'], + 'LookupPatron' => ['id'], + 'AuthenticatePatron' => ['username', 'password'], + 'GetPatronInfo' => ['patron_id'], + 'GetPatronStatus' => ['patron_id'], + 'GetServices' => ['patron_id', 'item_id'], + 'RenewLoan' => ['patron_id', 'item_id'], + 'HoldTitle' => ['patron_id', 'bib_id', 'request_location'], + 'HoldItem' => ['patron_id', 'bib_id', 'item_id'], + 'CancelHold' => ['patron_id', 'item_id'], +); + +# List of optional arguments +my %optional = ( + 'Describe' => [], + 'GetAvailability' => ['return_type', 'return_fmt'], + 'GetRecords' => ['schema'], + 'GetAuthorityRecords' => ['schema'], + 'LookupPatron' => ['id_type'], + 'AuthenticatePatron' => [], + 'GetPatronInfo' => ['show_contact', 'show_fines', 'show_holds', 'show_loans'], + 'GetPatronStatus' => [], + 'GetServices' => [], + 'RenewLoan' => ['desired_due_date'], + 'HoldTitle' => ['pickup_location', 'needed_before_date', 'pickup_expiry_date'], + 'HoldItem' => ['pickup_location', 'needed_before_date', 'pickup_expiry_date'], + 'CancelHold' => [], +); + +# If ILS-DI module is disabled in System->Preferences, redirect to 404 +if (not C4::Context->preference('ILS-DI')) { + print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); +} + +# If no service is requested, display the online documentation +if (not $cgi->param('service')) { + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "ilsdi.tmpl", + query => $cgi, + type => "opac", + authnotrequired => 1, + debug => 1, + } + ); + output_html_with_http_headers $cgi, $cookie, $template->output; + exit 0; +} + +# If user requested a service description, then display it +if ($cgi->param('service') eq "Describe" and grep {$cgi->param('verb') eq $_} @services) { + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "ilsdi.tmpl", + query => $cgi, + type => "opac", + authnotrequired => 1, + debug => 1, + } + ); + $template->param( $cgi->param('verb') => 1 ); + output_html_with_http_headers $cgi, $cookie, $template->output; + exit 0; +} + +my $service = $cgi->param('service') || "ilsdi"; + +my $out; + +# Check if the requested service is in the list +if ($service and grep {$service eq $_} @services) { + + my @parmsrequired = @{$required{$service}}; + my @parmsoptional = @{$optional{$service}}; + my @parmsall = (@parmsrequired, @parmsoptional); + my @names = $cgi->param; + my %paramhash = (); + foreach my $name (@names) { + $paramhash{$name} = 1; + } + + # check for missing parameters + foreach my $name (@parmsrequired) { + if ((! exists $paramhash{$name})) { + $out->{'message'} = "missing $name parameter"; + } + } + + # check for illegal parameters + foreach my $name (@names) { + my $found = 0; + foreach my $name2 (@parmsall) { + if ($name eq $name2) { + $found = 1; + } + } + if (($found == 0) && ($name ne 'service')) { + $out->{'message'} = "$name is an illegal parameter"; + } + } + + # check for multiple parameters + foreach my $name (@names) { + my @values = $cgi->param($name); + if ($#values != 0) { + $out->{'message'} = "multiple values are not allowed for the $name parameter"; + } + } + + if (! $out->{'message'}) { + # GetAvailability is a special case, as it cannot use XML::Simple + if ($service eq "GetAvailability") { + print CGI::header('text/xml'); + print C4::ILSDI::Services::GetAvailability($cgi); + exit 0; + } + else { + # Variable functions + my $sub = do{ + no strict 'refs'; + my $symbol = 'C4::ILSDI::Services::'.$service; + \&{"$symbol"}; + }; + # Call the requested service, and get its return value + $out = &$sub($cgi); + } + } +} +else { + $out->{'message'} = "NotSupported"; +} + +# Output XML by passing the hashref to XMLOut +print CGI::header('text/xml'); +print XMLout($out, + noattr => 1, + noescape => 1, + nosort => 1, + xmldecl => '', + RootName => $service, + SuppressEmpty => 1); + From d86515a358d1285b19b16b295f685fde05be8706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 11 Jun 2009 11:24:21 +0200 Subject: [PATCH 3/9] This fixes the encoding of ampersand entities in GetRecords Signed-off-by: Galen Charlton --- C4/ILSDI/Services.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 9e907daf36..ed8916b0fe 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -28,6 +28,7 @@ use C4::Context; use C4::AuthoritiesMarc; use C4::ILSDI::Utility; use XML::Simple; +use HTML::Entities; use CGI; =head1 NAME @@ -209,6 +210,8 @@ sub GetRecords { $biblioitem->{'items'}->{'item'} = $items; $biblioitem->{'reserves'}->{'reserve'} = @reserves[1]; $biblioitem->{'issues'}->{'issue'} = $issues; + + map { $biblioitem->{$_} = encode_entities($biblioitem->{$_},'&') } grep(!/marcxml/, keys %$biblioitem); push @records, $biblioitem; } From e35abadbbfd87bb61c8670bc8e4e9b04f8c21366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Fri, 12 Jun 2009 11:33:00 +0200 Subject: [PATCH 4/9] I forgot to export functions from Utility.pm Signed-off-by: Galen Charlton --- C4/ILSDI/Utility.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/C4/ILSDI/Utility.pm b/C4/ILSDI/Utility.pm index b6a167fd41..995b3b3f7f 100644 --- a/C4/ILSDI/Utility.pm +++ b/C4/ILSDI/Utility.pm @@ -25,6 +25,18 @@ use C4::Reserves; use C4::Context; use Digest::MD5 qw(md5_base64); +use vars qw($VERSION @ISA @EXPORT); + +BEGIN { + # set the version for version checking + $VERSION = 3.00; + require Exporter; + @ISA = qw(Exporter); + @EXPORT = qw( + &BorrowerExists &CanBookBeReserved &Availability + ); +} + =head1 NAME C4::ILS-DI::Utility - ILS-DI Utilities From a9dacab04a86706177e973d1fee9eb69d7b1ca6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Fri, 12 Jun 2009 12:10:14 +0200 Subject: [PATCH 5/9] Changed the way to get borrower's branchcode in HoldItem and HoldTitle Signed-off-by: Galen Charlton --- C4/ILSDI/Services.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index ed8916b0fe..a40df6201f 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -629,7 +629,7 @@ sub HoldTitle { return $out; } } else { # if user provide no branch, use his own - $branch = C4::Context->userenv->{'branch'}; + $branch = $borrower->{'branchcode'}; } # Add the reserve @@ -718,7 +718,7 @@ sub HoldItem { return $out; } } else { # if user provide no branch, use his own - $branch = C4::Context->userenv->{'branch'}; + $branch = $borrower->{'branchcode'}; } my $rank; From e7450455c883299d9474e139c7d608151d41e140 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 11 Aug 2009 07:31:14 -0400 Subject: [PATCH 6/9] added missing module import to C4::ILSDI::Utility Signed-off-by: Galen Charlton --- C4/ILSDI/Utility.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/C4/ILSDI/Utility.pm b/C4/ILSDI/Utility.pm index 995b3b3f7f..186d94bd40 100644 --- a/C4/ILSDI/Utility.pm +++ b/C4/ILSDI/Utility.pm @@ -23,6 +23,7 @@ use C4::Circulation; use C4::Biblio; use C4::Reserves; use C4::Context; +use C4::Branch qw/GetBranchName/; use Digest::MD5 qw(md5_base64); use vars qw($VERSION @ISA @EXPORT); From ccdc20496fd78d72955e64ff99355e1635a403ad Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 11 Aug 2009 08:20:27 -0400 Subject: [PATCH 7/9] bug 2505: enable strict and warnings in ILS-DI code Signed-off-by: Galen Charlton --- C4/ILSDI/Services.pm | 103 ++++++++++++++++++------------------------- C4/ILSDI/Utility.pm | 3 ++ opac/ilsdi.pl | 3 ++ 3 files changed, 48 insertions(+), 61 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index a40df6201f..f0d86d7131 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -17,6 +17,9 @@ package C4::ILSDI::Services; # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA +use strict; +use warnings; + use C4::Members; use C4::Items; use C4::Circulation; @@ -97,7 +100,7 @@ sub GetAvailability { $out .= " xsi:schemaLocation=\"http://diglib.org/ilsdi/1.1\n"; $out .= " http://diglib.org/architectures/ilsdi/schemas/1.1/dlfexpanded.xsd\">\n"; - foreach $id (split(/ /, $cgi->param('id'))) + foreach my $id (split(/ /, $cgi->param('id'))) { if ($cgi->param('id_type') eq "item") { @@ -171,13 +174,12 @@ sub GetRecords { # Check if the schema is supported. For now, GetRecords only supports MARCXML if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML") { - $out->{'message'} = "UnsupportedSchema"; - return $out; + return { message => 'UnsupportedSchema' }; } my @records; # Loop over biblionumbers - foreach $biblionumber (split(/ /, $cgi->param('id'))) + foreach my $biblionumber (split(/ /, $cgi->param('id'))) { # Get the biblioitem from the biblionumber my $biblioitem = (GetBiblioItemByBiblioNumber($biblionumber, undef))[0]; @@ -197,7 +199,7 @@ sub GetRecords { my $items = GetItemsByBiblioitemnumber($biblioitemnumber); # We loop over the items to clean them - foreach $item (@$items) + foreach my $item (@$items) { # This hides additionnal XML subfields, we don't need these info delete $item->{'more_subfields_xml'}; @@ -208,7 +210,7 @@ sub GetRecords { # Hashref building... $biblioitem->{'items'}->{'item'} = $items; - $biblioitem->{'reserves'}->{'reserve'} = @reserves[1]; + $biblioitem->{'reserves'}->{'reserve'} = $reserves[1]; $biblioitem->{'issues'}->{'issue'} = $issues; map { $biblioitem->{$_} = encode_entities($biblioitem->{$_},'&') } grep(!/marcxml/, keys %$biblioitem); @@ -216,9 +218,7 @@ sub GetRecords { push @records, $biblioitem; } - $records->{'record'} = \@records; - - return $records; + return { record => \@records }; } =head2 GetAuthorityRecords @@ -242,13 +242,12 @@ sub GetAuthorityRecords { # If the user asks for an unsupported schema, return an error code if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML") { - $out->{'message'} = "UnsupportedSchema"; - return $out; + return { message => 'UnsupportedSchema' }; } my $records; # Let's loop over the authority IDs - foreach $authid (split(/ /, $cgi->param('id'))) + foreach my $authid (split(/ /, $cgi->param('id'))) { # Get the record as XML string, or error code my $record= GetAuthorityXML($authid) || "RecordNotFound"; @@ -282,8 +281,7 @@ sub LookupPatron { # Get the borrower... my $borrower = GetMember($cgi->param('id'), $cgi->param('id_type')); if ( not $borrower->{'borrowernumber'} ) { - $out->{'message'} = "PatronNotFound"; - return $out; + return { message => 'PatronNotFound' }; } # Build the hashref @@ -312,8 +310,7 @@ sub AuthenticatePatron { # Check if borrower exists, using a C4::ILSDI::Utility function... if ( not (BorrowerExists($cgi->param('username'), $cgi->param('password')))) { - $out->{'message'} = "PatronNotFound"; - return $out; + return { message => 'PatronNotFound' }; } # Get the borrower @@ -354,8 +351,7 @@ sub GetPatronInfo { my $borrowernumber = $cgi->param('patron_id'); my $borrower = GetMemberDetails($borrowernumber, undef); if ( not $borrower->{'borrowernumber'}) { - $out->{'message'} = "PatronNotFound"; - return $out; + return { message => 'PatronNotFound' }; } # Cleaning the borrower hashref @@ -436,11 +432,11 @@ sub GetPatronStatus { my $borrowernumber = $cgi->param('patron_id'); my $borrower = GetMemberDetails($borrowernumber, undef); if ( not $borrower->{'borrowernumber'} ) { - $out->{'message'} = "PatronNotFound"; - return $out; + return { message => 'PatronNotFound' }; } # Hashref building + my $patron; $patron->{'type'} = $borrower->{'categorycode'}; $patron->{'status'} = 0; #TODO $patron->{'expiry'} = $borrower->{'dateexpiry'}; @@ -468,16 +464,14 @@ sub GetServices { my $borrowernumber = $cgi->param('patron_id'); my $borrower = GetMemberDetails($borrowernumber, undef); if ( not $borrower->{'borrowernumber'} ) { - $out->{'message'} = "PatronNotFound"; - return $out; + return { message => 'PatronNotFound' }; } # Get the item, or return an error code if not found my $itemnumber = $cgi->param('item_id'); my $item = GetItem($itemnumber, undef, undef); if ( not $item->{'itemnumber'} ) { - $out->{'message'} = "RecordNotFound"; - return $out; + return { message => 'RecordNotFound' }; } my @availablefor; @@ -505,7 +499,7 @@ sub GetServices { # Renewal management my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); - if ( @renewal[0] ) { + if ( $renewal[0] ) { push @availablefor, 'loan renewal'; } @@ -517,6 +511,7 @@ sub GetServices { # TODO push @availablefor, 'loan'; } + my $out; $out->{'AvailableFor'} = \@availablefor; return $out; @@ -544,29 +539,28 @@ sub RenewLoan { my $borrowernumber = $cgi->param('patron_id'); my $borrower = GetMemberDetails($borrowernumber, undef); if ( not $borrower->{'borrowernumber'} ) { - $out->{'message'} = "PatronNotFound"; - return $out; + return { message => 'PatronNotFound' }; } # Get the item, or return an error code my $itemnumber = $cgi->param('item_id'); my $item = GetItem($itemnumber, undef, undef); if ( not $item->{'itemnumber'} ) { - $out->{'message'} = "RecordNotFound"; - return $out; + return { message => 'RecordNotFound' }; } # Add renewal if possible my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); - if (@renewal[0]) { AddRenewal( $borrowernumber, $itemnumber ); } + if ($renewal[0]) { AddRenewal( $borrowernumber, $itemnumber ); } my $issue = GetItemIssue($itemnumber); # Hashref building + my $out; $out->{'renewals'} = $issue->{'renewals'}; $out->{'date_due'} = $issue->{'date_due'}; - $out->{'success'} = @renewal[0]; - $out->{'error'} = @renewal[1]; + $out->{'success'} = $renewal[0]; + $out->{'error'} = $renewal[1]; return $out; } @@ -599,24 +593,21 @@ sub HoldTitle { my $borrowernumber = $cgi->param('patron_id'); my $borrower = GetMemberDetails($borrowernumber, undef); if ( not $borrower->{'borrowernumber'} ) { - $out->{'message'} = "PatronNotFound"; - return $out; + return { message => 'PatronNotFound' }; } # Get the biblio record, or return an error code my $biblionumber = $cgi->param('bib_id'); my ($count, $biblio) = GetBiblio($biblionumber); if ( not $biblio->{'biblionumber'} ) { - $out->{'message'} = "RecordNotFound"; - return $out; + return { message => 'RecordNotFound' }; } my $title = $biblio->{'title'}; # Check if the biblio can be reserved my $canbereserved = CanBookBeReserved($borrower, $biblionumber); if ( not $canbereserved ) { - $out->{'message'} = "NotHoldable"; - return $out; + return { message => 'NotHoldable' }; } my $branch; @@ -625,8 +616,7 @@ sub HoldTitle { $branch = $cgi->param('pickup_location'); my $branches = GetBranches(); if ( not $branches->{$branch} ) { - $out->{'message'} = "LocationNotFound"; - return $out; + return { message => 'LocationNotFound' }; } } else { # if user provide no branch, use his own $branch = $borrower->{'branchcode'}; @@ -637,6 +627,7 @@ sub HoldTitle { AddReserve($branch, $borrowernumber, $biblionumber, 'a', undef, 0, undef, $title, undef, undef); # Hashref building + my $out; $out->{'title'} = $title; $out->{'pickup_location'} = GetBranchName($branch); # TODO $out->{'date_available'} = ''; @@ -673,16 +664,14 @@ sub HoldItem { my $borrowernumber = $cgi->param('patron_id'); my $borrower = GetMemberDetails($borrowernumber, undef); if ( not $borrower->{'borrowernumber'} ) { - $out->{'message'} = "PatronNotFound"; - return $out; + return { message => 'PatronNotFound' }; } # Get the biblio or return an error code my $biblionumber = $cgi->param('bib_id'); my ($count, $biblio) = GetBiblio($biblionumber); if ( not $biblio->{'biblionumber'} ) { - $out->{'message'} = "RecordNotFound"; - return $out; + return { message => 'RecordNotFound' }; } my $title = $biblio->{'title'}; @@ -690,22 +679,19 @@ sub HoldItem { my $itemnumber = $cgi->param('item_id'); my $item = GetItem($itemnumber, undef, undef); if ( not $item->{'itemnumber'} ) { - $out->{'message'} = "RecordNotFound"; - return $out; + return { message => 'RecordNotFound' }; } # if the biblio does not match the item, return an error code if ( $item->{'biblionumber'} ne $biblio->{'biblionumber'} ) { - $out->{'message'} = "RecordNotFound"; - return $out; + return { message => 'RecordNotFound' }; } # Check for item disponibility my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber); my $canbookbereserved = CanBookBeReserved($borrower, $biblionumber); if ( (not $canbookbereserved) or not ($canitembereserved) ) { - $out->{'message'} = "NotHoldable"; - return $out; + return { message => 'NotHoldable' }; } my $branch; @@ -714,8 +700,7 @@ sub HoldItem { $branch = $cgi->param('pickup_location'); my $branches = GetBranches(); if ( not $branches->{$branch} ) { - $out->{'message'} = "LocationNotFound"; - return $out; + return { message => 'LocationNotFound' }; } } else { # if user provide no branch, use his own $branch = $borrower->{'branchcode'}; @@ -734,7 +719,7 @@ sub HoldItem { AddReserve($branch, $borrowernumber, $biblionumber, 'a', undef, $rank, undef, $title, $itemnumber, $found); # Hashref building - $out->{'title'} = $title; + my $out; $out->{'pickup_location'} = GetBranchName($branch); # TODO $out->{'date_available'} = ''; @@ -761,16 +746,14 @@ sub CancelHold { my $borrowernumber = $cgi->param('patron_id'); my $borrower = GetMemberDetails($borrowernumber, undef); if ( not $borrower->{'borrowernumber'} ) { - $out->{'message'} = "PatronNotFound"; - return $out; + return { message => 'PatronNotFound' }; } # Get the item or return an error code my $itemnumber = $cgi->param('item_id'); my $item = GetItem($itemnumber, undef, undef); if ( not $item->{'itemnumber'} ) { - $out->{'message'} = "RecordNotFound"; - return $out; + return { message => 'RecordNotFound' }; } # Get borrower's reserves @@ -782,16 +765,14 @@ sub CancelHold { } # if the item was not reserved by the borrower, returns an error code if ( not grep {$itemnumber eq $_} @reserveditems) { - $out->{'message'} = "NotCanceled"; - return $out; + return { message => 'NotCanceled' }; } # Cancel the reserve CancelReserve($itemnumber, undef, $borrowernumber); - $out->{'message'} = "Canceled"; + return { message => 'Canceled' }; - return $out; } 1; diff --git a/C4/ILSDI/Utility.pm b/C4/ILSDI/Utility.pm index 186d94bd40..ab270dfe74 100644 --- a/C4/ILSDI/Utility.pm +++ b/C4/ILSDI/Utility.pm @@ -17,6 +17,9 @@ package C4::ILSDI::Utility; # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA +use strict; +use warnings; + use C4::Members; use C4::Items; use C4::Circulation; diff --git a/opac/ilsdi.pl b/opac/ilsdi.pl index b22bd691c5..50004980ed 100755 --- a/opac/ilsdi.pl +++ b/opac/ilsdi.pl @@ -17,6 +17,9 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA +use strict; +use warnings; + use C4::ILSDI::Services; use C4::Auth; use C4::Output; From f7f783226abd73c3a4bd58b76fcd8b3893e9022d Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 11 Aug 2009 08:36:34 -0400 Subject: [PATCH 8/9] ran ILS-DI code through perltidy Signed-off-by: Galen Charlton --- C4/ILSDI/Services.pm | 806 ++++++++++++++++++++++--------------------- C4/ILSDI/Utility.pm | 149 ++++---- opac/ilsdi.pl | 300 ++++++++-------- 3 files changed, 635 insertions(+), 620 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index f0d86d7131..ffd4792a2f 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -91,59 +91,55 @@ C4::ILS-DI::Services - ILS-DI Services =cut sub GetAvailability { - my ( $cgi ) = @_; - - my $out = "\n"; - $out .= "\n"; + my ($cgi) = @_; - foreach my $id (split(/ /, $cgi->param('id'))) - { - if ($cgi->param('id_type') eq "item") - { - my ($biblionumber, $status, $msg, $location) = Availability($id); + my $out = "\n"; + $out .= "\n"; - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - $out .= " " . $id . "\n"; - $out .= " " . $status . "\n"; - if ($msg) { $out .= " " . $msg . "\n"; } - if ($location) { $out .= " " . $location . "\n"; } - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - } - else - { - my $status; - my $msg; - my $biblioitem = (GetBiblioItemByBiblioNumber($id, undef))[0]; - if ($biblioitem) { - - } else { - $status = "unknown"; - $msg = "Error: could not retrieve availability for this ID"; - } - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - $out .= " " . $id . "\n"; - $out .= " " . $status . "\n"; - $out .= " " . $msg . "\n"; - $out .= " \n"; - $out .= " \n"; - } - } - $out .= "\n"; - - return $out; + foreach my $id ( split( / /, $cgi->param('id') ) ) { + if ( $cgi->param('id_type') eq "item" ) { + my ( $biblionumber, $status, $msg, $location ) = Availability($id); + + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " " . $id . "\n"; + $out .= " " . $status . "\n"; + if ($msg) { $out .= " " . $msg . "\n"; } + if ($location) { $out .= " " . $location . "\n"; } + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + } else { + my $status; + my $msg; + my $biblioitem = ( GetBiblioItemByBiblioNumber( $id, undef ) )[0]; + if ($biblioitem) { + + } else { + $status = "unknown"; + $msg = "Error: could not retrieve availability for this ID"; + } + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " " . $id . "\n"; + $out .= " " . $status . "\n"; + $out .= " " . $msg . "\n"; + $out .= " \n"; + $out .= " \n"; + } + } + $out .= "\n"; + + return $out; } =head2 GetRecords @@ -170,55 +166,58 @@ sub GetAvailability { =cut sub GetRecords { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Check if the schema is supported. For now, GetRecords only supports MARCXML - if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML") { + # Check if the schema is supported. For now, GetRecords only supports MARCXML + if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML" ) { return { message => 'UnsupportedSchema' }; - } + } - my @records; - # Loop over biblionumbers - foreach my $biblionumber (split(/ /, $cgi->param('id'))) - { - # Get the biblioitem from the biblionumber - my $biblioitem = (GetBiblioItemByBiblioNumber($biblionumber, undef))[0]; - if ( not $biblioitem->{'biblionumber'} ) { - $biblioitem = "RecordNotFound"; - } + my @records; - # We don't want MARC to be displayed - delete $biblioitem->{'marc'}; - # nor the XML declaration of MARCXML - $biblioitem->{'marcxml'} =~ s/<\?xml version="1.0" encoding="UTF-8"\?>//go; + # Loop over biblionumbers + foreach my $biblionumber ( split( / /, $cgi->param('id') ) ) { - # Get most of the needed data - my $biblioitemnumber = $biblioitem->{'biblioitemnumber'}; - my @reserves = GetReservesFromBiblionumber($biblionumber, undef, undef); - my $issues = GetBiblioIssues($biblionumber); - my $items = GetItemsByBiblioitemnumber($biblioitemnumber); + # Get the biblioitem from the biblionumber + my $biblioitem = ( GetBiblioItemByBiblioNumber( $biblionumber, undef ) )[0]; + if ( not $biblioitem->{'biblionumber'} ) { + $biblioitem = "RecordNotFound"; + } - # We loop over the items to clean them - foreach my $item (@$items) - { - # This hides additionnal XML subfields, we don't need these info - delete $item->{'more_subfields_xml'}; - # Display branch names instead of branch codes - $item->{'homebranchname'} = GetBranchName($item->{'homebranch'}); - $item->{'holdingbranchname'} = GetBranchName($item->{'holdingbranch'}); - } + # We don't want MARC to be displayed + delete $biblioitem->{'marc'}; - # Hashref building... - $biblioitem->{'items'}->{'item'} = $items; - $biblioitem->{'reserves'}->{'reserve'} = $reserves[1]; - $biblioitem->{'issues'}->{'issue'} = $issues; + # nor the XML declaration of MARCXML + $biblioitem->{'marcxml'} =~ s/<\?xml version="1.0" encoding="UTF-8"\?>//go; - map { $biblioitem->{$_} = encode_entities($biblioitem->{$_},'&') } grep(!/marcxml/, keys %$biblioitem); - - push @records, $biblioitem; - } + # Get most of the needed data + my $biblioitemnumber = $biblioitem->{'biblioitemnumber'}; + my @reserves = GetReservesFromBiblionumber( $biblionumber, undef, undef ); + my $issues = GetBiblioIssues($biblionumber); + my $items = GetItemsByBiblioitemnumber($biblioitemnumber); - return { record => \@records }; + # We loop over the items to clean them + foreach my $item (@$items) { + + # This hides additionnal XML subfields, we don't need these info + delete $item->{'more_subfields_xml'}; + + # Display branch names instead of branch codes + $item->{'homebranchname'} = GetBranchName( $item->{'homebranch'} ); + $item->{'holdingbranchname'} = GetBranchName( $item->{'holdingbranch'} ); + } + + # Hashref building... + $biblioitem->{'items'}->{'item'} = $items; + $biblioitem->{'reserves'}->{'reserve'} = $reserves[1]; + $biblioitem->{'issues'}->{'issue'} = $issues; + + map { $biblioitem->{$_} = encode_entities( $biblioitem->{$_}, '&' ) } grep( !/marcxml/, keys %$biblioitem ); + + push @records, $biblioitem; + } + + return { record => \@records }; } =head2 GetAuthorityRecords @@ -238,24 +237,25 @@ sub GetRecords { =cut sub GetAuthorityRecords { - my ( $cgi ) = @_; + my ($cgi) = @_; - # If the user asks for an unsupported schema, return an error code - if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML") { + # If the user asks for an unsupported schema, return an error code + if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML" ) { return { message => 'UnsupportedSchema' }; - } + } - my $records; - # Let's loop over the authority IDs - foreach my $authid (split(/ /, $cgi->param('id'))) - { - # Get the record as XML string, or error code - my $record= GetAuthorityXML($authid) || "RecordNotFound"; - $record =~ s/<\?xml version="1.0" encoding="UTF-8"\?>//go; - $records .= $record; - } - - return $records; + my $records; + + # Let's loop over the authority IDs + foreach my $authid ( split( / /, $cgi->param('id') ) ) { + + # Get the record as XML string, or error code + my $record = GetAuthorityXML($authid) || "RecordNotFound"; + $record =~ s/<\?xml version="1.0" encoding="UTF-8"\?>//go; + $records .= $record; + } + + return $records; } =head2 LookupPatron @@ -276,19 +276,19 @@ sub GetAuthorityRecords { =cut sub LookupPatron { - my ( $cgi ) = @_; - - # Get the borrower... - my $borrower = GetMember($cgi->param('id'), $cgi->param('id_type')); - if ( not $borrower->{'borrowernumber'} ) { - return { message => 'PatronNotFound' }; - } + my ($cgi) = @_; - # Build the hashref - my $patron->{'id'} = $borrower->{'borrowernumber'}; - - # ...and return his ID - return $patron; + # Get the borrower... + my $borrower = GetMember( $cgi->param('id'), $cgi->param('id_type') ); + if ( not $borrower->{'borrowernumber'} ) { + return { message => 'PatronNotFound' }; + } + + # Build the hashref + my $patron->{'id'} = $borrower->{'borrowernumber'}; + + # ...and return his ID + return $patron; } =head2 AuthenticatePatron @@ -306,21 +306,21 @@ sub LookupPatron { =cut sub AuthenticatePatron { - my ( $cgi ) = @_; - - # Check if borrower exists, using a C4::ILSDI::Utility function... - if ( not (BorrowerExists($cgi->param('username'), $cgi->param('password')))) { - return { message => 'PatronNotFound' }; - } - - # Get the borrower - my $borrower = GetMember($cgi->param('username'), "userid"); - - # Build the hashref - my $patron->{'id'} = $borrower->{'borrowernumber'}; + my ($cgi) = @_; - # ... and return his ID - return $patron; + # Check if borrower exists, using a C4::ILSDI::Utility function... + if ( not( BorrowerExists( $cgi->param('username'), $cgi->param('password') ) ) ) { + return { message => 'PatronNotFound' }; + } + + # Get the borrower + my $borrower = GetMember( $cgi->param('username'), "userid" ); + + # Build the hashref + my $patron->{'id'} = $borrower->{'borrowernumber'}; + + # ... and return his ID + return $patron; } =head2 GetPatronInfo @@ -345,73 +345,79 @@ sub AuthenticatePatron { =cut sub GetPatronInfo { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get Member details - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'}) { + # Get Member details + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails( $borrowernumber, undef ); + if ( not $borrower->{'borrowernumber'} ) { return { message => 'PatronNotFound' }; - } + } - # Cleaning the borrower hashref - $borrower->{'charges'} = $borrower->{'flags'}->{'CHARGES'}->{'amount'}; - $borrower->{'branchname'} = GetBranchName($borrower->{'branchcode'}); - delete $borrower->{'flags'}; - delete $borrower->{'userid'}; - delete $borrower->{'password'}; + # Cleaning the borrower hashref + $borrower->{'charges'} = $borrower->{'flags'}->{'CHARGES'}->{'amount'}; + $borrower->{'branchname'} = GetBranchName( $borrower->{'branchcode'} ); + delete $borrower->{'flags'}; + delete $borrower->{'userid'}; + delete $borrower->{'password'}; - # Contact fields management - if ($cgi->param('show_contact') eq "0") { - # Define contact fields - my @contactfields = ('email', 'emailpro', 'fax', 'mobile', - 'phone', 'phonepro', 'streetnumber', 'zipcode', 'city', - 'streettype', 'B_address', 'B_city', 'B_email', 'B_phone', - 'B_zipcode', 'address', 'address2', 'altcontactaddress1', - 'altcontactaddress2', 'altcontactaddress3', 'altcontactfirstname', - 'altcontactphone', 'altcontactsurname', 'altcontactzipcode'); - # and delete them - foreach my $field (@contactfields) { - delete $borrower->{$field}; - } - } + # Contact fields management + if ( $cgi->param('show_contact') eq "0" ) { - # Fines management - if ($cgi->param('show_fines') eq "1") { - my @charges; - for(my $i = 1; my @charge = getcharges($borrowernumber, undef, $i); $i++) { - push(@charges, @charge); - } - $borrower->{'fines'}->{'fine'} = \@charges; - } + # Define contact fields + my @contactfields = ( + 'email', 'emailpro', 'fax', 'mobile', 'phone', 'phonepro', + 'streetnumber', 'zipcode', 'city', 'streettype', 'B_address', 'B_city', + 'B_email', 'B_phone', 'B_zipcode', 'address', 'address2', 'altcontactaddress1', + 'altcontactaddress2', 'altcontactaddress3', 'altcontactfirstname', 'altcontactphone', 'altcontactsurname', 'altcontactzipcode' + ); - # Reserves management - if ($cgi->param('show_holds') eq "1") { - # Get borrower's reserves - my @reserves = GetReservesFromBorrowernumber($borrowernumber, undef); - foreach my $reserve (@reserves) { - # Get additional informations - my $item = GetBiblioFromItemNumber($reserve->{'itemnumber'}, undef); - my $branchname = GetBranchName($reserve->{'branchcode'}); - # Remove unwanted fields - delete $item->{'marc'}; - delete $item->{'marcxml'}; - delete $item->{'more_subfields_xml'}; - # Add additional fields - $reserve->{'item'} = $item; - $reserve->{'branchname'} = $branchname; - $reserve->{'title'} = (GetBiblio($reserve->{'biblionumber'}))[1]->{'title'}; - } - $borrower->{'holds'}->{'hold'} = \@reserves; - } + # and delete them + foreach my $field (@contactfields) { + delete $borrower->{$field}; + } + } - # Issues management - if ($cgi->param('show_loans') eq "1") { - my $issues = GetPendingIssues($borrowernumber); - $borrower->{'loans'}->{'loan'} = $issues; - } - - return $borrower; + # Fines management + if ( $cgi->param('show_fines') eq "1" ) { + my @charges; + for ( my $i = 1 ; my @charge = getcharges( $borrowernumber, undef, $i ) ; $i++ ) { + push( @charges, @charge ); + } + $borrower->{'fines'}->{'fine'} = \@charges; + } + + # Reserves management + if ( $cgi->param('show_holds') eq "1" ) { + + # Get borrower's reserves + my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); + foreach my $reserve (@reserves) { + + # Get additional informations + my $item = GetBiblioFromItemNumber( $reserve->{'itemnumber'}, undef ); + my $branchname = GetBranchName( $reserve->{'branchcode'} ); + + # Remove unwanted fields + delete $item->{'marc'}; + delete $item->{'marcxml'}; + delete $item->{'more_subfields_xml'}; + + # Add additional fields + $reserve->{'item'} = $item; + $reserve->{'branchname'} = $branchname; + $reserve->{'title'} = ( GetBiblio( $reserve->{'biblionumber'} ) )[1]->{'title'}; + } + $borrower->{'holds'}->{'hold'} = \@reserves; + } + + # Issues management + if ( $cgi->param('show_loans') eq "1" ) { + my $issues = GetPendingIssues($borrowernumber); + $borrower->{'loans'}->{'loan'} = $issues; + } + + return $borrower; } =head2 GetPatronStatus @@ -426,22 +432,22 @@ sub GetPatronInfo { =cut sub GetPatronStatus { - my ( $cgi ) = @_; - - # Get Member details - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { - return { message => 'PatronNotFound' }; - } + my ($cgi) = @_; - # Hashref building + # Get Member details + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails( $borrowernumber, undef ); + if ( not $borrower->{'borrowernumber'} ) { + return { message => 'PatronNotFound' }; + } + + # Hashref building my $patron; - $patron->{'type'} = $borrower->{'categorycode'}; - $patron->{'status'} = 0; #TODO - $patron->{'expiry'} = $borrower->{'dateexpiry'}; - - return $patron; + $patron->{'type'} = $borrower->{'categorycode'}; + $patron->{'status'} = 0; #TODO + $patron->{'expiry'} = $borrower->{'dateexpiry'}; + + return $patron; } =head2 GetServices @@ -458,63 +464,64 @@ sub GetPatronStatus { =cut sub GetServices { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get the member, or return an error code if not found - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + # Get the member, or return an error code if not found + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails( $borrowernumber, undef ); + if ( not $borrower->{'borrowernumber'} ) { return { message => 'PatronNotFound' }; - } + } - # Get the item, or return an error code if not found - my $itemnumber = $cgi->param('item_id'); - my $item = GetItem($itemnumber, undef, undef); - if ( not $item->{'itemnumber'} ) { + # Get the item, or return an error code if not found + my $itemnumber = $cgi->param('item_id'); + my $item = GetItem( $itemnumber, undef, undef ); + if ( not $item->{'itemnumber'} ) { return { message => 'RecordNotFound' }; - } - - my @availablefor; - - # Reserve level management - my $biblionumber = $item->{'biblionumber'}; - my $canbookbereserved = CanBookBeReserved($borrower, $biblionumber); - if ( $canbookbereserved ) { - push @availablefor, 'title level hold'; - my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber); - if ( $canitembereserved ) { - push @availablefor, 'item level hold'; - } - } - - # Reserve cancellation management - my @reserves = GetReservesFromBorrowernumber($borrowernumber, undef); - my @reserveditems; - foreach my $reserve (@reserves) { - push @reserveditems, $reserve->{'itemnumber'}; - } - if ( grep {$itemnumber eq $_} @reserveditems) { - push @availablefor, 'hold cancellation'; - } - - # Renewal management - my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); - if ( $renewal[0] ) { - push @availablefor, 'loan renewal'; - } - - # Issuing management - my $barcode = $item->{'barcode'} || ''; - $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter')); - if ($barcode) { - my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, $barcode ); - # TODO push @availablefor, 'loan'; - } + } + + my @availablefor; + + # Reserve level management + my $biblionumber = $item->{'biblionumber'}; + my $canbookbereserved = CanBookBeReserved( $borrower, $biblionumber ); + if ($canbookbereserved) { + push @availablefor, 'title level hold'; + my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber); + if ($canitembereserved) { + push @availablefor, 'item level hold'; + } + } + + # Reserve cancellation management + my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); + my @reserveditems; + foreach my $reserve (@reserves) { + push @reserveditems, $reserve->{'itemnumber'}; + } + if ( grep { $itemnumber eq $_ } @reserveditems ) { + push @availablefor, 'hold cancellation'; + } + + # Renewal management + my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); + if ( $renewal[0] ) { + push @availablefor, 'loan renewal'; + } + + # Issuing management + my $barcode = $item->{'barcode'} || ''; + $barcode = barcodedecode($barcode) if ( $barcode && C4::Context->preference('itemBarcodeInputFilter') ); + if ($barcode) { + my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, $barcode ); + + # TODO push @availablefor, 'loan'; + } my $out; - $out->{'AvailableFor'} = \@availablefor; - - return $out; + $out->{'AvailableFor'} = \@availablefor; + + return $out; } =head2 RenewLoan @@ -533,36 +540,36 @@ sub GetServices { =cut sub RenewLoan { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get borrower infos or return an error code - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + # Get borrower infos or return an error code + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails( $borrowernumber, undef ); + if ( not $borrower->{'borrowernumber'} ) { return { message => 'PatronNotFound' }; - } + } - # Get the item, or return an error code - my $itemnumber = $cgi->param('item_id'); - my $item = GetItem($itemnumber, undef, undef); - if ( not $item->{'itemnumber'} ) { + # Get the item, or return an error code + my $itemnumber = $cgi->param('item_id'); + my $item = GetItem( $itemnumber, undef, undef ); + if ( not $item->{'itemnumber'} ) { return { message => 'RecordNotFound' }; - } + } - # Add renewal if possible - my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); - if ($renewal[0]) { AddRenewal( $borrowernumber, $itemnumber ); } + # Add renewal if possible + my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); + if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); } - my $issue = GetItemIssue($itemnumber); + my $issue = GetItemIssue($itemnumber); - # Hashref building + # Hashref building my $out; - $out->{'renewals'} = $issue->{'renewals'}; - $out->{'date_due'} = $issue->{'date_due'}; - $out->{'success'} = $renewal[0]; - $out->{'error'} = $renewal[1]; - - return $out; + $out->{'renewals'} = $issue->{'renewals'}; + $out->{'date_due'} = $issue->{'date_due'}; + $out->{'success'} = $renewal[0]; + $out->{'error'} = $renewal[1]; + + return $out; } =head2 HoldTitle @@ -587,52 +594,54 @@ sub RenewLoan { =cut sub HoldTitle { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get the borrower or return an error code - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + # Get the borrower or return an error code + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails( $borrowernumber, undef ); + if ( not $borrower->{'borrowernumber'} ) { return { message => 'PatronNotFound' }; - } - - # Get the biblio record, or return an error code - my $biblionumber = $cgi->param('bib_id'); - my ($count, $biblio) = GetBiblio($biblionumber); - if ( not $biblio->{'biblionumber'} ) { + } + + # Get the biblio record, or return an error code + my $biblionumber = $cgi->param('bib_id'); + my ( $count, $biblio ) = GetBiblio($biblionumber); + if ( not $biblio->{'biblionumber'} ) { return { message => 'RecordNotFound' }; - } - my $title = $biblio->{'title'}; - - # Check if the biblio can be reserved - my $canbereserved = CanBookBeReserved($borrower, $biblionumber); - if ( not $canbereserved ) { + } + my $title = $biblio->{'title'}; + + # Check if the biblio can be reserved + my $canbereserved = CanBookBeReserved( $borrower, $biblionumber ); + if ( not $canbereserved ) { return { message => 'NotHoldable' }; - } + } - my $branch; - # Pickup branch management - if ($cgi->param('pickup_location')) { - $branch = $cgi->param('pickup_location'); - my $branches = GetBranches(); - if ( not $branches->{$branch} ) { + my $branch; + + # Pickup branch management + if ( $cgi->param('pickup_location') ) { + $branch = $cgi->param('pickup_location'); + my $branches = GetBranches(); + if ( not $branches->{$branch} ) { return { message => 'LocationNotFound' }; - } - } else { # if user provide no branch, use his own - $branch = $borrower->{'branchcode'}; - } + } + } else { # if user provide no branch, use his own + $branch = $borrower->{'branchcode'}; + } - # Add the reserve - # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found - AddReserve($branch, $borrowernumber, $biblionumber, 'a', undef, 0, undef, $title, undef, undef); + # Add the reserve + # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found + AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, 0, undef, $title, undef, undef ); - # Hashref building + # Hashref building my $out; - $out->{'title'} = $title; - $out->{'pickup_location'} = GetBranchName($branch); - # TODO $out->{'date_available'} = ''; + $out->{'title'} = $title; + $out->{'pickup_location'} = GetBranchName($branch); - return $out; + # TODO $out->{'date_available'} = ''; + + return $out; } =head2 HoldItem @@ -658,72 +667,75 @@ sub HoldTitle { =cut sub HoldItem { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get the borrower or return an error code - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + # Get the borrower or return an error code + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails( $borrowernumber, undef ); + if ( not $borrower->{'borrowernumber'} ) { return { message => 'PatronNotFound' }; - } - - # Get the biblio or return an error code - my $biblionumber = $cgi->param('bib_id'); - my ($count, $biblio) = GetBiblio($biblionumber); - if ( not $biblio->{'biblionumber'} ) { - return { message => 'RecordNotFound' }; - } - my $title = $biblio->{'title'}; + } - # Get the item or return an error code - my $itemnumber = $cgi->param('item_id'); - my $item = GetItem($itemnumber, undef, undef); - if ( not $item->{'itemnumber'} ) { + # Get the biblio or return an error code + my $biblionumber = $cgi->param('bib_id'); + my ( $count, $biblio ) = GetBiblio($biblionumber); + if ( not $biblio->{'biblionumber'} ) { return { message => 'RecordNotFound' }; - } - - # if the biblio does not match the item, return an error code - if ( $item->{'biblionumber'} ne $biblio->{'biblionumber'} ) { + } + my $title = $biblio->{'title'}; + + # Get the item or return an error code + my $itemnumber = $cgi->param('item_id'); + my $item = GetItem( $itemnumber, undef, undef ); + if ( not $item->{'itemnumber'} ) { return { message => 'RecordNotFound' }; - } - - # Check for item disponibility - my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber); - my $canbookbereserved = CanBookBeReserved($borrower, $biblionumber); - if ( (not $canbookbereserved) or not ($canitembereserved) ) { + } + + # if the biblio does not match the item, return an error code + if ( $item->{'biblionumber'} ne $biblio->{'biblionumber'} ) { + return { message => 'RecordNotFound' }; + } + + # Check for item disponibility + my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber); + my $canbookbereserved = CanBookBeReserved( $borrower, $biblionumber ); + if ( ( not $canbookbereserved ) or not($canitembereserved) ) { return { message => 'NotHoldable' }; - } - - my $branch; - # Pickup branch management - if ($cgi->param('pickup_location')) { - $branch = $cgi->param('pickup_location'); - my $branches = GetBranches(); - if ( not $branches->{$branch} ) { + } + + my $branch; + + # Pickup branch management + if ( $cgi->param('pickup_location') ) { + $branch = $cgi->param('pickup_location'); + my $branches = GetBranches(); + if ( not $branches->{$branch} ) { return { message => 'LocationNotFound' }; - } - } else { # if user provide no branch, use his own - $branch = $borrower->{'branchcode'}; - } - - my $rank; - my $found; - # Get rank and found - $rank = '0' unless C4::Context->preference('ReservesNeedReturns'); - if ( $item->{'holdingbranch'} eq $branch ){ - $found = 'W' unless C4::Context->preference('ReservesNeedReturns'); - } + } + } else { # if user provide no branch, use his own + $branch = $borrower->{'branchcode'}; + } - # Add the reserve - # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found - AddReserve($branch, $borrowernumber, $biblionumber, 'a', undef, $rank, undef, $title, $itemnumber, $found); + my $rank; + my $found; - # Hashref building + # Get rank and found + $rank = '0' unless C4::Context->preference('ReservesNeedReturns'); + if ( $item->{'holdingbranch'} eq $branch ) { + $found = 'W' unless C4::Context->preference('ReservesNeedReturns'); + } + + # Add the reserve + # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found + AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $rank, undef, $title, $itemnumber, $found ); + + # Hashref building my $out; - $out->{'pickup_location'} = GetBranchName($branch); - # TODO $out->{'date_available'} = ''; + $out->{'pickup_location'} = GetBranchName($branch); - return $out; + # TODO $out->{'date_available'} = ''; + + return $out; } =head2 CancelHold @@ -740,39 +752,41 @@ sub HoldItem { =cut sub CancelHold { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get the borrower or return an error code - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + # Get the borrower or return an error code + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails( $borrowernumber, undef ); + if ( not $borrower->{'borrowernumber'} ) { return { message => 'PatronNotFound' }; - } + } - # Get the item or return an error code - my $itemnumber = $cgi->param('item_id'); - my $item = GetItem($itemnumber, undef, undef); - if ( not $item->{'itemnumber'} ) { + # Get the item or return an error code + my $itemnumber = $cgi->param('item_id'); + my $item = GetItem( $itemnumber, undef, undef ); + if ( not $item->{'itemnumber'} ) { return { message => 'RecordNotFound' }; - } - - # Get borrower's reserves - my @reserves = GetReservesFromBorrowernumber($borrowernumber, undef); - my @reserveditems; - # ...and loop over it to build an array of reserved itemnumbers - foreach my $reserve (@reserves) { - push @reserveditems, $reserve->{'itemnumber'}; - } - # if the item was not reserved by the borrower, returns an error code - if ( not grep {$itemnumber eq $_} @reserveditems) { - return { message => 'NotCanceled' }; - } + } - # Cancel the reserve - CancelReserve($itemnumber, undef, $borrowernumber); + # Get borrower's reserves + my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); + my @reserveditems; + + # ...and loop over it to build an array of reserved itemnumbers + foreach my $reserve (@reserves) { + push @reserveditems, $reserve->{'itemnumber'}; + } + + # if the item was not reserved by the borrower, returns an error code + if ( not grep { $itemnumber eq $_ } @reserveditems ) { + return { message => 'NotCanceled' }; + } + + # Cancel the reserve + CancelReserve( $itemnumber, undef, $borrowernumber ); return { message => 'Canceled' }; - + } 1; diff --git a/C4/ILSDI/Utility.pm b/C4/ILSDI/Utility.pm index ab270dfe74..77886ca118 100644 --- a/C4/ILSDI/Utility.pm +++ b/C4/ILSDI/Utility.pm @@ -32,13 +32,14 @@ use Digest::MD5 qw(md5_base64); use vars qw($VERSION @ISA @EXPORT); BEGIN { - # set the version for version checking - $VERSION = 3.00; - require Exporter; - @ISA = qw(Exporter); - @EXPORT = qw( - &BorrowerExists &CanBookBeReserved &Availability - ); + + # set the version for version checking + $VERSION = 3.00; + require Exporter; + @ISA = qw(Exporter); + @EXPORT = qw( + &BorrowerExists &CanBookBeReserved &Availability + ); } =head1 NAME @@ -58,13 +59,12 @@ Checks, for a given userid and password, if the borrower exists. =cut sub BorrowerExists { - my ( $userid, $password ) = @_; - $password = md5_base64($password); - my $dbh = C4::Context->dbh; - my $sth = - $dbh->prepare("SELECT COUNT(*) FROM borrowers WHERE userid =? and password=? "); - $sth->execute( $userid, $password ); - return $sth->fetchrow; + my ( $userid, $password ) = @_; + $password = md5_base64($password); + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT COUNT(*) FROM borrowers WHERE userid =? and password=? "); + $sth->execute( $userid, $password ); + return $sth->fetchrow; } =head2 CanBookBeReserved @@ -78,42 +78,42 @@ Checks if a book (at bibliographic level) can be reserved by a borrower. =cut sub CanBookBeReserved { - my ( $borrower, $biblionumber ) = @_; + my ( $borrower, $biblionumber ) = @_; - my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves"); - my $MAXOUTSTANDING = C4::Context->preference("maxoutstanding"); + my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves"); + my $MAXOUTSTANDING = C4::Context->preference("maxoutstanding"); - my $out = 1; + my $out = 1; - if ( $borrower->{'amountoutstanding'} > $MAXOUTSTANDING ) { - $out = undef; - } - if ( $borrower->{gonenoaddress} eq 1 ) { - $out = undef; - } - if ( $borrower->{lost} eq 1 ) { - $out = undef; - } - if ( $borrower->{debarred} eq 1 ) { - $out = undef; - } - my @reserves = GetReservesFromBorrowernumber( $borrower->{'borrowernumber'} ); - if ( scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) { - $out = undef; - } - foreach my $res (@reserves) { - if ( $res->{'biblionumber'} == $biblionumber ) { - $out = undef; - } - } - my $issues = GetPendingIssues($borrower->{'borrowernumber'}); - foreach my $issue (@$issues) { - if ( $issue->{'biblionumber'} == $biblionumber ) { - $out = undef; - } - } - - return $out; + if ( $borrower->{'amountoutstanding'} > $MAXOUTSTANDING ) { + $out = undef; + } + if ( $borrower->{gonenoaddress} eq 1 ) { + $out = undef; + } + if ( $borrower->{lost} eq 1 ) { + $out = undef; + } + if ( $borrower->{debarred} eq 1 ) { + $out = undef; + } + my @reserves = GetReservesFromBorrowernumber( $borrower->{'borrowernumber'} ); + if ( scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) { + $out = undef; + } + foreach my $res (@reserves) { + if ( $res->{'biblionumber'} == $biblionumber ) { + $out = undef; + } + } + my $issues = GetPendingIssues( $borrower->{'borrowernumber'} ); + foreach my $issue (@$issues) { + if ( $issue->{'biblionumber'} == $biblionumber ) { + $out = undef; + } + } + + return $out; } =head2 Availability @@ -125,36 +125,31 @@ Returns, for an itemnumber, an array containing availability information. =cut sub Availability { - my ( $itemnumber ) = @_; - my $item = GetItem($itemnumber, undef, undef); - - if ( not $item->{'itemnumber'} ) { - return (undef, 'unknown', 'Error: could not retrieve availability for this ID', undef); - } - - my $biblionumber = $item->{'biblioitemnumber'}; - my $location = GetBranchName($item->{'holdingbranch'}); - - if ($item->{'notforloan'}) { - return ($biblionumber, 'not available', 'Not for loan', $location); - } - elsif ($item->{'onloan'}) { - return ($biblionumber, 'not available', 'Checked out', $location); - } - elsif ($item->{'itemlost'}) { - return ($biblionumber, 'not available', 'Item lost', $location); - } - elsif ($item->{'wthdrawn'}) { - return ($biblionumber, 'not available', 'Item withdrawn', $location); - } - elsif ($item->{'damaged'}) { - return ($biblionumber, 'not available', 'Item damaged', $location); - } - else { - return ($biblionumber, 'available', undef, $location); - } - - die Data::Dumper::Dumper($item); + my ($itemnumber) = @_; + my $item = GetItem( $itemnumber, undef, undef ); + + if ( not $item->{'itemnumber'} ) { + return ( undef, 'unknown', 'Error: could not retrieve availability for this ID', undef ); + } + + my $biblionumber = $item->{'biblioitemnumber'}; + my $location = GetBranchName( $item->{'holdingbranch'} ); + + if ( $item->{'notforloan'} ) { + return ( $biblionumber, 'not available', 'Not for loan', $location ); + } elsif ( $item->{'onloan'} ) { + return ( $biblionumber, 'not available', 'Checked out', $location ); + } elsif ( $item->{'itemlost'} ) { + return ( $biblionumber, 'not available', 'Item lost', $location ); + } elsif ( $item->{'wthdrawn'} ) { + return ( $biblionumber, 'not available', 'Item withdrawn', $location ); + } elsif ( $item->{'damaged'} ) { + return ( $biblionumber, 'not available', 'Item damaged', $location ); + } else { + return ( $biblionumber, 'available', undef, $location ); + } + + die Data::Dumper::Dumper($item); } 1; diff --git a/opac/ilsdi.pl b/opac/ilsdi.pl index 50004980ed..18f424d30f 100755 --- a/opac/ilsdi.pl +++ b/opac/ilsdi.pl @@ -41,106 +41,109 @@ my $cgi = new CGI; # List of available services, sorted by level my @services = ( - 'Describe', # Not part of ILS-DI, online API doc -# Level 1: Basic Discovery Interfaces -# 'HarvestBibliographicRecords', # OAI-PMH -# 'HarvestExpandedRecords', # OAI-PMH - 'GetAvailability', # FIXME Add bibbliographic level -# 'GoToBibliographicRequestPage' # I don't understant this one -# Level 2: Elementary OPAC supplement -# 'HarvestAuthorityRecords', # OAI-PMH -# 'HarvestHoldingsRecords', # OAI-PMH - 'GetRecords', # Note that we can use OAI-PMH for this too -# 'Search', # TODO -# 'Scan', # TODO - 'GetAuthorityRecords', -# 'OutputRewritablePage', # I don't understant this one -# 'OutputIntermediateFormat', # I don't understant this one -# Level 3: Elementary OPAC alternative - 'LookupPatron', - 'AuthenticatePatron', - 'GetPatronInfo', - 'GetPatronStatus', - 'GetServices', # FIXME Loans - 'RenewLoan', - 'HoldTitle', # FIXME Add dates support - 'HoldItem', # FIXME Add dates support - 'CancelHold', -# 'RecallItem', # Not supported by Koha -# 'CancelRecall', # Not supported by Koha -# Level 4: Robust/domain specific discovery platforms -# 'SearchCourseReserves', # TODO -# 'Explain' # TODO + 'Describe', # Not part of ILS-DI, online API doc + + # Level 1: Basic Discovery Interfaces + # 'HarvestBibliographicRecords', # OAI-PMH + # 'HarvestExpandedRecords', # OAI-PMH + 'GetAvailability', # FIXME Add bibbliographic level + + # 'GoToBibliographicRequestPage' # I don't understant this one + # Level 2: Elementary OPAC supplement + # 'HarvestAuthorityRecords', # OAI-PMH + # 'HarvestHoldingsRecords', # OAI-PMH + 'GetRecords', # Note that we can use OAI-PMH for this too + + # 'Search', # TODO + # 'Scan', # TODO + 'GetAuthorityRecords', + + # 'OutputRewritablePage', # I don't understant this one + # 'OutputIntermediateFormat', # I don't understant this one + # Level 3: Elementary OPAC alternative + 'LookupPatron', + 'AuthenticatePatron', + 'GetPatronInfo', + 'GetPatronStatus', + 'GetServices', # FIXME Loans + 'RenewLoan', + 'HoldTitle', # FIXME Add dates support + 'HoldItem', # FIXME Add dates support + 'CancelHold', + + # 'RecallItem', # Not supported by Koha + # 'CancelRecall', # Not supported by Koha + # Level 4: Robust/domain specific discovery platforms + # 'SearchCourseReserves', # TODO + # 'Explain' # TODO ); # List of required arguments my %required = ( - 'Describe' => ['verb'], - 'GetAvailability' => ['id', 'id_type'], - 'GetRecords' => ['id'], - 'GetAuthorityRecords' => ['id'], - 'LookupPatron' => ['id'], - 'AuthenticatePatron' => ['username', 'password'], - 'GetPatronInfo' => ['patron_id'], - 'GetPatronStatus' => ['patron_id'], - 'GetServices' => ['patron_id', 'item_id'], - 'RenewLoan' => ['patron_id', 'item_id'], - 'HoldTitle' => ['patron_id', 'bib_id', 'request_location'], - 'HoldItem' => ['patron_id', 'bib_id', 'item_id'], - 'CancelHold' => ['patron_id', 'item_id'], + 'Describe' => ['verb'], + 'GetAvailability' => [ 'id', 'id_type' ], + 'GetRecords' => ['id'], + 'GetAuthorityRecords' => ['id'], + 'LookupPatron' => ['id'], + 'AuthenticatePatron' => [ 'username', 'password' ], + 'GetPatronInfo' => ['patron_id'], + 'GetPatronStatus' => ['patron_id'], + 'GetServices' => [ 'patron_id', 'item_id' ], + 'RenewLoan' => [ 'patron_id', 'item_id' ], + 'HoldTitle' => [ 'patron_id', 'bib_id', 'request_location' ], + 'HoldItem' => [ 'patron_id', 'bib_id', 'item_id' ], + 'CancelHold' => [ 'patron_id', 'item_id' ], ); # List of optional arguments my %optional = ( - 'Describe' => [], - 'GetAvailability' => ['return_type', 'return_fmt'], - 'GetRecords' => ['schema'], - 'GetAuthorityRecords' => ['schema'], - 'LookupPatron' => ['id_type'], - 'AuthenticatePatron' => [], - 'GetPatronInfo' => ['show_contact', 'show_fines', 'show_holds', 'show_loans'], - 'GetPatronStatus' => [], - 'GetServices' => [], - 'RenewLoan' => ['desired_due_date'], - 'HoldTitle' => ['pickup_location', 'needed_before_date', 'pickup_expiry_date'], - 'HoldItem' => ['pickup_location', 'needed_before_date', 'pickup_expiry_date'], - 'CancelHold' => [], + 'Describe' => [], + 'GetAvailability' => [ 'return_type', 'return_fmt' ], + 'GetRecords' => ['schema'], + 'GetAuthorityRecords' => ['schema'], + 'LookupPatron' => ['id_type'], + 'AuthenticatePatron' => [], + 'GetPatronInfo' => [ 'show_contact', 'show_fines', 'show_holds', 'show_loans' ], + 'GetPatronStatus' => [], + 'GetServices' => [], + 'RenewLoan' => ['desired_due_date'], + 'HoldTitle' => [ 'pickup_location', 'needed_before_date', 'pickup_expiry_date' ], + 'HoldItem' => [ 'pickup_location', 'needed_before_date', 'pickup_expiry_date' ], + 'CancelHold' => [], ); # If ILS-DI module is disabled in System->Preferences, redirect to 404 -if (not C4::Context->preference('ILS-DI')) { - print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); +if ( not C4::Context->preference('ILS-DI') ) { + print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); } # If no service is requested, display the online documentation -if (not $cgi->param('service')) { - my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "ilsdi.tmpl", - query => $cgi, - type => "opac", - authnotrequired => 1, - debug => 1, - } - ); - output_html_with_http_headers $cgi, $cookie, $template->output; - exit 0; +if ( not $cgi->param('service') ) { + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "ilsdi.tmpl", + query => $cgi, + type => "opac", + authnotrequired => 1, + debug => 1, + } + ); + output_html_with_http_headers $cgi, $cookie, $template->output; + exit 0; } # If user requested a service description, then display it -if ($cgi->param('service') eq "Describe" and grep {$cgi->param('verb') eq $_} @services) { - my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "ilsdi.tmpl", - query => $cgi, - type => "opac", - authnotrequired => 1, - debug => 1, - } - ); - $template->param( $cgi->param('verb') => 1 ); - output_html_with_http_headers $cgi, $cookie, $template->output; - exit 0; +if ( $cgi->param('service') eq "Describe" and grep { $cgi->param('verb') eq $_ } @services ) { + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "ilsdi.tmpl", + query => $cgi, + type => "opac", + authnotrequired => 1, + debug => 1, + } + ); + $template->param( $cgi->param('verb') => 1 ); + output_html_with_http_headers $cgi, $cookie, $template->output; + exit 0; } my $service = $cgi->param('service') || "ilsdi"; @@ -148,75 +151,78 @@ my $service = $cgi->param('service') || "ilsdi"; my $out; # Check if the requested service is in the list -if ($service and grep {$service eq $_} @services) { +if ( $service and grep { $service eq $_ } @services ) { - my @parmsrequired = @{$required{$service}}; - my @parmsoptional = @{$optional{$service}}; - my @parmsall = (@parmsrequired, @parmsoptional); - my @names = $cgi->param; - my %paramhash = (); - foreach my $name (@names) { - $paramhash{$name} = 1; - } + my @parmsrequired = @{ $required{$service} }; + my @parmsoptional = @{ $optional{$service} }; + my @parmsall = ( @parmsrequired, @parmsoptional ); + my @names = $cgi->param; + my %paramhash = (); + foreach my $name (@names) { + $paramhash{$name} = 1; + } - # check for missing parameters - foreach my $name (@parmsrequired) { - if ((! exists $paramhash{$name})) { - $out->{'message'} = "missing $name parameter"; - } - } - - # check for illegal parameters - foreach my $name (@names) { - my $found = 0; - foreach my $name2 (@parmsall) { - if ($name eq $name2) { - $found = 1; - } - } - if (($found == 0) && ($name ne 'service')) { - $out->{'message'} = "$name is an illegal parameter"; - } - } - - # check for multiple parameters - foreach my $name (@names) { - my @values = $cgi->param($name); - if ($#values != 0) { - $out->{'message'} = "multiple values are not allowed for the $name parameter"; - } - } + # check for missing parameters + foreach my $name (@parmsrequired) { + if ( ( !exists $paramhash{$name} ) ) { + $out->{'message'} = "missing $name parameter"; + } + } - if (! $out->{'message'}) { - # GetAvailability is a special case, as it cannot use XML::Simple - if ($service eq "GetAvailability") { - print CGI::header('text/xml'); - print C4::ILSDI::Services::GetAvailability($cgi); - exit 0; - } - else { - # Variable functions - my $sub = do{ - no strict 'refs'; - my $symbol = 'C4::ILSDI::Services::'.$service; - \&{"$symbol"}; - }; - # Call the requested service, and get its return value - $out = &$sub($cgi); - } - } -} -else { - $out->{'message'} = "NotSupported"; + # check for illegal parameters + foreach my $name (@names) { + my $found = 0; + foreach my $name2 (@parmsall) { + if ( $name eq $name2 ) { + $found = 1; + } + } + if ( ( $found == 0 ) && ( $name ne 'service' ) ) { + $out->{'message'} = "$name is an illegal parameter"; + } + } + + # check for multiple parameters + foreach my $name (@names) { + my @values = $cgi->param($name); + if ( $#values != 0 ) { + $out->{'message'} = "multiple values are not allowed for the $name parameter"; + } + } + + if ( !$out->{'message'} ) { + + # GetAvailability is a special case, as it cannot use XML::Simple + if ( $service eq "GetAvailability" ) { + print CGI::header('text/xml'); + print C4::ILSDI::Services::GetAvailability($cgi); + exit 0; + } else { + + # Variable functions + my $sub = do { + no strict 'refs'; + my $symbol = 'C4::ILSDI::Services::' . $service; + \&{"$symbol"}; + }; + + # Call the requested service, and get its return value + $out = &$sub($cgi); + } + } +} else { + $out->{'message'} = "NotSupported"; } # Output XML by passing the hashref to XMLOut print CGI::header('text/xml'); -print XMLout($out, - noattr => 1, - noescape => 1, - nosort => 1, - xmldecl => '', - RootName => $service, - SuppressEmpty => 1); +print XMLout( + $out, + noattr => 1, + noescape => 1, + nosort => 1, + xmldecl => '', + RootName => $service, + SuppressEmpty => 1 +); From c46187eb743d518dbb583d4c193346692084c4fb Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 23 Sep 2009 17:59:04 +0200 Subject: [PATCH 9/9] Adding one template file missing Signed-off-by: Galen Charlton --- .../opac-tmpl/prog/en/modules/ilsdi.tmpl | 738 ++++++++++++++++++ 1 file changed, 738 insertions(+) create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/ilsdi.tmpl diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/ilsdi.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/ilsdi.tmpl new file mode 100644 index 0000000000..d57f016f82 --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/modules/ilsdi.tmpl @@ -0,0 +1,738 @@ + Catalog › ISBD + + + +
17"> +
+ + +
+
+

ILS-DI

+ + + +

GetAvailability

+

Given a set of bibliographic or item identifiers, returns a + list with availability of the items associated with the identifiers.

+

Parameters

+
+
id (Required)
+
list of either bibliographic or item identifiers
+
id_type (Required)
+
defines the type of record identifier being used in the request, possible values: +
    +
  • bib
  • +
  • item
  • +
+
+
return_type (Optional)
+
requests a particular level of detail in reporting availability, possible values: +
    +
  • bib
  • +
  • item
  • +
+
+
return_fmt (Optional)
+
requests a particular format or set of formats in reporting availability
+
+

Example Call

+ + ilsdi.pl?service=GetAvailability&id=1+2+99999&id_type=item + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<dlf:collection
+  xmlns:dlf="http://diglib.org/ilsdi/1.1"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://diglib.org/ilsdi/1.1
+    http://diglib.org/architectures/ilsdi/schemas/1.1/dlfexpanded.xsd">
+  <dlf:record>
+    <dlf:bibliographic id="1" />
+    <dlf:items>
+      <dlf:item id="1">
+        <dlf:simpleavailability>
+          <dlf:identifier>1</dlf:identifier>
+          <dlf:availabilitystatus>available</dlf:availabilitystatus>
+          <dlf:location>Bibliothèque Jean Prunier</dlf:location>
+        </dlf:simpleavailability>
+      </dlf:item>
+    </dlf:items>
+  </dlf:record>
+  <dlf:record>
+    <dlf:bibliographic id="2" />
+    <dlf:items>
+      <dlf:item id="2">
+        <dlf:simpleavailability>
+          <dlf:identifier>2</dlf:identifier>
+          <dlf:availabilitystatus>available</dlf:availabilitystatus>
+          <dlf:location>Bibliothèque Jean Prunier</dlf:location>
+        </dlf:simpleavailability>
+      </dlf:item>
+    </dlf:items>
+  </dlf:record>
+  <dlf:record>
+    <dlf:bibliographic id="99999" />
+    <dlf:items>
+      <dlf:item id="99999">
+        <dlf:simpleavailability>
+          <dlf:identifier>99999</dlf:identifier>
+
+          <dlf:availabilitystatus>unknown</dlf:availabilitystatus>
+          <dlf:availabilitymsg>Error: could not retrieve availability for this ID</dlf:availabilitymsg>
+        </dlf:simpleavailability>
+      </dlf:item>
+    </dlf:items>
+  </dlf:record>
+</dlf:collection>
+ + + +

GetRecords

+

Given a list of record identifiers, returns a list of record + objects that contain bibliographic information, as well as + associated holdings and item information. The caller may request + a specific metadata schema for the record objects to be returned. + This function behaves similarly to HarvestBibliographicRecords and + HarvestExpandedRecords in Data Aggregation, but allows quick, real + time lookup by bibliographic identifier.

+

You can use OAI-PMH ListRecords instead of this service.

+

Parameters

+
+
id (Required)
+
list of system record identifiers
+
id_type (Optional)
+
Defines the metadata schema in which the records are + returned, possible values: +
    +
  • MARCXML
  • +
+
+
+

Example Call

+ + ilsdi.pl?service=GetRecords&id=1+2+99999 + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<GetRecords>
+  <record>
+    <biblioitemnumber>1</biblioitemnumber>
+    <isbn>9782862749198</isbn>
+    <marcxml>
+      <record
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/ standards/marcxml/schema/MARC21slim.xsd"
+          xmlns="http://www.loc.gov/MARC21/slim">
+        <leader>00397nac a22001451u 4500</leader>
+        <datafield tag="010" ind1=" " ind2=" ">
+          <subfield code="a">9782862749198</subfield>
+        </datafield>
+        <datafield tag="090" ind1=" " ind2=" ">
+          <subfield code="a">1</subfield>
+        </datafield>
+        <datafield tag="101" ind1=" " ind2=" ">
+          <subfield code="a">fre</subfield>
+        </datafield>
+        <datafield tag="100" ind1=" " ind2=" ">
+          <subfield code="a">20080725              frey50       </subfield>
+        </datafield>
+        <datafield tag="200" ind1=" " ind2=" ">
+          <subfield code="a">Jardins d'enfance</subfield>
+          <subfield code="b">LITT</subfield>
+          <subfield code="f">Abécassis, Eliette</subfield>
+        </datafield>
+        <datafield tag="210" ind1=" " ind2=" ">
+          <subfield code="c">cherche midi éditeur</subfield>
+          <subfield code="d">11/2001</subfield>
+        </datafield>
+        <datafield tag="215" ind1=" " ind2=" ">
+          <subfield code="a">180</subfield>
+        </datafield>
+        <datafield tag="225" ind1=" " ind2=" ">
+          <subfield code="a">nouvelles</subfield>
+        </datafield>
+        <datafield tag="995" ind1=" " ind2=" ">
+          <subfield code="9">1</subfield>
+          <subfield code="c">BIB</subfield>
+          <subfield code="2">0</subfield>
+          <subfield code="k">R ABE</subfield>
+          <subfield code="o">0</subfield>
+          <subfield code="e">Secteur Adulte</subfield>
+          <subfield code="b">BIB</subfield>
+          <subfield code="j">7786000200</subfield>
+          <subfield code="q">a</subfield>
+          <subfield code="r">2</subfield>
+          <subfield code="s">Achats</subfield>
+        </datafield>
+        <controlfield tag="001">1</controlfield>
+      </record>
+    </marcxml>
+    <publicationyear>2001</publicationyear>
+    <collectiontitle>nouvelles</collectiontitle>
+    <pages>180</pages>
+    <issues>
+    </issues>
+    <itemtype>LITT</itemtype>
+    <biblionumber>1</biblionumber>
+    <timestamp>2008-09-03 18:43:19</timestamp>
+    <cn_sort>_</cn_sort>
+    <publishercode>cherche midi éditeur</publishercode>
+    <reserves>
+    </reserves>
+    <items>
+      <item>
+        <biblioitemnumber>1</biblioitemnumber>
+        <wthdrawn>0</wthdrawn>
+        <holdingbranchname>Bibliothèque Jean Prunier</holdingbranchname>
+        <notforloan>0</notforloan>
+        <replacementpricedate>2008-08-20</replacementpricedate>
+        <itemnumber>1</itemnumber>
+        <location>Secteur Adulte</location>
+        <itemcallnumber>R ABE</itemcallnumber>
+        <date_due></date_due>
+        <itemlost>0</itemlost>
+        <datelastseen>2008-08-20</datelastseen>
+        <homebranch>BIB</homebranch>
+        <homebranchname>Bibliothèque Jean Prunier</homebranchname>
+        <biblionumber>1</biblionumber>
+        <holdingbranch>BIB</holdingbranch>
+        <timestamp>2008-08-20 17:15:51</timestamp>
+        <damaged>0</damaged>
+        <cn_sort>R_ABE</cn_sort>
+        <dateaccessioned>2008-08-20</dateaccessioned>
+      </item>
+    </items>
+  </record>
+  <record>
+    <biblioitemnumber>2</biblioitemnumber>
+    <isbn>9782265078031</isbn>
+    <marcxml>
+      <record
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/ standards/marcxml/schema/MARC21slim.xsd"
+          xmlns="http://www.loc.gov/MARC21/slim">
+        <leader>00407nac a22001451u 4500</leader>
+        <datafield tag="010" ind1=" " ind2=" ">
+          <subfield code="a">9782265078031</subfield>
+        </datafield>
+        <datafield tag="090" ind1=" " ind2=" ">
+          <subfield code="a">2</subfield>
+        </datafield>
+        <datafield tag="101" ind1=" " ind2=" ">
+          <subfield code="a">fre</subfield>
+        </datafield>
+        <datafield tag="100" ind1=" " ind2=" ">
+          <subfield code="a">20080725              frey50       </subfield>
+        </datafield>
+        <datafield tag="200" ind1=" " ind2=" ">
+          <subfield code="a">(Les) tribulations d'une jeune divorcée</subfield>
+          <subfield code="b">LITT</subfield>
+          <subfield code="f">Abécassis, Eliette</subfield>
+        </datafield>
+        <datafield tag="210" ind1=" " ind2=" ">
+          <subfield code="c">bussière</subfield>
+          <subfield code="d">01/2005</subfield>
+        </datafield>
+        <datafield tag="215" ind1=" " ind2=" ">
+          <subfield code="a">306</subfield>
+        </datafield>
+        <datafield tag="225" ind1=" " ind2=" ">
+          <subfield code="a">fleuve noir</subfield>
+        </datafield>
+        <datafield tag="995" ind1=" " ind2=" ">
+          <subfield code="9">2</subfield>
+          <subfield code="c">BIB</subfield>
+          <subfield code="2">0</subfield>
+          <subfield code="k">R ABE</subfield>
+          <subfield code="o">0</subfield>
+          <subfield code="e">Secteur Adulte</subfield>
+          <subfield code="b">BIB</subfield>
+          <subfield code="j">7786004672</subfield>
+          <subfield code="q">a</subfield>
+          <subfield code="s">Achats</subfield>
+        </datafield>
+        <controlfield tag="001">2</controlfield>
+      </record>
+    </marcxml>
+    <publicationyear>2005</publicationyear>
+    <collectiontitle>fleuve noir</collectiontitle>
+    <pages>306</pages>
+    <issues>
+    </issues>
+    <itemtype>LITT</itemtype>
+    <biblionumber>2</biblionumber>
+    <timestamp>2008-09-03 18:43:19</timestamp>
+    <cn_sort>_</cn_sort>
+    <publishercode>bussière</publishercode>
+    <reserves>
+    </reserves>
+    <items>
+      <item>
+        <biblioitemnumber>2</biblioitemnumber>
+        <wthdrawn>0</wthdrawn>
+        <holdingbranchname>Bibliothèque Jean Prunier</holdingbranchname>
+        <notforloan>0</notforloan>
+        <replacementpricedate>2008-08-20</replacementpricedate>
+        <itemnumber>2</itemnumber>
+        <location>Secteur Adulte</location>
+        <itemcallnumber>R ABE</itemcallnumber>
+        <date_due></date_due>
+        <itemlost>0</itemlost>
+        <datelastseen>2008-08-20</datelastseen>
+        <homebranch>BIB</homebranch>
+        <homebranchname>Bibliothèque Jean Prunier</homebranchname>
+        <biblionumber>2</biblionumber>
+        <holdingbranch>BIB</holdingbranch>
+        <timestamp>2008-08-20 17:15:51</timestamp>
+        <damaged>0</damaged>
+        <cn_sort>R_ABE</cn_sort>
+        <dateaccessioned>2008-08-20</dateaccessioned>
+      </item>
+    </items>
+  </record>
+  <record>RecordNotFound</record>
+</GetRecords>
+ + + +

GetAuthorityRecords

+

Given a list of authority record identifiers, returns a list + of record objects that contain the authority records. The function + user may request a specific metadata schema for the record objects.

+

Parameters

+
+
id (Required)
+
list of authority record identifiers
+
schema (Optional)
+
specifies the metadata schema of records to be returned, possible values: +
    +
  • MARCXML
  • +
+
+
+

Example Call

+ + ilsdi.pl?service=GetAuthorityRecords&id=1+2+99999 + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<GetAuthorityRecords>
+  <record
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/ standards/marcxml/schema/MARC21slim.xsd"
+    xmlns="http://www.loc.gov/MARC21/slim">
+    <leader>00126nx  j2200073   4500 </leader>
+    <controlfield tag="001">1</controlfield>
+    <datafield tag="250" ind1=" " ind2=" ">
+      <subfield code="a">TECHNIQUE</subfield>
+    </datafield>
+    <datafield tag="100" ind1=" " ind2=" ">
+      <subfield code="a">20071210afrey50      ba0</subfield>
+    </datafield>
+    <datafield tag="152" ind1=" " ind2=" ">
+      <subfield code="b">NC</subfield>
+    </datafield>
+  </record>
+  <record
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/ standards/marcxml/schema/MARC21slim.xsd"
+    xmlns="http://www.loc.gov/MARC21/slim">
+    <leader>00130nx  j2200073   4500 </leader>
+    <controlfield tag="001">2</controlfield>
+    <datafield tag="250" ind1=" " ind2=" ">
+      <subfield code="a">CHEMIN DE FER</subfield>
+    </datafield>
+    <datafield tag="100" ind1=" " ind2=" ">
+      <subfield code="a">20071210afrey50      ba0</subfield>
+    </datafield>
+    <datafield tag="152" ind1=" " ind2=" ">
+      <subfield code="b">NC</subfield>
+    </datafield>
+  </record>
+  <record>RecordNotFound</record>
+</GetAuthorityRecords>
+ + + +

LookupPatron

+

Looks up a patron in the ILS by an identifier, and returns + the ILS identifier for that patron, aka the patron identifier.

+

Parameters

+
+
id (Required)
+
an identifier used to look up the patron in Koha
+
id_type (Optional)
+
the type of the identifier, possible values: +
    +
  • cardnumber
  • +
  • firstname
  • +
  • userid
  • +
  • borrowernumber
  • +
+
+
+

Example Call

+ + ilsdi.pl?service=LookupPatron&id=815&id_type=cardnumber + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<LookupPatron>
+  <id>419</id>
+</LookupPatron>
+ + + +

AuthenticatePatron

+

Authenticates a user's login credentials and returns the identifier for the patron.

+

Parameters

+
+
username (Required)
+
user's login identifier
+
password (Required)
+
user's password
+
+

Example Call

+ + ilsdi.pl?service=AuthenticatePatron&username=john9&password=soul + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<AuthenticatePatron>
+  <id>419</id>
+</AuthenticatePatron>
+ + + +

GetPatronInfo

+

Returns specified information about the patron, based on + options in the request. This function can optionally return + patron's contact information, fine information, hold request + information, loan information, and messages.

+

Parameters

+
+
patron_id (Required)
+
the unique patron identifier in the ILS; the same identifier returned by LookupPatron or AuthenticatePatron
+
show_contact (Optional, default 1)
+
whether or not to return patron's contact information in the response
+
show_fines (Optional, default 0)
+
whether or not to return fine information in the response
+
show_holds (Optional, default 0)
+
whether or not to return hold request information in the response
+
show_loans (Optional, default 0)
+
whether or not to return loan information request information in the response
+
+

Example Call

+ + ilsdi.pl?service=GetPatronInfo&patron_id=1&show_contact=0&show_loans=1 + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<GetPatronInfo>
+  <category_type>A</category_type>
+  <categorycode>ADUEXT</categorycode>
+  <borrowernumber>419</borrowernumber>
+  <lost>0</lost>
+  <branchcode>BIB</branchcode>
+  <amountoutstanding>6</amountoutstanding>
+  <description>Adulte extérieur</description>
+  <title>M</title>
+  <enrolmentperiod>12</enrolmentperiod>
+  <charges>6.00</charges>
+  <dateenrolled>2009-03-04</dateenrolled>
+  <borrowernotes></borrowernotes>
+  <dateexpiry>2010-03-04</dateexpiry>
+  <firstname>Jean-André</firstname>
+  <gonenoaddress>0</gonenoaddress>
+  <dateofbirth>1984-06-08</dateofbirth>
+  <debarred>0</debarred>
+  <branchname>Bibliothèque Jean Prunier</branchname>
+  <surname>SANTONI</surname>
+  <cardnumber>815</cardnumber>
+  <initials>JAS</initials>
+  <sort1>CSP5</sort1>
+  <sex>M</sex>
+  <loans>
+    <loan>
+      <lastreneweddate>2009-04-03</lastreneweddate>
+      <isbn>2253003689</isbn>
+      <borrowernumber>419</borrowernumber>
+      <branchcode>BIB</branchcode>
+      <itemnumber>4454</itemnumber>
+      <date_due>2009-05-06</date_due>
+      <barcode>4765476</barcode>
+      <datelastseen>2008-08-23</datelastseen>
+      <issuedate>2008-08-23</issuedate>
+      <title>L'Île au trésor</title>
+      <itemtype>LITT</itemtype>
+      <author>Robert Louis Stevenson</author>
+      <timestamp>2009-04-03 14:46:10</timestamp>
+      <publishercode>Librairie générale française</publishercode>
+      <datecreated>2008-08-23</datecreated>
+      <totalrenewals>11</totalrenewals>
+      <dateaccessioned>2008-08-23</dateaccessioned>
+      <onloan>2008-09-17</onloan>
+      <biblioitemnumber>4483</biblioitemnumber>
+      <wthdrawn>0</wthdrawn>
+      <notforloan>0</notforloan>
+      <replacementpricedate>2008-08-23</replacementpricedate>
+      <itemcallnumber>RO STE</itemcallnumber>
+      <location>Salle de lecture</location>
+      <itemlost>0</itemlost>
+      <publicationyear>1985</publicationyear>
+      <issues>1</issues>
+      <homebranch>BIB</homebranch>
+      <holdingbranch>BIB</holdingbranch>
+      <biblionumber>4483</biblionumber>
+      <renewals>3</renewals>
+      <damaged>0</damaged>
+      <cn_sort>RO_STE</cn_sort>
+      <frameworkcode></frameworkcode>
+      <datelastborrowed>2008-08-23</datelastborrowed>
+    </loan>
+    <loan>
+      <lastreneweddate>2009-03-17</lastreneweddate>
+      <isbn>9782700017823</isbn>
+      <borrowernumber>419</borrowernumber>
+      <branchcode>BIB</branchcode>
+      <itemnumber>4456</itemnumber>
+      <date_due>2009-04-18</date_due>
+      <barcode>2700017UUU</barcode>
+      <datelastseen>2008-08-23</datelastseen>
+      <issuedate>2008-08-23</issuedate>
+      <title>La guitare en 10 leçons</title>
+      <itemtype>LITT</itemtype>
+      <author>Jon Buck</author>
+      <timestamp>2009-03-17 16:48:14</timestamp>
+      <publishercode>Gründ</publishercode>
+      <datecreated>2008-08-23</datecreated>
+      <totalrenewals>6</totalrenewals>
+      <dateaccessioned>2008-08-23</dateaccessioned>
+      <notes>La couv. porte en plus : "un guide simple et facile pour apprendre la guitare" | Glossaire. Index</notes>
+      <onloan>2008-09-25</onloan>
+      <biblioitemnumber>4486</biblioitemnumber>
+      <wthdrawn>0</wthdrawn>
+      <notforloan>0</notforloan>
+      <replacementpricedate>2008-08-23</replacementpricedate>
+      <itemcallnumber>787.87 BUC</itemcallnumber>
+      <location>Salle de lecture</location>
+      <itemlost>0</itemlost>
+      <publicationyear>2007</publicationyear>
+      <issues>1</issues>
+      <homebranch>BIB</homebranch>
+      <holdingbranch>BIB</holdingbranch>
+      <biblionumber>4486</biblionumber>
+      <renewals>3</renewals>
+      <damaged>0</damaged>
+      <cn_sort>78787_BUC</cn_sort>
+      <volume>une méthode simple et facile pour apprendre la guitare</volume>
+      <frameworkcode></frameworkcode>
+      <datelastborrowed>2008-08-23</datelastborrowed>
+    </loan>
+  </loans>
+</GetPatronInfo>
+ + + +

GetPatronStatus

+

Returns a patron's status information from Koha.

+

Parameters

+
+
patron_id (Required)
+
the unique patron identifier in the ILS; the same identifier returned by LookupPatron or AuthenticatePatron
+
+

Example Call

+ + ilsdi.pl?service=GetPatronStatus&patron_id=1 + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<GetPatronStatus>
+  <expiry>2010-03-04</expiry>
+  <status>0</status>
+  <type>ADUEXT</type>
+</GetPatronStatus>
+ + + +

GetServices

+

Returns information about the services available on a particular item for a particular patron.

+

Parameters

+
+
patron_id (Required)
+
the unique patron identifier in the ILS; the same identifier returned by LookupPatron or AuthenticatePatron
+
item_id (Required)
+
system item identifier
+
+

Example Call

+ + ilsdi.pl?service=GetServices&patron_id=1&item_id=1 + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<GetServices>
+  <AvailableFor>title level hold</AvailableFor>
+  <AvailableFor>item level hold</AvailableFor>
+</GetServices>
+ + + +

RenewLoan

+

Extends the due date for a patron's existing loan.

+

Parameters

+
+
patron_id (Required)
+
the unique patron identifier in the ILS; the same identifier returned by LookupPatron or AuthenticatePatron
+
item_id (Required)
+
system item identifier
+
desired_due_date (Required)
+
the date the patron would like the item returned by
+
+

Example Call

+ + ilsdi.pl?service=RenewLoan&patron_id=1&item_id=1 + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<RenewLoan>
+  <success>0</success>
+  <renewals>5</renewals>
+  <date_due>2009-05-11</date_due>
+</RenewLoan>
+ + + +

HoldTitle

+

Creates, for a patron, a title-level hold request on a given bibliographic record in Koha.

+

Parameters

+
+
patron_id (Required)
+
the ILS identifier for the patron for whom the request is placed
+
bib_id (Required)
+
the ILS identifier for the bibliographic record on which the request is placed
+
request_location (Required)
+
IP address where the end user request is being placed
+
pickup_location (Optional)
+
an identifier indicating the location to which to deliver the item for pickup
+
needed_before_date (Optional)
+
date after which hold request is no longer needed
+
pickup_expiry_date (Optional)
+
date after which item returned to shelf if item is not picked up
+
+

Example Call

+ + ilsdi.pl?service=HoldTitle&patron_id=1&bib_id=1&request_location=127.0.0.1 + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<HoldTitle>
+  <title>(les) galères de l'Orfèvre</title>
+  <date_available>2009-05-11</date_available>
+  <pickup_location>Bibliothèque Jean-Prunier</pickup_location>
+</HoldTitle>
+ + + +

HoldItem

+

Creates, for a patron, an item-level hold request on a specific item of a bibliographic record Koha.

+

Parameters

+
+
patron_id (Required)
+
the ILS identifier for the patron for whom the request is placed
+
bib_id (Required)
+
the ILS identifier for the bibliographic record on which the request is placed
+
item_id (Required)
+
the ILS identifier for the specific item on which the request is placed
+
pickup_location (Optional)
+
an identifier indicating the location to which to deliver the item for pickup
+
needed_before_date (Optional)
+
date after which hold request is no longer needed
+
pickup_expiry_date (Optional)
+
date after which item returned to shelf if item is not picked up
+
+

Example Call

+ + ilsdi.pl?service=HoldItem&patron_id=1&bib_id=1&item_id=1 + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<HoldTitle>
+  <title>(les) galères de l'Orfèvre</title>
+  <date_available>2009-05-11</date_available>
+  <pickup_location>Bibliothèque Jean-Prunier</pickup_location>
+</HoldTitle>
+ + + +

CancelHold

+

Cancels an active hold request for the patron.

+

Parameters

+
+
patron_id (Required)
+
the unique patron identifier in the ILS; the same identifier returned by LookupPatron or AuthenticatePatron
+
item_id (Required)
+
system item identifier
+
+

Example Call

+ + ilsdi.pl?service=CancelHold&patron_id=1&item_id=1 + +

Example Response

+
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<CancelHold>
+  <message>Canceled</message>
+</CancelHold>
+ + + +

Level 1: Basic Discovery Interfaces

+
    +
  • HarvestBibliographicRecords (Use OAI-PMH instead)
  • +
  • HarvestExpandedRecords (Use OAI-PMH instead)
  • +
  • GetAvailability
  • +
  • GoToBibliographicRequestPage (Use OPAC instead)
  • +
+

Level 2: Elementary OPAC supplement

+
    +
  • HarvestAuthorityRecords (Use OAI-PMH instead)
  • +
  • HarvestHoldingsRecords (Use OAI-PMH instead)
  • +
  • GetRecords
  • +
  • Search
  • +
  • Scan
  • +
  • GetAuthorityRecords
  • +
  • OutputRewritablePage
  • +
  • OutputIntermediateFormat
  • +
+

Level 3: Elementary OPAC alternative

+ +

Level 4: Robust/domain specific discovery platforms

+
    +
  • SearchCourseReserves
  • +
  • Explain
  • +
+ + + +
+
+ +
+ +
+ +
+
+