1) Be more careful when checking the NorwegianPatronDBEnable syspref.
Before:
if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
After:
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
This should avoid complaints if the syspref is not initialized.
2) Fix some empty =head2 POD sections
3) Fix some indentation in patrons.pref, to make xt/yaml_valid.t happy
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
I couldn't find any regressions with adding, editing and deleting members.
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
use Koha::AuthUtils qw(hash_password);
use Koha::Database;
use Module::Load;
-if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
load Koha::NorwegianPatronDB, qw( NLUpdateHashedPIN NLEncryptPIN NLSync );
}
if ($data{password} eq '****' or $data{password} eq '') {
delete $data{password};
} else {
- if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
# Update the hashed PIN in borrower_sync.hashed_pin, before Koha hashes it
NLUpdateHashedPIN( $data{'borrowernumber'}, $data{password} );
}
# If NorwegianPatronDBEnable is enabled, we set syncstatus to something that a
# cronjob will use for syncing with NL
- if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
my $borrowersync = Koha::Database->new->schema->resultset('BorrowerSync')->find({
'synctype' => 'norwegianpatrondb',
'borrowernumber' => $data{'borrowernumber'}
# If NorwegianPatronDBEnable is enabled, we set syncstatus to something that a
# cronjob will use for syncing with NL
- if ( exists $data{'borrowernumber'} && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+ if ( exists $data{'borrowernumber'} && C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
Koha::Database->new->schema->resultset('BorrowerSync')->create({
'borrowernumber' => $data{'borrowernumber'},
'synctype' => 'norwegianpatrondb',
be polite to only load the module at runtime, if it is needed:
use Module::Load;
- if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
}
- pref: CardnumberLength
- "characters long. The length can be a single number to specify an exact length, a range separated by a comma (i.e., 'Min,Max'), or a maximum with no minimum (i.e., ',Max')."
- "If 'cardnumber' is included in the BorrowerMandatoryField list, the minimum length, if not specified here, defaults to one."
- Norwegian patron database:
- -
+ "Norwegian patron database":
+ -
- pref: NorwegianPatronDBEnable
choices:
yes: Enable
- the ability to communicate with the Norwegian national patron database via the
- pref: NorwegianPatronDBEndpoint
- endpoint.
- -
+ -
- Communicate with the Norwegian national patron database using the username
- pref: NorwegianPatronDBUsername
- and the password
- pref: NorwegianPatronDBPassword
- . You can get these from "Base Bibliotek", which is maintained by the Norwegian National Library.
- -
+ -
- pref: NorwegianPatronDBSearchNLAfterLocalHit
choices:
yes: Do
use C4::Branch; # GetBranches
use C4::VirtualShelves (); #no import
use Module::Load;
-if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync );
}
# out. If "deletelocal" is set to "true", or not set to anything normal
# deletion will be done.
my $deletelocal = $input->param('deletelocal') eq 'false' ? 0 : 1; # Deleting locally is the default
-if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
if ( $input->param('deleteremote') eq 'true' ) {
# Mark for deletion, then try a live sync
NLMarkForDeletion( $member );
use Koha::Borrower::Debarments;
use Koha::DateUtils;
use Module::Load;
-if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
}
C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template, 1, $newdata{'categorycode'});
}
# Try to do the live sync with the Norwegian national patron database, if it is enabled
- if ( exists $data{'borrowernumber'} && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+ if ( exists $data{'borrowernumber'} && C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
NLSync({ 'borrowernumber' => $borrowernumber });
}
} elsif ($op eq 'save'){
$template->param( categorycode => $borrower_data->{'categorycode'} );
}
# Add sync data to the user data
- if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
my $sync = NLGetSyncDataFromBorrowernumber( $borrowernumber );
if ( $sync ) {
$template->param(
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
use Module::Load;
-if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
}
#use Smart::Comments;
}
# Add sync data to the user data
-if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
my $sync = NLGetSyncDataFromBorrowernumber( $borrowernumber );
if ( $sync ) {
$data->{'sync'} = $sync->sync;
=head2 Check sysprefs
+Check that the necessary sysprefs are set before proceeding.
+
=cut
my $check_result = NLCheckSysprefs();
=head2 Find patrons that need to be synced
+Patrons with either of these statuses:
+
+=over 4
+
+=item * edited
+
+=item * new
+
+=item * deleted
+
+=back
+
=cut
my @needs_sync = Koha::Database->new->schema->resultset('BorrowerSync')->search({
=head2 Do the actual sync
+Data is synced to NL with NLSync.
+
=cut
my $sync_success = 0;
=head2 Summarize if verbose mode is enabled
+Specify -v on the command line to get a summary of the syncing operations.
+
=cut
if ( $verbose ) {