View | Details | Raw Unified | Return to bug 11401
Collapse All | Expand All

(-)a/C4/Members.pm (-4 / +4 lines)
Lines 44-50 use Text::Unaccent qw( unac_string ); Link Here
44
use Koha::AuthUtils qw(hash_password);
44
use Koha::AuthUtils qw(hash_password);
45
use Koha::Database;
45
use Koha::Database;
46
use Module::Load;
46
use Module::Load;
47
if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
47
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
48
    load Koha::NorwegianPatronDB, qw( NLUpdateHashedPIN NLEncryptPIN NLSync );
48
    load Koha::NorwegianPatronDB, qw( NLUpdateHashedPIN NLEncryptPIN NLSync );
49
}
49
}
50
50
Lines 789-795 sub ModMember { Link Here
789
        if ($data{password} eq '****' or $data{password} eq '') {
789
        if ($data{password} eq '****' or $data{password} eq '') {
790
            delete $data{password};
790
            delete $data{password};
791
        } else {
791
        } else {
792
            if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
792
            if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
793
                # Update the hashed PIN in borrower_sync.hashed_pin, before Koha hashes it
793
                # Update the hashed PIN in borrower_sync.hashed_pin, before Koha hashes it
794
                NLUpdateHashedPIN( $data{'borrowernumber'}, $data{password} );
794
                NLUpdateHashedPIN( $data{'borrowernumber'}, $data{password} );
795
            }
795
            }
Lines 815-821 sub ModMember { Link Here
815
815
816
        # If NorwegianPatronDBEnable is enabled, we set syncstatus to something that a
816
        # If NorwegianPatronDBEnable is enabled, we set syncstatus to something that a
817
        # cronjob will use for syncing with NL
817
        # cronjob will use for syncing with NL
818
        if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
818
        if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
819
            my $borrowersync = Koha::Database->new->schema->resultset('BorrowerSync')->find({
819
            my $borrowersync = Koha::Database->new->schema->resultset('BorrowerSync')->find({
820
                'synctype'       => 'norwegianpatrondb',
820
                'synctype'       => 'norwegianpatrondb',
821
                'borrowernumber' => $data{'borrowernumber'}
821
                'borrowernumber' => $data{'borrowernumber'}
Lines 883-889 sub AddMember { Link Here
883
883
884
    # If NorwegianPatronDBEnable is enabled, we set syncstatus to something that a
884
    # If NorwegianPatronDBEnable is enabled, we set syncstatus to something that a
885
    # cronjob will use for syncing with NL
885
    # cronjob will use for syncing with NL
886
    if ( exists $data{'borrowernumber'} && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
886
    if ( exists $data{'borrowernumber'} && C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
887
        Koha::Database->new->schema->resultset('BorrowerSync')->create({
887
        Koha::Database->new->schema->resultset('BorrowerSync')->create({
888
            'borrowernumber' => $data{'borrowernumber'},
888
            'borrowernumber' => $data{'borrowernumber'},
889
            'synctype'       => 'norwegianpatrondb',
889
            'synctype'       => 'norwegianpatrondb',
(-)a/Koha/NorwegianPatronDB.pm (-1 / +1 lines)
Lines 39-45 But in scripts that are also used by others (like e.g. moremember.pl), it will Link Here
39
be polite to only load the module at runtime, if it is needed:
39
be polite to only load the module at runtime, if it is needed:
40
40
41
  use Module::Load;
41
  use Module::Load;
42
  if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
42
  if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
43
      load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
43
      load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
44
  }
44
  }
45
45
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-4 / +4 lines)
Lines 139-146 Patrons: Link Here
139
         - pref: CardnumberLength
139
         - pref: CardnumberLength
140
         - "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')."
140
         - "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')."
141
         - "If 'cardnumber' is included in the BorrowerMandatoryField list, the minimum length, if not specified here, defaults to one."
141
         - "If 'cardnumber' is included in the BorrowerMandatoryField list, the minimum length, if not specified here, defaults to one."
142
    Norwegian patron database:
142
    "Norwegian patron database":
143
    -
143
     -
144
         - pref: NorwegianPatronDBEnable
144
         - pref: NorwegianPatronDBEnable
145
           choices:
145
           choices:
146
               yes: Enable
146
               yes: Enable
Lines 148-160 Patrons: Link Here
148
         - the ability to communicate with the Norwegian national patron database via the
148
         - the ability to communicate with the Norwegian national patron database via the
149
         - pref: NorwegianPatronDBEndpoint
149
         - pref: NorwegianPatronDBEndpoint
150
         - endpoint.
150
         - endpoint.
151
    -
151
     -
152
         - Communicate with the Norwegian national patron database using the username
152
         - Communicate with the Norwegian national patron database using the username
153
         - pref: NorwegianPatronDBUsername
153
         - pref: NorwegianPatronDBUsername
154
         - and the password
154
         - and the password
155
         - pref: NorwegianPatronDBPassword
155
         - pref: NorwegianPatronDBPassword
156
         - . You can get these from "Base Bibliotek", which is maintained by the Norwegian National Library.
156
         - . You can get these from "Base Bibliotek", which is maintained by the Norwegian National Library.
157
    -
157
     -
158
         - pref: NorwegianPatronDBSearchNLAfterLocalHit
158
         - pref: NorwegianPatronDBSearchNLAfterLocalHit
159
           choices:
159
           choices:
160
               yes: Do
160
               yes: Do
(-)a/members/deletemem.pl (-2 / +2 lines)
Lines 32-38 use C4::Members; Link Here
32
use C4::Branch; # GetBranches
32
use C4::Branch; # GetBranches
33
use C4::VirtualShelves (); #no import
33
use C4::VirtualShelves (); #no import
34
use Module::Load;
34
use Module::Load;
35
if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
35
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
36
    load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync );
36
    load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync );
37
}
37
}
38
38
Lines 56-62 my $member = $input->param('member'); Link Here
56
# out. If "deletelocal" is set to "true", or not set to anything normal
56
# out. If "deletelocal" is set to "true", or not set to anything normal
57
# deletion will be done.
57
# deletion will be done.
58
my $deletelocal  = $input->param('deletelocal')  eq 'false' ? 0 : 1; # Deleting locally is the default
58
my $deletelocal  = $input->param('deletelocal')  eq 'false' ? 0 : 1; # Deleting locally is the default
59
if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
59
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
60
    if ( $input->param('deleteremote') eq 'true' ) {
60
    if ( $input->param('deleteremote') eq 'true' ) {
61
        # Mark for deletion, then try a live sync
61
        # Mark for deletion, then try a live sync
62
        NLMarkForDeletion( $member );
62
        NLMarkForDeletion( $member );
(-)a/members/memberentry.pl (-3 / +3 lines)
Lines 44-50 use C4::Form::MessagingPreferences; Link Here
44
use Koha::Borrower::Debarments;
44
use Koha::Borrower::Debarments;
45
use Koha::DateUtils;
45
use Koha::DateUtils;
46
use Module::Load;
46
use Module::Load;
47
if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
47
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
48
    load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
48
    load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
49
}
49
}
50
50
Lines 421-427 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
421
            C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template, 1, $newdata{'categorycode'});
421
            C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template, 1, $newdata{'categorycode'});
422
        }
422
        }
423
        # Try to do the live sync with the Norwegian national patron database, if it is enabled
423
        # Try to do the live sync with the Norwegian national patron database, if it is enabled
424
        if ( exists $data{'borrowernumber'} && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
424
        if ( exists $data{'borrowernumber'} && C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
425
            NLSync({ 'borrowernumber' => $borrowernumber });
425
            NLSync({ 'borrowernumber' => $borrowernumber });
426
        }
426
        }
427
	} elsif ($op eq 'save'){ 
427
	} elsif ($op eq 'save'){ 
Lines 479-485 if ($op eq "modify") { Link Here
479
        $template->param( categorycode => $borrower_data->{'categorycode'} );
479
        $template->param( categorycode => $borrower_data->{'categorycode'} );
480
    }
480
    }
481
    # Add sync data to the user data
481
    # Add sync data to the user data
482
    if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
482
    if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
483
        my $sync = NLGetSyncDataFromBorrowernumber( $borrowernumber );
483
        my $sync = NLGetSyncDataFromBorrowernumber( $borrowernumber );
484
        if ( $sync ) {
484
        if ( $sync ) {
485
            $template->param(
485
            $template->param(
(-)a/members/moremember.pl (-2 / +2 lines)
Lines 54-60 use List::MoreUtils qw/uniq/; Link Here
54
use C4::Members::Attributes qw(GetBorrowerAttributes);
54
use C4::Members::Attributes qw(GetBorrowerAttributes);
55
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
55
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
56
use Module::Load;
56
use Module::Load;
57
if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
57
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
58
    load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
58
    load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
59
}
59
}
60
#use Smart::Comments;
60
#use Smart::Comments;
Lines 295-301 else { Link Here
295
}
295
}
296
296
297
# Add sync data to the user data
297
# Add sync data to the user data
298
if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
298
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
299
    my $sync = NLGetSyncDataFromBorrowernumber( $borrowernumber );
299
    my $sync = NLGetSyncDataFromBorrowernumber( $borrowernumber );
300
    if ( $sync ) {
300
    if ( $sync ) {
301
        $data->{'sync'}       = $sync->sync;
301
        $data->{'sync'}       = $sync->sync;
(-)a/misc/cronjobs/nl-sync-from-koha.pl (-1 / +18 lines)
Lines 46-51 This script performs the following steps: Link Here
46
46
47
=head2 Check sysprefs
47
=head2 Check sysprefs
48
48
49
Check that the necessary sysprefs are set before proceeding.
50
49
=cut
51
=cut
50
52
51
my $check_result = NLCheckSysprefs();
53
my $check_result = NLCheckSysprefs();
Lines 62-67 unless ( $run ) { Link Here
62
64
63
=head2 Find patrons that need to be synced
65
=head2 Find patrons that need to be synced
64
66
67
Patrons with either of these statuses:
68
69
=over 4
70
71
=item * edited
72
73
=item * new
74
75
=item * deleted
76
77
=back
78
65
=cut
79
=cut
66
80
67
my @needs_sync = Koha::Database->new->schema->resultset('BorrowerSync')->search({
81
my @needs_sync = Koha::Database->new->schema->resultset('BorrowerSync')->search({
Lines 78-83 my @needs_sync = Koha::Database->new->schema->resultset('BorrowerSync')->search( Link Here
78
92
79
=head2 Do the actual sync
93
=head2 Do the actual sync
80
94
95
Data is synced to NL with NLSync.
96
81
=cut
97
=cut
82
98
83
my $sync_success = 0;
99
my $sync_success = 0;
Lines 106-111 foreach my $borrower ( @needs_sync ) { Link Here
106
122
107
=head2 Summarize if verbose mode is enabled
123
=head2 Summarize if verbose mode is enabled
108
124
125
Specify -v on the command line to get a summary of the syncing operations.
126
109
=cut
127
=cut
110
128
111
if ( $verbose ) {
129
if ( $verbose ) {
112
- 

Return to bug 11401