DirectorActivityLog: improve removal logging

This commit is contained in:
Thomas Gelf 2016-03-20 12:02:45 +01:00
parent 547b13d53f
commit 3e016311d6
2 changed files with 18 additions and 2 deletions

View File

@ -80,12 +80,13 @@ class DirectorActivityLog extends DbObject
public static function logRemoval(DbObject $object, Db $db)
{
$plain = $object->getCachedUnmodifiedObject();
$data = array(
'object_name' => $object->object_name,
'object_name' => $plain->object_name,
'action_name' => 'delete',
'author' => self::username(),
'object_type' => $object->getTableName(),
'old_properties' => json_encode($object->getPlainUnmodifiedObject()),
'old_properties' => json_encode($plain),
'change_time' => date('Y-m-d H:i:s'), // TODO -> postgres!
'parent_checksum' => $db->getLastActivityChecksum()
);

View File

@ -1082,6 +1082,16 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return $this;
}
public function beforeDelete()
{
$this->cachedPlainUnmodified = $this->getPlainUnmodifiedObject();
}
public function getCachedUnmodifiedObject()
{
return $this->cachedPlainUnmodified;
}
public function onDelete()
{
DirectorActivityLog::logRemoval($this, $this->connection);
@ -1650,6 +1660,11 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return $params;
}
public function getOnDeleteUrl()
{
return 'director/' . strtolower($this->getShortTableName()) . 's';
}
public function toJson(
$resolved = false,
$skipDefaults = false,