AtkEventLog

From Achievo/ATK Wiki

Jump to: navigation, search

Classname: atkEventLog

API docs

List of other documented ATK classes

Contents

Description

The atkEventLog is a class that logs actions that happen on a record. It tracks the user that performs the action, the timestamp, the node, the action and the primary key of the affected record.

Preparation

The log is stored in a table. To be able to use the atkEventLog you need to create the following table:

CREATE TABLE atkeventlog ( 
  id INT(10), 
  userid INT(10), 
  stamp DATETIME, 
  node VARCHAR(100), 
  action VARCHAR(100), 
  primarykey VARCHAR(255) 
);

(Note that the 'userid' field is numeric; if your user primary key is a string (username) then you have to change the table accordingly)

Usage

Add the atkEventLog as a listener to your node:

$this->addListener(new atkEventLog());

If you want all your nodes to have an eventlog, either derive all your nodes from a custom node that adds this, or use a global node modifier in your module, like this:

  class mod_somemodule extends atkModule
  {
     ..
 
     function modifier($node)
     {
       $node->addListener(new atkEventLog());
       parent::modifier($node);
     }
  }

This will apply the listener to all nodes in the module.

Customizing the logging

The logging is fairly simple. If you want to log more than what atkEventLog logs, it's best to extend the class and to override it's actionPerformed method.

Personal tools
Navigation