breadcrumbs=array( $this->module->id, ); ?>

Welcome to Audit Trail!

Introduction

This is the audit trail module. This module provides basic access to any changes performed via active record through any class that has the LoggableBehavior assigned. It is based off of . I've noticed I always do the same things with it, and I hoped to help others who probably do the same thing.

Changes

Requirements

This module requires:

Installation

If you are looking at this page, you at least enabled the module in your main.php config. Good job! Now we can continue with the installation:

  1. Make sure your components->db is configured in protected/config/main.php
  2. Make sure the rest of this module is set up in your protected/config/main.php. See configuration for help with this.
  3. Run the database migrations to create the tables for audit trail. Keep in mind that you will have to use the --migrationPath flag to tell the yiic tool where the migrations are. It should look something like this:
    prompt:> php ./yiic.php migrate up --migrationPath=application.modules.auditTrail.migrations
    Keep in mind that you may have to change the mirgrationPath to match where you installed the extension. My examples assumes you put it in MyWebApp/protected/modules
  4. Make sure any active record objects you want to log are using the loggable behavior
  5. Add the audit trail widget to any admin pages you want (optional)
  6. Build in RBAC rules if using RBAC (optional). This controllers in this module automatically extend the Controller class of the current web app, so any logic you built into your app for RBAC should work fine. You may need to adjust settings in your RBAC management interface, but specific instructions depend on which implementation you are using. If you need a recommendation, I really like Rights by Chris83.
  7. Use the Audit Trail Manager to manage your audit trail!

Parts

main.php Configuration

Please add the AuditTrail model to the import section of your main.php config file so that all models that need it can find the AR model:

	'import'=>array(
		'application.models.*',
		'application.components.*',
		'application.modules.auditTrail.models.AuditTrail',
		.....
	),
Here are the following options for your main.php configurations (the defaults for all of them should work, so you may not need to use any of them, but if you need to override them you can)
	'modules'=>array(
		'auditTrail'=>array(
			'userClass' => 'User', // the class name for the user object
			'userIdColumn' => 'id', // the column name of the primary key for the user
			'userNameColumn' => 'username', // the column name of the primary key for the user
		),
	.......

Loggable Behavior

You should make sure your ActiveRecord objects use the LoggableBehavior. If you installed AuditTrail to your modules directory, this would typically be referenced by adding this function to your AR model: public function behaviors() { return array( 'LoggableBehavior'=> 'application.modules.auditTrail.behaviors.LoggableBehavior', ); }

Audit Trail Widget

You can easily add the audit trail widget to any page that is specifcally about one row of one thing (ie: one instance of one model, like an update or view page, not like an admin or list page), and it will give you insight into changes for just that object. $this->widget( 'application.modules.auditTrail.widgets.portlets.ShowAuditTrail', array( 'model' => $model, ) );

Audit Trail Manager

The manager is just a searchable table of all audits. You can find it here: