Added a basic audit trail.

This commit is contained in:
JT Smith 2002-08-13 02:25:11 +00:00
parent a64bbf9281
commit e0ac5beaf6
4 changed files with 49 additions and 15 deletions

View file

@ -148,8 +148,8 @@ sub page {
}
}
if ($session{setting}{showDebug} || ($session{form}{debug}==1 && WebGUI::Privilege::isInGroup(3))) {
$debug = '<div style="background-color: #ffdddd;color: #000000;">'
.$session{debug}{warning}.'</div>';
$debug = '<div style="background-color: #ffdddd;color: #000000;">'.$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;">';
while (my ($section, $hash) = each %session) {
while (my ($key, $value) = each %$hash) {

View file

@ -13,6 +13,16 @@ package WebGUI::ErrorHandler;
use FileHandle;
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 {
my ($key, $log, $cgi, $logfile, $config);
@ -73,15 +83,8 @@ sub fatalError {
#-------------------------------------------------------------------
sub warn {
my ($log, $logfile, $config);
if (exists $session{config}{logfile}) {
$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.");
my ($log);
$log = FileHandle->new(">>".$session{config}{logfile}) or fatalError("Can't open log file for warning.");
print $log localtime(time)." ".$0." WARNING: ".$_[0]."\n";
$session{debug}{warning} .= localtime(time)." ".$0." WARNING: ".$_[0]."<p>";
$log->close;

View file

@ -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 ( )
@ -258,6 +285,7 @@ sub getCollateral {
return WebGUI::SQL->quickHashRef("select * from $_[1] where $_[2]=".quote($_[3]));
}
#-------------------------------------------------------------------
=head2 inDateRange ( )
@ -493,6 +521,7 @@ sub set {
if (@update) {
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}."'";
}
WebGUI::SQL->write($sql);
WebGUI::ErrorHandler::audit("edited ".$keyName." ".$properties->{$keyName});
return $properties->{$keyName};
}
@ -614,6 +644,7 @@ sub www_delete {
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.WebGUI::URL::page().'">';
$output .= WebGUI::International::get(45);
$output .= '</a></div>';
WebGUI::ErrorHandler::audit("moved Wobject ".$_[0]->{_property}{wobjectId}." to the trash.");
return $output;
} else {
return WebGUI::Privilege::insufficient();

View file

@ -336,7 +336,7 @@ sub www_deleteBenefit {
#-------------------------------------------------------------------
sub www_deleteBenefitConfirm {
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"));
return "";
} else {
@ -355,7 +355,7 @@ sub www_deleteFeature {
#-------------------------------------------------------------------
sub www_deleteFeatureConfirm {
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"));
return "";
} else {
@ -413,7 +413,7 @@ sub www_deleteSpecification {
#-------------------------------------------------------------------
sub www_deleteSpecificationConfirm {
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"));
return "";
} else {
@ -434,7 +434,7 @@ sub www_deleteTemplate {
#-------------------------------------------------------------------
sub www_deleteTemplateConfirm {
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}");
return $_[0]->www_edit();
} else {