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

(-)a/C4/Auth_with_ldap.pm (-3 / +3 lines)
Lines 398-405 sub update_local { Link Here
398
398
399
# Subroutine to update a user with LDAP using its cardnumber.
399
# Subroutine to update a user with LDAP using its cardnumber.
400
sub updateborrower_ldap {
400
sub updateborrower_ldap {
401
    my $local_borrower = shift;
401
    my $patron = shift;
402
    my $cardnumber = $local_borrower->{'cardnumber'};
402
    my $cardnumber = $patron->cardnumber;
403
403
404
    return 0 unless ($config{update});
404
    return 0 unless ($config{update});
405
405
Lines 425-431 sub updateborrower_ldap { Link Here
425
    if ($count == 1) {
425
    if ($count == 1) {
426
        # User was found, update!
426
        # User was found, update!
427
        my %borrower = ldap_entry_2_hash($search->shift_entry,$cardnumber);
427
        my %borrower = ldap_entry_2_hash($search->shift_entry,$cardnumber);
428
        &update_local($local_borrower->{userid},$local_borrower->{password},$local_borrower->{borrowernumber},\%borrower);
428
        &update_local($patron->userid, $patron->password, $patron->borrowernumber, \%borrower);
429
429
430
        return 1;
430
        return 1;
431
    }
431
    }
(-)a/circ/circulation.pl (-3 / +12 lines)
Lines 252-257 if ($findborrower) { Link Here
252
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
252
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
253
    if ( $patron ) {
253
    if ( $patron ) {
254
        $borrowernumber = $patron->borrowernumber;
254
        $borrowernumber = $patron->borrowernumber;
255
        # Update the user with LDAP if we need to
256
        if(C4::Context->config('useldapserver') and C4::Context->preference("SearchCardnumberWithLDAP") eq "always") {
257
            my ($result, $ldap_error) = C4::Auth_with_ldap::updateborrower_ldap($patron);
258
            $template->param(ldap_error => $ldap_error) if $ldap_error;
259
        }
255
    } else {
260
    } else {
256
        my $dt_params = { iDisplayLength => -1 };
261
        my $dt_params = { iDisplayLength => -1 };
257
        my $results = C4::Utils::DataTables::Members::search(
262
        my $results = C4::Utils::DataTables::Members::search(
Lines 265-272 if ($findborrower) { Link Here
265
        if ( scalar @$borrowers == 1 ) {
270
        if ( scalar @$borrowers == 1 ) {
266
            $borrowernumber = $borrowers->[0]->{borrowernumber};
271
            $borrowernumber = $borrowers->[0]->{borrowernumber};
267
            # Update the user with LDAP if we need to
272
            # Update the user with LDAP if we need to
268
            if(C4::Context->config('useldapserver') and C4::Context->preference("SearchCardnumberWithLDAP")) {
273
            if(C4::Context->config('useldapserver') and C4::Context->preference("SearchCardnumberWithLDAP") eq "always") {
269
                my ($result, $ldap_error) = C4::Auth_with_ldap::updateborrower_ldap($borrowers->[0]);
274
                my $patron_obj = Koha::Patrons->find( $borrowernumber );
275
                my ($result, $ldap_error) = C4::Auth_with_ldap::updateborrower_ldap($patron_obj);
270
                $template->param(ldap_error => $ldap_error) if $ldap_error;
276
                $template->param(ldap_error => $ldap_error) if $ldap_error;
271
            }
277
            }
272
            $query->param( 'borrowernumber', $borrowernumber );
278
            $query->param( 'borrowernumber', $borrowernumber );
Lines 275-282 if ($findborrower) { Link Here
275
            # Try to find a user using LDAP if we couldn't find it locally
281
            # Try to find a user using LDAP if we couldn't find it locally
276
            my $borrowernumber_ldap;
282
            my $borrowernumber_ldap;
277
            my $ldap_error;
283
            my $ldap_error;
278
            if (C4::Context->config('useldapserver') and C4::Context->preference("SearchCardnumberWithLDAP")) {
284
            if (C4::Context->config('useldapserver') and
285
                (C4::Context->preference("SearchCardnumberWithLDAP") eq "always" or C4::Context->preference("SearchCardnumberWithLDAP") eq "not_found")
286
            ) {
279
                ($borrowernumber_ldap, $ldap_error) = C4::Auth_with_ldap::findcardnumber_ldap($findborrower);
287
                ($borrowernumber_ldap, $ldap_error) = C4::Auth_with_ldap::findcardnumber_ldap($findborrower);
288
                $template->param(ldap_error => $ldap_error) if $ldap_error;
280
            }
289
            }
281
290
282
            if ($borrowernumber_ldap) {
291
            if ($borrowernumber_ldap) {
(-)a/installer/data/mysql/atomicupdate/bug_11808.perl (+10 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{
4
        INSERT INTO systempreferences (variable,value,explanation,options,type)
5
        VALUES('SearchCardnumberWithLDAP', 'never', 'Search for a cardnumber with LDAP when searching for a patron that does not exist locally. If the cardnumber is found via LDAP, the user is added or updated.', 'always|not_found|never', 'Choice');
6
    });
7
8
    SetVersion( $DBversion );
9
    print "Upgrade to $DBversion done (Bug 11808 - Search cardnumber on the LDAP server if one is configured and add/update user.)\n";
10
}
(-)a/installer/data/mysql/atomicupdate/bug_11808_SearchCardnumberWithLDAP_sys_pref.sql (-2 lines)
Lines 1-2 Link Here
1
INSERT INTO systempreferences (variable,value,explanation,options,type)
2
VALUES('SearchCardnumberWithLDAP','','Search for a cardnumber with LDAP when trying to do a checkout with a cardnumber that does not exist locally. If the cardnumber is found via LDAP, the user is added locally.','','YesNo');
(-)a/installer/data/mysql/sysprefs.sql (-2 / +2 lines)
Lines 533-538 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
533
('SCOMainUserBlock','','70|10','Add a block of HTML that will display on the self checkout screen','Textarea'),
533
('SCOMainUserBlock','','70|10','Add a block of HTML that will display on the self checkout screen','Textarea'),
534
('SCOUserCSS','',NULL,'Add CSS to be included in the SCO module in an embedded <style> tag.','free'),
534
('SCOUserCSS','',NULL,'Add CSS to be included in the SCO module in an embedded <style> tag.','free'),
535
('SCOUserJS','',NULL,'Define custom javascript for inclusion in the SCO module','free'),
535
('SCOUserJS','',NULL,'Define custom javascript for inclusion in the SCO module','free'),
536
('SearchCardnumberWithLDAP', 'never', 'Search for a cardnumber with LDAP when searching for a patron that does not exist locally. If the cardnumber is found via LDAP, the user is added or updated.', 'always|not_found|never', 'Choice'),
536
('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'),
537
('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'),
537
('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
538
('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
538
('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
539
('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
Lines 671-676 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
671
('XSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages display on intranet','Free'),
672
('XSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages display on intranet','Free'),
672
('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'),
673
('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'),
673
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
674
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
674
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
675
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo')
675
('SearchCardnumberWithLDAP','','Search for a cardnumber with LDAP when trying to do a checkout with a cardnumber that does not exist locally. If the cardnumber is found via LDAP, the user is added locally.','','YesNo')
676
;
676
;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-3 / +4 lines)
Lines 164-172 Patrons: Link Here
164
     -
164
     -
165
         - pref: SearchCardnumberWithLDAP
165
         - pref: SearchCardnumberWithLDAP
166
           choices:
166
           choices:
167
               yes: Do
167
               always: Always
168
               no: "Don't"
168
               not_found: If not found locally,
169
         - search for a cardnumber with LDAP when trying to do a checkout with a cardnumber that doesn't exist locally. If the cardnumber is found via LDAP, the user is added locally. Note : This feature only works if auth_by_bind is disabled in koha-conf.xml.
169
               never: Never
170
         - "search cardnumbers on the LDAP server. If the cardnumber is found via LDAP, the user is added or updated locally. Note : This feature only works if auth_by_bind is disabled in koha-conf.xml."
170
     -
171
     -
171
         - pref: TalkingTechItivaPhoneNotification
172
         - pref: TalkingTechItivaPhoneNotification
172
           choices:
173
           choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-2 / +6 lines)
Lines 477-485 Link Here
477
                        <p>Item checked out</p>
477
                        <p>Item checked out</p>
478
                    [% END %]
478
                    [% END %]
479
479
480
                    [% IF (ldap_error) %]
481
                        <div class="dialog alert">
482
                            [% IF ( ldap_error ) %]<h4><span>An error occured while trying to contact the LDAP server : [% ldap_error | html %]</span></h4>[% END %]
483
                        </div>
484
                    [% END %]
485
480
                    [% IF ( message ) %]
486
                    [% IF ( message ) %]
481
                        [% INCLUDE 'patron-toolbar.inc' %]
487
                        [% INCLUDE 'patron-toolbar.inc' %]
482
                        [% IF ( ldap_error ) %]<h4><span>An error occured while trying to contact the LDAP server : [% ldap_error %]</span></h4>[% END %]
483
                        <h4>No patron matched <span class="ex">[% message | html %]</span></h4>
488
                        <h4>No patron matched <span class="ex">[% message | html %]</span></h4>
484
                    [% END %]
489
                    [% END %]
485
490
486
- 

Return to bug 11808