Bugzilla – Attachment 93768 Details for
Bug 11808
When searching for a cardnumber in the intranet, also try to search for it on the LDAP server if one is configured and add/update user
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11808: (QA follow-up) Adds a third option to SearchCardnumberWithLDAP and other fixes
Bug-11808-QA-follow-up-Adds-a-third-option-to-Sear.patch (text/plain), 11.48 KB, created by
Maryse Simard
on 2019-10-04 21:48:50 UTC
(
hide
)
Description:
Bug 11808: (QA follow-up) Adds a third option to SearchCardnumberWithLDAP and other fixes
Filename:
MIME Type:
Creator:
Maryse Simard
Created:
2019-10-04 21:48:50 UTC
Size:
11.48 KB
patch
obsolete
>From b1541c7da575be447ab9e483aad6675c908250c9 Mon Sep 17 00:00:00 2001 >From: Maryse Simard <maryse.simard@inlibro.com> >Date: Fri, 4 Oct 2019 11:37:47 -0400 >Subject: [PATCH] Bug 11808: (QA follow-up) Adds a third option to > SearchCardnumberWithLDAP and other fixes > >This patch does a few things: > >- Adds a third option to the new system preference to choose between: > never use ldap, > make a request (and add) only when no patron is found, > and always make a request (add/update). >- Adds search and update with ldap in the case the patron is found >by it's cardnumber in circulation. >- Use Patron object in the new subs in C4/Auth_with_ldap.pm. > >To test: >0. You need to have an ldap server containing patron informations >configured in Koha. > >1. Apply patch and update database. > >2. Check that the new system preference SearchCardnumberWithLDAP has >been added and set as 'never'. > >3. Choose a patron who exists in your ldap server but not in Koha. >(you can delete an existing patron from Koha if needed) > >4. Search for the patron by both it's cardnumber and any other >attributes (results should be the same in both case) in the search >bar in circ/circulation.pl.Do not choose from the dropdown list, >use the submit button. > => Should return cardnumber not found > >5. Change SearchCardnumberWithLDAP to 'if not found locally'. > >6. Repeat step 4. > => The patron should be added to Koha. > >7. Edit the patron and change any of the existing information. > >8. Repeat step 4. > => The patron has not been updated (the change made in step 7 is > still there) > >9. Change SearchCardnumberWithLDAP to 'always'. > >10. Repeat step 4. > => The patron has been updated. Change made in step 7 has been > rewritten and patron informations is the same as in step 6. >--- > C4/Auth_with_ldap.pm | 6 +++--- > circ/circulation.pl | 15 ++++++++++++--- > installer/data/mysql/atomicupdate/bug_11808.perl | 10 ++++++++++ > .../bug_11808_SearchCardnumberWithLDAP_sys_pref.sql | 2 -- > installer/data/mysql/sysprefs.sql | 4 ++-- > .../prog/en/modules/admin/preferences/patrons.pref | 7 ++++--- > .../intranet-tmpl/prog/en/modules/circ/circulation.tt | 7 ++++++- > 7 files changed, 37 insertions(+), 14 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_11808.perl > delete mode 100644 installer/data/mysql/atomicupdate/bug_11808_SearchCardnumberWithLDAP_sys_pref.sql > >diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm >index 3a707ee..57faab9 100644 >--- a/C4/Auth_with_ldap.pm >+++ b/C4/Auth_with_ldap.pm >@@ -398,8 +398,8 @@ sub update_local { > > # Subroutine to update a user with LDAP using its cardnumber. > sub updateborrower_ldap { >- my $local_borrower = shift; >- my $cardnumber = $local_borrower->{'cardnumber'}; >+ my $patron = shift; >+ my $cardnumber = $patron->cardnumber; > > return 0 unless ($config{update}); > >@@ -425,7 +425,7 @@ sub updateborrower_ldap { > if ($count == 1) { > # User was found, update! > my %borrower = ldap_entry_2_hash($search->shift_entry,$cardnumber); >- &update_local($local_borrower->{userid},$local_borrower->{password},$local_borrower->{borrowernumber},\%borrower); >+ &update_local($patron->userid, $patron->password, $patron->borrowernumber, \%borrower); > > return 1; > } >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 10338f6..fd23f1d 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -252,6 +252,11 @@ if ($findborrower) { > my $patron = Koha::Patrons->find( { cardnumber => $findborrower } ); > if ( $patron ) { > $borrowernumber = $patron->borrowernumber; >+ # Update the user with LDAP if we need to >+ if(C4::Context->config('useldapserver') and C4::Context->preference("SearchCardnumberWithLDAP") eq "always") { >+ my ($result, $ldap_error) = C4::Auth_with_ldap::updateborrower_ldap($patron); >+ $template->param(ldap_error => $ldap_error) if $ldap_error; >+ } > } else { > my $dt_params = { iDisplayLength => -1 }; > my $results = C4::Utils::DataTables::Members::search( >@@ -265,8 +270,9 @@ if ($findborrower) { > if ( scalar @$borrowers == 1 ) { > $borrowernumber = $borrowers->[0]->{borrowernumber}; > # Update the user with LDAP if we need to >- if(C4::Context->config('useldapserver') and C4::Context->preference("SearchCardnumberWithLDAP")) { >- my ($result, $ldap_error) = C4::Auth_with_ldap::updateborrower_ldap($borrowers->[0]); >+ if(C4::Context->config('useldapserver') and C4::Context->preference("SearchCardnumberWithLDAP") eq "always") { >+ my $patron_obj = Koha::Patrons->find( $borrowernumber ); >+ my ($result, $ldap_error) = C4::Auth_with_ldap::updateborrower_ldap($patron_obj); > $template->param(ldap_error => $ldap_error) if $ldap_error; > } > $query->param( 'borrowernumber', $borrowernumber ); >@@ -275,8 +281,11 @@ if ($findborrower) { > # Try to find a user using LDAP if we couldn't find it locally > my $borrowernumber_ldap; > my $ldap_error; >- if (C4::Context->config('useldapserver') and C4::Context->preference("SearchCardnumberWithLDAP")) { >+ if (C4::Context->config('useldapserver') and >+ (C4::Context->preference("SearchCardnumberWithLDAP") eq "always" or C4::Context->preference("SearchCardnumberWithLDAP") eq "not_found") >+ ) { > ($borrowernumber_ldap, $ldap_error) = C4::Auth_with_ldap::findcardnumber_ldap($findborrower); >+ $template->param(ldap_error => $ldap_error) if $ldap_error; > } > > if ($borrowernumber_ldap) { >diff --git a/installer/data/mysql/atomicupdate/bug_11808.perl b/installer/data/mysql/atomicupdate/bug_11808.perl >new file mode 100644 >index 0000000..f871d28 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_11808.perl >@@ -0,0 +1,10 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{ >+ INSERT INTO systempreferences (variable,value,explanation,options,type) >+ 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'); >+ }); >+ >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug 11808 - Search cardnumber on the LDAP server if one is configured and add/update user.)\n"; >+} >\ No newline at end of file >diff --git a/installer/data/mysql/atomicupdate/bug_11808_SearchCardnumberWithLDAP_sys_pref.sql b/installer/data/mysql/atomicupdate/bug_11808_SearchCardnumberWithLDAP_sys_pref.sql >deleted file mode 100644 >index 5ccf071..0000000 >--- a/installer/data/mysql/atomicupdate/bug_11808_SearchCardnumberWithLDAP_sys_pref.sql >+++ /dev/null >@@ -1,2 +0,0 @@ >-INSERT INTO systempreferences (variable,value,explanation,options,type) >-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'); >\ No newline at end of file >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 08c6a00..433f5d7 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -533,6 +533,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('SCOMainUserBlock','','70|10','Add a block of HTML that will display on the self checkout screen','Textarea'), > ('SCOUserCSS','',NULL,'Add CSS to be included in the SCO module in an embedded <style> tag.','free'), > ('SCOUserJS','',NULL,'Define custom javascript for inclusion in the SCO module','free'), >+('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'), > ('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'), > ('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'), > ('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'), >@@ -671,6 +672,5 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('XSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages display on intranet','Free'), > ('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'), > ('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'), >-('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'), >-('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') >+('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo') > ; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index 6b4d3ca..9b6a622 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -164,9 +164,10 @@ Patrons: > - > - pref: SearchCardnumberWithLDAP > choices: >- yes: Do >- no: "Don't" >- - 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. >+ always: Always >+ not_found: If not found locally, >+ never: Never >+ - "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." > - > - pref: TalkingTechItivaPhoneNotification > choices: >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index ade5425..4601efd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -477,9 +477,14 @@ > <p>Item checked out</p> > [% END %] > >+ [% IF (ldap_error) %] >+ <div class="dialog alert"> >+ [% IF ( ldap_error ) %]<h4><span>An error occured while trying to contact the LDAP server : [% ldap_error | html %]</span></h4>[% END %] >+ </div> >+ [% END %] >+ > [% IF ( message ) %] > [% INCLUDE 'patron-toolbar.inc' %] >- [% IF ( ldap_error ) %]<h4><span>An error occured while trying to contact the LDAP server : [% ldap_error %]</span></h4>[% END %] > <h4>No patron matched <span class="ex">[% message | html %]</span></h4> > [% END %] > >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11808
:
25527
|
26374
|
60562
|
93767
|
93768
|
95573
|
144823
|
144826
|
162857
|
166773
|
173237
|
174288