From cd2ec22cea9ede06def546bffb2faad1a6ac4a21 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 1 Jul 2016 18:26:13 -0300 Subject: [PATCH] Bug 16829: make logaction and GetLogs aware of the interface column This patch changes the logaction API so it accepts a new 'interface' param. Current code calling logaction is not changed, and this parameter can be ommited in most contexts, and it will correctly fall-back to C4::Context->interface. Unit tests are provided on a different patch. GetLogs gets patched as well, so it can be required to filter by 'interface' param. Sponsored-by: NEKLS --- C4/Log.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/C4/Log.pm b/C4/Log.pm index de5f1d0..0ee08cf 100644 --- a/C4/Log.pm +++ b/C4/Log.pm @@ -64,7 +64,7 @@ number is set to 0, which is the same as the superlibrarian's number. #' sub logaction { - my ($modulename, $actionname, $objectnumber, $infos)=@_; + my ($modulename, $actionname, $objectnumber, $infos, $interface)=@_; # Get ID of logged in user. if called from a batch job, # no user session exists and C4::Context->userenv() returns @@ -72,10 +72,11 @@ sub logaction { my $userenv = C4::Context->userenv(); my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : 0; $usernumber ||= 0; + $interface //= C4::Context->interface; my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,object,info) values (now(),?,?,?,?,?)"); - $sth->execute($usernumber,$modulename,$actionname,$objectnumber,$infos); + my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,object,info,interface) values (now(),?,?,?,?,?,?)"); + $sth->execute($usernumber,$modulename,$actionname,$objectnumber,$infos,$interface); $sth->finish; } @@ -217,6 +218,7 @@ sub GetLogs { my $action = shift; my $object = shift; my $info = shift; + my $interfaces = shift; my $iso_datefrom = $datefrom ? output_pref({ dt => dt_from_string( $datefrom ), dateformat => 'iso', dateonly => 1 }) : undef; my $iso_dateto = $dateto ? output_pref({ dt => dt_from_string( $dateto ), dateformat => 'iso', dateonly => 1 }) : undef; @@ -258,6 +260,11 @@ sub GetLogs { $query .= " AND info LIKE ? "; push( @parameters, "%" . $info . "%" ); } + if ( $interfaces && scalar(@$interfaces) ) { + $query .= + " AND interface IN (" . join( ",", map { "?" } @$interfaces ) . ") "; + push( @parameters, @$interfaces ); + } my $sth = $dbh->prepare($query); $sth->execute(@parameters); -- 2.9.0