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 |