<<

NAME

Koha::NorwegianPatronDB

SYNOPSIS

  use Koha::NorwegianPatronDB;

CONDITIONAL LOADING

This module depends on some Perl modules that have not been marked as required. This is because the module only will be of interest to Norwegian libraries, and it seems polite not to bother the rest of the world with these modules. It is also good practice to check that the module is actually needed before loading it. So in a NorwegianPatronDB page or script it will be OK to just do:

  use Koha::NorwegianPatronDB qw(...);

But in scripts that are also used by others (like e.g. moremember.pl), it will be polite to only load the module at runtime, if it is needed:

  use Module::Load;
  if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
      load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
  }

(Module::Load::Conditional is used for this in other parts of Koha, but it does not seem to allow for a list of subroutines to import, so Module::Load looks like a better candidate.)

FUNCTIONS

SOAP::Transport::HTTP::Client::get_basic_credentials

This is included to set the username and password used by SOAP::Lite.

NLCheckSysprefs

Check that sysprefs relevant to NL are set.

NLSearch

Search the NL patron database.

SOAP call: "hent" (fetch)

NLSync

Sync a patron that has been changed or created in Koha "upstream" to NL.

Input is a hashref with one of two possible elements, either a patron retrieved from the database:

    my $result = NLSync({ 'patron' => $borrower_from_dbic });

or a plain old borrowernumber:

    my $result = NLSync({ 'borrowernumber' => $borrowernumber });

In the latter case, this function will retrieve the patron record from the database using DBIC.

Which part of the API is called depends on the value of the "syncstatus" column:

Required values for new and edited:

NLGetChanged

Fetches patrons from NL that have been changed since a given timestamp. This includes patrons that have been changed by the library that runs the sync, so we have to check which library was the last one to change a patron, before we update patrons locally.

This is supposed to be executed once per night.

SOAP call: soekEndret

NLMarkForDeletion

Mark a borrower for deletion, but do not do the actual deletion. Deleting the borrower from NL will be done later by the nl-sync-from-koha.pl script.

NLDecodePin

Takes a string encoded with AES/ECB/PKCS5PADDING and a 128-bits key, and returns the decoded string as plain text.

The key needs to be stored in koha-conf.xml, like so:

<yazgfs> ... <config> ... <nlkey>xyz</nlkey> </config> </yazgfs>

NLEncryptPIN

Takes a plain text PIN as argument, returns the encrypted PIN, according to the NL specs.

    my $encrypted_pin = NLEncryptPIN( $plain_text_pin );

NLUpdateHashedPIN

Takes two arguments:

Hashes the password and saves it in borrower_sync.hashed_pin.

_encrypt_pin

Takes a plain text PIN and returns the encrypted version, according to the NL specs.

NLGetSyncDataFromBorrowernumber

Takes a borrowernumber as argument, returns a Koha::Schema::Result::BorrowerSync object.

    my $syncdata = NLGetSyncDataFromBorrowernumber( $borrowernumber );

NLGetFirstname

Takes a string like "Surname, Firstname" and returns the "Firstname" part.

If there is no comma, the string is returned unaltered.

    my $firstname = NLGetFirstname( $name );

NLGetSurname

Takes a string like "Surname, Firstname" and returns the "Surname" part.

If there is no comma, the string is returned unaltered.

    my $surname = NLGetSurname( $name );

_split_name

Takes a string like "Surname, Firstname" and returns a list of surname and firstname.

If there is no comma, the string is returned unaltered.

    my ( $surname, $firstname ) = _split_name( $name );

_format_soap_error

Takes a soap result object as input and returns a formatted string containing SOAP error data.

_soap_to_koha_patron

Convert a SOAP object of type "Laaner" into a hash that can be sent to AddMember or ModMember.

_koha_patron_to_soap

Convert a patron (in the form of a Koha::Schema::Result::Borrower) into a SOAP object that can be sent to NL.

EXPORT

None by default.

AUTHOR

Magnus Enger <digitalutvikling@gmail.com>

<<