When importing users from LDAP, Auth_with_ldap.pm doesn't check if value for
categorycode is present in categories table in Koha resulting in referential
integrity error instead of using default value from koha-conf.xml
---
C4/Auth_with_ldap.pm | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm
index 5baa07f..671d291 100644
--- a/C4/Auth_with_ldap.pm
+++ b/C4/Auth_with_ldap.pm
@@ -228,6 +228,17 @@ sub ldap_entry_2_hash ($$) {
( substr($borrower{'firstname'},0,1)
. substr($borrower{ 'surname' },0,1)
. " ");
+
+ # check if categorycode exists, if not, fallback to default from
koha-conf.xml
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("SELECT categorycode FROM categories WHERE
categorycode = ?");
+ $sth->execute( uc($borrower{'categorycode'}) );
+ unless ( my $row = $sth->fetchrow_hashref ) {
+ my $default = $mapping{'categorycode'}->{content};
+ $debug && warn "Can't find ", $borrower{'categorycode'}, "
default to: $default for ", $borrower{userid};
+ $borrower{'categorycode'} = $default
+ }
+
return %borrower;
}
--
1.7.2.5
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/