Added a basic audit trail.
This commit is contained in:
parent
a64bbf9281
commit
e0ac5beaf6
4 changed files with 49 additions and 15 deletions
|
|
@ -148,8 +148,8 @@ sub page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($session{setting}{showDebug} || ($session{form}{debug}==1 && WebGUI::Privilege::isInGroup(3))) {
|
if ($session{setting}{showDebug} || ($session{form}{debug}==1 && WebGUI::Privilege::isInGroup(3))) {
|
||||||
$debug = '<div style="background-color: #ffdddd;color: #000000;">'
|
$debug = '<div style="background-color: #ffdddd;color: #000000;">'.$session{debug}{warning}.'</div>';
|
||||||
.$session{debug}{warning}.'</div>';
|
$debug .= '<div style="background-color: #ffffdd;color: #000000;">'.$session{debug}{audit}.'</div>';
|
||||||
$debug .= '<table bgcolor="#ffffff" style="color: #000000; font-size: 10pt; font-family: helvetica;">';
|
$debug .= '<table bgcolor="#ffffff" style="color: #000000; font-size: 10pt; font-family: helvetica;">';
|
||||||
while (my ($section, $hash) = each %session) {
|
while (my ($section, $hash) = each %session) {
|
||||||
while (my ($key, $value) = each %$hash) {
|
while (my ($key, $value) = each %$hash) {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,16 @@ package WebGUI::ErrorHandler;
|
||||||
use FileHandle;
|
use FileHandle;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub audit {
|
||||||
|
my ($log, $data);
|
||||||
|
$log = FileHandle->new(">>".$session{config}{logfile}) or fatalError("Can't open log file for audit.");
|
||||||
|
$data = localtime(time)." ".$0." AUDIT: ".$session{user}{username}." (".$session{user}{userId}.") ".$_[0]."\n";
|
||||||
|
print $log $data;
|
||||||
|
$session{debug}{audit} .= $data."<p>";
|
||||||
|
$log->close;
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub fatalError {
|
sub fatalError {
|
||||||
my ($key, $log, $cgi, $logfile, $config);
|
my ($key, $log, $cgi, $logfile, $config);
|
||||||
|
|
@ -73,15 +83,8 @@ sub fatalError {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub warn {
|
sub warn {
|
||||||
my ($log, $logfile, $config);
|
my ($log);
|
||||||
if (exists $session{config}{logfile}) {
|
$log = FileHandle->new(">>".$session{config}{logfile}) or fatalError("Can't open log file for warning.");
|
||||||
$logfile = $session{config}{logfile};
|
|
||||||
} else {
|
|
||||||
use Data::Config;
|
|
||||||
$config = new Data::Config '../etc/WebGUI.conf';
|
|
||||||
$logfile = $config->param('logfile');
|
|
||||||
}
|
|
||||||
$log = FileHandle->new(">>".$logfile) or fatalError("Can't open log file for warning.");
|
|
||||||
print $log localtime(time)." ".$0." WARNING: ".$_[0]."\n";
|
print $log localtime(time)." ".$0." WARNING: ".$_[0]."\n";
|
||||||
$session{debug}{warning} .= localtime(time)." ".$0." WARNING: ".$_[0]."<p>";
|
$session{debug}{warning} .= localtime(time)." ".$0." WARNING: ".$_[0]."<p>";
|
||||||
$log->close;
|
$log->close;
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,33 @@ sub confirm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 deleteCollateral ( tableName, keyName, keyValue )
|
||||||
|
|
||||||
|
Deletes a row of collateral data.
|
||||||
|
|
||||||
|
=item tableName
|
||||||
|
|
||||||
|
The name of the table you wish to delete the data from.
|
||||||
|
|
||||||
|
=item keyName
|
||||||
|
|
||||||
|
The name of the column that is the primary key in the table.
|
||||||
|
|
||||||
|
=item keyValue
|
||||||
|
|
||||||
|
An integer containing the key value.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub deleteCollateral {
|
||||||
|
WebGUI::SQL->write("delete from $_[1] where $_[2]=".quote($_[3]));
|
||||||
|
WebGUI::ErrorHandler::audit("deleted ".$_[2]." ".$_[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 description ( )
|
=head2 description ( )
|
||||||
|
|
@ -258,6 +285,7 @@ sub getCollateral {
|
||||||
return WebGUI::SQL->quickHashRef("select * from $_[1] where $_[2]=".quote($_[3]));
|
return WebGUI::SQL->quickHashRef("select * from $_[1] where $_[2]=".quote($_[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 inDateRange ( )
|
=head2 inDateRange ( )
|
||||||
|
|
@ -493,6 +521,7 @@ sub set {
|
||||||
if (@update) {
|
if (@update) {
|
||||||
WebGUI::SQL->write("update ".$_[0]->{_property}{namespace}." set ".join(",",@update)." where wobjectId=".$_[0]->{_property}{wobjectId});
|
WebGUI::SQL->write("update ".$_[0]->{_property}{namespace}." set ".join(",",@update)." where wobjectId=".$_[0]->{_property}{wobjectId});
|
||||||
}
|
}
|
||||||
|
WebGUI::ErrorHandler::audit("edited Wobject ".$_[0]->{_property}{wobjectId});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -570,6 +599,7 @@ sub setCollateral {
|
||||||
$sql .= " where $keyName='".$properties->{$keyName}."'";
|
$sql .= " where $keyName='".$properties->{$keyName}."'";
|
||||||
}
|
}
|
||||||
WebGUI::SQL->write($sql);
|
WebGUI::SQL->write($sql);
|
||||||
|
WebGUI::ErrorHandler::audit("edited ".$keyName." ".$properties->{$keyName});
|
||||||
return $properties->{$keyName};
|
return $properties->{$keyName};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -614,6 +644,7 @@ sub www_delete {
|
||||||
$output .= ' <a href="'.WebGUI::URL::page().'">';
|
$output .= ' <a href="'.WebGUI::URL::page().'">';
|
||||||
$output .= WebGUI::International::get(45);
|
$output .= WebGUI::International::get(45);
|
||||||
$output .= '</a></div>';
|
$output .= '</a></div>';
|
||||||
|
WebGUI::ErrorHandler::audit("moved Wobject ".$_[0]->{_property}{wobjectId}." to the trash.");
|
||||||
return $output;
|
return $output;
|
||||||
} else {
|
} else {
|
||||||
return WebGUI::Privilege::insufficient();
|
return WebGUI::Privilege::insufficient();
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ sub www_deleteBenefit {
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub www_deleteBenefitConfirm {
|
sub www_deleteBenefitConfirm {
|
||||||
if (WebGUI::Privilege::canEditPage()) {
|
if (WebGUI::Privilege::canEditPage()) {
|
||||||
WebGUI::SQL->write("delete from Product_benefit where productBenefitId=$session{form}{bid}");
|
$_[0]->deleteCollateral("Product_benefit","productBenefitId",$session{form}{bid});
|
||||||
_reorderBenefits($_[0]->get("wobjectId"));
|
_reorderBenefits($_[0]->get("wobjectId"));
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -355,7 +355,7 @@ sub www_deleteFeature {
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub www_deleteFeatureConfirm {
|
sub www_deleteFeatureConfirm {
|
||||||
if (WebGUI::Privilege::canEditPage()) {
|
if (WebGUI::Privilege::canEditPage()) {
|
||||||
WebGUI::SQL->write("delete from Product_feature where productFeatureId=$session{form}{fid}");
|
$_[0]->deleteCollateral("Product_feature","productFeatureId",$session{form}{fid});
|
||||||
_reorderFeatures($_[0]->get("wobjectId"));
|
_reorderFeatures($_[0]->get("wobjectId"));
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -413,7 +413,7 @@ sub www_deleteSpecification {
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub www_deleteSpecificationConfirm {
|
sub www_deleteSpecificationConfirm {
|
||||||
if (WebGUI::Privilege::canEditPage()) {
|
if (WebGUI::Privilege::canEditPage()) {
|
||||||
WebGUI::SQL->write("delete from Product_specification where productSpecificationId=$session{form}{sid}");
|
$_[0]->deleteCollateral("Product_specification","productSpecificationId",$session{form}{sid});
|
||||||
_reorderSpecifications($_[0]->get("wobjectId"));
|
_reorderSpecifications($_[0]->get("wobjectId"));
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -434,7 +434,7 @@ sub www_deleteTemplate {
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub www_deleteTemplateConfirm {
|
sub www_deleteTemplateConfirm {
|
||||||
if (WebGUI::Privilege::canEditPage()) {
|
if (WebGUI::Privilege::canEditPage()) {
|
||||||
WebGUI::SQL->write("delete from Product_template where productTemplateId=$session{form}{tid}");
|
$_[0]->deleteCollateral("Product_template","productTemplateId",$session{form}{tid});
|
||||||
WebGUI::SQL->write("update Product set productTemplateId=1 where productTemplateId=$session{form}{tid}");
|
WebGUI::SQL->write("update Product set productTemplateId=1 where productTemplateId=$session{form}{tid}");
|
||||||
return $_[0]->www_edit();
|
return $_[0]->www_edit();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue