Adding an object field to action_logs.
+ Minor Correction to updatedatabase Changing Activate_Log from choice to YesNo Variable.
This commit is contained in:
parent
fa19e39d95
commit
e4a19baab6
67
C4/Log.pm
67
C4/Log.pm
|
|
@ -60,10 +60,10 @@ Adds a record into action_logs table to report the different changes upon the da
|
|||
=cut
|
||||
#'
|
||||
sub logaction{
|
||||
my ($usernumber,$modulename, $actionname, $infos)=@_;
|
||||
my ($usernumber,$modulename, $actionname, $objectnumber, $infos)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,info) values (now(),?,?,?,?)");
|
||||
$sth->execute($usernumber,$modulename,$actionname,$infos);
|
||||
my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,object,info) values (now(),?,?,?,?,?)");
|
||||
$sth->execute($usernumber,$modulename,$actionname,$objectnumber,$infos);
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
|
|
@ -76,15 +76,62 @@ Activate_Log is a system preference Variable
|
|||
=cut
|
||||
#'
|
||||
sub logstatus{
|
||||
my ($usernumber,$modulename, $actionname, $infos)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select value from systempreferences where variable='Activate_Log'");
|
||||
$sth->execute;
|
||||
my ($var)=$sth->fetchrow;
|
||||
$sth->finish;
|
||||
return ($var eq "On"?"True":"")
|
||||
return C4::Context->preference("Activate_Log");
|
||||
}
|
||||
|
||||
=item displaylog
|
||||
|
||||
&displaylog($modulename, @filters);
|
||||
$modulename is the name of the module on which the user wants to display logs
|
||||
@filters is an optional table of hash containing :
|
||||
- name : the name of the variable to filter
|
||||
- value : the value of the filter.... May be with * joker
|
||||
|
||||
returns a table of hash containing who did what on which object at what time
|
||||
|
||||
=cut
|
||||
#'
|
||||
sub displaylog{
|
||||
my ($modulename, @filters)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $strsth;
|
||||
if ($modulename eq "acqui.simple"){
|
||||
$strsth="select action_logs.timestamp, action_logs.action, borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.userid,";
|
||||
$strsth .= "biblio.biblionumber, biblio.title, biblio.author" ;#if ($modulename eq "acqui.simple");
|
||||
$strsth .= "FROM borrowers,action_logs ";
|
||||
$strsth .= ",biblio" ;#if ($modulename eq "acqui.simple");
|
||||
|
||||
$strsth .="WHERE borrowers.borrowernumber=action_logs.user";
|
||||
$strsth .= "AND action_logs.module = 'acqui.simple' AND action_logs.object=biblio.biblionumber ";# if ($modulename eq "acqui.simple");
|
||||
if (@filters){
|
||||
foreach my $filter (@filters){
|
||||
if ($filter->{name} =~ /user/){
|
||||
$filter->{value}=~s/\*/%/g;
|
||||
$strsth .= " AND borrowers.surname like ".$filter->{value};
|
||||
}elsif ($filter->{name} =~ /title/){
|
||||
$filter->{value}=~s/\*/%/g;
|
||||
$strsth .= " AND biblio.title like ".$filter->{value};
|
||||
}elsif ($filter->{name} =~ /author/){
|
||||
$filter->{value}=~s/\*/%/g;
|
||||
$strsth .= " AND biblio.author like ".$filter->{value};
|
||||
}
|
||||
}
|
||||
}
|
||||
} elsif ($modulename eq "acqui") {
|
||||
} elsif ($modulename eq "circ") {
|
||||
} elsif ($modulename eq "members"){
|
||||
}
|
||||
warn "displaylog :".$strsth;
|
||||
my $sth=$dbh->prepare($strsth);
|
||||
$sth->execute;
|
||||
my @results;
|
||||
my $count;
|
||||
while (my $data = $sth->fetchrow_hashref){
|
||||
push @results, $data;
|
||||
$count++;
|
||||
}
|
||||
return ($count, \@results);
|
||||
}
|
||||
END { } # module clean-up code here (global destructor)
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -429,10 +429,10 @@ if ($op eq "addbiblio") {
|
|||
if ($is_a_modif) {
|
||||
NEWmodbiblioframework($dbh,$bibid,$frameworkcode);
|
||||
NEWmodbiblio($dbh,$record,$bibid,$frameworkcode);
|
||||
logaction($loggedinuser,"acqui.simple","modify","biblionumber :$oldbiblionumber\nrecord : ".$record->as_formatted) if (logstatus);
|
||||
logaction($loggedinuser,"acqui.simple","modify",$oldbiblionumber,"record : ".$record->as_formatted) if (C4::Context->preference("Activate_Log"));
|
||||
} else {
|
||||
($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$record,$frameworkcode);
|
||||
logaction($loggedinuser,"acqui.simple","add","biblionumber :$oldbibnum\nrecord : ".$record->as_formatted) if (logstatus);
|
||||
logaction($loggedinuser,"acqui.simple","add",$oldbibnum,"record : ".$record->as_formatted) if (C4::Context->preference("Activate_Log"));
|
||||
}
|
||||
# now, redirect to additem page
|
||||
print $input->redirect("additem.pl?bibid=$bibid&frameworkcode=$frameworkcode");
|
||||
|
|
@ -485,7 +485,7 @@ if ($op eq "addbiblio") {
|
|||
} elsif ($op eq "delete") {
|
||||
#------------------------------------------------------------------------------------------------------------------------------
|
||||
&NEWdelbiblio($dbh,$bibid);
|
||||
logaction($loggedinuser,"acqui.simple","del","biblionumber :$bibid") if (logstatus);
|
||||
logaction($loggedinuser,"acqui.simple","del",$bibid,"") if (logstatus);
|
||||
|
||||
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=/cgi-bin/koha/search.marc/search.pl?type=intranet\"></html>";
|
||||
exit;
|
||||
|
|
|
|||
|
|
@ -388,6 +388,7 @@ my %requiretables = (
|
|||
`user` INT( 11 ) NOT NULL ,
|
||||
`module` TEXT default '',
|
||||
`action` TEXT default '' ,
|
||||
`object` INT(11) default '' ,
|
||||
`info` TEXT default '' ,
|
||||
PRIMARY KEY ( `timestamp` , `user` )
|
||||
)",
|
||||
|
|
@ -911,13 +912,12 @@ my %tabledata = (
|
|||
},
|
||||
{
|
||||
uniquefieldrequired => 'variable',
|
||||
variable => 'Acitvate_Log',
|
||||
variable => 'Activate_Log',
|
||||
value => 'On',
|
||||
forceupdate => { 'explanation' => 1,
|
||||
'type' => 1},
|
||||
explanation => 'Turn Log Actions on DB On an Off',
|
||||
type => 'Choice',
|
||||
options => 'On|Off'
|
||||
type => 'YesNo',
|
||||
},
|
||||
],
|
||||
|
||||
|
|
@ -1520,6 +1520,11 @@ $sth->finish;
|
|||
exit;
|
||||
|
||||
# $Log$
|
||||
# Revision 1.109 2005/07/19 16:48:16 hdl
|
||||
# Adding an object field to action_logs.
|
||||
# + Minor Correction to updatedatabase
|
||||
# Changing Activate_Log from choice to YesNo Variable.
|
||||
#
|
||||
# Revision 1.108 2005/07/15 16:10:35 hdl
|
||||
# Adding Log Facility.
|
||||
# Needs Two Update in database...
|
||||
|
|
|
|||
Loading…
Reference in New Issue