View | Details | Raw Unified | Return to bug 11998
Collapse All | Expand All

(-)a/C4/Context.pm (-3 / +3 lines)
Lines 103-109 use ZOOM; Link Here
103
use XML::Simple;
103
use XML::Simple;
104
use C4::Boolean;
104
use C4::Boolean;
105
use C4::Debug;
105
use C4::Debug;
106
use C4::Log qw/ logaction /;
106
use C4::LogStatic qw/ logaction /;
107
use Koha::Cache;
107
use Koha::Cache;
108
use POSIX ();
108
use POSIX ();
109
use DateTime::TimeZone;
109
use DateTime::TimeZone;
Lines 660-666 ON DUPLICATE KEY UPDATE value = VALUES(value)'; Link Here
660
    my $sth = $dbh->prepare($query);
660
    my $sth = $dbh->prepare($query);
661
    if ( $sth->execute(@params) ) {
661
    if ( $sth->execute(@params) ) {
662
        $syspref_cache->set_in_cache("syspref_$var", $value) if $use_syspref_cache;
662
        $syspref_cache->set_in_cache("syspref_$var", $value) if $use_syspref_cache;
663
        logaction( 'SYSTEMPREFERENCE', $logtype, undef, $var . " | " . $value );
663
        logaction( $dbh, userenv(), 'SYSTEMPREFERENCE', $logtype, undef, $var . " | " . $value );
664
    }
664
    }
665
    $sth->finish;
665
    $sth->finish;
666
}
666
}
Lines 685-691 sub delete_preference { Link Here
685
    my $res = $sth->execute($var);
685
    my $res = $sth->execute($var);
686
    if ($res) {
686
    if ($res) {
687
        $syspref_cache->clear_from_cache("syspref_$var") if $use_syspref_cache;
687
        $syspref_cache->clear_from_cache("syspref_$var") if $use_syspref_cache;
688
        logaction( 'SYSTEMPREFERENCE', 'DELETE', undef,
688
        logaction( $dbh, userenv(), 'SYSTEMPREFERENCE', 'DELETE', undef,
689
            $var . " | " . ( $val // 'undefined' ) );
689
            $var . " | " . ( $val // 'undefined' ) );
690
        return 1;
690
        return 1;
691
    }
691
    }
(-)a/C4/LogStatic.pm (-1 / +96 lines)
Line 0 Link Here
0
- 
1
package C4::LogStatic;
2
3
# This is a very simple logging system, designed to be only used in
4
# circumstances where C4::Context can't be loaded. Typically, this is
5
# only in C4::Context itself.
6
#
7
# This is intended to be temporary until C4::Context gets refactored to not
8
# handle things like sysprefs that need logged about.
9
10
11
# Copyright 2000-2002 Katipo Communications
12
# Copyright 2011 MJ Ray and software.coop
13
# Copyright 2014 Catalyst IT
14
#
15
# This file is part of Koha.
16
#
17
# Koha is free software; you can redistribute it and/or modify it under the
18
# terms of the GNU General Public License as published by the Free Software
19
# Foundation; either version 2 of the License, or (at your option) any later
20
# version.
21
#
22
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
23
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
24
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
25
#
26
# You should have received a copy of the GNU General Public License along
27
# with Koha; if not, write to the Free Software Foundation, Inc.,
28
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29
30
use strict;
31
use warnings;
32
33
use vars qw($VERSION @ISA @EXPORT);
34
35
BEGIN {
36
    # set the version for version checking
37
    $VERSION = 3.07.00.049;
38
    require Exporter;
39
    @ISA = qw(Exporter);
40
    @EXPORT = qw(&logaction);
41
}
42
43
=head1 NAME
44
45
C4::LogStatic - basic logging function for Koha.
46
47
=head1 SYNOPSIS
48
49
  use C4::LogStatic;
50
  logaction($dbh, $userenv, "module", "action", $objectnum, "what happened");
51
52
=head1 DESCRIPTION
53
54
This allows simple logging in situtations where C4::Context can't be loaded.
55
56
=head1 FUNCTIONS
57
58
=over 2
59
60
=item logaction
61
62
  logaction($dbh, $userenv, $modulename, $actionname, $objectnumber, $infos);
63
64
Adds a record into action_logs table to report the different changes upon the database.
65
Each log entry includes the number of the user currently logged in.  For batch
66
jobs, which operate without authenticating a user and setting up a session, the user
67
number is set to 0, which is the same as the superlibrarian's number.
68
69
=cut
70
71
#'
72
sub logaction {
73
    my ($dbh, $userenv, $modulename, $actionname, $objectnumber, $infos)=@_;
74
75
    # Get ID of logged in user.  if called from a batch job,
76
    # no user session exists and C4::Context->userenv() returns
77
    # the scalar '0'.
78
    my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : 0;
79
    $usernumber ||= 0;
80
81
    my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,object,info) values (now(),?,?,?,?,?)");
82
    $sth->execute($usernumber,$modulename,$actionname,$objectnumber,$infos);
83
    $sth->finish;
84
}
85
86
87
1;
88
__END__
89
90
=back
91
92
=head1 AUTHOR
93
94
Koha Development Team <http://koha-community.org/>
95
96
=cut

Return to bug 11998