https://github.com/thedumbtechguy/ordit--kohana-orm-audit-module
A Kohana 3.x module that adds automatic auditing to the Official ORM module.
https://github.com/thedumbtechguy/ordit--kohana-orm-audit-module
Last synced: 8 months ago
JSON representation
A Kohana 3.x module that adds automatic auditing to the Official ORM module.
- Host: GitHub
- URL: https://github.com/thedumbtechguy/ordit--kohana-orm-audit-module
- Owner: thedumbtechguy
- Created: 2013-06-24T18:15:42.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2015-11-14T23:02:31.000Z (over 10 years ago)
- Last Synced: 2025-07-23T13:52:20.619Z (11 months ago)
- Language: PHP
- Size: 272 KB
- Stars: 2
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 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
Kohana::modules(array(
...
'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 ::
`ordit_logs`
Columns ::
`id` INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY
`model` CHAR(50) NOT NULL,
`action` CHAR(7) NOT NULL,
`values` TEXT NOT NULL,
`user` CHAR(50) NOT NULL,
`timestamp_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
### 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.
## TODO
### 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`