Login   Register  
PHP Classes

File: readme.md

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Stefan Jibrail Froelich  >  Ordit Kohana ORM Audit  >  readme.md  >  Download  
File: readme.md
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Ordit Kohana ORM Audit
Track calls to Kohana framework ORM classes
Author: By
Last change:
Date: 2013-07-11 21:40
Size: 2,222 bytes


Class file image Download
# Ordit

Ordit is a Kohana 3.x module that adds automatic auditing to the Official ORM module.

Ordit is a transparent extension that audits all CUD actions on your objects.
It includes  a Log Viewer to view all Audit logs.

## Getting started

Before we use Ordit, we must enable the modules required

		'database' => MODPATH.'database',
		'orm' => MODPATH.'orm',
		'ordit' => MODPATH.'ordit',

[!!] Ordit requires the ORM module (plus its dependencies) to work.

### Setting up the database

You need to create a table in your database to hold all your logs.

A script is included in the module named `ordit_logs.sql`
The script is for a mysql database running the InnoDB engine.

The table is configured as follows:

	Table Name :: 
	Columns ::
		`model` CHAR(50) NOT NULL,
		`action` CHAR(7) NOT NULL,
		`values` TEXT NOT NULL,
		`user` CHAR(50) NOT NULL,
### Overriding the Ordit::get_username Method

In order to provide the current logged in user's username for auditing,
create a class in your classes folder named `Ordit` that extends the `Model_Ordit` class. 
Then override the `get_username` method to return the current logged in user's username. The example below uses
the default `Auth` module.

	class Ordit extends Model_Ordit
		protected function get_username()
			return Auth::instance()->get_user()->username;

### Auditing Your Models

To enable auditing of your ORM models, you simple extend `Ordit`.

	class Model_Model extends Ordit

Any CREATE, UPDATE and DELETE actions are automatically and transparently logged.
You don't have to do anything else.

### Viewing Your Logs
The module includes a log viewer. 

You can view logs at (http://site_root/ordit)

[!!]The log viewer was modified from [Kohana Log Viewer](https://github.com/ajaxray/Kohana-Log-Viewer) viewer.


### Log Changes to Related Modules
Currently, changes to related modules are logged as an empty array.

##Improve Viewer

Add pagination to the log results

Add ability to search by currently `undefined parameters`