Forum OpenACS Development: Re: Re: logging parameter value changes

Collapse
Posted by Malte Sussdorff on
This looks good. I was wondering if there should be a general audit mechanism for OpenACS for non cr items. Something like

util::audit -object_id -modifing_user -creation_ip -attributes {list of attribute key/value pairs} -table_name -table_primary_key -table_primary_key_value

This will store the values in a general audit table. If we have an object_id, use the reference to acs_objects, for all other tables use tablename and primary_key_name and value:

create table audit (
audit_id primary key,
object_id references acs_objects,
table_name references pg_(whatever the view for user tables is),
table_primary_key,
table_primary_key_value,
last_modified timestamptz default current_timestamp not null default now(),
-- get following 2 values from acs_objects table
modifying_user integer,
modifying_ip varchar(50)
);

create table audit_value {
audit_id references audit,
key,
value
};

and then obviously something like

ad_proc util::audit::get_changes {
{-object_id ""}
{-modifing_user ""}
{-table_name ""}
{-table_primary_key ""}
{-table_primary_key_value ""}
} {
Retrieve audit log
@return list of list of changes matching the given combination of object_id, user or table definition with one row per change ordered by date.
@return the list will look like {$object_id $modifing_user $modifing_ip $table_name $table_primary_key $table_primary_key_value $modification_date {[list {key new_value old_value}]}}
}

What do you think? This should also take care of Torben's request.