DirectorActivityLog: work based on new methods
This commit is contained in:
parent
6c72eaf176
commit
c2b0e48c7f
|
@ -43,83 +43,6 @@ 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();
|
||||
}
|
||||
if ($object->supportsCustomVars()) {
|
||||
$props['vars'] = $object->getVars();
|
||||
}
|
||||
if ($object->supportsImports()) {
|
||||
$props['imports'] = $object->imports()->listImportNames();
|
||||
}
|
||||
|
||||
return json_encode($props);
|
||||
}
|
||||
|
||||
protected static function prepareModifiedProperties(DbObject $object)
|
||||
{
|
||||
$props = $object->getModifiedProperties();
|
||||
if ($object->supportsCustomVars()) {
|
||||
$mod = array();
|
||||
foreach ($object->vars() as $name => $var) {
|
||||
if ($var->hasBeenModified()) {
|
||||
$mod[$name] = $var->getValue();
|
||||
}
|
||||
}
|
||||
if (! empty($mod)) {
|
||||
$props['vars'] = (object) $mod;
|
||||
}
|
||||
}
|
||||
if ($object->supportsGroups()) {
|
||||
$old = $object->groups()->listOriginalGroupNames();
|
||||
$new = $object->groups()->listGroupNames();
|
||||
if ($old !== $new) {
|
||||
$props['groups'] = $new;
|
||||
}
|
||||
}
|
||||
if ($object->supportsImports()) {
|
||||
$old = $object->imports()->listOriginalImportNames();
|
||||
$new = $object->imports()->listImportNames();
|
||||
if ($old !== $new) {
|
||||
$props['imports'] = $new;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return json_encode($props);
|
||||
}
|
||||
|
||||
protected static function prepareOriginalProperties(DbObject $object)
|
||||
{
|
||||
$props = $object->getOriginalProperties();
|
||||
if ($object->supportsCustomVars()) {
|
||||
$props['vars'] = (object) array();
|
||||
foreach ($object->vars()->getOriginalVars() as $name => $var) {
|
||||
$props['vars']->$name = $var->getValue();
|
||||
}
|
||||
}
|
||||
if ($object->supportsGroups()) {
|
||||
$groups = $object->groups()->listOriginalGroupNames();
|
||||
if (! empty($groups)) {
|
||||
$props['groups'] = $groups;
|
||||
}
|
||||
}
|
||||
if ($object->supportsImports()) {
|
||||
$imports = $object->imports()->listOriginalImportNames();
|
||||
if (! empty($imports)) {
|
||||
$props['imports'] = $imports;
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($props);
|
||||
}
|
||||
|
||||
public static function logCreation(DbObject $object, Db $db)
|
||||
{
|
||||
$data = array(
|
||||
|
@ -127,7 +50,7 @@ class DirectorActivityLog extends DbObject
|
|||
'action_name' => 'create',
|
||||
'author' => self::username(),
|
||||
'object_type' => $object->getTableName(),
|
||||
'new_properties' => self::prepareNewObjectProperties($object),
|
||||
'new_properties' => $object->toJson(null, true),
|
||||
'change_time' => date('Y-m-d H:i:s'), // TODO -> postgres!
|
||||
'parent_checksum' => $db->getLastActivityChecksum()
|
||||
);
|
||||
|
@ -144,8 +67,8 @@ class DirectorActivityLog extends DbObject
|
|||
'action_name' => 'modify',
|
||||
'author' => self::username(),
|
||||
'object_type' => $object->getTableName(),
|
||||
'old_properties' => self::prepareOriginalProperties($object),
|
||||
'new_properties' => self::prepareModifiedProperties($object),
|
||||
'old_properties' => json_encode($object->getPlainUnmodifiedObject()),
|
||||
'new_properties' => $object->toJson(null, true),
|
||||
'change_time' => date('Y-m-d H:i:s'), // TODO -> postgres!
|
||||
'parent_checksum' => $db->getLastActivityChecksum()
|
||||
);
|
||||
|
@ -162,7 +85,7 @@ class DirectorActivityLog extends DbObject
|
|||
'action_name' => 'delete',
|
||||
'author' => self::username(),
|
||||
'object_type' => $object->getTableName(),
|
||||
'old_properties' => json_encode($object->getOriginalProperties()),
|
||||
'old_properties' => json_encode($object->getPlainUnmodifiedObject()),
|
||||
'change_time' => date('Y-m-d H:i:s'), // TODO -> postgres!
|
||||
'parent_checksum' => $db->getLastActivityChecksum()
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue