use Text::Unaccent qw( unac_string );
use Koha::AuthUtils qw(hash_password);
use Koha::Database;
-use Module::Load;
-if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
- load Koha::NorwegianPatronDB, qw( NLUpdateHashedPIN NLEncryptPIN NLSync );
-}
+require Koha::NorwegianPatronDB;
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
} else {
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
# Update the hashed PIN in borrower_sync.hashed_pin, before Koha hashes it
- NLUpdateHashedPIN( $data{'borrowernumber'}, $data{password} );
+ Koha::NorwegianPatronDB::NLUpdateHashedPIN( $data{'borrowernumber'}, $data{password} );
}
$data{password} = hash_password($data{password});
}
# Set the value of 'sync'
$borrowersync->update( { 'sync' => $data{'sync'} } );
# Try to do the live sync
- NLSync({ 'borrowernumber' => $data{'borrowernumber'} });
+ Koha::NorwegianPatronDB::NLSync({ 'borrowernumber' => $data{'borrowernumber'} });
}
logaction("MEMBERS", "MODIFY", $data{'borrowernumber'}, "UPDATE (executed w/ arg: $data{'borrowernumber'})") if C4::Context->preference("BorrowersLog");
'synctype' => 'norwegianpatrondb',
'sync' => 1,
'syncstatus' => 'new',
- 'hashed_pin' => NLEncryptPIN( $plain_text_password ),
+ 'hashed_pin' => Koha::NorwegianPatronDB::NLEncryptPIN( $plain_text_password ),
});
}
SELECT *
FROM accountlines
WHERE borrowernumber=?);
- $strsth.=" ORDER BY date desc,timestamp DESC";
+ $strsth.=" ORDER BY accountlines_id desc";
my $sth= $dbh->prepare( $strsth );
$sth->execute( $borrowernumber );
return $sth->rows;
}
+=head2 HandleDelBorrower
+
+ HandleDelBorrower($borrower);
+
+When a member is deleted (DelMember in Members.pm), you should call me first.
+This routine deletes/moves lists and entries for the deleted member/borrower.
+Lists owned by the borrower are deleted, but entries from the borrower to
+other lists are kept.
+
+=cut
+
+sub HandleDelBorrower {
+ my ($borrower)= @_;
+ my $query;
+ my $dbh = C4::Context->dbh;
+
+ #Delete all lists and all shares of this borrower
+ #Consistent with the approach Koha uses on deleting individual lists
+ #Note that entries in virtualshelfcontents added by this borrower to
+ #lists of others will be handled by a table constraint: the borrower
+ #is set to NULL in those entries.
+ $query="DELETE FROM virtualshelves WHERE owner=?";
+ $dbh->do($query,undef,($borrower));
+
+ #NOTE:
+ #We could handle the above deletes via a constraint too.
+ #But a new BZ report 11889 has been opened to discuss another approach.
+ #Instead of deleting we could also disown lists (based on a pref).
+ #In that way we could save shared and public lists.
+ #The current table constraints support that idea now.
+ #This pref should then govern the results of other routines/methods such as
+ #Koha::Virtualshelf->new->delete too.
+}
+
=head2 ExtendMemberSubscriptionTo (OUEST-PROVENCE)
$date = ExtendMemberSubscriptionTo($borrowerid, $date);