[Koha-patches] [Signed Off] [PATCH] Bug 6022: Auth_with_ldap check if categorycode is valid
Chris Cormack
chrisc at catalyst.net.nz
Tue May 17 12:39:27 CEST 2011
From: Dobrica Pavlinusic <dpavlin at rot13.org>
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
Signed-off-by: Chris Cormack <chrisc at catalyst.net.nz>
---
C4/Auth_with_ldap.pm | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm
index acbd923..ef4a732 100644
--- a/C4/Auth_with_ldap.pm
+++ b/C4/Auth_with_ldap.pm
@@ -221,6 +221,19 @@ sub ldap_entry_2_hash ($$) {
( substr($borrower{'firstname'},0,1)
. substr($borrower{ 'surname' },0,1)
. " ");
+
+ # XXX 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 upper(categorycode) = upper(?)");
+ $sth->execute( $borrower{'categorycode'} );
+ if ( my $row = $sth->fetchrow_hashref ) {
+
+ } else {
+ my $default = $mapping{'categorycode'}->{content};
+ warn "Can't find ", $borrower{'categorycode'}, " default to: $default for ", $borrower{userid};
+ $borrower{'categorycode'} = $default
+ }
+
return %borrower;
}
--
1.7.4.1
More information about the Koha-patches
mailing list