@@ -, +, @@ --- C4/Log.pm | 3 +- .../intranet-tmpl/prog/en/modules/tools/viewlog.tt | 85 +------------------ t/db_dependent/Log.t | 52 ++++++++++++ tools/viewlog.pl | 6 +- 4 files changed, 64 insertions(+), 82 deletions(-) create mode 100644 t/db_dependent/Log.t --- a/C4/Log.pm +++ a/C4/Log.pm @@ -4,6 +4,7 @@ package C4::Log; # Copyright 2000-2002 Katipo Communications +# Copyright 2011 MJ Ray and software.coop # # This file is part of Koha. # @@ -217,7 +218,7 @@ sub GetLogs { $query .= " AND user = ? "; push(@parameters,$user); } - if(scalar @$modules > 1 or @$modules[0] ne "") { + if($modules && scalar(@$modules)) { $query .= " AND module IN (".join(",",map {"?"} @$modules).") "; push(@parameters,@$modules); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -59,11 +59,11 @@
  • @@ -133,81 +133,6 @@ - [% IF ( do_it ) %] - [% IF ( total ) %] -

    [% total %] lines found.

    - - - - - - - - - - [% FOREACH loopro IN looprow %] - [% UNLESS ( loop.odd ) %][% ELSE %][% END %] - - - - - - - - [% END %] -
    DateLibrarianModuleActionObjectInfo
    [% loopro.timestamp %] - [% loopro.user %] - [% loopro.module %][% loopro.action %] - [% IF ( module == 'MEMBERS' ) %] - member [% loopro.object %] - [% ELSE %] - [% IF ( module == 'CIRCULATION' ) %] - - [% IF ( loopro.object ) %] - member [% loopro.object %] - [% END %] - - [% ELSE %] - [% IF ( module == 'CATALOGUING' ) %] - [% IF ( info == 'item' ) %] - Item [% loopro.object %] - [% ELSE %] - biblio [% loopro.object %] - [% END %] - [% ELSE %] - [% IF ( module == 'SERIAL' ) %] - [% loopro.object %] - [% ELSE %] - [% IF ( module == 'AUTHORITIES' ) %] - auth [% loopro.object %] - [% ELSE %] - [% loopro.object %] - [% END %] - [% END %] - [% END %] - [% END %] - [% END %] - - [% IF ( loopro.CIRCULATION ) %] - biblio [% loopro.info |html %] - [% ELSE %] - [% loopro.info |html %] - [% END %] -
    - [% ELSE %] -
    - No log found - [% IF ( CATALOGUING ) %] - for Bibliographic Record [% object %] - [% END %] - [% IF ( MEMBERS ) %] - for [% firstname %] [% surname %] ([% cardnumber %]) - [% END %] - . -
    - [% END %] - [% END %] - [% END %] [% IF ( do_it ) %] --- a/t/db_dependent/Log.t +++ a/t/db_dependent/Log.t @@ -0,0 +1,52 @@ +#!/usr/bin/perl +# +# Copyright 2011 MJ Ray and software.coop +# This Koha test module is a stub! +# Add more tests here!!! + +use strict; +use warnings; +use Test::More tests => 5; +use C4::Log; + +BEGIN { + use_ok('C4::Log'); +} +my $success; + +eval { + # FIXME: are we sure there is an member number 1? + # FIXME: can we remove this log entry somehow? + logaction("MEMBERS","MODIFY",1,"test operation"); + $success = 1; +} or do { + diag($@); + $success = 0; +}; +ok($success, "logaction seemed to work"); + +eval { + # FIXME: US formatted date hardcoded into test for now + $success = scalar(@{GetLogs("","","",undef,undef,"","")}); +} or do { + diag($@); + $success = 0; +}; +ok($success, "GetLogs returns results for an open search"); + +eval { + # FIXME: US formatted date hardcoded into test for now + $success = scalar(@{GetLogs("09/01/2011","10/01/2011","",undef,undef,"","")}); +} or do { + diag($@); + $success = 0; +}; +ok($success, "GetLogs accepts dates in an All-matching search"); + +eval { + $success = scalar(@{GetLogs("","","",["MEMBERS"],["MODIFY"],1,"")}); +} or do { + diag($@); + $success = 0; +}; +ok($success, "GetLogs seemed to find ".$success." like our test record in a tighter search"); --- a/tools/viewlog.pl +++ a/tools/viewlog.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl # Copyright 2010 BibLibre +# Copyright 2011 MJ Ray and software.coop # # This file is part of Koha. # @@ -105,7 +106,10 @@ $template->param( if ($do_it) { my @data; - my $results = GetLogs($datefrom,$dateto,$user,\@modules,\@action,$object,$info); + my ($results,$modules,$action); + if ($action[0] ne '') { $action = \@action; } # match All means no limit + if ($modules[0] ne '') { $modules = \@modules; } # match All means no limit + $results = GetLogs($datefrom,$dateto,$user,$modules,$action,$object,$info); @data=@$results; my $total = scalar @data; foreach my $result (@data){ --