Bug 25996: Add logging to restrictions actions

This patch adds logging for the following actions:

* CREATE_RESTRICITON
* MODIFY_RESTRICTION
* DELETE_RESTRICTION

To test:
1. Apply the unit tests
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Patron/Borrower_Debarments.t
=> FAIL: The feature is not implemented! Nothing is logged!
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Tomás Cohen Arazi 2024-04-22 01:04:31 -03:00 committed by Katrin Fischer
parent 96f5240601
commit 00ec0035cf
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -20,6 +20,7 @@ package Koha::Patron::Debarments;
use Modern::Perl;
use C4::Context;
use C4::Log qw( logaction );
use Koha::Patron::Restriction::Types;
use Koha::Patron::Restrictions;
@ -86,6 +87,9 @@ sub AddDebarment {
UpdateBorrowerDebarmentFlags($borrowernumber);
logaction( "MEMBERS", "CREATE_RESTRICTION", $borrowernumber, $restriction )
if C4::Context->preference("BorrowersLog");
return $restriction ? 1 : 0;
}
@ -108,6 +112,9 @@ sub DelDebarment {
UpdateBorrowerDebarmentFlags($borrowernumber);
logaction( "MEMBERS", "DELETE_RESTRICTION", $borrowernumber, q{} )
if C4::Context->preference("BorrowersLog");
return $r;
}
@ -149,7 +156,13 @@ sub ModDebarment {
my $r = C4::Context->dbh->do( $sql, {}, ( @values, $borrower_debarment_id ) );
UpdateBorrowerDebarmentFlags( _GetBorrowernumberByDebarmentId($borrower_debarment_id) );
my $borrowernumber = _GetBorrowernumberByDebarmentId($borrower_debarment_id);
UpdateBorrowerDebarmentFlags($borrowernumber);
logaction(
"MEMBERS", "MODIFY_RESTRICTION", $borrowernumber,
Koha::Patron::Restrictions->find($borrower_debarment_id)
) if C4::Context->preference("BorrowersLog");
return $r;
}