2017 © Pedro Peláez
 

library AuditableBehavior

AuditableBehavior is a propel behavior to track and record changes in your propel models.

image

CarpeHora/AuditableBehavior

AuditableBehavior is a propel behavior to track and record changes in your propel models.

  • Friday, September 14, 2012
  • by themouette
  • Repository
  • 2 Watchers
  • 7 Stars
  • 38 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

AuditableBehavior

Build Status, (*1)

Quick start

Add the behavior to your database schema :, (*2)

``` xml

, (*3)


``` php <?php $auditable = new Auditable(); $auditable->setName('audit'); $auditable->save(); // and now access audit trail $auditable->countActivity(); foreach ($auditable->getLastActivity() as $activity) { echo $activity->getLabel() . '<br />'; } // will result in "CREATE<br />"

Installation

Install the behavior in your vendor directory, (*4)

``` bash $ git submodule add git://github.com/Carpe-Hora/AuditableBehavior.git lib/vendor/AuditableBehavior, (*5)


add following to your ```propel.ini``` file: ``` ini propel.behavior.auditable.class = lib.vendor.AuditableBehavior.src.AuditableBehavior

Declare behavior for the whole database in your config/schema.xml, (*6)

``` xml , (*7)


or for a table only ``` xml <database name="propel" defaultIdMethod="native" package="lib.model"> <table name="my_table"> <column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" /> <behavior name="auditable" /> </table> </database>

Configuration

Following paramters are available :, (*8)

  • create_label : activity log for create (default CREATE)
  • update_label : activity log for update (default UPDATE)
  • delete_label : activity log for delete (default DELETE)
  • audit_create : log object creation (default true)
  • audit_update : log object update (default true)
  • audit_delete : log object deletion (default true)
  • activity_table : activity table name (default audit_activity)
  • activity_label_column : column for activity log in activity_table
  • object_column : column for object table in activity_table
  • object_pk_column : column for object primarikey in activity_table
  • blacklist: a coma separated list of tables to exclude from audit

How it works

This behavior create an activity table and log activity for auditableed object., (*9)

To achieve this goal, method logActivity($label, $con=null) is called on postHooks., (*10)

This method create a new MonitorActivity with following parameters:, (*11)

  • auditable_label corresponding value for CREATE, UPDATE or DELETE
  • auditable_object_class corresponding object class
  • auditable_object_pk corresponding object primary key

Built in methods

Active record extension

  • getLastActivity($number=10, $label=null, $con=null) return the recent object related activity.
  • logActivity($label, $con=null) create an activity entry for $label
  • countActivity($label = null, $con=null) count related activity
  • isAudited() is the current objcet auditableing its activity
  • disableLocalAudit() temporary remove auditableing activity for this object
  • enableLocalAudit() temporary force auditableing activity for this object
  • getActivityCriteria get a criteria to filter activity against this object

and both static methods, (*12)

  • disableAudit() disable auditableing activity globaly.
  • enableAudit() enable auditableing activity globaly.

Activity table

Active Query extension

  • filterByObject($auditableedObject) filter query for $auditableObject related activity.

Active record extension

  • getRelatedObject() return the activity related object.

TODO

  • alter activty active record and query

The Versions

14/09 2012

dev-master

9999999-dev http://carpe-hora.github.com/AuditableBehavior/

AuditableBehavior is a propel behavior to track and record changes in your propel models.

  Sources   Download

MIT

The Requires

 

behavior propel blameable auditable