DirectorActivityLog: start to log related objects

First implementation: groups
This commit is contained in:
Thomas Gelf 2015-07-30 11:46:27 +02:00
parent 3b7cf5a4d4
commit a88563f925
1 changed files with 14 additions and 1 deletions

View File

@ -39,6 +39,19 @@ class DirectorActivityLog extends DbObject
}
}
protected static function prepareNewObjectProperties(DbObject $object)
{
$props = $object->getProperties();
if ($object->supportsCustomVars()) {
// $props->vars = $object->vars()->toJson();
}
if ($object->supportsGroups()) {
$props['groups'] = $object->groups()->listGroupNames();
}
return json_encode($props);
}
public static function logCreation(DbObject $object, Db $db)
{
$data = array(
@ -46,7 +59,7 @@ class DirectorActivityLog extends DbObject
'action_name' => 'create',
'author' => self::username(),
'object_type' => $object->getTableName(),
'new_properties' => json_encode($object->getProperties()),
'new_properties' => self::prepareNewObjectProperties($object),
'change_time' => date('Y-m-d H:i:s'), // TODO -> postgres!
'parent_checksum' => $db->getLastActivityChecksum()
);