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 Signed-off-by: Nicole C Engard <nengard@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
8a135fd21a
commit
baeba970f7
13
C4/Log.pm
13
C4/Log.pm
|
|
@ -67,7 +67,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
|
||||
|
|
@ -75,10 +75,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;
|
||||
|
||||
my $logger = Koha::Logger->get(
|
||||
|
|
@ -240,6 +241,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;
|
||||
|
|
@ -281,6 +283,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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue