From 8b38ee999b1ac4bf055c359080a3d82c2e272b1e Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sat, 9 Mar 2019 18:00:09 +0000 Subject: [PATCH] Added audit info for template create and modify events. --- WEB-INF/lib/ttTemplateHelper.class.php | 14 ++++++++++---- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/WEB-INF/lib/ttTemplateHelper.class.php b/WEB-INF/lib/ttTemplateHelper.class.php index cc1818d2..e3a93564 100644 --- a/WEB-INF/lib/ttTemplateHelper.class.php +++ b/WEB-INF/lib/ttTemplateHelper.class.php @@ -59,7 +59,9 @@ class ttTemplateHelper { $group_id = $user->getGroup(); $org_id = $user->org_id; - $sql = "update tt_templates set status = null". + $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$user->id; + + $sql = "update tt_templates set status = null".$modified_part. " where id = $id and group_id = $group_id and org_id = $org_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) @@ -80,9 +82,12 @@ class ttTemplateHelper { $description = $fields['description']; $content = $fields['content']; - $sql = "insert into tt_templates (group_id, org_id, name, description, content)". + $created_part = ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$user->id; + + $sql = "insert into tt_templates (group_id, org_id, name, description, content,". + " created, created_ip, created_by)". " values ($group_id, $org_id, ".$mdb2->quote($name). - ", ".$mdb2->quote($description).", ".$mdb2->quote($content).")"; + ", ".$mdb2->quote($description).", ".$mdb2->quote($content).$created_part.")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -102,11 +107,12 @@ class ttTemplateHelper { $name = $fields['name']; $description = $fields['description']; $content = $fields['content']; + $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$user->id; $status = (int) $fields['status']; $sql = "update tt_templates set name = ".$mdb2->quote($name). ", description = ".$mdb2->quote($description). - ", content = ".$mdb2->quote($content). + ", content = ".$mdb2->quote($content).$modified_part. ", status = ".$status. " where id = $template_id and group_id = $group_id and org_id = $org_id"; $affected = $mdb2->exec($sql); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 27f18061..dcc75949 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.56.4852 | Copyright © Anuko | +  Anuko Time Tracker 1.18.56.4853 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1