Adding Log Facility.
[koha.git] / C4 / Log.pm
1 package C4::Log; #assumes C4/Log
2
3 #package to deal with Logging Actions in DB
4
5
6 # Copyright 2000-2002 Katipo Communications
7 #
8 # This file is part of Koha.
9 #
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
14 #
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA  02111-1307 USA
22
23 use strict;
24 use C4::Context;
25
26 require Exporter;
27
28 use vars qw($VERSION @ISA @EXPORT);
29
30 # set the version for version checking
31 $VERSION = 0.01;
32
33 =head1 NAME
34
35 C4::Log - Koha Log Facility functions
36
37 =head1 SYNOPSIS
38
39   use C4::Log;
40
41 =head1 DESCRIPTION
42
43 The functions in this module perform various functions in order to log all the operations done on the Database, including deleting and undeleting books, adding/editing members, etc.
44
45 =head1 FUNCTIONS
46
47 =over 2
48
49 =cut
50
51 @ISA = qw(Exporter);
52 @EXPORT = qw(&logaction &logstatus);
53
54 =item logaction
55
56   &logaction($usernumber, $modulename, $actionname, $infos);
57
58 Adds a record into action_logs table to report the different changes upon the database
59
60 =cut
61 #'
62 sub logaction{
63   my ($usernumber,$modulename, $actionname, $infos)=@_;
64         my $dbh = C4::Context->dbh;
65         my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,info) values (now(),?,?,?,?)");
66         $sth->execute($usernumber,$modulename,$actionname,$infos);
67         $sth->finish;
68 }
69
70 =item logstatus
71
72   &logstatus;
73
74 returns True If Activate_Log variable is equal to On
75 Activate_Log is a system preference Variable
76 =cut
77 #'
78 sub logstatus{
79   my ($usernumber,$modulename, $actionname, $infos)=@_;
80         my $dbh = C4::Context->dbh;
81         my $sth=$dbh->prepare("select value from systempreferences where variable='Activate_Log'");
82         $sth->execute;
83         my ($var)=$sth->fetchrow;
84         $sth->finish;
85         return ($var eq "On"?"True":"")
86 }
87
88 END { }       # module clean-up code here (global destructor)
89
90 1;
91 __END__
92
93 =back
94
95 =head1 AUTHOR
96
97 Koha Developement team <info@koha.org>
98
99 =cut