diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm
index 56acc3f10..ee6394611 100644
--- a/lib/WebGUI.pm
+++ b/lib/WebGUI.pm
@@ -148,8 +148,8 @@ sub page {
}
}
if ($session{setting}{showDebug} || ($session{form}{debug}==1 && WebGUI::Privilege::isInGroup(3))) {
- $debug = '
';
while (my ($section, $hash) = each %session) {
while (my ($key, $value) = each %$hash) {
diff --git a/lib/WebGUI/ErrorHandler.pm b/lib/WebGUI/ErrorHandler.pm
index 8c4a9adc9..45c21f130 100644
--- a/lib/WebGUI/ErrorHandler.pm
+++ b/lib/WebGUI/ErrorHandler.pm
@@ -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."";
+ $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]."
";
$log->close;
diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm
index 33a566886..c8c055f7d 100644
--- a/lib/WebGUI/Wobject.pm
+++ b/lib/WebGUI/Wobject.pm
@@ -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 .= ' ';
$output .= WebGUI::International::get(45);
$output .= '';
+ WebGUI::ErrorHandler::audit("moved Wobject ".$_[0]->{_property}{wobjectId}." to the trash.");
return $output;
} else {
return WebGUI::Privilege::insufficient();
diff --git a/lib/WebGUI/Wobject/Product.pm b/lib/WebGUI/Wobject/Product.pm
index 4c55ca6b1..9d5116826 100644
--- a/lib/WebGUI/Wobject/Product.pm
+++ b/lib/WebGUI/Wobject/Product.pm
@@ -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 {