From f77d3318965091da9d2c0004835fc9209884dd34 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 22 Apr 2024 01:04:31 -0300 Subject: [PATCH] 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 --- Koha/Patron/Debarments.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Koha/Patron/Debarments.pm b/Koha/Patron/Debarments.pm index 2ac587307f..8890fedf4f 100644 --- a/Koha/Patron/Debarments.pm +++ b/Koha/Patron/Debarments.pm @@ -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; } -- 2.39.2