VuFind API Documentation

KohaILSDI extends AbstractBase
in package
implements HttpServiceAwareInterface, LoggerAwareInterface Uses CacheTrait, HttpServiceAwareTrait, LoggerAwareTrait

VuFind Driver for Koha, using web APIs (ILSDI)

Minimum Koha Version: 3.18.6

Tags
category

VuFind

author

Alex Sassmannshausen alex.sassmannshausen@ptfs-europe.com

author

Tom Misilo misilot@fit.edu

author

Josef Moravec josef.moravec@gmail.com

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Interfaces, Classes, Traits and Enums

HttpServiceAwareInterface
LoggerAwareInterface

Table of Contents

$availableLocationsDefault  : array<string|int, mixed>
Codes of locations always should be available - For example reference material or material not for loan
$blockTerms  : array<string|int, mixed>
Default terms for block types, can be overridden by configuration
$cache  : StorageInterface
Cache for storing data temporarily (e.g. patron blocks with the ILS driver)
$cacheLifetime  : int
Lifetime of cache (in seconds).
$config  : array<string|int, mixed>
Driver configuration
$dateConverter  : Converter
Date converter object
$db  : PDO
Database connection
$defaultLocation  : string
Default location code
$host  : string
Web services host
$ilsBaseUrl  : string
ILS base URL
$locationAuthorisedValuesCategory  : string
Authorised values category for location, defaults to 'LOC'
$locations  : array<string|int, mixed>
Location codes
$pickupEnableBranchcodes  : array<string|int, mixed>
Codes of locations available for pickup
$showBlockComments  : array<string|int, mixed>
Display comments for patron debarments, see KohaILSDI.ini
$showHomebranch  : bool
Should we show homebranch instead of holdingbranch
$showPermanentLocation  : bool
Should we show permanent location (or current)
$validatePasswords  : bool
Should validate passwords against Koha system?
__construct()  : mixed
Constructor
cancelHolds()  : array<string|int, mixed>
Cancel Holds
changePassword()  : array<string|int, mixed>
Change Password
displayDate()  : string
Convert a database date to a displayable date.
displayDateTime()  : string
Convert a database datetime to a displayable date and time.
findReserves()  : array<string|int, mixed>
Find Reserves
getAccountBlocks()  : mixed
Check whether the patron has any blocks on their account.
getCancelHoldDetails()  : string
Get Cancel Hold Details
getConfig()  : array<string|int, mixed>
Public Function which retrieves renew, hold and cancel settings from the driver ini file.
getCourses()  : array<string|int, mixed>
Get Courses
getDefaultPickUpLocation()  : string
Get Default Pick Up Location
getDepartments()  : array<string|int, mixed>
Get Departments
getHolding()  : array<string|int, mixed>
Get Holding
getInstructors()  : array<string|int, mixed>
Get Instructors
getMyFines()  : mixed
Get Patron Fines
getMyFinesILS()  : mixed
Get Patron Fines
getMyHolds()  : array<string|int, mixed>
Get Patron Holds
getMyProfile()  : array<string|int, mixed>
Get Patron Profile
getMyTransactionHistory()  : array<string|int, mixed>
Get Patron Loan History
getMyTransactions()  : array<string|int, mixed>
Get Patron Transactions
getNewItems()  : array<string|int, mixed>
This method queries the ILS for new items
getPickUpLocations()  : array<string|int, mixed>
Get Pick Up Locations
getPurchaseHistory()  : array<string|int, mixed>
Get Purchase History
getRenewDetails()  : string
Get Renew Details
getStatus()  : mixed
Get Status
getStatuses()  : array<string|int, mixed>
Get Statuses
getSuppressedRecords()  : array<string|int, mixed>
Get suppressed records.
init()  : void
Initialize the driver.
patronLogin()  : mixed
Patron Login
placeHold()  : mixed
Place Hold
renewMyItems()  : array<string|int, mixed>
Renew My Items
setCacheStorage()  : void
Set a cache storage object.
setConfig()  : void
Set configuration.
supportsMethod()  : bool
Helper method to determine whether or not a certain method can be called on this driver. Required method for any smart drivers.
debug()  : void
Log a debug message.
getCachedData()  : mixed|null
Helper function for fetching cached data.
getCacheKey()  : string
Koha ILS-DI driver specific override of method to ensure uniform cache keys for cached VuFind objects.
getDb()  : PDO
Get the database connection (and make sure it is initialized).
getField()  : string
Get Field
initDb()  : void
Initialize the DB driver.
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logWarning()  : void
Log a warning message.
makeIlsdiRequest()  : obj
Make Ilsdi Request Array
makeRequest()  : obj
Make Request
putCachedData()  : void
Helper function for storing cached data.
removeCachedData()  : void
Helper function for removing cached data.
tableExists()  : bool
Check if a table exists in the current database.
throwAsIlsException()  : never
Rethrow the provided exception as an ILS exception.
toKohaDate()  : string|null
To Koha Date

Properties

$availableLocationsDefault

Codes of locations always should be available - For example reference material or material not for loan

protected array<string|int, mixed> $availableLocationsDefault

$blockTerms

Default terms for block types, can be overridden by configuration

protected array<string|int, mixed> $blockTerms = ['SUSPENSION' => 'Account Suspended', 'OVERDUES' => 'Account Blocked (Overdue Items)', 'MANUAL' => 'Account Blocked', 'DISCHARGE' => 'Account Blocked for Discharge']

$cache

Cache for storing data temporarily (e.g. patron blocks with the ILS driver)

protected StorageInterface $cache = null

$cacheLifetime

Lifetime of cache (in seconds).

protected int $cacheLifetime = 30

$config

Driver configuration

protected array<string|int, mixed> $config = []

$dateConverter

Date converter object

protected Converter $dateConverter

$defaultLocation

Default location code

protected string $defaultLocation

$host

Web services host

protected string $host

$ilsBaseUrl

ILS base URL

protected string $ilsBaseUrl

$locationAuthorisedValuesCategory

Authorised values category for location, defaults to 'LOC'

protected string $locationAuthorisedValuesCategory

$locations

Location codes

protected array<string|int, mixed> $locations

$pickupEnableBranchcodes

Codes of locations available for pickup

protected array<string|int, mixed> $pickupEnableBranchcodes

$showBlockComments

Display comments for patron debarments, see KohaILSDI.ini

protected array<string|int, mixed> $showBlockComments

$showHomebranch

Should we show homebranch instead of holdingbranch

protected bool $showHomebranch

$showPermanentLocation

Should we show permanent location (or current)

protected bool $showPermanentLocation

$validatePasswords

Should validate passwords against Koha system?

protected bool $validatePasswords

Methods

__construct()

Constructor

public __construct(Converter $dateConverter) : mixed
Parameters
$dateConverter : Converter

Date converter object

Return values
mixed

cancelHolds()

Cancel Holds

public cancelHolds(array<string|int, mixed> $cancelDetails) : array<string|int, mixed>

Attempts to Cancel a hold or recall on a particular item. The data in $cancelDetails['details'] is determined by getCancelHoldDetails().

Parameters
$cancelDetails : array<string|int, mixed>

An array of item and patron data

Return values
array<string|int, mixed>

An array of data on each request including whether or not it was successful and a system message (if available)

changePassword()

Change Password

public changePassword(array<string|int, mixed> $detail) : array<string|int, mixed>

This method changes patron's password

Parameters
$detail : array<string|int, mixed>

An associative array with three keys patron - The patron array from patronLogin oldPassword - Old password newPassword - New password

Return values
array<string|int, mixed>

An associative array with keys: success - boolean, true if change was made status - string, A status message - subject to translation

displayDate()

Convert a database date to a displayable date.

public displayDate(string $date) : string
Parameters
$date : string

Date to convert

Return values
string

displayDateTime()

Convert a database datetime to a displayable date and time.

public displayDateTime(string $date) : string
Parameters
$date : string

Datetime to convert

Return values
string

findReserves()

Find Reserves

public findReserves(string $course, string $inst, string $dept) : array<string|int, mixed>

Obtain information on course reserves.

This version of findReserves was contributed by Matthew Hooper and includes support for electronic reserves (though eReserve support is still a work in progress).

Parameters
$course : string

ID from getCourses (empty string to match all)

$inst : string

ID from getInstructors (empty string to match all)

$dept : string

ID from getDepartments (empty string to match all)

Tags
throws
ILS
Return values
array<string|int, mixed>

An array of associative arrays representing reserve items.

getAccountBlocks()

Check whether the patron has any blocks on their account.

public getAccountBlocks(array<string|int, mixed> $patron) : mixed
Parameters
$patron : array<string|int, mixed>

Patron data from patronLogin

Tags
throws
ILS
Return values
mixed

A boolean false if no blocks are in place and an array of block reasons if blocks are in place

getCancelHoldDetails()

Get Cancel Hold Details

public getCancelHoldDetails(array<string|int, mixed> $holdDetails[, array<string|int, mixed> $patron = [] ]) : string

In order to cancel a hold, Koha requires the patron details and an item ID. This function returns the item id as a string. This value is then used by the CancelHolds function.

Parameters
$holdDetails : array<string|int, mixed>

A single hold array from getMyHolds

$patron : array<string|int, mixed> = []

Patron information from patronLogin

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
string

Data for use in a form field

getConfig()

Public Function which retrieves renew, hold and cancel settings from the driver ini file.

public getConfig(string $function[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
$function : string

The name of the feature to be checked

$params : array<string|int, mixed> = []

Optional feature-specific parameters (array)

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
array<string|int, mixed>

An array with key-value pairs.

getCourses()

Get Courses

public getCourses() : array<string|int, mixed>
Tags
throws
ILS
Return values
array<string|int, mixed>

An associative array with key = ID, value = name.

getDefaultPickUpLocation()

Get Default Pick Up Location

public getDefaultPickUpLocation([array<string|int, mixed> $patron = false ][, array<string|int, mixed> $holdDetails = null ]) : string

Returns the default pick up location set in KohaILSDI.ini

Parameters
$patron : array<string|int, mixed> = false

Patron information returned by the patronLogin method.

$holdDetails : array<string|int, mixed> = null

Optional array, only passed in when getting a list in the context of placing a hold; contains most of the same values passed to placeHold, minus the patron data. May be used to limit the pickup options or may be ignored.

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
string

The default pickup location for the patron.

getDepartments()

Get Departments

public getDepartments() : array<string|int, mixed>
Tags
throws
ILS
Return values
array<string|int, mixed>

An associative array with key = ID, value = dept. name.

getHolding()

Get Holding

public getHolding(string $id[, array<string|int, mixed> $patron = null ][, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>

This is responsible for retrieving the holding information of a certain record.

Parameters
$id : string

The record id to retrieve the holdings for

$patron : array<string|int, mixed> = null

Patron data

$options : array<string|int, mixed> = []

Extra options (not currently used)

Tags
throws
DateException
throws
ILS
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
array<string|int, mixed>

On success, an associative array with the following keys: id, availability (boolean), status, location, reserve, callnumber, duedate, number, barcode.

getInstructors()

Get Instructors

public getInstructors() : array<string|int, mixed>
Tags
throws
ILS
Return values
array<string|int, mixed>

An associative array with key = ID, value = name.

getMyFines()

Get Patron Fines

public getMyFines(array<string|int, mixed> $patron) : mixed

This is responsible for retrieving all fines by a specific patron.

Parameters
$patron : array<string|int, mixed>

The patron array from patronLogin

Tags
throws
DateException
throws
ILS
Return values
mixed

Array of the patron's fines on success.

getMyFinesILS()

Get Patron Fines

public getMyFinesILS(array<string|int, mixed> $patron) : mixed

This is responsible for retrieving all fines by a specific patron.

Parameters
$patron : array<string|int, mixed>

The patron array from patronLogin

Tags
throws
DateException
throws
ILS
Return values
mixed

Array of the patron's fines on success.

getMyHolds()

Get Patron Holds

public getMyHolds(array<string|int, mixed> $patron) : array<string|int, mixed>

This is responsible for retrieving all holds by a specific patron.

Parameters
$patron : array<string|int, mixed>

The patron array from patronLogin

Tags
throws
DateException
throws
ILS
Return values
array<string|int, mixed>

Array of the patron's holds on success.

getMyProfile()

Get Patron Profile

public getMyProfile(array<string|int, mixed> $patron) : array<string|int, mixed>

This is responsible for retrieving the profile for a specific patron.

Parameters
$patron : array<string|int, mixed>

The patron array

Tags
throws
ILS
Return values
array<string|int, mixed>

Array of the patron's profile data on success.

getMyTransactionHistory()

Get Patron Loan History

public getMyTransactionHistory(array<string|int, mixed> $patron, array<string|int, mixed> $params) : array<string|int, mixed>

This is responsible for retrieving all historic loans (i.e. items previously checked out and then returned), for a specific patron.

Parameters
$patron : array<string|int, mixed>

The patron array from patronLogin

$params : array<string|int, mixed>

Parameters

Tags
throws
DateException
throws
ILS
Return values
array<string|int, mixed>

Array of the patron's transactions on success.

getMyTransactions()

Get Patron Transactions

public getMyTransactions(array<string|int, mixed> $patron) : array<string|int, mixed>

This is responsible for retrieving all transactions (i.e. checked out items) by a specific patron.

Parameters
$patron : array<string|int, mixed>

The patron array from patronLogin

Tags
throws
DateException
throws
ILS
Return values
array<string|int, mixed>

Array of the patron's transactions on success.

getNewItems()

This method queries the ILS for new items

public getNewItems(int $page, int $limit, int $daysOld[, int $fundId = null ]) : array<string|int, mixed>
Parameters
$page : int

Page number of results to retrieve (counting starts at 1)

$limit : int

The size of each page of results to retrieve

$daysOld : int

The maximum age of records to retrieve in days (max. 30)

$fundId : int = null

optional fund ID to use for limiting results (use a value returned by getFunds, or exclude for no limit); note that "fund" may be a misnomer - if funds are not an appropriate way to limit your new item results, you can return a different set of values from getFunds. The important thing is that this parameter supports an ID returned by getFunds, whatever that may mean.

Return values
array<string|int, mixed>

provides a count and the results of new items.

getPickUpLocations()

Get Pick Up Locations

public getPickUpLocations([array<string|int, mixed> $patron = false ][, array<string|int, mixed> $holdDetails = null ]) : array<string|int, mixed>

This is responsible for gettting a list of valid library locations for holds / recall retrieval

Parameters
$patron : array<string|int, mixed> = false

Patron information returned by the patronLogin method.

$holdDetails : array<string|int, mixed> = null

Optional array, only passed in when getting a list in the context of placing or editing a hold. When placing a hold, it contains most of the same values passed to placeHold, minus the patron data. When editing a hold it contains all the hold information returned by getMyHolds. May be used to limit the pickup options or may be ignored. The driver must not add new options to the return array based on this data or other areas of VuFind may behave incorrectly.

Tags
throws
ILS
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
array<string|int, mixed>

An array of associative arrays with locationID and locationDisplay keys

getPurchaseHistory()

Get Purchase History

public getPurchaseHistory(string $id) : array<string|int, mixed>

This is responsible for retrieving the acquisitions history data for the specific record (usually recently received issues of a serial).

Parameters
$id : string

The record id to retrieve the info for

Tags
throws
ILS
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
array<string|int, mixed>

An array with the acquisitions data on success.

getRenewDetails()

Get Renew Details

public getRenewDetails(array<string|int, mixed> $checkOutDetails) : string

In order to renew an item, Koha requires the patron details and an item id. This function returns the item id as a string which is then used as submitted form data in checkedOut.php. This value is then extracted by the RenewMyItems function.

Parameters
$checkOutDetails : array<string|int, mixed>

An array of item data

Return values
string

Data for use in a form field

getStatus()

Get Status

public getStatus(string $id) : mixed

This is responsible for retrieving the status information of a certain record.

Parameters
$id : string

The record id to retrieve the holdings for

Tags
throws
ILS
Return values
mixed

On success, an associative array with the following keys: id, availability (boolean), status, location, reserve, callnumber.

getStatuses()

Get Statuses

public getStatuses(array<string|int, mixed> $idLst) : array<string|int, mixed>

This is responsible for retrieving the status information for a collection of records.

Parameters
$idLst : array<string|int, mixed>

The array of record ids to retrieve the status for

Tags
throws
ILS
Return values
array<string|int, mixed>

An array of getStatus() return values on success.

getSuppressedRecords()

Get suppressed records.

public getSuppressedRecords() : array<string|int, mixed>
Tags
throws
ILS
Return values
array<string|int, mixed>

ID numbers of suppressed records in the system.

init()

Initialize the driver.

public init() : void

Validate configuration and perform all resource-intensive tasks needed to make the driver active.

Tags
throws
ILS
Return values
void

patronLogin()

Patron Login

public patronLogin(string $username, string $password) : mixed

This is responsible for authenticating a patron against the catalog.

Parameters
$username : string

The patron username

$password : string

The patron's password

Tags
throws
ILS
Return values
mixed

Associative array of patron info on successful login, null on unsuccessful login.

placeHold()

Place Hold

public placeHold(array<string|int, mixed> $holdDetails) : mixed

Attempts to place a hold or recall on a particular item and returns an array with result details or throws an exception on failure of support classes

Parameters
$holdDetails : array<string|int, mixed>

An array of item and patron data

Tags
throws
ILS
Return values
mixed

An array of data on the request including whether or not it was successful and a system message (if available)

renewMyItems()

Renew My Items

public renewMyItems(array<string|int, mixed> $renewDetails) : array<string|int, mixed>

Function for attempting to renew a patron's items. The data in $renewDetails['details'] is determined by getRenewDetails().

Parameters
$renewDetails : array<string|int, mixed>

An array of data required for renewing items including the Patron ID and an array of renewal IDS

Return values
array<string|int, mixed>

An array of renewal information keyed by item ID

setCacheStorage()

Set a cache storage object.

public setCacheStorage([StorageInterface $cache = null ]) : void
Parameters
$cache : StorageInterface = null

Cache storage interface

Return values
void

setConfig()

Set configuration.

public setConfig(array<string|int, mixed> $config) : void

Set the configuration for the driver.

Parameters
$config : array<string|int, mixed>

Configuration array (usually loaded from a VuFind .ini file whose name corresponds with the driver class name).

Return values
void

supportsMethod()

Helper method to determine whether or not a certain method can be called on this driver. Required method for any smart drivers.

public supportsMethod(string $method, array<string|int, mixed> $params) : bool
Parameters
$method : string

The name of the called method.

$params : array<string|int, mixed>

Array of passed parameters

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
bool

True if the method can be called with the given parameters, false otherwise.

debug()

Log a debug message.

protected debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

getCachedData()

Helper function for fetching cached data.

protected getCachedData(string $key) : mixed|null

Data is cached for up to $this->cacheLifetime.

Parameters
$key : string

Cache entry key

Return values
mixed|null

Cached entry or null if not cached or expired

getCacheKey()

Koha ILS-DI driver specific override of method to ensure uniform cache keys for cached VuFind objects.

protected getCacheKey([string|null $suffix = null ]) : string
Parameters
$suffix : string|null = null

Optional suffix that will get appended to the object class name calling getCacheKey()

Return values
string

getDb()

Get the database connection (and make sure it is initialized).

protected getDb() : PDO
Return values
PDO

getField()

Get Field

protected getField(string $contents[, string $default = 'Unknown' ]) : string

Check $contents is not "", return it; else return $default.

Parameters
$contents : string

string to be checked

$default : string = 'Unknown'

value to return if $contents is ""

Return values
string

initDb()

Initialize the DB driver.

protected initDb() : void

Validate configuration and perform all resource-intensive tasks needed to make the driver active.

Tags
throws
ILS
Return values
void

log()

Send a message to the logger.

protected log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
$level : string

Log level

$message : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = false

Prepend class name to message?

Return values
void

logError()

Log an error message.

protected logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

logWarning()

Log a warning message.

protected logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

makeIlsdiRequest()

Make Ilsdi Request Array

protected makeIlsdiRequest(string $service, array<string|int, mixed> $params[, string $http_method = 'GET' ]) : obj

Makes a request to the Koha ILSDI API

Parameters
$service : string

Called function (GetAvailability, GetRecords, GetAuthorityRecords, LookupPatron, AuthenticatePatron, GetPatronInfo, GetPatronStatus, GetServices, RenewLoan, HoldTitle, HoldItem, CancelHold)

$params : array<string|int, mixed>

Key is parameter name, value is parameter value

$http_method : string = 'GET'

HTTP method (default = GET)

Tags
throws
ILS
Return values
obj

makeRequest()

Make Request

protected makeRequest(string $api_query[, string $http_method = 'GET' ]) : obj

Makes a request to the Koha ILSDI API

Parameters
$api_query : string

Query string for request

$http_method : string = 'GET'

HTTP method (default = GET)

Tags
throws
ILS
Return values
obj

putCachedData()

Helper function for storing cached data.

protected putCachedData(string $key, mixed $entry[, int $lifetime = null ]) : void

Data is cached for up to $this->cacheLifetime seconds.

Parameters
$key : string

Cache entry key

$entry : mixed

Entry to be cached

$lifetime : int = null

Optional lifetime for the entry in seconds

Return values
void

removeCachedData()

Helper function for removing cached data.

protected removeCachedData(string $key) : void
Parameters
$key : string

Cache entry key

Return values
void

tableExists()

Check if a table exists in the current database.

protected tableExists(string $table) : bool
Parameters
$table : string

Table to search for.

Return values
bool

throwAsIlsException()

Rethrow the provided exception as an ILS exception.

protected throwAsIlsException(Throwable $exception[, string $msg = null ]) : never
Parameters
$exception : Throwable

Exception to rethrow

$msg : string = null

Override exception message (optional)

Tags
throws
ILS
Return values
never

toKohaDate()

To Koha Date

protected toKohaDate(string|null $display_date) : string|null

Turns a display date into a date format expected by Koha.

Parameters
$display_date : string|null

Date to be converted

Tags
throws
ILS
Return values
string|null

$koha_date

Search results